blob: e8d54a85dcda28559ceac505eecec36275d82cd4 [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"
Jeff Johnson295189b2012-06-20 16:38:30 -070098
99#define g_mode_rates_size (12)
100#define a_mode_rates_size (8)
101#define FREQ_BASE_80211G (2407)
102#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700103#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530104#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800106 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
108#define HDD2GHZCHAN(freq, chan, flag) { \
109 .band = IEEE80211_BAND_2GHZ, \
110 .center_freq = (freq), \
111 .hw_value = (chan),\
112 .flags = (flag), \
113 .max_antenna_gain = 0 ,\
114 .max_power = 30, \
115}
116
117#define HDD5GHZCHAN(freq, chan, flag) { \
118 .band = IEEE80211_BAND_5GHZ, \
119 .center_freq = (freq), \
120 .hw_value = (chan),\
121 .flags = (flag), \
122 .max_antenna_gain = 0 ,\
123 .max_power = 30, \
124}
125
126#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
127{\
128 .bitrate = rate, \
129 .hw_value = rate_id, \
130 .flags = flag, \
131}
132
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530133#ifdef WLAN_FEATURE_VOWIFI_11R
134#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
135#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
136#endif
137
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530138#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530139#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530140
Sunil Duttc69bccb2014-05-26 21:30:20 +0530141#ifdef WLAN_FEATURE_LINK_LAYER_STATS
142/*
143 * Used to allocate the size of 4096 for the link layer stats.
144 * The size of 4096 is considered assuming that all data per
145 * respective event fit with in the limit.Please take a call
146 * on the limit based on the data requirements on link layer
147 * statistics.
148 */
149#define LL_STATS_EVENT_BUF_SIZE 4096
150#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530151#ifdef WLAN_FEATURE_EXTSCAN
152/*
153 * Used to allocate the size of 4096 for the EXTScan NL data.
154 * The size of 4096 is considered assuming that all data per
155 * respective event fit with in the limit.Please take a call
156 * on the limit based on the data requirements.
157 */
158
159#define EXTSCAN_EVENT_BUF_SIZE 4096
160#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
161#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530162
Atul Mittal115287b2014-07-08 13:26:33 +0530163/*EXT TDLS*/
164/*
165 * Used to allocate the size of 4096 for the TDLS.
166 * The size of 4096 is considered assuming that all data per
167 * respective event fit with in the limit.Please take a call
168 * on the limit based on the data requirements on link layer
169 * statistics.
170 */
171#define EXTTDLS_EVENT_BUF_SIZE 4096
172
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530173static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700174{
175 WLAN_CIPHER_SUITE_WEP40,
176 WLAN_CIPHER_SUITE_WEP104,
177 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800178#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700179#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
180 WLAN_CIPHER_SUITE_KRK,
181 WLAN_CIPHER_SUITE_CCMP,
182#else
183 WLAN_CIPHER_SUITE_CCMP,
184#endif
185#ifdef FEATURE_WLAN_WAPI
186 WLAN_CIPHER_SUITE_SMS4,
187#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700188#ifdef WLAN_FEATURE_11W
189 WLAN_CIPHER_SUITE_AES_CMAC,
190#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700191};
192
193static inline int is_broadcast_ether_addr(const u8 *addr)
194{
195 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
196 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
197}
198
199static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530200{
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 HDD2GHZCHAN(2412, 1, 0) ,
202 HDD2GHZCHAN(2417, 2, 0) ,
203 HDD2GHZCHAN(2422, 3, 0) ,
204 HDD2GHZCHAN(2427, 4, 0) ,
205 HDD2GHZCHAN(2432, 5, 0) ,
206 HDD2GHZCHAN(2437, 6, 0) ,
207 HDD2GHZCHAN(2442, 7, 0) ,
208 HDD2GHZCHAN(2447, 8, 0) ,
209 HDD2GHZCHAN(2452, 9, 0) ,
210 HDD2GHZCHAN(2457, 10, 0) ,
211 HDD2GHZCHAN(2462, 11, 0) ,
212 HDD2GHZCHAN(2467, 12, 0) ,
213 HDD2GHZCHAN(2472, 13, 0) ,
214 HDD2GHZCHAN(2484, 14, 0) ,
215};
216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
218{
219 HDD2GHZCHAN(2412, 1, 0) ,
220 HDD2GHZCHAN(2437, 6, 0) ,
221 HDD2GHZCHAN(2462, 11, 0) ,
222};
Jeff Johnson295189b2012-06-20 16:38:30 -0700223
224static struct ieee80211_channel hdd_channels_5_GHZ[] =
225{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700226 HDD5GHZCHAN(4920, 240, 0) ,
227 HDD5GHZCHAN(4940, 244, 0) ,
228 HDD5GHZCHAN(4960, 248, 0) ,
229 HDD5GHZCHAN(4980, 252, 0) ,
230 HDD5GHZCHAN(5040, 208, 0) ,
231 HDD5GHZCHAN(5060, 212, 0) ,
232 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 HDD5GHZCHAN(5180, 36, 0) ,
234 HDD5GHZCHAN(5200, 40, 0) ,
235 HDD5GHZCHAN(5220, 44, 0) ,
236 HDD5GHZCHAN(5240, 48, 0) ,
237 HDD5GHZCHAN(5260, 52, 0) ,
238 HDD5GHZCHAN(5280, 56, 0) ,
239 HDD5GHZCHAN(5300, 60, 0) ,
240 HDD5GHZCHAN(5320, 64, 0) ,
241 HDD5GHZCHAN(5500,100, 0) ,
242 HDD5GHZCHAN(5520,104, 0) ,
243 HDD5GHZCHAN(5540,108, 0) ,
244 HDD5GHZCHAN(5560,112, 0) ,
245 HDD5GHZCHAN(5580,116, 0) ,
246 HDD5GHZCHAN(5600,120, 0) ,
247 HDD5GHZCHAN(5620,124, 0) ,
248 HDD5GHZCHAN(5640,128, 0) ,
249 HDD5GHZCHAN(5660,132, 0) ,
250 HDD5GHZCHAN(5680,136, 0) ,
251 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800252#ifdef FEATURE_WLAN_CH144
253 HDD5GHZCHAN(5720,144, 0) ,
254#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 HDD5GHZCHAN(5745,149, 0) ,
256 HDD5GHZCHAN(5765,153, 0) ,
257 HDD5GHZCHAN(5785,157, 0) ,
258 HDD5GHZCHAN(5805,161, 0) ,
259 HDD5GHZCHAN(5825,165, 0) ,
260};
261
262static struct ieee80211_rate g_mode_rates[] =
263{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530264 HDD_G_MODE_RATETAB(10, 0x1, 0),
265 HDD_G_MODE_RATETAB(20, 0x2, 0),
266 HDD_G_MODE_RATETAB(55, 0x4, 0),
267 HDD_G_MODE_RATETAB(110, 0x8, 0),
268 HDD_G_MODE_RATETAB(60, 0x10, 0),
269 HDD_G_MODE_RATETAB(90, 0x20, 0),
270 HDD_G_MODE_RATETAB(120, 0x40, 0),
271 HDD_G_MODE_RATETAB(180, 0x80, 0),
272 HDD_G_MODE_RATETAB(240, 0x100, 0),
273 HDD_G_MODE_RATETAB(360, 0x200, 0),
274 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530276};
Jeff Johnson295189b2012-06-20 16:38:30 -0700277
278static struct ieee80211_rate a_mode_rates[] =
279{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530280 HDD_G_MODE_RATETAB(60, 0x10, 0),
281 HDD_G_MODE_RATETAB(90, 0x20, 0),
282 HDD_G_MODE_RATETAB(120, 0x40, 0),
283 HDD_G_MODE_RATETAB(180, 0x80, 0),
284 HDD_G_MODE_RATETAB(240, 0x100, 0),
285 HDD_G_MODE_RATETAB(360, 0x200, 0),
286 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 HDD_G_MODE_RATETAB(540, 0x800, 0),
288};
289
290static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
291{
292 .channels = hdd_channels_2_4_GHZ,
293 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
294 .band = IEEE80211_BAND_2GHZ,
295 .bitrates = g_mode_rates,
296 .n_bitrates = g_mode_rates_size,
297 .ht_cap.ht_supported = 1,
298 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
299 | IEEE80211_HT_CAP_GRN_FLD
300 | IEEE80211_HT_CAP_DSSSCCK40
301 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
302 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
303 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
304 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
305 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
306 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
307};
308
Jeff Johnson295189b2012-06-20 16:38:30 -0700309static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
310{
311 .channels = hdd_social_channels_2_4_GHZ,
312 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
313 .band = IEEE80211_BAND_2GHZ,
314 .bitrates = g_mode_rates,
315 .n_bitrates = g_mode_rates_size,
316 .ht_cap.ht_supported = 1,
317 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
318 | IEEE80211_HT_CAP_GRN_FLD
319 | IEEE80211_HT_CAP_DSSSCCK40
320 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
321 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
322 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
323 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
324 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
325 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
326};
Jeff Johnson295189b2012-06-20 16:38:30 -0700327
328static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
329{
330 .channels = hdd_channels_5_GHZ,
331 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
332 .band = IEEE80211_BAND_5GHZ,
333 .bitrates = a_mode_rates,
334 .n_bitrates = a_mode_rates_size,
335 .ht_cap.ht_supported = 1,
336 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
337 | IEEE80211_HT_CAP_GRN_FLD
338 | IEEE80211_HT_CAP_DSSSCCK40
339 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
340 | IEEE80211_HT_CAP_SGI_40
341 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
342 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
343 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
344 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
345 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
346 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
347};
348
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530349/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700350 TX/RX direction for each kind of interface */
351static const struct ieee80211_txrx_stypes
352wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
353 [NL80211_IFTYPE_STATION] = {
354 .tx = 0xffff,
355 .rx = BIT(SIR_MAC_MGMT_ACTION) |
356 BIT(SIR_MAC_MGMT_PROBE_REQ),
357 },
358 [NL80211_IFTYPE_AP] = {
359 .tx = 0xffff,
360 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
361 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
362 BIT(SIR_MAC_MGMT_PROBE_REQ) |
363 BIT(SIR_MAC_MGMT_DISASSOC) |
364 BIT(SIR_MAC_MGMT_AUTH) |
365 BIT(SIR_MAC_MGMT_DEAUTH) |
366 BIT(SIR_MAC_MGMT_ACTION),
367 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700368 [NL80211_IFTYPE_ADHOC] = {
369 .tx = 0xffff,
370 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
371 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
372 BIT(SIR_MAC_MGMT_PROBE_REQ) |
373 BIT(SIR_MAC_MGMT_DISASSOC) |
374 BIT(SIR_MAC_MGMT_AUTH) |
375 BIT(SIR_MAC_MGMT_DEAUTH) |
376 BIT(SIR_MAC_MGMT_ACTION),
377 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 [NL80211_IFTYPE_P2P_CLIENT] = {
379 .tx = 0xffff,
380 .rx = BIT(SIR_MAC_MGMT_ACTION) |
381 BIT(SIR_MAC_MGMT_PROBE_REQ),
382 },
383 [NL80211_IFTYPE_P2P_GO] = {
384 /* This is also same as for SoftAP */
385 .tx = 0xffff,
386 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
387 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
388 BIT(SIR_MAC_MGMT_PROBE_REQ) |
389 BIT(SIR_MAC_MGMT_DISASSOC) |
390 BIT(SIR_MAC_MGMT_AUTH) |
391 BIT(SIR_MAC_MGMT_DEAUTH) |
392 BIT(SIR_MAC_MGMT_ACTION),
393 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700394};
395
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800396#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800397static const struct ieee80211_iface_limit
398wlan_hdd_iface_limit[] = {
399 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800400 /* max = 3 ; Our driver create two interfaces during driver init
401 * wlan0 and p2p0 interfaces. p2p0 is considered as station
402 * interface until a group is formed. In JB architecture, once the
403 * group is formed, interface type of p2p0 is changed to P2P GO or
404 * Client.
405 * When supplicant remove the group, it first issue a set interface
406 * cmd to change the mode back to Station. In JB this works fine as
407 * we advertize two station type interface during driver init.
408 * Some vendors create separate interface for P2P GO/Client,
409 * after group formation(Third one). But while group remove
410 * supplicant first tries to change the mode(3rd interface) to STATION
411 * But as we advertized only two sta type interfaces nl80211 was
412 * returning error for the third one which was leading to failure in
413 * delete interface. Ideally while removing the group, supplicant
414 * should not try to change the 3rd interface mode to Station type.
415 * Till we get a fix in wpa_supplicant, we advertize max STA
416 * interface type to 3
417 */
418 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800419 .types = BIT(NL80211_IFTYPE_STATION),
420 },
421 {
422 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700423 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800424 },
425 {
426 .max = 1,
427 .types = BIT(NL80211_IFTYPE_P2P_GO) |
428 BIT(NL80211_IFTYPE_P2P_CLIENT),
429 },
430};
431
432/* By default, only single channel concurrency is allowed */
433static struct ieee80211_iface_combination
434wlan_hdd_iface_combination = {
435 .limits = wlan_hdd_iface_limit,
436 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800437 /*
438 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
439 * and p2p0 interfaces during driver init
440 * Some vendors create separate interface for P2P operations.
441 * wlan0: STA interface
442 * p2p0: P2P Device interface, action frames goes
443 * through this interface.
444 * p2p-xx: P2P interface, After GO negotiation this interface is
445 * created for p2p operations(GO/CLIENT interface).
446 */
447 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800448 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
449 .beacon_int_infra_match = false,
450};
451#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800452
Jeff Johnson295189b2012-06-20 16:38:30 -0700453static struct cfg80211_ops wlan_hdd_cfg80211_ops;
454
455/* Data rate 100KBPS based on IE Index */
456struct index_data_rate_type
457{
458 v_U8_t beacon_rate_index;
459 v_U16_t supported_rate[4];
460};
461
462/* 11B, 11G Rate table include Basic rate and Extended rate
463 The IDX field is the rate index
464 The HI field is the rate when RSSI is strong or being ignored
465 (in this case we report actual rate)
466 The MID field is the rate when RSSI is moderate
467 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
468 The LO field is the rate when RSSI is low
469 (in this case we don't report rates, actual current rate used)
470 */
471static const struct
472{
473 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700474 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700475} supported_data_rate[] =
476{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700477/* IDX HI HM LM LO (RSSI-based index */
478 {2, { 10, 10, 10, 0}},
479 {4, { 20, 20, 10, 0}},
480 {11, { 55, 20, 10, 0}},
481 {12, { 60, 55, 20, 0}},
482 {18, { 90, 55, 20, 0}},
483 {22, {110, 55, 20, 0}},
484 {24, {120, 90, 60, 0}},
485 {36, {180, 120, 60, 0}},
486 {44, {220, 180, 60, 0}},
487 {48, {240, 180, 90, 0}},
488 {66, {330, 180, 90, 0}},
489 {72, {360, 240, 90, 0}},
490 {96, {480, 240, 120, 0}},
491 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700492};
493
494/* MCS Based rate table */
495static struct index_data_rate_type supported_mcs_rate[] =
496{
497/* MCS L20 L40 S20 S40 */
498 {0, {65, 135, 72, 150}},
499 {1, {130, 270, 144, 300}},
500 {2, {195, 405, 217, 450}},
501 {3, {260, 540, 289, 600}},
502 {4, {390, 810, 433, 900}},
503 {5, {520, 1080, 578, 1200}},
504 {6, {585, 1215, 650, 1350}},
505 {7, {650, 1350, 722, 1500}}
506};
507
Leo Chang6f8870f2013-03-26 18:11:36 -0700508#ifdef WLAN_FEATURE_11AC
509
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530510#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700511
512struct index_vht_data_rate_type
513{
514 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530515 v_U16_t supported_VHT80_rate[2];
516 v_U16_t supported_VHT40_rate[2];
517 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700518};
519
520typedef enum
521{
522 DATA_RATE_11AC_MAX_MCS_7,
523 DATA_RATE_11AC_MAX_MCS_8,
524 DATA_RATE_11AC_MAX_MCS_9,
525 DATA_RATE_11AC_MAX_MCS_NA
526} eDataRate11ACMaxMcs;
527
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530528/* SSID broadcast type */
529typedef enum eSSIDBcastType
530{
531 eBCAST_UNKNOWN = 0,
532 eBCAST_NORMAL = 1,
533 eBCAST_HIDDEN = 2,
534} tSSIDBcastType;
535
Leo Chang6f8870f2013-03-26 18:11:36 -0700536/* MCS Based VHT rate table */
537static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
538{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530539/* MCS L80 S80 L40 S40 L20 S40*/
540 {0, {293, 325}, {135, 150}, {65, 72}},
541 {1, {585, 650}, {270, 300}, {130, 144}},
542 {2, {878, 975}, {405, 450}, {195, 217}},
543 {3, {1170, 1300}, {540, 600}, {260, 289}},
544 {4, {1755, 1950}, {810, 900}, {390, 433}},
545 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
546 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
547 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
548 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
549 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700550};
551#endif /* WLAN_FEATURE_11AC */
552
c_hpothu79aab322014-07-14 21:11:01 +0530553/*array index points to MCS and array value points respective rssi*/
554static int rssiMcsTbl[][10] =
555{
556/*MCS 0 1 2 3 4 5 6 7 8 9*/
557 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
558 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
559 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
560};
561
Jeff Johnson295189b2012-06-20 16:38:30 -0700562extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530563#ifdef FEATURE_WLAN_SCAN_PNO
564static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
565#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700566
Leo Chang9056f462013-08-01 19:21:11 -0700567#ifdef WLAN_NL80211_TESTMODE
568enum wlan_hdd_tm_attr
569{
570 WLAN_HDD_TM_ATTR_INVALID = 0,
571 WLAN_HDD_TM_ATTR_CMD = 1,
572 WLAN_HDD_TM_ATTR_DATA = 2,
573 WLAN_HDD_TM_ATTR_TYPE = 3,
574 /* keep last */
575 WLAN_HDD_TM_ATTR_AFTER_LAST,
576 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
577};
578
579enum wlan_hdd_tm_cmd
580{
581 WLAN_HDD_TM_CMD_WLAN_HB = 1,
582};
583
584#define WLAN_HDD_TM_DATA_MAX_LEN 5000
585
586static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
587{
588 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
589 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
590 .len = WLAN_HDD_TM_DATA_MAX_LEN },
591};
592#endif /* WLAN_NL80211_TESTMODE */
593
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800594#ifdef FEATURE_WLAN_CH_AVOID
595/*
596 * FUNCTION: wlan_hdd_send_avoid_freq_event
597 * This is called when wlan driver needs to send vendor specific
598 * avoid frequency range event to userspace
599 */
600int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
601 tHddAvoidFreqList *pAvoidFreqList)
602{
603 struct sk_buff *vendor_event;
604
605 ENTER();
606
607 if (!pHddCtx)
608 {
609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
610 "%s: HDD context is null", __func__);
611 return -1;
612 }
613
614 if (!pAvoidFreqList)
615 {
616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
617 "%s: pAvoidFreqList is null", __func__);
618 return -1;
619 }
620
621 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
622 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530623 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800624 GFP_KERNEL);
625 if (!vendor_event)
626 {
627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
628 "%s: cfg80211_vendor_event_alloc failed", __func__);
629 return -1;
630 }
631
632 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
633 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
634
635 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
636
637 EXIT();
638 return 0;
639}
640#endif /* FEATURE_WLAN_CH_AVOID */
641
Srinivas Dasari030bad32015-02-18 23:23:54 +0530642/*
643 * FUNCTION: __wlan_hdd_cfg80211_nan_request
644 * This is called when wlan driver needs to send vendor specific
645 * nan request event.
646 */
647static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
648 struct wireless_dev *wdev,
649 const void *data, int data_len)
650{
651 tNanRequestReq nan_req;
652 VOS_STATUS status;
653 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530654 struct net_device *dev = wdev->netdev;
655 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
656 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530657 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
658
659 if (0 == data_len)
660 {
661 hddLog(VOS_TRACE_LEVEL_ERROR,
662 FL("NAN - Invalid Request, length = 0"));
663 return ret_val;
664 }
665
666 if (NULL == data)
667 {
668 hddLog(VOS_TRACE_LEVEL_ERROR,
669 FL("NAN - Invalid Request, data is NULL"));
670 return ret_val;
671 }
672
673 status = wlan_hdd_validate_context(pHddCtx);
674 if (0 != status)
675 {
676 hddLog(VOS_TRACE_LEVEL_ERROR,
677 FL("HDD context is not valid"));
678 return -EINVAL;
679 }
680
681 hddLog(LOG1, FL("Received NAN command"));
682 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
683 (tANI_U8 *)data, data_len);
684
685 /* check the NAN Capability */
686 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
687 {
688 hddLog(VOS_TRACE_LEVEL_ERROR,
689 FL("NAN is not supported by Firmware"));
690 return -EINVAL;
691 }
692
693 nan_req.request_data_len = data_len;
694 nan_req.request_data = data;
695
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530696 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530697 if (VOS_STATUS_SUCCESS == status)
698 {
699 ret_val = 0;
700 }
701 return ret_val;
702}
703
704/*
705 * FUNCTION: wlan_hdd_cfg80211_nan_request
706 * Wrapper to protect the nan vendor command from ssr
707 */
708static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
709 struct wireless_dev *wdev,
710 const void *data, int data_len)
711{
712 int ret;
713
714 vos_ssr_protect(__func__);
715 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
716 vos_ssr_unprotect(__func__);
717
718 return ret;
719}
720
721/*
722 * FUNCTION: wlan_hdd_cfg80211_nan_callback
723 * This is a callback function and it gets called
724 * when we need to report nan response event to
725 * upper layers.
726 */
727static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
728{
729 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
730 struct sk_buff *vendor_event;
731 int status;
732 tSirNanEvent *data;
733
734 ENTER();
735 if (NULL == msg)
736 {
737 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
738 FL(" msg received here is null"));
739 return;
740 }
741 data = msg;
742
743 status = wlan_hdd_validate_context(pHddCtx);
744
745 if (0 != status)
746 {
747 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
748 FL("HDD context is not valid"));
749 return;
750 }
751
752 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
753 data->event_data_len +
754 NLMSG_HDRLEN,
755 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
756 GFP_KERNEL);
757
758 if (!vendor_event)
759 {
760 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
761 FL("cfg80211_vendor_event_alloc failed"));
762 return;
763 }
764 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
765 data->event_data_len, data->event_data))
766 {
767 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
768 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
769 kfree_skb(vendor_event);
770 return;
771 }
772 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
773 EXIT();
774}
775
776/*
777 * FUNCTION: wlan_hdd_cfg80211_nan_init
778 * This function is called to register the callback to sme layer
779 */
780inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
781{
782 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
783}
784
785
Sunil Duttc69bccb2014-05-26 21:30:20 +0530786#ifdef WLAN_FEATURE_LINK_LAYER_STATS
787
788static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
789 struct sk_buff *vendor_event)
790{
791 if (nla_put_u8(vendor_event,
792 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
793 stats->rate.preamble) ||
794 nla_put_u8(vendor_event,
795 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
796 stats->rate.nss) ||
797 nla_put_u8(vendor_event,
798 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
799 stats->rate.bw) ||
800 nla_put_u8(vendor_event,
801 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
802 stats->rate.rateMcsIdx) ||
803 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
804 stats->rate.bitrate ) ||
805 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
806 stats->txMpdu ) ||
807 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
808 stats->rxMpdu ) ||
809 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
810 stats->mpduLost ) ||
811 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
812 stats->retries) ||
813 nla_put_u32(vendor_event,
814 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
815 stats->retriesShort ) ||
816 nla_put_u32(vendor_event,
817 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
818 stats->retriesLong))
819 {
820 hddLog(VOS_TRACE_LEVEL_ERROR,
821 FL("QCA_WLAN_VENDOR_ATTR put fail"));
822 return FALSE;
823 }
824 return TRUE;
825}
826
827static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
828 struct sk_buff *vendor_event)
829{
830 u32 i = 0;
831 struct nlattr *rateInfo;
832 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
833 stats->type) ||
834 nla_put(vendor_event,
835 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
836 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
837 nla_put_u32(vendor_event,
838 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
839 stats->capabilities) ||
840 nla_put_u32(vendor_event,
841 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
842 stats->numRate))
843 {
844 hddLog(VOS_TRACE_LEVEL_ERROR,
845 FL("QCA_WLAN_VENDOR_ATTR put fail"));
846 goto error;
847 }
848
849 rateInfo = nla_nest_start(vendor_event,
850 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530851 if(!rateInfo)
852 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530853 for (i = 0; i < stats->numRate; i++)
854 {
855 struct nlattr *rates;
856 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
857 stats->rateStats +
858 (i * sizeof(tSirWifiRateStat)));
859 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530860 if(!rates)
861 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530862
863 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
864 {
865 hddLog(VOS_TRACE_LEVEL_ERROR,
866 FL("QCA_WLAN_VENDOR_ATTR put fail"));
867 return FALSE;
868 }
869 nla_nest_end(vendor_event, rates);
870 }
871 nla_nest_end(vendor_event, rateInfo);
872
873 return TRUE;
874error:
875 return FALSE;
876}
877
878static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
879 struct sk_buff *vendor_event)
880{
881 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
882 stats->ac ) ||
883 nla_put_u32(vendor_event,
884 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
885 stats->txMpdu ) ||
886 nla_put_u32(vendor_event,
887 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
888 stats->rxMpdu ) ||
889 nla_put_u32(vendor_event,
890 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
891 stats->txMcast ) ||
892 nla_put_u32(vendor_event,
893 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
894 stats->rxMcast ) ||
895 nla_put_u32(vendor_event,
896 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
897 stats->rxAmpdu ) ||
898 nla_put_u32(vendor_event,
899 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
900 stats->txAmpdu ) ||
901 nla_put_u32(vendor_event,
902 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
903 stats->mpduLost )||
904 nla_put_u32(vendor_event,
905 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
906 stats->retries ) ||
907 nla_put_u32(vendor_event,
908 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
909 stats->retriesShort ) ||
910 nla_put_u32(vendor_event,
911 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
912 stats->retriesLong ) ||
913 nla_put_u32(vendor_event,
914 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
915 stats->contentionTimeMin ) ||
916 nla_put_u32(vendor_event,
917 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
918 stats->contentionTimeMax ) ||
919 nla_put_u32(vendor_event,
920 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
921 stats->contentionTimeAvg ) ||
922 nla_put_u32(vendor_event,
923 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
924 stats->contentionNumSamples ))
925 {
926 hddLog(VOS_TRACE_LEVEL_ERROR,
927 FL("QCA_WLAN_VENDOR_ATTR put fail") );
928 return FALSE;
929 }
930 return TRUE;
931}
932
933static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
934 struct sk_buff *vendor_event)
935{
Dino Myclec8f3f332014-07-21 16:48:27 +0530936 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530937 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
938 nla_put(vendor_event,
939 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
940 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
941 nla_put_u32(vendor_event,
942 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
943 stats->state ) ||
944 nla_put_u32(vendor_event,
945 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
946 stats->roaming ) ||
947 nla_put_u32(vendor_event,
948 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
949 stats->capabilities ) ||
950 nla_put(vendor_event,
951 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
952 strlen(stats->ssid), stats->ssid) ||
953 nla_put(vendor_event,
954 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
955 WNI_CFG_BSSID_LEN, stats->bssid) ||
956 nla_put(vendor_event,
957 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
958 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
959 nla_put(vendor_event,
960 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
961 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
962 )
963 {
964 hddLog(VOS_TRACE_LEVEL_ERROR,
965 FL("QCA_WLAN_VENDOR_ATTR put fail") );
966 return FALSE;
967 }
968 return TRUE;
969}
970
Dino Mycle3b9536d2014-07-09 22:05:24 +0530971static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
972 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530973 struct sk_buff *vendor_event)
974{
975 int i = 0;
976 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530977 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
978 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530979 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530980
Sunil Duttc69bccb2014-05-26 21:30:20 +0530981 if (FALSE == put_wifi_interface_info(
982 &pWifiIfaceStat->info,
983 vendor_event))
984 {
985 hddLog(VOS_TRACE_LEVEL_ERROR,
986 FL("QCA_WLAN_VENDOR_ATTR put fail") );
987 return FALSE;
988
989 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530990 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
991 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
992 if (NULL == pWifiIfaceStatTL)
993 {
994 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
995 return FALSE;
996 }
997
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530998 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
999 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
1000 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
1001 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1002
1003 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1004 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1005 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1006 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301007
1008 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1009 {
1010 if (VOS_STATUS_SUCCESS ==
1011 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1012 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1013 {
1014 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1015 * obtained from TL structure
1016 */
1017
1018 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1019 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301020 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1021
Srinivas Dasari98947432014-11-07 19:41:24 +05301022 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1023 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1024 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1025 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1026 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1027 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1028 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1029 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301030
Srinivas Dasari98947432014-11-07 19:41:24 +05301031 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1032 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1033 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1034 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1035 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1036 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1037 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1038 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301039
Srinivas Dasari98947432014-11-07 19:41:24 +05301040 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1041 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1042 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1043 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1044 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1045 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1046 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1047 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301048 }
1049 else
1050 {
1051 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1052 }
1053
Dino Mycle3b9536d2014-07-09 22:05:24 +05301054 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1055 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1056 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1057 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1058 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1059 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1060 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1061 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1062 }
1063 else
1064 {
1065 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1066 }
1067
1068
Sunil Duttc69bccb2014-05-26 21:30:20 +05301069
1070 if (nla_put_u32(vendor_event,
1071 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1072 pWifiIfaceStat->beaconRx) ||
1073 nla_put_u32(vendor_event,
1074 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1075 pWifiIfaceStat->mgmtRx) ||
1076 nla_put_u32(vendor_event,
1077 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1078 pWifiIfaceStat->mgmtActionRx) ||
1079 nla_put_u32(vendor_event,
1080 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1081 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301082 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301083 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1084 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301085 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301086 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1087 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301088 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301089 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1090 pWifiIfaceStat->rssiAck))
1091 {
1092 hddLog(VOS_TRACE_LEVEL_ERROR,
1093 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301094 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301095 return FALSE;
1096 }
1097
1098 wmmInfo = nla_nest_start(vendor_event,
1099 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301100 if(!wmmInfo)
1101 {
1102 vos_mem_free(pWifiIfaceStatTL);
1103 return FALSE;
1104 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301105 for (i = 0; i < WIFI_AC_MAX; i++)
1106 {
1107 struct nlattr *wmmStats;
1108 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301109 if(!wmmStats)
1110 {
1111 vos_mem_free(pWifiIfaceStatTL);
1112 return FALSE;
1113 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301114 if (FALSE == put_wifi_wmm_ac_stat(
1115 &pWifiIfaceStat->AccessclassStats[i],
1116 vendor_event))
1117 {
1118 hddLog(VOS_TRACE_LEVEL_ERROR,
1119 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301120 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301121 return FALSE;
1122 }
1123
1124 nla_nest_end(vendor_event, wmmStats);
1125 }
1126 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301127 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301128 return TRUE;
1129}
1130
1131static tSirWifiInterfaceMode
1132 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1133{
1134 switch (deviceMode)
1135 {
1136 case WLAN_HDD_INFRA_STATION:
1137 return WIFI_INTERFACE_STA;
1138 case WLAN_HDD_SOFTAP:
1139 return WIFI_INTERFACE_SOFTAP;
1140 case WLAN_HDD_P2P_CLIENT:
1141 return WIFI_INTERFACE_P2P_CLIENT;
1142 case WLAN_HDD_P2P_GO:
1143 return WIFI_INTERFACE_P2P_GO;
1144 case WLAN_HDD_IBSS:
1145 return WIFI_INTERFACE_IBSS;
1146 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301147 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301148 }
1149}
1150
1151static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1152 tpSirWifiInterfaceInfo pInfo)
1153{
1154 v_U8_t *staMac = NULL;
1155 hdd_station_ctx_t *pHddStaCtx;
1156 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1157 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1158
1159 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1160
1161 vos_mem_copy(pInfo->macAddr,
1162 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1163
1164 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1165 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1166 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1167 {
1168 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1169 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1170 {
1171 pInfo->state = WIFI_DISCONNECTED;
1172 }
1173 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1174 {
1175 hddLog(VOS_TRACE_LEVEL_ERROR,
1176 "%s: Session ID %d, Connection is in progress", __func__,
1177 pAdapter->sessionId);
1178 pInfo->state = WIFI_ASSOCIATING;
1179 }
1180 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1181 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1182 {
1183 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1184 hddLog(VOS_TRACE_LEVEL_ERROR,
1185 "%s: client " MAC_ADDRESS_STR
1186 " is in the middle of WPS/EAPOL exchange.", __func__,
1187 MAC_ADDR_ARRAY(staMac));
1188 pInfo->state = WIFI_AUTHENTICATING;
1189 }
1190 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1191 {
1192 pInfo->state = WIFI_ASSOCIATED;
1193 vos_mem_copy(pInfo->bssid,
1194 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1195 vos_mem_copy(pInfo->ssid,
1196 pHddStaCtx->conn_info.SSID.SSID.ssId,
1197 pHddStaCtx->conn_info.SSID.SSID.length);
1198 //NULL Terminate the string.
1199 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1200 }
1201 }
1202 vos_mem_copy(pInfo->countryStr,
1203 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1204
1205 vos_mem_copy(pInfo->apCountryStr,
1206 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1207
1208 return TRUE;
1209}
1210
1211/*
1212 * hdd_link_layer_process_peer_stats () - This function is called after
1213 * receiving Link Layer Peer statistics from FW.This function converts
1214 * the firmware data to the NL data and sends the same to the kernel/upper
1215 * layers.
1216 */
1217static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1218 v_VOID_t *pData)
1219{
1220 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1221 tpSirWifiRateStat pWifiRateStat;
1222 tpSirWifiPeerStat pWifiPeerStat;
1223 tpSirWifiPeerInfo pWifiPeerInfo;
1224 struct nlattr *peerInfo;
1225 struct sk_buff *vendor_event;
1226 int status, i;
1227
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301228 ENTER();
1229
Sunil Duttc69bccb2014-05-26 21:30:20 +05301230 status = wlan_hdd_validate_context(pHddCtx);
1231 if (0 != status)
1232 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301233 return;
1234 }
1235
1236 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1237
1238 hddLog(VOS_TRACE_LEVEL_INFO,
1239 "LL_STATS_PEER_ALL : numPeers %u",
1240 pWifiPeerStat->numPeers);
1241 {
1242 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1243 {
1244 pWifiPeerInfo = (tpSirWifiPeerInfo)
1245 ((uint8 *)pWifiPeerStat->peerInfo +
1246 ( i * sizeof(tSirWifiPeerInfo)));
1247
Dasari Srinivas1be0c4e2014-10-19 13:03:41 +05301248 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) {
1249 pWifiPeerInfo->type = WIFI_PEER_AP;
1250 }
1251 if (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) {
1252 pWifiPeerInfo->type = WIFI_PEER_P2P_GO;
1253 }
1254
Sunil Duttc69bccb2014-05-26 21:30:20 +05301255 hddLog(VOS_TRACE_LEVEL_INFO,
1256 " %d) LL_STATS Channel Stats "
1257 " Peer Type %u "
1258 " peerMacAddress %pM "
1259 " capabilities 0x%x "
1260 " numRate %u ",
1261 i,
1262 pWifiPeerInfo->type,
1263 pWifiPeerInfo->peerMacAddress,
1264 pWifiPeerInfo->capabilities,
1265 pWifiPeerInfo->numRate);
1266 {
1267 int j;
1268 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1269 {
1270 pWifiRateStat = (tpSirWifiRateStat)
1271 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1272 ( j * sizeof(tSirWifiRateStat)));
1273
1274 hddLog(VOS_TRACE_LEVEL_INFO,
1275 " peer Rate Stats "
1276 " preamble %u "
1277 " nss %u "
1278 " bw %u "
1279 " rateMcsIdx %u "
1280 " reserved %u "
1281 " bitrate %u "
1282 " txMpdu %u "
1283 " rxMpdu %u "
1284 " mpduLost %u "
1285 " retries %u "
1286 " retriesShort %u "
1287 " retriesLong %u",
1288 pWifiRateStat->rate.preamble,
1289 pWifiRateStat->rate.nss,
1290 pWifiRateStat->rate.bw,
1291 pWifiRateStat->rate.rateMcsIdx,
1292 pWifiRateStat->rate.reserved,
1293 pWifiRateStat->rate.bitrate,
1294 pWifiRateStat->txMpdu,
1295 pWifiRateStat->rxMpdu,
1296 pWifiRateStat->mpduLost,
1297 pWifiRateStat->retries,
1298 pWifiRateStat->retriesShort,
1299 pWifiRateStat->retriesLong);
1300 }
1301 }
1302 }
1303 }
1304
1305 /*
1306 * Allocate a size of 4096 for the peer stats comprising
1307 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1308 * sizeof (tSirWifiRateStat).Each field is put with an
1309 * NL attribute.The size of 4096 is considered assuming
1310 * that number of rates shall not exceed beyond 50 with
1311 * the sizeof (tSirWifiRateStat) being 32.
1312 */
1313 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1314 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1315 QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX,
1316 GFP_KERNEL);
1317 if (!vendor_event)
1318 {
1319 hddLog(VOS_TRACE_LEVEL_ERROR,
1320 "%s: cfg80211_vendor_event_alloc failed",
1321 __func__);
1322 return;
1323 }
1324 if (nla_put_u32(vendor_event,
1325 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1326 pWifiPeerStat->numPeers))
1327 {
1328 hddLog(VOS_TRACE_LEVEL_ERROR,
1329 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1330 kfree_skb(vendor_event);
1331 return;
1332 }
1333
1334 peerInfo = nla_nest_start(vendor_event,
1335 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301336 if(!peerInfo)
1337 {
1338 hddLog(VOS_TRACE_LEVEL_ERROR,
1339 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1340 __func__);
1341 kfree_skb(vendor_event);
1342 return;
1343 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301344
1345 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1346 pWifiPeerStat->peerInfo);
1347
1348 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1349 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301350 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301351 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301352
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301353 if(!peers)
1354 {
1355 hddLog(VOS_TRACE_LEVEL_ERROR,
1356 "%s: peer stats put fail",
1357 __func__);
1358 kfree_skb(vendor_event);
1359 return;
1360 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301361 if (FALSE == put_wifi_peer_info(
1362 pWifiPeerInfo, vendor_event))
1363 {
1364 hddLog(VOS_TRACE_LEVEL_ERROR,
1365 "%s: put_wifi_peer_info put fail", __func__);
1366 kfree_skb(vendor_event);
1367 return;
1368 }
1369
1370 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1371 pWifiPeerStat->peerInfo +
1372 (i * sizeof(tSirWifiPeerInfo)) +
1373 (numRate * sizeof (tSirWifiRateStat)));
1374 nla_nest_end(vendor_event, peers);
1375 }
1376 nla_nest_end(vendor_event, peerInfo);
1377 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301378
1379 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301380}
1381
1382/*
1383 * hdd_link_layer_process_iface_stats () - This function is called after
1384 * receiving Link Layer Interface statistics from FW.This function converts
1385 * the firmware data to the NL data and sends the same to the kernel/upper
1386 * layers.
1387 */
1388static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1389 v_VOID_t *pData)
1390{
1391 tpSirWifiIfaceStat pWifiIfaceStat;
1392 struct sk_buff *vendor_event;
1393 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1394 int status;
1395
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301396 ENTER();
1397
Sunil Duttc69bccb2014-05-26 21:30:20 +05301398 status = wlan_hdd_validate_context(pHddCtx);
1399 if (0 != status)
1400 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301401 return;
1402 }
1403 /*
1404 * Allocate a size of 4096 for the interface stats comprising
1405 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1406 * assuming that all these fit with in the limit.Please take
1407 * a call on the limit based on the data requirements on
1408 * interface statistics.
1409 */
1410 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1411 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1412 QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX,
1413 GFP_KERNEL);
1414 if (!vendor_event)
1415 {
1416 hddLog(VOS_TRACE_LEVEL_ERROR,
1417 FL("cfg80211_vendor_event_alloc failed") );
1418 return;
1419 }
1420
1421 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1422
Dino Mycle3b9536d2014-07-09 22:05:24 +05301423
1424 if (FALSE == hdd_get_interface_info( pAdapter,
1425 &pWifiIfaceStat->info))
1426 {
1427 hddLog(VOS_TRACE_LEVEL_ERROR,
1428 FL("hdd_get_interface_info get fail") );
1429 kfree_skb(vendor_event);
1430 return;
1431 }
1432
1433 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1434 vendor_event))
1435 {
1436 hddLog(VOS_TRACE_LEVEL_ERROR,
1437 FL("put_wifi_iface_stats fail") );
1438 kfree_skb(vendor_event);
1439 return;
1440 }
1441
Sunil Duttc69bccb2014-05-26 21:30:20 +05301442 hddLog(VOS_TRACE_LEVEL_INFO,
1443 "WMI_LINK_STATS_IFACE Data");
1444
1445 hddLog(VOS_TRACE_LEVEL_INFO,
1446 "LL_STATS_IFACE: "
1447 " Mode %u "
1448 " MAC %pM "
1449 " State %u "
1450 " Roaming %u "
1451 " capabilities 0x%x "
1452 " SSID %s "
1453 " BSSID %pM",
1454 pWifiIfaceStat->info.mode,
1455 pWifiIfaceStat->info.macAddr,
1456 pWifiIfaceStat->info.state,
1457 pWifiIfaceStat->info.roaming,
1458 pWifiIfaceStat->info.capabilities,
1459 pWifiIfaceStat->info.ssid,
1460 pWifiIfaceStat->info.bssid);
1461
1462 hddLog(VOS_TRACE_LEVEL_INFO,
1463 " AP country str: %c%c%c",
1464 pWifiIfaceStat->info.apCountryStr[0],
1465 pWifiIfaceStat->info.apCountryStr[1],
1466 pWifiIfaceStat->info.apCountryStr[2]);
1467
1468
1469 hddLog(VOS_TRACE_LEVEL_INFO,
1470 " Country Str Association: %c%c%c",
1471 pWifiIfaceStat->info.countryStr[0],
1472 pWifiIfaceStat->info.countryStr[1],
1473 pWifiIfaceStat->info.countryStr[2]);
1474
1475 hddLog(VOS_TRACE_LEVEL_INFO,
1476 " beaconRx %u "
1477 " mgmtRx %u "
1478 " mgmtActionRx %u "
1479 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301480 " rssiMgmt %d "
1481 " rssiData %d "
1482 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301483 pWifiIfaceStat->beaconRx,
1484 pWifiIfaceStat->mgmtRx,
1485 pWifiIfaceStat->mgmtActionRx,
1486 pWifiIfaceStat->mgmtActionTx,
1487 pWifiIfaceStat->rssiMgmt,
1488 pWifiIfaceStat->rssiData,
1489 pWifiIfaceStat->rssiAck );
1490
1491
1492 {
1493 int i;
1494 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1495 {
1496 hddLog(VOS_TRACE_LEVEL_INFO,
1497
1498 " %d) LL_STATS IFACE: "
1499 " ac: %u txMpdu: %u "
1500 " rxMpdu: %u txMcast: %u "
1501 " rxMcast: %u rxAmpdu: %u "
1502 " txAmpdu: %u mpduLost: %u "
1503 " retries: %u retriesShort: %u "
1504 " retriesLong: %u contentionTimeMin: %u "
1505 " contentionTimeMax: %u contentionTimeAvg: %u "
1506 " contentionNumSamples: %u",
1507 i,
1508 pWifiIfaceStat->AccessclassStats[i].ac,
1509 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1510 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1511 pWifiIfaceStat->AccessclassStats[i].txMcast,
1512 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1513 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1514 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1515 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1516 pWifiIfaceStat->AccessclassStats[i].retries,
1517 pWifiIfaceStat->
1518 AccessclassStats[i].retriesShort,
1519 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1520 pWifiIfaceStat->
1521 AccessclassStats[i].contentionTimeMin,
1522 pWifiIfaceStat->
1523 AccessclassStats[i].contentionTimeMax,
1524 pWifiIfaceStat->
1525 AccessclassStats[i].contentionTimeAvg,
1526 pWifiIfaceStat->
1527 AccessclassStats[i].contentionNumSamples);
1528
1529 }
1530 }
1531
Sunil Duttc69bccb2014-05-26 21:30:20 +05301532 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301533
1534 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301535}
1536
1537/*
1538 * hdd_link_layer_process_radio_stats () - This function is called after
1539 * receiving Link Layer Radio statistics from FW.This function converts
1540 * the firmware data to the NL data and sends the same to the kernel/upper
1541 * layers.
1542 */
1543static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1544 v_VOID_t *pData)
1545{
1546 int status, i;
1547 tpSirWifiRadioStat pWifiRadioStat;
1548 tpSirWifiChannelStats pWifiChannelStats;
1549 struct sk_buff *vendor_event;
1550 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1551 struct nlattr *chList;
1552
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301553 ENTER();
1554
Sunil Duttc69bccb2014-05-26 21:30:20 +05301555 status = wlan_hdd_validate_context(pHddCtx);
1556 if (0 != status)
1557 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301558 return;
1559 }
1560 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1561
1562 hddLog(VOS_TRACE_LEVEL_INFO,
1563 "LL_STATS_RADIO"
1564 " radio is %d onTime is %u "
1565 " txTime is %u rxTime is %u "
1566 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301567 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301568 " onTimePnoScan is %u onTimeHs20 is %u "
1569 " numChannels is %u",
1570 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1571 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1572 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301573 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301574 pWifiRadioStat->onTimeRoamScan,
1575 pWifiRadioStat->onTimePnoScan,
1576 pWifiRadioStat->onTimeHs20,
1577 pWifiRadioStat->numChannels);
1578 /*
1579 * Allocate a size of 4096 for the Radio stats comprising
1580 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1581 * (tSirWifiChannelStats).Each channel data is put with an
1582 * NL attribute.The size of 4096 is considered assuming that
1583 * number of channels shall not exceed beyond 60 with the
1584 * sizeof (tSirWifiChannelStats) being 24 bytes.
1585 */
1586
1587 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1588 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN ,
1589 QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX,
1590 GFP_KERNEL);
1591
1592 if (!vendor_event)
1593 {
1594 hddLog(VOS_TRACE_LEVEL_ERROR,
1595 FL("cfg80211_vendor_event_alloc failed") );
1596 return;
1597 }
1598
1599 if (nla_put_u32(vendor_event,
1600 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1601 pWifiRadioStat->radio) ||
1602 nla_put_u32(vendor_event,
1603 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1604 pWifiRadioStat->onTime) ||
1605 nla_put_u32(vendor_event,
1606 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1607 pWifiRadioStat->txTime) ||
1608 nla_put_u32(vendor_event,
1609 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1610 pWifiRadioStat->rxTime) ||
1611 nla_put_u32(vendor_event,
1612 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1613 pWifiRadioStat->onTimeScan) ||
1614 nla_put_u32(vendor_event,
1615 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1616 pWifiRadioStat->onTimeNbd) ||
1617 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301618 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1619 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301620 nla_put_u32(vendor_event,
1621 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1622 pWifiRadioStat->onTimeRoamScan) ||
1623 nla_put_u32(vendor_event,
1624 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1625 pWifiRadioStat->onTimePnoScan) ||
1626 nla_put_u32(vendor_event,
1627 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1628 pWifiRadioStat->onTimeHs20) ||
1629 nla_put_u32(vendor_event,
1630 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1631 pWifiRadioStat->numChannels))
1632 {
1633 hddLog(VOS_TRACE_LEVEL_ERROR,
1634 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1635 kfree_skb(vendor_event);
1636 return ;
1637 }
1638
1639 chList = nla_nest_start(vendor_event,
1640 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301641 if(!chList)
1642 {
1643 hddLog(VOS_TRACE_LEVEL_ERROR,
1644 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1645 __func__);
1646 kfree_skb(vendor_event);
1647 return;
1648 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301649 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1650 {
1651 struct nlattr *chInfo;
1652
1653 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1654 pWifiRadioStat->channels +
1655 (i * sizeof(tSirWifiChannelStats)));
1656
1657 hddLog(VOS_TRACE_LEVEL_INFO,
1658 " %d) Channel Info"
1659 " width is %u "
1660 " CenterFreq %u "
1661 " CenterFreq0 %u "
1662 " CenterFreq1 %u "
1663 " onTime %u "
1664 " ccaBusyTime %u",
1665 i,
1666 pWifiChannelStats->channel.width,
1667 pWifiChannelStats->channel.centerFreq,
1668 pWifiChannelStats->channel.centerFreq0,
1669 pWifiChannelStats->channel.centerFreq1,
1670 pWifiChannelStats->onTime,
1671 pWifiChannelStats->ccaBusyTime);
1672
1673
1674 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301675 if(!chInfo)
1676 {
1677 hddLog(VOS_TRACE_LEVEL_ERROR,
1678 "%s: failed to put chInfo",
1679 __func__);
1680 kfree_skb(vendor_event);
1681 return;
1682 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301683
1684 if (nla_put_u32(vendor_event,
1685 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1686 pWifiChannelStats->channel.width) ||
1687 nla_put_u32(vendor_event,
1688 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1689 pWifiChannelStats->channel.centerFreq) ||
1690 nla_put_u32(vendor_event,
1691 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1692 pWifiChannelStats->channel.centerFreq0) ||
1693 nla_put_u32(vendor_event,
1694 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1695 pWifiChannelStats->channel.centerFreq1) ||
1696 nla_put_u32(vendor_event,
1697 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1698 pWifiChannelStats->onTime) ||
1699 nla_put_u32(vendor_event,
1700 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1701 pWifiChannelStats->ccaBusyTime))
1702 {
1703 hddLog(VOS_TRACE_LEVEL_ERROR,
1704 FL("cfg80211_vendor_event_alloc failed") );
1705 kfree_skb(vendor_event);
1706 return ;
1707 }
1708 nla_nest_end(vendor_event, chInfo);
1709 }
1710 nla_nest_end(vendor_event, chList);
1711
1712 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301713
1714 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301715 return;
1716}
1717
1718/*
1719 * hdd_link_layer_stats_ind_callback () - This function is called after
1720 * receiving Link Layer indications from FW.This callback converts the firmware
1721 * data to the NL data and send the same to the kernel/upper layers.
1722 */
1723static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1724 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301725 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301726{
Dino Mycled3d50022014-07-07 12:58:25 +05301727 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1728 hdd_adapter_t *pAdapter = NULL;
1729 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301730 int status;
1731
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301732 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301733
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301734 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301735 if (0 != status)
1736 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301737 return;
1738 }
1739
Dino Mycled3d50022014-07-07 12:58:25 +05301740 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1741 if (NULL == pAdapter)
1742 {
1743 hddLog(VOS_TRACE_LEVEL_ERROR,
1744 FL(" MAC address %pM does not exist with host"),
1745 macAddr);
1746 return;
1747 }
1748
Sunil Duttc69bccb2014-05-26 21:30:20 +05301749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301750 "%s: Interface: %s LLStats indType: %d", __func__,
1751 pAdapter->dev->name, indType);
1752
Sunil Duttc69bccb2014-05-26 21:30:20 +05301753 switch (indType)
1754 {
1755 case SIR_HAL_LL_STATS_RESULTS_RSP:
1756 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301757 hddLog(VOS_TRACE_LEVEL_INFO,
1758 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1759 hddLog(VOS_TRACE_LEVEL_INFO,
1760 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1761 linkLayerStatsResults->paramId);
1762 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301763 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1764 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301765 hddLog(VOS_TRACE_LEVEL_INFO,
1766 "LL_STATS RESULTS RESPONSE respId = %u",
1767 linkLayerStatsResults->respId);
1768 hddLog(VOS_TRACE_LEVEL_INFO,
1769 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1770 linkLayerStatsResults->moreResultToFollow);
1771 hddLog(VOS_TRACE_LEVEL_INFO,
1772 "LL_STATS RESULTS RESPONSE result = %p",
1773 linkLayerStatsResults->result);
1774 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1775 {
1776 hdd_link_layer_process_radio_stats(pAdapter,
1777 (v_VOID_t *)linkLayerStatsResults->result);
1778 }
1779 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1780 {
1781 hdd_link_layer_process_iface_stats(pAdapter,
1782 (v_VOID_t *)linkLayerStatsResults->result);
1783 }
1784 else if ( linkLayerStatsResults->paramId &
1785 WMI_LINK_STATS_ALL_PEER )
1786 {
1787 hdd_link_layer_process_peer_stats(pAdapter,
1788 (v_VOID_t *)linkLayerStatsResults->result);
1789 } /* WMI_LINK_STATS_ALL_PEER */
1790 else
1791 {
1792 hddLog(VOS_TRACE_LEVEL_ERROR,
1793 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1794 }
1795
1796 break;
1797 }
1798 default:
1799 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1800 break;
1801 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301802
1803 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301804 return;
1805}
1806
1807const struct
1808nla_policy
1809qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1810{
1811 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1812 { .type = NLA_U32 },
1813 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1814 { .type = NLA_U32 },
1815};
1816
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301817static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1818 struct wireless_dev *wdev,
1819 const void *data,
1820 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301821{
1822 int status;
1823 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301824 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301825 struct net_device *dev = wdev->netdev;
1826 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1827 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Srinivas Dasari98947432014-11-07 19:41:24 +05301828 hdd_station_ctx_t *pHddStaCtx;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301829
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301830 ENTER();
1831
Sunil Duttc69bccb2014-05-26 21:30:20 +05301832 status = wlan_hdd_validate_context(pHddCtx);
1833 if (0 != status)
1834 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301835 return -EINVAL;
1836 }
1837
1838 if (NULL == pAdapter)
1839 {
1840 hddLog(VOS_TRACE_LEVEL_ERROR,
1841 FL("HDD adapter is Null"));
1842 return -ENODEV;
1843 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301844 /* check the LLStats Capability */
1845 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1846 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1847 {
1848 hddLog(VOS_TRACE_LEVEL_ERROR,
1849 FL("Link Layer Statistics not supported by Firmware"));
1850 return -EINVAL;
1851 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301852
1853 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1854 (struct nlattr *)data,
1855 data_len, qca_wlan_vendor_ll_set_policy))
1856 {
1857 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1858 return -EINVAL;
1859 }
1860 if (!tb_vendor
1861 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1862 {
1863 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1864 return -EINVAL;
1865 }
1866 if (!tb_vendor[
1867 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1868 {
1869 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1870 return -EINVAL;
1871 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301872 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301873 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301874
Dino Mycledf0a5d92014-07-04 09:41:55 +05301875 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301876 nla_get_u32(
1877 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1878
Dino Mycledf0a5d92014-07-04 09:41:55 +05301879 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301880 nla_get_u32(
1881 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1882
Dino Mycled3d50022014-07-07 12:58:25 +05301883 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1884 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301885
1886
1887 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301888 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301889 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301890 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301891 hddLog(VOS_TRACE_LEVEL_INFO,
1892 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301893 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301894 hddLog(VOS_TRACE_LEVEL_INFO,
1895 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301896 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301897
1898 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1899 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301900 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301901 {
1902 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1903 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301904 return -EINVAL;
1905
1906 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301907
1908 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1909 if (VOS_STATUS_SUCCESS !=
1910 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1911 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE))
1912 {
1913 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1914 "WLANTL_ClearInterfaceStats Failed", __func__);
1915 return -EINVAL;
1916 }
1917
Sunil Duttc69bccb2014-05-26 21:30:20 +05301918 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301919 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301920 {
1921 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1922 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301923 return -EINVAL;
1924 }
1925
1926 pAdapter->isLinkLayerStatsSet = 1;
1927
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301928 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301929 return 0;
1930}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301931static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1932 struct wireless_dev *wdev,
1933 const void *data,
1934 int data_len)
1935{
1936 int ret = 0;
1937
1938 vos_ssr_protect(__func__);
1939 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1940 vos_ssr_unprotect(__func__);
1941
1942 return ret;
1943}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301944
1945const struct
1946nla_policy
1947qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1948{
1949 /* Unsigned 32bit value provided by the caller issuing the GET stats
1950 * command. When reporting
1951 * the stats results, the driver uses the same value to indicate
1952 * which GET request the results
1953 * correspond to.
1954 */
1955 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1956
1957 /* Unsigned 32bit value . bit mask to identify what statistics are
1958 requested for retrieval */
1959 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1960};
1961
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301962static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1963 struct wireless_dev *wdev,
1964 const void *data,
1965 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301966{
1967 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1968 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301969 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301970 struct net_device *dev = wdev->netdev;
1971 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1972 int status;
1973
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301974 ENTER();
1975
Sunil Duttc69bccb2014-05-26 21:30:20 +05301976 status = wlan_hdd_validate_context(pHddCtx);
1977 if (0 != status)
1978 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301979 return -EINVAL ;
1980 }
1981
1982 if (NULL == pAdapter)
1983 {
1984 hddLog(VOS_TRACE_LEVEL_FATAL,
1985 "%s: HDD adapter is Null", __func__);
1986 return -ENODEV;
1987 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301988 /* check the LLStats Capability */
1989 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1990 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1991 {
1992 hddLog(VOS_TRACE_LEVEL_ERROR,
1993 FL("Link Layer Statistics not supported by Firmware"));
1994 return -EINVAL;
1995 }
1996
Sunil Duttc69bccb2014-05-26 21:30:20 +05301997
1998 if (!pAdapter->isLinkLayerStatsSet)
1999 {
2000 hddLog(VOS_TRACE_LEVEL_FATAL,
2001 "%s: isLinkLayerStatsSet : %d",
2002 __func__, pAdapter->isLinkLayerStatsSet);
2003 return -EINVAL;
2004 }
2005
2006 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2007 (struct nlattr *)data,
2008 data_len, qca_wlan_vendor_ll_get_policy))
2009 {
2010 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2011 return -EINVAL;
2012 }
2013
2014 if (!tb_vendor
2015 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2016 {
2017 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2018 return -EINVAL;
2019 }
2020
2021 if (!tb_vendor
2022 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2023 {
2024 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
2025 return -EINVAL;
2026 }
2027
Sunil Duttc69bccb2014-05-26 21:30:20 +05302028
Dino Mycledf0a5d92014-07-04 09:41:55 +05302029 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302030 nla_get_u32( tb_vendor[
2031 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05302032 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302033 nla_get_u32( tb_vendor[
2034 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
2035
Dino Mycled3d50022014-07-07 12:58:25 +05302036 vos_mem_copy(linkLayerStatsGetReq.macAddr,
2037 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302038
2039 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302040 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302041 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302042 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302043 hddLog(VOS_TRACE_LEVEL_INFO,
2044 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302045 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302046
2047 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302048 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302049 {
2050 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2051 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302052 return -EINVAL;
2053 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302054
2055 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302056 return 0;
2057}
2058
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302059static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2060 struct wireless_dev *wdev,
2061 const void *data,
2062 int data_len)
2063{
2064 int ret = 0;
2065
2066 vos_ssr_protect(__func__);
2067 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
2068 vos_ssr_unprotect(__func__);
2069
2070 return ret;
2071}
2072
Sunil Duttc69bccb2014-05-26 21:30:20 +05302073const struct
2074nla_policy
2075qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
2076{
2077 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
2078 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
2079 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
2080 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
2081};
2082
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302083static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2084 struct wireless_dev *wdev,
2085 const void *data,
2086 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302087{
2088 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2089 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302090 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302091 struct net_device *dev = wdev->netdev;
2092 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2093 u32 statsClearReqMask;
2094 u8 stopReq;
2095 int status;
2096
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302097 ENTER();
2098
Sunil Duttc69bccb2014-05-26 21:30:20 +05302099 status = wlan_hdd_validate_context(pHddCtx);
2100 if (0 != status)
2101 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302102 return -EINVAL;
2103 }
2104
2105 if (NULL == pAdapter)
2106 {
2107 hddLog(VOS_TRACE_LEVEL_FATAL,
2108 "%s: HDD adapter is Null", __func__);
2109 return -ENODEV;
2110 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302111 /* check the LLStats Capability */
2112 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2113 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2114 {
2115 hddLog(VOS_TRACE_LEVEL_ERROR,
2116 FL("Enable LLStats Capability"));
2117 return -EINVAL;
2118 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302119
2120 if (!pAdapter->isLinkLayerStatsSet)
2121 {
2122 hddLog(VOS_TRACE_LEVEL_FATAL,
2123 "%s: isLinkLayerStatsSet : %d",
2124 __func__, pAdapter->isLinkLayerStatsSet);
2125 return -EINVAL;
2126 }
2127
2128 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2129 (struct nlattr *)data,
2130 data_len, qca_wlan_vendor_ll_clr_policy))
2131 {
2132 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2133 return -EINVAL;
2134 }
2135
2136 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2137
2138 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2139 {
2140 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2141 return -EINVAL;
2142
2143 }
2144
Sunil Duttc69bccb2014-05-26 21:30:20 +05302145
Dino Mycledf0a5d92014-07-04 09:41:55 +05302146 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302147 nla_get_u32(
2148 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2149
Dino Mycledf0a5d92014-07-04 09:41:55 +05302150 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302151 nla_get_u8(
2152 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2153
2154 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302155 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302156
Dino Mycled3d50022014-07-07 12:58:25 +05302157 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2158 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302159
2160 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302161 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302162 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302163 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302164 hddLog(VOS_TRACE_LEVEL_INFO,
2165 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302166 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302167 hddLog(VOS_TRACE_LEVEL_INFO,
2168 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302169 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302170
2171 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302172 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302173 {
2174 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302175 hdd_station_ctx_t *pHddStaCtx;
2176
2177 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2178 if (VOS_STATUS_SUCCESS !=
2179 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2180 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2181 {
2182 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2183 "WLANTL_ClearInterfaceStats Failed", __func__);
2184 return -EINVAL;
2185 }
2186 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2187 (statsClearReqMask & WIFI_STATS_IFACE)) {
2188 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2189 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2190 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2191 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2192 }
2193
Sunil Duttc69bccb2014-05-26 21:30:20 +05302194 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2195 2 * sizeof(u32) +
2196 NLMSG_HDRLEN);
2197
2198 if (temp_skbuff != NULL)
2199 {
2200
2201 if (nla_put_u32(temp_skbuff,
2202 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2203 statsClearReqMask) ||
2204 nla_put_u32(temp_skbuff,
2205 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2206 stopReq))
2207 {
2208 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2209 kfree_skb(temp_skbuff);
2210 return -EINVAL;
2211 }
2212 /* If the ask is to stop the stats collection as part of clear
2213 * (stopReq = 1) , ensure that no further requests of get
2214 * go to the firmware by having isLinkLayerStatsSet set to 0.
2215 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302216 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302217 * case the firmware is just asked to clear the statistics.
2218 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302219 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302220 pAdapter->isLinkLayerStatsSet = 0;
2221 return cfg80211_vendor_cmd_reply(temp_skbuff);
2222 }
2223 return -ENOMEM;
2224 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302225
2226 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302227 return -EINVAL;
2228}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302229static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2230 struct wireless_dev *wdev,
2231 const void *data,
2232 int data_len)
2233{
2234 int ret = 0;
2235
2236 vos_ssr_protect(__func__);
2237 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2238 vos_ssr_unprotect(__func__);
2239
2240 return ret;
2241
2242
2243}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302244#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2245
Dino Mycle6fb96c12014-06-10 11:52:40 +05302246#ifdef WLAN_FEATURE_EXTSCAN
2247static const struct nla_policy
2248wlan_hdd_extscan_config_policy
2249 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2250{
2251 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2252 { .type = NLA_U32 },
2253 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2254 { .type = NLA_U32 },
2255 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2256 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2257 { .type = NLA_U32 },
2258 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2259 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2260
2261 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2262 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2263 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2264 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2265 { .type = NLA_U8 },
2266 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2267 { .type = NLA_U32 },
2268 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2269 { .type = NLA_U32 },
2270 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2271 { .type = NLA_U32 },
2272 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] =
2273 { .type = NLA_U8 },
2274 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2275 { .type = NLA_U8 },
2276 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2277 { .type = NLA_U8 },
2278
2279 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2280 { .type = NLA_U32 },
2281 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2282 { .type = NLA_UNSPEC },
2283 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2284 { .type = NLA_S32 },
2285 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2286 { .type = NLA_S32 },
2287 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2288 { .type = NLA_U32 },
2289 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2290 { .type = NLA_U32 },
2291 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] =
2292 { .type = NLA_U32 },
2293 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]
2294 = { .type = NLA_U32 },
2295 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] =
2296 { .type = NLA_U32 },
2297 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type =
2298 NLA_U32 },
2299};
2300
2301static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg)
2302{
2303 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2304 struct sk_buff *skb = NULL;
2305 tpSirEXTScanCapabilitiesEvent pData =
2306 (tpSirEXTScanCapabilitiesEvent) pMsg;
2307
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302308 ENTER();
2309
2310 if (wlan_hdd_validate_context(pHddCtx))
2311 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302312 return;
2313 }
2314
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302315 if (!pMsg)
2316 {
2317 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2318 return;
2319 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302320 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2321 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2322 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
2323 GFP_KERNEL);
2324
2325 if (!skb) {
2326 hddLog(VOS_TRACE_LEVEL_ERROR,
2327 FL("cfg80211_vendor_event_alloc failed"));
2328 return;
2329 }
2330
2331 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2332 hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize);
2333 hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets);
2334 hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan);
2335 hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)",
2336 pData->maxRssiSampleSize);
2337 hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)",
2338 pData->maxScanReportingThreshold);
2339 hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs);
2340 hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)",
2341 pData->maxSignificantWifiChangeAPs);
2342 hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)",
2343 pData->maxBsidHistoryEntries);
2344
2345 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2346 pData->requestId) ||
2347 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) ||
2348 nla_put_u32(skb,
2349 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
2350 pData->scanCacheSize) ||
2351 nla_put_u32(skb,
2352 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
2353 pData->scanBuckets) ||
2354 nla_put_u32(skb,
2355 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
2356 pData->maxApPerScan) ||
2357 nla_put_u32(skb,
2358 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
2359 pData->maxRssiSampleSize) ||
2360 nla_put_u32(skb,
2361 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
2362 pData->maxScanReportingThreshold) ||
2363 nla_put_u32(skb,
2364 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS,
2365 pData->maxHotlistAPs) ||
2366 nla_put_u32(skb,
2367 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
2368 pData->maxSignificantWifiChangeAPs) ||
2369 nla_put_u32(skb,
2370 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
2371 pData->maxBsidHistoryEntries)) {
2372 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2373 goto nla_put_failure;
2374 }
2375
2376 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302377 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302378 return;
2379
2380nla_put_failure:
2381 kfree_skb(skb);
2382 return;
2383}
2384
2385
2386static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2387{
2388 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2389 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2390 struct sk_buff *skb = NULL;
2391 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
2392
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302393 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302394
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302395 if (wlan_hdd_validate_context(pHddCtx)){
2396 return;
2397 }
2398 if (!pMsg)
2399 {
2400 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302401 return;
2402 }
2403
2404 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2405 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2406 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
2407 GFP_KERNEL);
2408
2409 if (!skb) {
2410 hddLog(VOS_TRACE_LEVEL_ERROR,
2411 FL("cfg80211_vendor_event_alloc failed"));
2412 return;
2413 }
2414 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2415 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2416 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2417
2418 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2419 pData->requestId) ||
2420 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2421 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2422 goto nla_put_failure;
2423 }
2424
2425 /*
2426 * Store the Request ID for comparing with the requestID obtained
2427 * in other requests.HDD shall return a failure is the extscan_stop
2428 * request is issued with a different requestId as that of the
2429 * extscan_start request. Also, This requestId shall be used while
2430 * indicating the full scan results to the upper layers.
2431 * The requestId is stored with the assumption that the firmware
2432 * shall return the ext scan start request's requestId in ext scan
2433 * start response.
2434 */
2435 if (pData->status == 0)
2436 pMac->sme.extScanStartReqId = pData->requestId;
2437
2438
2439 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302440 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302441 return;
2442
2443nla_put_failure:
2444 kfree_skb(skb);
2445 return;
2446}
2447
2448
2449static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2450{
2451 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2452 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2453 struct sk_buff *skb = NULL;
2454
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302455 ENTER();
2456
2457 if (wlan_hdd_validate_context(pHddCtx)){
2458 return;
2459 }
2460 if (!pMsg)
2461 {
2462 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302463 return;
2464 }
2465
2466 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2467 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2468 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2469 GFP_KERNEL);
2470
2471 if (!skb) {
2472 hddLog(VOS_TRACE_LEVEL_ERROR,
2473 FL("cfg80211_vendor_event_alloc failed"));
2474 return;
2475 }
2476 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2477 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2478
2479 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2480 pData->requestId) ||
2481 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2482 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2483 goto nla_put_failure;
2484 }
2485
2486 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302487 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302488 return;
2489
2490nla_put_failure:
2491 kfree_skb(skb);
2492 return;
2493}
2494
2495
2496static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2497 void *pMsg)
2498{
2499 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2500 struct sk_buff *skb = NULL;
2501 tpSirEXTScanSetBssidHotListRspParams pData =
2502 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2503
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302504 ENTER();
2505
2506 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302507 return;
2508 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302509 if (!pMsg)
2510 {
2511 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2512 return;
2513 }
2514
Dino Mycle6fb96c12014-06-10 11:52:40 +05302515 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2516 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2517 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2518 GFP_KERNEL);
2519
2520 if (!skb) {
2521 hddLog(VOS_TRACE_LEVEL_ERROR,
2522 FL("cfg80211_vendor_event_alloc failed"));
2523 return;
2524 }
2525 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2526 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2527 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2528
2529 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2530 pData->requestId) ||
2531 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2532 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2533 goto nla_put_failure;
2534 }
2535
2536 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302537 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302538 return;
2539
2540nla_put_failure:
2541 kfree_skb(skb);
2542 return;
2543}
2544
2545static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2546 void *pMsg)
2547{
2548 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2549 struct sk_buff *skb = NULL;
2550 tpSirEXTScanResetBssidHotlistRspParams pData =
2551 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2552
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302553 ENTER();
2554
2555 if (wlan_hdd_validate_context(pHddCtx)) {
2556 return;
2557 }
2558 if (!pMsg)
2559 {
2560 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302561 return;
2562 }
2563
2564 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2565 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2566 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2567 GFP_KERNEL);
2568
2569 if (!skb) {
2570 hddLog(VOS_TRACE_LEVEL_ERROR,
2571 FL("cfg80211_vendor_event_alloc failed"));
2572 return;
2573 }
2574 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2575 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2576
2577 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2578 pData->requestId) ||
2579 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2580 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2581 goto nla_put_failure;
2582 }
2583
2584 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302585 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302586 return;
2587
2588nla_put_failure:
2589 kfree_skb(skb);
2590 return;
2591}
2592
2593
2594static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2595 void *pMsg)
2596{
2597 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2598 struct sk_buff *skb = NULL;
2599 tpSirEXTScanSetSignificantChangeRspParams pData =
2600 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2601
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302602 ENTER();
2603
2604 if (wlan_hdd_validate_context(pHddCtx)) {
2605 return;
2606 }
2607 if (!pMsg)
2608 {
2609 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302610 return;
2611 }
2612
2613 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2614 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2615 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2616 GFP_KERNEL);
2617
2618 if (!skb) {
2619 hddLog(VOS_TRACE_LEVEL_ERROR,
2620 FL("cfg80211_vendor_event_alloc failed"));
2621 return;
2622 }
2623 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2624 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2625 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2626
2627 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2628 pData->requestId) ||
2629 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2630 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2631 goto nla_put_failure;
2632 }
2633
2634 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302635 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302636 return;
2637
2638nla_put_failure:
2639 kfree_skb(skb);
2640 return;
2641}
2642
2643
2644static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2645 void *pMsg)
2646{
2647 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2648 struct sk_buff *skb = NULL;
2649 tpSirEXTScanResetSignificantChangeRspParams pData =
2650 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2651
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302652 ENTER();
2653
2654 if (wlan_hdd_validate_context(pHddCtx)) {
2655 return;
2656 }
2657 if (!pMsg)
2658 {
2659 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302660 return;
2661 }
2662
2663 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2664 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2665 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2666 GFP_KERNEL);
2667
2668 if (!skb) {
2669 hddLog(VOS_TRACE_LEVEL_ERROR,
2670 FL("cfg80211_vendor_event_alloc failed"));
2671 return;
2672 }
2673 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2674 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2675 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2676
2677 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2678 pData->requestId) ||
2679 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2680 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2681 goto nla_put_failure;
2682 }
2683
2684 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302685 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302686 return;
2687
2688nla_put_failure:
2689 kfree_skb(skb);
2690 return;
2691}
2692
2693static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2694 void *pMsg)
2695{
2696 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2697 struct sk_buff *skb = NULL;
2698 tANI_U32 i = 0, j, resultsPerEvent;
2699 tANI_S32 totalResults;
2700 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2701 tpSirWifiScanResult pSirWifiScanResult;
2702
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302703 ENTER();
2704
2705 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302706 return;
2707 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302708 if (!pMsg)
2709 {
2710 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2711 return;
2712 }
2713
Dino Mycle6fb96c12014-06-10 11:52:40 +05302714 totalResults = pData->numOfAps;
2715 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2716 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2717 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2718
2719 do{
2720 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2721 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2722 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2723
2724 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2725 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2726 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2727 GFP_KERNEL);
2728
2729 if (!skb) {
2730 hddLog(VOS_TRACE_LEVEL_ERROR,
2731 FL("cfg80211_vendor_event_alloc failed"));
2732 return;
2733 }
2734
2735 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2736
2737 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2738 pData->requestId) ||
2739 nla_put_u32(skb,
2740 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2741 resultsPerEvent)) {
2742 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2743 goto fail;
2744 }
2745 if (nla_put_u8(skb,
2746 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2747 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2748 {
2749 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2750 goto fail;
2751 }
2752
2753 if (resultsPerEvent) {
2754 struct nlattr *aps;
2755
2756 aps = nla_nest_start(skb,
2757 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2758 if (!aps)
2759 {
2760 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2761 goto fail;
2762 }
2763
2764 for (j = 0; j < resultsPerEvent; j++, i++) {
2765 struct nlattr *ap;
2766 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2767 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2768
2769 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2770 "Ssid (%s)"
2771 "Bssid: %pM "
2772 "Channel (%u)"
2773 "Rssi (%d)"
2774 "RTT (%u)"
2775 "RTT_SD (%u)",
2776 i,
2777 pSirWifiScanResult->ts,
2778 pSirWifiScanResult->ssid,
2779 pSirWifiScanResult->bssid,
2780 pSirWifiScanResult->channel,
2781 pSirWifiScanResult->rssi,
2782 pSirWifiScanResult->rtt,
2783 pSirWifiScanResult->rtt_sd);
2784
2785 ap = nla_nest_start(skb, j + 1);
2786 if (!ap)
2787 {
2788 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2789 goto fail;
2790 }
2791
2792 if (nla_put_u64(skb,
2793 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2794 pSirWifiScanResult->ts) )
2795 {
2796 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2797 goto fail;
2798 }
2799 if (nla_put(skb,
2800 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2801 sizeof(pSirWifiScanResult->ssid),
2802 pSirWifiScanResult->ssid) )
2803 {
2804 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2805 goto fail;
2806 }
2807 if (nla_put(skb,
2808 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2809 sizeof(pSirWifiScanResult->bssid),
2810 pSirWifiScanResult->bssid) )
2811 {
2812 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2813 goto fail;
2814 }
2815 if (nla_put_u32(skb,
2816 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2817 pSirWifiScanResult->channel) )
2818 {
2819 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2820 goto fail;
2821 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302822 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302823 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2824 pSirWifiScanResult->rssi) )
2825 {
2826 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2827 goto fail;
2828 }
2829 if (nla_put_u32(skb,
2830 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2831 pSirWifiScanResult->rtt) )
2832 {
2833 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2834 goto fail;
2835 }
2836 if (nla_put_u32(skb,
2837 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2838 pSirWifiScanResult->rtt_sd))
2839 {
2840 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2841 goto fail;
2842 }
2843
2844 nla_nest_end(skb, ap);
2845 }
2846 nla_nest_end(skb, aps);
2847
2848 }
2849 cfg80211_vendor_event(skb, GFP_KERNEL);
2850 } while (totalResults > 0);
2851
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302852 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302853 return;
2854fail:
2855 kfree_skb(skb);
2856 return;
2857}
2858
2859static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2860 void *pMsg)
2861{
2862 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2863 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2864 struct sk_buff *skb = NULL;
2865 tANI_U32 i;
2866
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302867 ENTER();
2868
2869 if (wlan_hdd_validate_context(pHddCtx)) {
2870 return;
2871 }
2872 if (!pMsg)
2873 {
2874 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302875 return;
2876 }
2877
2878 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2879 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2880 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
2881 GFP_KERNEL);
2882
2883 if (!skb) {
2884 hddLog(VOS_TRACE_LEVEL_ERROR,
2885 FL("cfg80211_vendor_event_alloc failed"));
2886 return;
2887 }
2888 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2889 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2890 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2891 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2892
2893 for (i = 0; i < pData->numOfAps; i++) {
2894 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2895 "Ssid (%s) "
2896 "Bssid (" MAC_ADDRESS_STR ") "
2897 "Channel (%u) "
2898 "Rssi (%d) "
2899 "RTT (%u) "
2900 "RTT_SD (%u) ",
2901 i,
2902 pData->ap[i].ts,
2903 pData->ap[i].ssid,
2904 MAC_ADDR_ARRAY(pData->ap[i].bssid),
2905 pData->ap[i].channel,
2906 pData->ap[i].rssi,
2907 pData->ap[i].rtt,
2908 pData->ap[i].rtt_sd);
2909 }
2910
2911 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2912 pData->requestId) ||
2913 nla_put_u32(skb,
2914 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2915 pData->numOfAps)) {
2916 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2917 goto fail;
2918 }
2919 if (pData->numOfAps) {
2920 struct nlattr *aps;
2921
2922 aps = nla_nest_start(skb,
2923 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2924 if (!aps)
2925 goto fail;
2926
2927 for (i = 0; i < pData->numOfAps; i++) {
2928 struct nlattr *ap;
2929
2930 ap = nla_nest_start(skb, i + 1);
2931 if (!ap)
2932 goto fail;
2933
2934 if (nla_put_u64(skb,
2935 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2936 pData->ap[i].ts) ||
2937 nla_put(skb,
2938 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2939 sizeof(pData->ap[i].ssid),
2940 pData->ap[i].ssid) ||
2941 nla_put(skb,
2942 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2943 sizeof(pData->ap[i].bssid),
2944 pData->ap[i].bssid) ||
2945 nla_put_u32(skb,
2946 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2947 pData->ap[i].channel) ||
2948 nla_put_s32(skb,
2949 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2950 pData->ap[i].rssi) ||
2951 nla_put_u32(skb,
2952 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2953 pData->ap[i].rtt) ||
2954 nla_put_u32(skb,
2955 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2956 pData->ap[i].rtt_sd))
2957 goto fail;
2958
2959 nla_nest_end(skb, ap);
2960 }
2961 nla_nest_end(skb, aps);
2962
2963 if (nla_put_u8(skb,
2964 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2965 pData->moreData))
2966 goto fail;
2967 }
2968
2969 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302970 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302971 return;
2972
2973fail:
2974 kfree_skb(skb);
2975 return;
2976
2977}
2978static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
2979 void *pMsg)
2980{
2981 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2982 struct sk_buff *skb = NULL;
2983 tANI_U32 i, j;
2984 tpSirWifiSignificantChangeEvent pData =
2985 (tpSirWifiSignificantChangeEvent) pMsg;
2986
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302987 ENTER();
2988
2989 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302990 return;
2991 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302992 if (!pMsg)
2993 {
2994 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2995 return;
2996 }
2997
Dino Mycle6fb96c12014-06-10 11:52:40 +05302998 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2999 EXTSCAN_EVENT_BUF_SIZE,
3000 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
3001 GFP_KERNEL);
3002
3003 if (!skb) {
3004 hddLog(VOS_TRACE_LEVEL_ERROR,
3005 FL("cfg80211_vendor_event_alloc failed"));
3006 return;
3007 }
3008 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3009 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3010 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
3011 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
3012 pData->numSigRssiBss);
3013 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
3014
3015 for (i = 0; i < pData->numSigRssiBss; i++) {
3016 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
3017 " num RSSI %u ",
3018 i, pData->sigRssiResult[i].bssid,
3019 pData->sigRssiResult[i].channel,
3020 pData->sigRssiResult[i].numRssi);
3021
3022 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
3023
3024 hddLog(VOS_TRACE_LEVEL_INFO,
3025 " [%d]",
Dino Myclec8f3f332014-07-21 16:48:27 +05303026 pData->sigRssiResult[i].rssi[j]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303027
3028 }
3029 }
3030
3031
3032 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3033 pData->requestId) ||
3034 nla_put_u32(skb,
3035 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3036 pData->numSigRssiBss)) {
3037 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3038 goto fail;
3039 }
3040
3041 if (pData->numSigRssiBss) {
3042 struct nlattr *aps;
3043 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3044 if (!aps)
3045 goto fail;
3046 for (i = 0; i < pData->numSigRssiBss; i++) {
3047 struct nlattr *ap;
3048
3049 ap = nla_nest_start(skb, i);
3050 if (!ap)
3051 goto fail;
3052 if (nla_put(skb,
3053 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
3054 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
3055 nla_put_u32(skb,
3056 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
3057 pData->sigRssiResult[i].channel) ||
3058 nla_put_u32(skb,
3059 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
3060 pData->sigRssiResult[i].numRssi) ||
3061 nla_put(skb,
3062 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
3063 sizeof(s32) * pData->sigRssiResult[i].numRssi,
3064 pData->sigRssiResult[i].rssi))
3065 goto fail;
3066 nla_nest_end(skb, ap);
3067 }
3068 nla_nest_end(skb, aps);
3069 if (nla_put_u8(skb,
3070 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3071 pData->moreData))
3072 goto fail;
3073 }
3074 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303075 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303076 return;
3077fail:
3078 kfree_skb(skb);
3079 return;
3080}
3081
3082static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3083 void *pMsg)
3084{
3085 struct sk_buff *skb;
3086 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3087 tpSirWifiFullScanResultEvent pData =
3088 (tpSirWifiFullScanResultEvent) (pMsg);
3089
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303090 ENTER();
3091
3092 if (wlan_hdd_validate_context(pHddCtx)) {
3093 return;
3094 }
3095 if (!pMsg)
3096 {
3097 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303098 return;
3099 }
3100
3101 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3102 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3103 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3104 GFP_KERNEL);
3105
3106 if (!skb) {
3107 hddLog(VOS_TRACE_LEVEL_ERROR,
3108 FL("cfg80211_vendor_event_alloc failed"));
3109 return;
3110 }
3111
3112 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3113 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3114 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3115 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3116 "Ssid (%s)"
3117 "Bssid (" MAC_ADDRESS_STR ")"
3118 "Channel (%u)"
3119 "Rssi (%d)"
3120 "RTT (%u)"
3121 "RTT_SD (%u)"),
3122 pData->ap.ts,
3123 pData->ap.ssid,
3124 MAC_ADDR_ARRAY(pData->ap.bssid),
3125 pData->ap.channel,
3126 pData->ap.rssi,
3127 pData->ap.rtt,
3128 pData->ap.rtt_sd);
3129 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3130 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3131 pData->requestId) ||
3132 nla_put_u64(skb,
3133 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3134 pData->ap.ts) ||
3135 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3136 sizeof(pData->ap.ssid),
3137 pData->ap.ssid) ||
3138 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3139 WNI_CFG_BSSID_LEN,
3140 pData->ap.bssid) ||
3141 nla_put_u32(skb,
3142 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3143 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303144 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303145 pData->ap.rssi) ||
3146 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3147 pData->ap.rtt) ||
3148 nla_put_u32(skb,
3149 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3150 pData->ap.rtt_sd) ||
3151 nla_put_u16(skb,
3152 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3153 pData->ap.beaconPeriod) ||
3154 nla_put_u16(skb,
3155 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3156 pData->ap.capability) ||
3157 nla_put_u32(skb,
3158 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3159 pData->ieLength))
3160 {
3161 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3162 goto nla_put_failure;
3163 }
3164 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3165 pData->ieLength,
3166 pData->ie))
3167 {
3168 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3169 goto nla_put_failure;
3170 }
3171
3172 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303173 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303174 return;
3175
3176nla_put_failure:
3177 kfree_skb(skb);
3178 return;
3179}
3180
3181static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3182 void *pMsg)
3183{
3184 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3185 struct sk_buff *skb = NULL;
3186 tpSirEXTScanResultsAvailableIndParams pData =
3187 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3188
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303189 ENTER();
3190
3191 if (wlan_hdd_validate_context(pHddCtx)){
3192 return;
3193 }
3194 if (!pMsg)
3195 {
3196 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303197 return;
3198 }
3199
3200 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3201 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3202 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3203 GFP_KERNEL);
3204
3205 if (!skb) {
3206 hddLog(VOS_TRACE_LEVEL_ERROR,
3207 FL("cfg80211_vendor_event_alloc failed"));
3208 return;
3209 }
3210
3211 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3212 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3213 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3214 pData->numResultsAvailable);
3215 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3216 pData->requestId) ||
3217 nla_put_u32(skb,
3218 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3219 pData->numResultsAvailable)) {
3220 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3221 goto nla_put_failure;
3222 }
3223
3224 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303225 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303226 return;
3227
3228nla_put_failure:
3229 kfree_skb(skb);
3230 return;
3231}
3232
3233static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3234{
3235 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3236 struct sk_buff *skb = NULL;
3237 tpSirEXTScanProgressIndParams pData =
3238 (tpSirEXTScanProgressIndParams) pMsg;
3239
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303240 ENTER();
3241
3242 if (wlan_hdd_validate_context(pHddCtx)){
3243 return;
3244 }
3245 if (!pMsg)
3246 {
3247 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303248 return;
3249 }
3250
3251 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3252 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3253 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3254 GFP_KERNEL);
3255
3256 if (!skb) {
3257 hddLog(VOS_TRACE_LEVEL_ERROR,
3258 FL("cfg80211_vendor_event_alloc failed"));
3259 return;
3260 }
3261 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3262 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3263 pData->extScanEventType);
3264 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3265 pData->status);
3266
3267 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3268 pData->extScanEventType) ||
3269 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303270 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3271 pData->requestId) ||
3272 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303273 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3274 pData->status)) {
3275 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3276 goto nla_put_failure;
3277 }
3278
3279 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303280 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303281 return;
3282
3283nla_put_failure:
3284 kfree_skb(skb);
3285 return;
3286}
3287
3288void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3289 void *pMsg)
3290{
3291 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3292
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303293 ENTER();
3294
Dino Mycle6fb96c12014-06-10 11:52:40 +05303295 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303296 return;
3297 }
3298
3299 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3300
3301
3302 switch(evType) {
3303 case SIR_HAL_EXTSCAN_START_RSP:
3304 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3305 break;
3306
3307 case SIR_HAL_EXTSCAN_STOP_RSP:
3308 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3309 break;
3310 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3311 /* There is no need to send this response to upper layer
3312 Just log the message */
3313 hddLog(VOS_TRACE_LEVEL_INFO,
3314 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3315 break;
3316 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3317 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3318 break;
3319
3320 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3321 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3322 break;
3323
3324 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
3325 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
3326 break;
3327
3328 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
3329 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
3330 break;
3331 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
3332 wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg);
3333 break;
3334 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3335 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3336 break;
3337 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3338 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3339 break;
3340 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3341 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3342 break;
3343 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3344 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3345 break;
3346 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
3347 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
3348 break;
3349 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3350 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3351 break;
3352 default:
3353 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3354 break;
3355 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303356 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303357}
3358
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303359static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3360 struct wireless_dev *wdev,
3361 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303362{
Dino Myclee8843b32014-07-04 14:21:45 +05303363 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303364 struct net_device *dev = wdev->netdev;
3365 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3366 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3367 struct nlattr
3368 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3369 eHalStatus status;
3370
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303371 ENTER();
3372
Dino Mycle6fb96c12014-06-10 11:52:40 +05303373 status = wlan_hdd_validate_context(pHddCtx);
3374 if (0 != status)
3375 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303376 return -EINVAL;
3377 }
Dino Myclee8843b32014-07-04 14:21:45 +05303378 /* check the EXTScan Capability */
3379 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3380 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3381 {
3382 hddLog(VOS_TRACE_LEVEL_ERROR,
3383 FL("EXTScan not enabled/supported by Firmware"));
3384 return -EINVAL;
3385 }
3386
Dino Mycle6fb96c12014-06-10 11:52:40 +05303387 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3388 data, dataLen,
3389 wlan_hdd_extscan_config_policy)) {
3390 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3391 return -EINVAL;
3392 }
3393
3394 /* Parse and fetch request Id */
3395 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3396 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3397 return -EINVAL;
3398 }
3399
Dino Mycle6fb96c12014-06-10 11:52:40 +05303400
Dino Myclee8843b32014-07-04 14:21:45 +05303401 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303402 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303403 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303404
Dino Myclee8843b32014-07-04 14:21:45 +05303405 reqMsg.sessionId = pAdapter->sessionId;
3406 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303407
Dino Myclee8843b32014-07-04 14:21:45 +05303408 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303409 if (!HAL_STATUS_SUCCESS(status)) {
3410 hddLog(VOS_TRACE_LEVEL_ERROR,
3411 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303412 return -EINVAL;
3413 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303414 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303415 return 0;
3416}
3417
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303418static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3419 struct wireless_dev *wdev,
3420 const void *data, int dataLen)
3421{
3422 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303423
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303424 vos_ssr_protect(__func__);
3425 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3426 vos_ssr_unprotect(__func__);
3427
3428 return ret;
3429}
3430
3431static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3432 struct wireless_dev *wdev,
3433 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303434{
Dino Myclee8843b32014-07-04 14:21:45 +05303435 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303436 struct net_device *dev = wdev->netdev;
3437 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3438 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3439 struct nlattr
3440 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3441 eHalStatus status;
3442
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303443 ENTER();
3444
Dino Mycle6fb96c12014-06-10 11:52:40 +05303445 status = wlan_hdd_validate_context(pHddCtx);
3446 if (0 != status)
3447 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303448 return -EINVAL;
3449 }
Dino Myclee8843b32014-07-04 14:21:45 +05303450 /* check the EXTScan Capability */
3451 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3452 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3453 {
3454 hddLog(VOS_TRACE_LEVEL_ERROR,
3455 FL("EXTScan not enabled/supported by Firmware"));
3456 return -EINVAL;
3457 }
3458
Dino Mycle6fb96c12014-06-10 11:52:40 +05303459 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3460 data, dataLen,
3461 wlan_hdd_extscan_config_policy)) {
3462 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3463 return -EINVAL;
3464 }
3465 /* Parse and fetch request Id */
3466 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3467 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3468 return -EINVAL;
3469 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303470
Dino Myclee8843b32014-07-04 14:21:45 +05303471 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303472 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3473
Dino Myclee8843b32014-07-04 14:21:45 +05303474 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303475
Dino Myclee8843b32014-07-04 14:21:45 +05303476 reqMsg.sessionId = pAdapter->sessionId;
3477 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303478
3479 /* Parse and fetch flush parameter */
3480 if (!tb
3481 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3482 {
3483 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3484 goto failed;
3485 }
Dino Myclee8843b32014-07-04 14:21:45 +05303486 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303487 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3488
Dino Myclee8843b32014-07-04 14:21:45 +05303489 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303490
Dino Myclee8843b32014-07-04 14:21:45 +05303491 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303492 if (!HAL_STATUS_SUCCESS(status)) {
3493 hddLog(VOS_TRACE_LEVEL_ERROR,
3494 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303495 return -EINVAL;
3496 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303497 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303498 return 0;
3499
3500failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303501 return -EINVAL;
3502}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303503static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3504 struct wireless_dev *wdev,
3505 const void *data, int dataLen)
3506{
3507 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303508
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303509 vos_ssr_protect(__func__);
3510 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3511 vos_ssr_unprotect(__func__);
3512
3513 return ret;
3514}
3515
3516static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303517 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303518 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303519{
3520 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3521 struct net_device *dev = wdev->netdev;
3522 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3523 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3524 struct nlattr
3525 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3526 struct nlattr
3527 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3528 struct nlattr *apTh;
3529 eHalStatus status;
3530 tANI_U8 i = 0;
3531 int rem;
3532
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303533 ENTER();
3534
Dino Mycle6fb96c12014-06-10 11:52:40 +05303535 status = wlan_hdd_validate_context(pHddCtx);
3536 if (0 != status)
3537 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303538 return -EINVAL;
3539 }
Dino Myclee8843b32014-07-04 14:21:45 +05303540 /* check the EXTScan Capability */
3541 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3542 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3543 {
3544 hddLog(VOS_TRACE_LEVEL_ERROR,
3545 FL("EXTScan not enabled/supported by Firmware"));
3546 return -EINVAL;
3547 }
3548
Dino Mycle6fb96c12014-06-10 11:52:40 +05303549 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3550 data, dataLen,
3551 wlan_hdd_extscan_config_policy)) {
3552 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3553 return -EINVAL;
3554 }
3555
3556 /* Parse and fetch request Id */
3557 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3558 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3559 return -EINVAL;
3560 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303561 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3562 vos_mem_malloc(sizeof(*pReqMsg));
3563 if (!pReqMsg) {
3564 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3565 return -ENOMEM;
3566 }
3567
Dino Myclee8843b32014-07-04 14:21:45 +05303568
Dino Mycle6fb96c12014-06-10 11:52:40 +05303569 pReqMsg->requestId = nla_get_u32(
3570 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3571 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3572
3573 /* Parse and fetch number of APs */
3574 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3575 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3576 goto fail;
3577 }
3578
3579 pReqMsg->sessionId = pAdapter->sessionId;
3580 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3581
3582 pReqMsg->numAp = nla_get_u32(
3583 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3584 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3585
3586 nla_for_each_nested(apTh,
3587 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3588 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3589 nla_data(apTh), nla_len(apTh),
3590 NULL)) {
3591 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3592 goto fail;
3593 }
3594
3595 /* Parse and fetch MAC address */
3596 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3597 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3598 goto fail;
3599 }
3600 memcpy(pReqMsg->ap[i].bssid, nla_data(
3601 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3602 sizeof(tSirMacAddr));
3603 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3604
3605 /* Parse and fetch low RSSI */
3606 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3607 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3608 goto fail;
3609 }
3610 pReqMsg->ap[i].low = nla_get_s32(
3611 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3612 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3613
3614 /* Parse and fetch high RSSI */
3615 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3616 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3617 goto fail;
3618 }
3619 pReqMsg->ap[i].high = nla_get_s32(
3620 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3621 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3622 pReqMsg->ap[i].high);
3623
3624 /* Parse and fetch channel */
3625 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3626 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3627 goto fail;
3628 }
3629 pReqMsg->ap[i].channel = nla_get_u32(
3630 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3631 hddLog(VOS_TRACE_LEVEL_INFO,
3632 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3633 i++;
3634 }
3635 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3636 if (!HAL_STATUS_SUCCESS(status)) {
3637 hddLog(VOS_TRACE_LEVEL_ERROR,
3638 FL("sme_SetBssHotlist failed(err=%d)"), status);
3639 vos_mem_free(pReqMsg);
3640 return -EINVAL;
3641 }
3642
Dino Myclee8843b32014-07-04 14:21:45 +05303643 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303644 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303645 return 0;
3646
3647fail:
3648 vos_mem_free(pReqMsg);
3649 return -EINVAL;
3650}
3651
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303652static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3653 struct wireless_dev *wdev,
3654 const void *data, int dataLen)
3655{
3656 int ret = 0;
3657
3658 vos_ssr_protect(__func__);
3659 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3660 dataLen);
3661 vos_ssr_unprotect(__func__);
3662
3663 return ret;
3664}
3665
3666static int __wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303667 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303668 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303669{
3670 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3671 struct net_device *dev = wdev->netdev;
3672 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3673 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3674 struct nlattr
3675 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3676 struct nlattr
3677 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3678 struct nlattr *apTh;
3679 eHalStatus status;
3680 int i = 0;
3681 int rem;
3682
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303683 ENTER();
3684
Dino Mycle6fb96c12014-06-10 11:52:40 +05303685 status = wlan_hdd_validate_context(pHddCtx);
3686 if (0 != status)
3687 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303688 return -EINVAL;
3689 }
Dino Myclee8843b32014-07-04 14:21:45 +05303690 /* check the EXTScan Capability */
3691 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3692 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3693 {
3694 hddLog(VOS_TRACE_LEVEL_ERROR,
3695 FL("EXTScan not enabled/supported by Firmware"));
3696 return -EINVAL;
3697 }
3698
Dino Mycle6fb96c12014-06-10 11:52:40 +05303699 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3700 data, dataLen,
3701 wlan_hdd_extscan_config_policy)) {
3702 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3703 return -EINVAL;
3704 }
3705
3706 /* Parse and fetch request Id */
3707 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3708 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3709 return -EINVAL;
3710 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303711 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303712 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303713 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303714 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3715 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303716 }
3717
Dino Myclee8843b32014-07-04 14:21:45 +05303718
3719
Dino Mycle6fb96c12014-06-10 11:52:40 +05303720 pReqMsg->requestId = nla_get_u32(
3721 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3722 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3723
3724 /* Parse and fetch RSSI sample size */
3725 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3726 {
3727 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3728 goto fail;
3729 }
3730 pReqMsg->rssiSampleSize = nla_get_u32(
3731 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3732 hddLog(VOS_TRACE_LEVEL_INFO,
3733 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3734
3735 /* Parse and fetch lost AP sample size */
3736 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3737 {
3738 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3739 goto fail;
3740 }
3741 pReqMsg->lostApSampleSize = nla_get_u32(
3742 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3743 hddLog(VOS_TRACE_LEVEL_INFO,
3744 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3745 /* Parse and fetch minimum Breaching */
3746 if (!tb
3747 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3748 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3749 goto fail;
3750 }
3751 pReqMsg->minBreaching = nla_get_u32(
3752 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3753 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3754
3755 /* Parse and fetch number of APs */
3756 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3757 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3758 goto fail;
3759 }
3760 pReqMsg->numAp = nla_get_u32(
3761 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3762 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3763
3764 pReqMsg->sessionId = pAdapter->sessionId;
3765 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3766
3767 nla_for_each_nested(apTh,
3768 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3769 if(nla_parse(tb2,
3770 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3771 nla_data(apTh), nla_len(apTh),
3772 NULL)) {
3773 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3774 goto fail;
3775 }
3776
3777 /* Parse and fetch MAC address */
3778 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3779 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3780 goto fail;
3781 }
3782 memcpy(pReqMsg->ap[i].bssid, nla_data(
3783 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3784 sizeof(tSirMacAddr));
3785
3786 /* Parse and fetch low RSSI */
3787 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3788 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3789 goto fail;
3790 }
3791 pReqMsg->ap[i].low = nla_get_s32(
3792 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3793 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3794
3795 /* Parse and fetch high RSSI */
3796 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3797 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3798 goto fail;
3799 }
3800 pReqMsg->ap[i].high = nla_get_s32(
3801 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3802 hddLog(VOS_TRACE_LEVEL_INFO,
3803 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
3804
3805 /* Parse and fetch channel */
3806 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3807 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3808 goto fail;
3809 }
3810 pReqMsg->ap[i].channel = nla_get_u32(
3811 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3812 hddLog(VOS_TRACE_LEVEL_INFO,
3813 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3814 i++;
3815 }
3816
3817 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
3818 if (!HAL_STATUS_SUCCESS(status)) {
3819 hddLog(VOS_TRACE_LEVEL_ERROR,
3820 FL("sme_SetSignificantChange failed(err=%d)"), status);
3821 vos_mem_free(pReqMsg);
3822 return -EINVAL;
3823 }
Dino Myclee8843b32014-07-04 14:21:45 +05303824 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303825 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303826 return 0;
3827
3828fail:
3829 vos_mem_free(pReqMsg);
3830 return -EINVAL;
3831}
3832
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303833static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
3834 struct wireless_dev *wdev,
3835 const void *data, int dataLen)
3836{
3837 int ret = 0;
3838
3839 vos_ssr_protect(__func__);
3840 ret = __wlan_hdd_cfg80211_extscan_set_significant_change(wiphy, wdev, data,
3841 dataLen);
3842 vos_ssr_unprotect(__func__);
3843
3844 return ret;
3845}
3846
3847static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303848 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303849 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303850{
3851 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3852 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3853 tANI_U8 numChannels = 0;
3854 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3855 tANI_U32 requestId;
3856 tWifiBand wifiBand;
3857 eHalStatus status;
3858 struct sk_buff *replySkb;
3859 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303860 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303861
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303862 ENTER();
3863
Dino Mycle6fb96c12014-06-10 11:52:40 +05303864 status = wlan_hdd_validate_context(pHddCtx);
3865 if (0 != status)
3866 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303867 return -EINVAL;
3868 }
Dino Myclee8843b32014-07-04 14:21:45 +05303869
Dino Mycle6fb96c12014-06-10 11:52:40 +05303870 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3871 data, dataLen,
3872 wlan_hdd_extscan_config_policy)) {
3873 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3874 return -EINVAL;
3875 }
3876
3877 /* Parse and fetch request Id */
3878 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3879 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3880 return -EINVAL;
3881 }
3882 requestId = nla_get_u32(
3883 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3884 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3885
3886 /* Parse and fetch wifi band */
3887 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3888 {
3889 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3890 return -EINVAL;
3891 }
3892 wifiBand = nla_get_u32(
3893 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3894 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3895
3896 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
3897 wifiBand, ChannelList,
3898 &numChannels);
3899 if (eHAL_STATUS_SUCCESS != status) {
3900 hddLog(VOS_TRACE_LEVEL_ERROR,
3901 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
3902 return -EINVAL;
3903 }
3904 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
3905 for (i = 0; i < numChannels; i++)
3906 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
3907
3908 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
3909 sizeof(u32) * numChannels +
3910 NLMSG_HDRLEN);
3911
3912 if (!replySkb) {
3913 hddLog(VOS_TRACE_LEVEL_ERROR,
3914 FL("valid channels: buffer alloc fail"));
3915 return -EINVAL;
3916 }
3917 if (nla_put_u32(replySkb,
3918 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
3919 numChannels) ||
3920 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
3921 sizeof(u32) * numChannels, ChannelList)) {
3922
3923 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3924 kfree_skb(replySkb);
3925 return -EINVAL;
3926 }
3927
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303928 ret = cfg80211_vendor_cmd_reply(replySkb);
3929
3930 EXIT();
3931 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303932}
3933
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303934static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
3935 struct wireless_dev *wdev,
3936 const void *data, int dataLen)
3937{
3938 int ret = 0;
3939
3940 vos_ssr_protect(__func__);
3941 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
3942 dataLen);
3943 vos_ssr_unprotect(__func__);
3944
3945 return ret;
3946}
3947
3948static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303949 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303950 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303951{
Dino Myclee8843b32014-07-04 14:21:45 +05303952 tpSirEXTScanStartReqParams pReqMsg = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303953 struct net_device *dev = wdev->netdev;
3954 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3955 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3956 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3957 struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3958 struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3959 struct nlattr *buckets;
3960 struct nlattr *channels;
3961 int rem1;
3962 int rem2;
3963 eHalStatus status;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303964 tANI_U32 j = 0, index = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303965
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303966 ENTER();
3967
Dino Mycle6fb96c12014-06-10 11:52:40 +05303968 status = wlan_hdd_validate_context(pHddCtx);
3969 if (0 != status)
3970 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303971 return -EINVAL;
3972 }
Dino Myclee8843b32014-07-04 14:21:45 +05303973 /* check the EXTScan Capability */
3974 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3975 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3976 {
3977 hddLog(VOS_TRACE_LEVEL_ERROR,
3978 FL("EXTScan not enabled/supported by Firmware"));
3979 return -EINVAL;
3980 }
3981
Dino Mycle6fb96c12014-06-10 11:52:40 +05303982 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3983 data, dataLen,
3984 wlan_hdd_extscan_config_policy)) {
3985 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3986 return -EINVAL;
3987 }
3988
3989 /* Parse and fetch request Id */
3990 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3991 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3992 return -EINVAL;
3993 }
3994
Dino Myclee8843b32014-07-04 14:21:45 +05303995 pReqMsg = (tpSirEXTScanStartReqParams)
3996 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303997 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303998 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3999 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304000 }
4001
4002 pReqMsg->requestId = nla_get_u32(
4003 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4004 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4005
4006 pReqMsg->sessionId = pAdapter->sessionId;
4007 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4008
4009 /* Parse and fetch base period */
4010 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) {
4011 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4012 goto fail;
4013 }
4014 pReqMsg->basePeriod = nla_get_u32(
4015 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]);
4016 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4017 pReqMsg->basePeriod);
4018
4019 /* Parse and fetch max AP per scan */
4020 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) {
4021 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4022 goto fail;
4023 }
4024 pReqMsg->maxAPperScan = nla_get_u32(
4025 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]);
4026 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4027 pReqMsg->maxAPperScan);
4028
4029 /* Parse and fetch report threshold */
4030 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) {
4031 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4032 goto fail;
4033 }
4034 pReqMsg->reportThreshold = nla_get_u8(
4035 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]);
4036 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
4037 pReqMsg->reportThreshold);
4038
4039 /* Parse and fetch number of buckets */
4040 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) {
4041 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4042 goto fail;
4043 }
4044 pReqMsg->numBuckets = nla_get_u8(
4045 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]);
4046 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4047 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4048 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4049 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4050 }
4051 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4052 pReqMsg->numBuckets);
4053 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4054 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4055 goto fail;
4056 }
4057
4058 nla_for_each_nested(buckets,
4059 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4060 if(nla_parse(bucket,
4061 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4062 nla_data(buckets), nla_len(buckets), NULL)) { //policy
4063 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4064 goto fail;
4065 }
4066
4067 /* Parse and fetch bucket spec */
4068 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4069 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed"));
4070 goto fail;
4071 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304072
4073 pReqMsg->buckets[index].bucket = nla_get_u8(
4074 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4075
4076 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"),
4077 pReqMsg->buckets[index].bucket);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304078
4079 /* Parse and fetch wifi band */
4080 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4081 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4082 goto fail;
4083 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304084 pReqMsg->buckets[index].band = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304085 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4086 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304087 pReqMsg->buckets[index].band);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304088
4089 /* Parse and fetch period */
4090 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4091 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed"));
4092 goto fail;
4093 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304094 pReqMsg->buckets[index].period = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304095 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4096 hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304097 pReqMsg->buckets[index].period);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304098
4099 /* Parse and fetch report events */
4100 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4101 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed"));
4102 goto fail;
4103 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304104 pReqMsg->buckets[index].reportEvents = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304105 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4106 hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304107 pReqMsg->buckets[index].reportEvents);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304108
4109 /* Parse and fetch number of channels */
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304110 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS])
4111 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304112 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed"));
4113 goto fail;
4114 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304115 pReqMsg->buckets[index].numChannels = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304116 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4117 hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304118 pReqMsg->buckets[index].numChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304119
4120 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4121 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed"));
4122 goto fail;
4123 }
4124
4125 j = 0;
4126 nla_for_each_nested(channels,
4127 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4128 if(nla_parse(channel,
4129 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4130 nla_data(channels), nla_len(channels),
4131 NULL)) { //wlan_hdd_extscan_config_policy here
4132 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4133 goto fail;
4134 }
4135
4136 /* Parse and fetch channel */
4137 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4138 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4139 goto fail;
4140 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304141 pReqMsg->buckets[index].channels[j].channel = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304142 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4143 hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304144 pReqMsg->buckets[index].channels[j].channel);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304145
4146 /* Parse and fetch dwell time */
4147 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4148 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed"));
4149 goto fail;
4150 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304151 pReqMsg->buckets[index].channels[j].dwellTimeMs = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304152 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4153 hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304154 pReqMsg->buckets[index].channels[j].dwellTimeMs);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304155
4156 /* Parse and fetch channel spec passive */
4157 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4158 hddLog(VOS_TRACE_LEVEL_ERROR,
4159 FL("attr channel spec passive failed"));
4160 goto fail;
4161 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304162 pReqMsg->buckets[index].channels[j].passive = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304163 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4164 hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304165 pReqMsg->buckets[index].channels[j].passive);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304166 j++;
4167 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304168 index++;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304169 }
4170 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4171 if (!HAL_STATUS_SUCCESS(status)) {
4172 hddLog(VOS_TRACE_LEVEL_ERROR,
4173 FL("sme_EXTScanStart failed(err=%d)"), status);
4174 vos_mem_free(pReqMsg);
4175 return -EINVAL;
4176 }
4177
Dino Myclee8843b32014-07-04 14:21:45 +05304178 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304179 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304180 return 0;
4181
4182fail:
4183 vos_mem_free(pReqMsg);
4184 return -EINVAL;
4185}
4186
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304187static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4188 struct wireless_dev *wdev,
4189 const void *data, int dataLen)
4190{
4191 int ret = 0;
4192
4193 vos_ssr_protect(__func__);
4194 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4195 vos_ssr_unprotect(__func__);
4196
4197 return ret;
4198}
4199
4200static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304201 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304202 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304203{
Dino Myclee8843b32014-07-04 14:21:45 +05304204 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304205 struct net_device *dev = wdev->netdev;
4206 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4207 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4208 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4209 eHalStatus status;
4210
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304211 ENTER();
4212
Dino Mycle6fb96c12014-06-10 11:52:40 +05304213 status = wlan_hdd_validate_context(pHddCtx);
4214 if (0 != status)
4215 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304216 return -EINVAL;
4217 }
Dino Myclee8843b32014-07-04 14:21:45 +05304218 /* check the EXTScan Capability */
4219 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4220 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4221 {
4222 hddLog(VOS_TRACE_LEVEL_ERROR,
4223 FL("EXTScan not enabled/supported by Firmware"));
4224 return -EINVAL;
4225 }
4226
Dino Mycle6fb96c12014-06-10 11:52:40 +05304227 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4228 data, dataLen,
4229 wlan_hdd_extscan_config_policy)) {
4230 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4231 return -EINVAL;
4232 }
4233
4234 /* Parse and fetch request Id */
4235 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4236 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4237 return -EINVAL;
4238 }
4239
Dino Myclee8843b32014-07-04 14:21:45 +05304240 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304241 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304242 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304243
Dino Myclee8843b32014-07-04 14:21:45 +05304244 reqMsg.sessionId = pAdapter->sessionId;
4245 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304246
Dino Myclee8843b32014-07-04 14:21:45 +05304247 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304248 if (!HAL_STATUS_SUCCESS(status)) {
4249 hddLog(VOS_TRACE_LEVEL_ERROR,
4250 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304251 return -EINVAL;
4252 }
4253
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304254 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304255 return 0;
4256}
4257
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304258static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4259 struct wireless_dev *wdev,
4260 const void *data, int dataLen)
4261{
4262 int ret = 0;
4263
4264 vos_ssr_protect(__func__);
4265 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4266 vos_ssr_unprotect(__func__);
4267
4268 return ret;
4269}
4270
4271static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304272 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304273 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304274{
Dino Myclee8843b32014-07-04 14:21:45 +05304275 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304276 struct net_device *dev = wdev->netdev;
4277 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4278 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4279 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4280 eHalStatus status;
4281
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304282 ENTER();
4283
Dino Mycle6fb96c12014-06-10 11:52:40 +05304284 status = wlan_hdd_validate_context(pHddCtx);
4285 if (0 != status)
4286 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304287 return -EINVAL;
4288 }
Dino Myclee8843b32014-07-04 14:21:45 +05304289 /* check the EXTScan Capability */
4290 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4291 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4292 {
4293 hddLog(VOS_TRACE_LEVEL_ERROR,
4294 FL("EXTScan not enabled/supported by Firmware"));
4295 return -EINVAL;
4296 }
4297
Dino Mycle6fb96c12014-06-10 11:52:40 +05304298 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4299 data, dataLen,
4300 wlan_hdd_extscan_config_policy)) {
4301 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4302 return -EINVAL;
4303 }
4304
4305 /* Parse and fetch request Id */
4306 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4307 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4308 return -EINVAL;
4309 }
4310
Dino Myclee8843b32014-07-04 14:21:45 +05304311 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304312 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304313 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304314
Dino Myclee8843b32014-07-04 14:21:45 +05304315 reqMsg.sessionId = pAdapter->sessionId;
4316 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304317
Dino Myclee8843b32014-07-04 14:21:45 +05304318 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304319 if (!HAL_STATUS_SUCCESS(status)) {
4320 hddLog(VOS_TRACE_LEVEL_ERROR,
4321 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304322 return -EINVAL;
4323 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304324 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304325 return 0;
4326}
4327
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304328static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4329 struct wireless_dev *wdev,
4330 const void *data, int dataLen)
4331{
4332 int ret = 0;
4333
4334 vos_ssr_protect(__func__);
4335 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4336 vos_ssr_unprotect(__func__);
4337
4338 return ret;
4339}
4340
4341static int __wlan_hdd_cfg80211_extscan_reset_significant_change(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304342 struct wiphy *wiphy,
4343 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304344 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304345{
Dino Myclee8843b32014-07-04 14:21:45 +05304346 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304347 struct net_device *dev = wdev->netdev;
4348 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4349 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4350 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4351 eHalStatus status;
4352
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304353 ENTER();
4354
Dino Mycle6fb96c12014-06-10 11:52:40 +05304355 status = wlan_hdd_validate_context(pHddCtx);
4356 if (0 != status)
4357 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304358 return -EINVAL;
4359 }
Dino Myclee8843b32014-07-04 14:21:45 +05304360 /* check the EXTScan Capability */
4361 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4362 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4363 {
4364 hddLog(VOS_TRACE_LEVEL_ERROR,
4365 FL("EXTScan not enabled/supported by Firmware"));
4366 return -EINVAL;
4367 }
4368
Dino Mycle6fb96c12014-06-10 11:52:40 +05304369 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4370 data, dataLen,
4371 wlan_hdd_extscan_config_policy)) {
4372 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4373 return -EINVAL;
4374 }
4375
4376 /* Parse and fetch request Id */
4377 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4378 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4379 return -EINVAL;
4380 }
4381
Dino Mycle6fb96c12014-06-10 11:52:40 +05304382
Dino Myclee8843b32014-07-04 14:21:45 +05304383 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304384 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304385 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304386
Dino Myclee8843b32014-07-04 14:21:45 +05304387 reqMsg.sessionId = pAdapter->sessionId;
4388 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304389
Dino Myclee8843b32014-07-04 14:21:45 +05304390 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304391 if (!HAL_STATUS_SUCCESS(status)) {
4392 hddLog(VOS_TRACE_LEVEL_ERROR,
4393 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304394 return -EINVAL;
4395 }
4396
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304397 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304398 return 0;
4399}
4400
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304401static int wlan_hdd_cfg80211_extscan_reset_significant_change(
4402 struct wiphy *wiphy,
4403 struct wireless_dev *wdev,
4404 const void *data, int dataLen)
4405{
4406 int ret = 0;
4407
4408 vos_ssr_protect(__func__);
4409 ret = __wlan_hdd_cfg80211_extscan_reset_significant_change(wiphy,
4410 wdev, data,
4411 dataLen);
4412 vos_ssr_unprotect(__func__);
4413
4414 return ret;
4415}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304416#endif /* WLAN_FEATURE_EXTSCAN */
4417
Atul Mittal115287b2014-07-08 13:26:33 +05304418/*EXT TDLS*/
4419static const struct nla_policy
4420wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4421{
4422 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4423 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4424 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4425 {.type = NLA_S32 },
4426 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4427 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4428
4429};
4430
4431static const struct nla_policy
4432wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4433{
4434 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4435
4436};
4437
4438static const struct nla_policy
4439wlan_hdd_tdls_config_state_change_policy[
4440 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4441{
4442 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4443 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4444 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304445 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4446 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4447 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304448
4449};
4450
4451static const struct nla_policy
4452wlan_hdd_tdls_config_get_status_policy[
4453 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4454{
4455 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4456 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4457 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304458 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4459 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4460 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304461
4462};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304463
4464static const struct nla_policy
4465wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4466{
4467 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4468};
4469
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304470static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304471 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304472 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304473 int data_len)
4474{
4475
4476 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4477 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4478
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304479 ENTER();
4480
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304481 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304482 return -EINVAL;
4483 }
4484 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
4485 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN disabled in ini"));
4486 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304487 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304488 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
4489 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN not supported by FW"));
4490 return -ENOTSUPP;
4491 }
4492
4493 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4494 data, data_len, wlan_hdd_mac_config)) {
4495 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4496 return -EINVAL;
4497 }
4498
4499 /* Parse and fetch mac address */
4500 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4501 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4502 return -EINVAL;
4503 }
4504
4505 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4506 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4507 VOS_MAC_ADDR_LAST_3_BYTES);
4508
Siddharth Bhal76972212014-10-15 16:22:51 +05304509 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4510
4511 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304512 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4513 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304514 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4515 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4516 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4517 {
4518 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4519 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4520 VOS_MAC_ADDRESS_LEN);
4521 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304522 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304523
Siddharth Bhal76972212014-10-15 16:22:51 +05304524 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
4525 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304526 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4527 }
4528
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304529 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304530 return 0;
4531}
4532
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304533static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4534 struct wireless_dev *wdev,
4535 const void *data,
4536 int data_len)
4537{
4538 int ret = 0;
4539
4540 vos_ssr_protect(__func__);
4541 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
4542 vos_ssr_unprotect(__func__);
4543
4544 return ret;
4545}
4546
4547static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304548 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304549 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304550 int data_len)
4551{
4552 u8 peer[6] = {0};
4553 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[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4557 eHalStatus ret;
4558 tANI_S32 state;
4559 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304560 tANI_S32 global_operating_class = 0;
4561 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304562 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304563 int retVal;
4564
4565 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304566
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304567 if (!pAdapter) {
4568 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4569 return -EINVAL;
4570 }
4571
Atul Mittal115287b2014-07-08 13:26:33 +05304572 ret = wlan_hdd_validate_context(pHddCtx);
4573 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304574 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304575 return -EINVAL;
4576 }
4577 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304578 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304579 return -ENOTSUPP;
4580 }
4581 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4582 data, data_len,
4583 wlan_hdd_tdls_config_get_status_policy)) {
4584 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4585 return -EINVAL;
4586 }
4587
4588 /* Parse and fetch mac address */
4589 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4590 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4591 return -EINVAL;
4592 }
4593
4594 memcpy(peer, nla_data(
4595 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4596 sizeof(peer));
4597 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4598
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05304599 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05304600
Atul Mittal115287b2014-07-08 13:26:33 +05304601 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304602 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304603 NLMSG_HDRLEN);
4604
4605 if (!skb) {
4606 hddLog(VOS_TRACE_LEVEL_ERROR,
4607 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4608 return -EINVAL;
4609 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304610 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 +05304611 reason,
4612 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304613 global_operating_class,
4614 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304615 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304616 if (nla_put_s32(skb,
4617 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4618 state) ||
4619 nla_put_s32(skb,
4620 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4621 reason) ||
4622 nla_put_s32(skb,
4623 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4624 global_operating_class) ||
4625 nla_put_s32(skb,
4626 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4627 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304628
4629 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4630 goto nla_put_failure;
4631 }
4632
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304633 retVal = cfg80211_vendor_cmd_reply(skb);
4634 EXIT();
4635 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05304636
4637nla_put_failure:
4638 kfree_skb(skb);
4639 return -EINVAL;
4640}
4641
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304642static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4643 struct wireless_dev *wdev,
4644 const void *data,
4645 int data_len)
4646{
4647 int ret = 0;
4648
4649 vos_ssr_protect(__func__);
4650 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
4651 vos_ssr_unprotect(__func__);
4652
4653 return ret;
4654}
4655
Atul Mittal115287b2014-07-08 13:26:33 +05304656static int wlan_hdd_cfg80211_exttdls_callback(tANI_U8* mac,
4657 tANI_S32 state,
4658 tANI_S32 reason,
4659 void *ctx)
4660{
4661 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05304662 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304663 tANI_S32 global_operating_class = 0;
4664 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304665 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05304666
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304667 ENTER();
4668
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304669 if (!pAdapter) {
4670 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4671 return -EINVAL;
4672 }
4673
4674 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05304675 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304676 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304677 return -EINVAL;
4678 }
4679
4680 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304681 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304682 return -ENOTSUPP;
4683 }
4684 skb = cfg80211_vendor_event_alloc(
4685 pHddCtx->wiphy,
4686 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4687 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4688 GFP_KERNEL);
4689
4690 if (!skb) {
4691 hddLog(VOS_TRACE_LEVEL_ERROR,
4692 FL("cfg80211_vendor_event_alloc failed"));
4693 return -EINVAL;
4694 }
4695 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304696 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4697 reason,
4698 state,
4699 global_operating_class,
4700 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304701 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4702 MAC_ADDR_ARRAY(mac));
4703
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304704 if (nla_put(skb,
4705 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4706 VOS_MAC_ADDR_SIZE, mac) ||
4707 nla_put_s32(skb,
4708 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4709 state) ||
4710 nla_put_s32(skb,
4711 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4712 reason) ||
4713 nla_put_s32(skb,
4714 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4715 channel) ||
4716 nla_put_s32(skb,
4717 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4718 global_operating_class)
4719 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304720 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4721 goto nla_put_failure;
4722 }
4723
4724 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304725 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05304726 return (0);
4727
4728nla_put_failure:
4729 kfree_skb(skb);
4730 return -EINVAL;
4731}
4732
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304733static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304734 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304735 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304736 int data_len)
4737{
4738 u8 peer[6] = {0};
4739 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304740 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4741 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4742 eHalStatus status;
4743 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304744 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304745 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304746
4747 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304748
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304749 if (!dev) {
4750 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4751 return -EINVAL;
4752 }
4753
4754 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4755 if (!pAdapter) {
4756 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4757 return -EINVAL;
4758 }
4759
Atul Mittal115287b2014-07-08 13:26:33 +05304760 status = wlan_hdd_validate_context(pHddCtx);
4761 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304762 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304763 return -EINVAL;
4764 }
4765 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304766 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304767 return -ENOTSUPP;
4768 }
4769 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4770 data, data_len,
4771 wlan_hdd_tdls_config_enable_policy)) {
4772 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4773 return -EINVAL;
4774 }
4775
4776 /* Parse and fetch mac address */
4777 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4778 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4779 return -EINVAL;
4780 }
4781
4782 memcpy(peer, nla_data(
4783 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4784 sizeof(peer));
4785 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4786
4787 /* Parse and fetch channel */
4788 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4789 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4790 return -EINVAL;
4791 }
4792 pReqMsg.channel = nla_get_s32(
4793 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4794 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4795
4796 /* Parse and fetch global operating class */
4797 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4798 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4799 return -EINVAL;
4800 }
4801 pReqMsg.global_operating_class = nla_get_s32(
4802 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4803 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4804 pReqMsg.global_operating_class);
4805
4806 /* Parse and fetch latency ms */
4807 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4808 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4809 return -EINVAL;
4810 }
4811 pReqMsg.max_latency_ms = nla_get_s32(
4812 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4813 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4814 pReqMsg.max_latency_ms);
4815
4816 /* Parse and fetch required bandwidth kbps */
4817 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4818 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4819 return -EINVAL;
4820 }
4821
4822 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4823 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4824 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4825 pReqMsg.min_bandwidth_kbps);
4826
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304827 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05304828 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05304829 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304830 wlan_hdd_cfg80211_exttdls_callback);
4831
4832 EXIT();
4833 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304834}
4835
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304836static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4837 struct wireless_dev *wdev,
4838 const void *data,
4839 int data_len)
4840{
4841 int ret = 0;
4842
4843 vos_ssr_protect(__func__);
4844 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
4845 vos_ssr_unprotect(__func__);
4846
4847 return ret;
4848}
4849
4850static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304851 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304852 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304853 int data_len)
4854{
4855 u8 peer[6] = {0};
4856 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304857 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4858 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4859 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304860 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304861 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304862
4863 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304864
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304865 if (!dev) {
4866 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4867 return -EINVAL;
4868 }
4869
4870 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4871 if (!pAdapter) {
4872 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
4873 return -EINVAL;
4874 }
4875
Atul Mittal115287b2014-07-08 13:26:33 +05304876 status = wlan_hdd_validate_context(pHddCtx);
4877 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304878 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304879 return -EINVAL;
4880 }
4881 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304882 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304883 return -ENOTSUPP;
4884 }
4885 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4886 data, data_len,
4887 wlan_hdd_tdls_config_disable_policy)) {
4888 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4889 return -EINVAL;
4890 }
4891 /* Parse and fetch mac address */
4892 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
4893 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4894 return -EINVAL;
4895 }
4896
4897 memcpy(peer, nla_data(
4898 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
4899 sizeof(peer));
4900 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4901
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304902 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
4903
4904 EXIT();
4905 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304906}
4907
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304908static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
4909 struct wireless_dev *wdev,
4910 const void *data,
4911 int data_len)
4912{
4913 int ret = 0;
4914
4915 vos_ssr_protect(__func__);
4916 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
4917 vos_ssr_unprotect(__func__);
4918
4919 return ret;
4920}
4921
Dasari Srinivas7875a302014-09-26 17:50:57 +05304922static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304923__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05304924 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304925 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05304926{
4927 struct net_device *dev = wdev->netdev;
4928 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4929 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4930 struct sk_buff *skb = NULL;
4931 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304932 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05304933
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304934 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304935
4936 ret = wlan_hdd_validate_context(pHddCtx);
4937 if (0 != ret)
4938 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304939 return ret;
4940 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304941 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
4942 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
4943 fset |= WIFI_FEATURE_INFRA;
4944 }
4945
4946 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
4947 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
4948 fset |= WIFI_FEATURE_INFRA_5G;
4949 }
4950
4951#ifdef WLAN_FEATURE_P2P
4952 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
4953 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
4954 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
4955 fset |= WIFI_FEATURE_P2P;
4956 }
4957#endif
4958
4959 /* Soft-AP is supported currently by default */
4960 fset |= WIFI_FEATURE_SOFT_AP;
4961
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05304962 /* HOTSPOT is a supplicant feature, enable it by default */
4963 fset |= WIFI_FEATURE_HOTSPOT;
4964
Dasari Srinivas7875a302014-09-26 17:50:57 +05304965#ifdef WLAN_FEATURE_EXTSCAN
4966 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
4967 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
4968 hddLog(LOG1, FL("EXTScan is supported by firmware"));
4969 fset |= WIFI_FEATURE_EXTSCAN;
4970 }
4971#endif
4972
Dasari Srinivas7875a302014-09-26 17:50:57 +05304973 if (sme_IsFeatureSupportedByFW(NAN)) {
4974 hddLog(LOG1, FL("NAN is supported by firmware"));
4975 fset |= WIFI_FEATURE_NAN;
4976 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304977
4978 /* D2D RTT is not supported currently by default */
4979 if (sme_IsFeatureSupportedByFW(RTT)) {
4980 hddLog(LOG1, FL("RTT is supported by firmware"));
4981 fset |= WIFI_FEATURE_D2AP_RTT;
4982 }
4983
4984#ifdef FEATURE_WLAN_BATCH_SCAN
4985 if (fset & WIFI_FEATURE_EXTSCAN) {
4986 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
4987 fset &= ~WIFI_FEATURE_BATCH_SCAN;
4988 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
4989 hddLog(LOG1, FL("Batch scan is supported by firmware"));
4990 fset |= WIFI_FEATURE_BATCH_SCAN;
4991 }
4992#endif
4993
4994#ifdef FEATURE_WLAN_SCAN_PNO
4995 if (pHddCtx->cfg_ini->configPNOScanSupport &&
4996 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
4997 hddLog(LOG1, FL("PNO is supported by firmware"));
4998 fset |= WIFI_FEATURE_PNO;
4999 }
5000#endif
5001
5002 /* STA+STA is supported currently by default */
5003 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5004
5005#ifdef FEATURE_WLAN_TDLS
5006 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5007 sme_IsFeatureSupportedByFW(TDLS)) {
5008 hddLog(LOG1, FL("TDLS is supported by firmware"));
5009 fset |= WIFI_FEATURE_TDLS;
5010 }
5011
5012 /* TDLS_OFFCHANNEL is not supported currently by default */
5013#endif
5014
5015#ifdef WLAN_AP_STA_CONCURRENCY
5016 /* AP+STA concurrency is supported currently by default */
5017 fset |= WIFI_FEATURE_AP_STA;
5018#endif
5019
5020 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5021 NLMSG_HDRLEN);
5022
5023 if (!skb) {
5024 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5025 return -EINVAL;
5026 }
5027 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5028
5029 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5030 hddLog(LOGE, FL("nla put fail"));
5031 goto nla_put_failure;
5032 }
5033
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305034 ret = cfg80211_vendor_cmd_reply(skb);
5035 EXIT();
5036 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305037
5038nla_put_failure:
5039 kfree_skb(skb);
5040 return -EINVAL;
5041}
5042
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305043static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305044wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5045 struct wireless_dev *wdev,
5046 const void *data, int data_len)
5047{
5048 int ret = 0;
5049
5050 vos_ssr_protect(__func__);
5051 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5052 vos_ssr_unprotect(__func__);
5053
5054 return ret;
5055}
5056
5057static int
5058__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305059 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305060 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305061{
5062 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5063 uint8_t i, feature_sets, max_feature_sets;
5064 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5065 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305066 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5067 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305068
5069 ENTER();
5070
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305071 ret = wlan_hdd_validate_context(pHddCtx);
5072 if (0 != ret)
5073 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305074 return ret;
5075 }
5076
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305077 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5078 data, data_len, NULL)) {
5079 hddLog(LOGE, FL("Invalid ATTR"));
5080 return -EINVAL;
5081 }
5082
5083 /* Parse and fetch max feature set */
5084 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5085 hddLog(LOGE, FL("Attr max feature set size failed"));
5086 return -EINVAL;
5087 }
5088 max_feature_sets = nla_get_u32(
5089 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5090 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5091
5092 /* Fill feature combination matrix */
5093 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305094 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5095 WIFI_FEATURE_P2P;
5096
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305097 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5098 WIFI_FEATURE_SOFT_AP;
5099
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305100 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5101 WIFI_FEATURE_SOFT_AP;
5102
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305103 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5104 WIFI_FEATURE_SOFT_AP |
5105 WIFI_FEATURE_P2P;
5106
5107 /* Add more feature combinations here */
5108
5109 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5110 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5111 hddLog(LOG1, "Feature set matrix");
5112 for (i = 0; i < feature_sets; i++)
5113 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5114
5115 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5116 sizeof(u32) * feature_sets +
5117 NLMSG_HDRLEN);
5118
5119 if (reply_skb) {
5120 if (nla_put_u32(reply_skb,
5121 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5122 feature_sets) ||
5123 nla_put(reply_skb,
5124 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5125 sizeof(u32) * feature_sets, feature_set_matrix)) {
5126 hddLog(LOGE, FL("nla put fail"));
5127 kfree_skb(reply_skb);
5128 return -EINVAL;
5129 }
5130
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305131 ret = cfg80211_vendor_cmd_reply(reply_skb);
5132 EXIT();
5133 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305134 }
5135 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5136 return -ENOMEM;
5137
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305138}
5139
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305140static int
5141wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5142 struct wireless_dev *wdev,
5143 const void *data, int data_len)
5144{
5145 int ret = 0;
5146
5147 vos_ssr_protect(__func__);
5148 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5149 data_len);
5150 vos_ssr_unprotect(__func__);
5151
5152 return ret;
5153}
5154
Agarwal Ashish738843c2014-09-25 12:27:56 +05305155static const struct nla_policy
5156wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5157 +1] =
5158{
5159 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5160};
5161
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305162static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305163 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305164 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305165 int data_len)
5166{
5167 struct net_device *dev = wdev->netdev;
5168 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5169 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5170 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5171 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5172 eHalStatus status;
5173 u32 dfsFlag = 0;
5174
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305175 ENTER();
5176
Agarwal Ashish738843c2014-09-25 12:27:56 +05305177 status = wlan_hdd_validate_context(pHddCtx);
5178 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305179 return -EINVAL;
5180 }
5181 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5182 data, data_len,
5183 wlan_hdd_set_no_dfs_flag_config_policy)) {
5184 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5185 return -EINVAL;
5186 }
5187
5188 /* Parse and fetch required bandwidth kbps */
5189 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5190 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5191 return -EINVAL;
5192 }
5193
5194 dfsFlag = nla_get_u32(
5195 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5196 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
5197 dfsFlag);
5198
5199 pHddCtx->disable_dfs_flag = dfsFlag;
5200
5201 sme_disable_dfs_channel(hHal, dfsFlag);
5202 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305203
5204 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05305205 return 0;
5206}
Atul Mittal115287b2014-07-08 13:26:33 +05305207
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305208static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
5209 struct wireless_dev *wdev,
5210 const void *data,
5211 int data_len)
5212{
5213 int ret = 0;
5214
5215 vos_ssr_protect(__func__);
5216 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
5217 vos_ssr_unprotect(__func__);
5218
5219 return ret;
5220
5221}
5222
Mukul Sharma2a271632014-10-13 14:59:01 +05305223const struct
5224nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
5225{
5226 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
5227 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
5228};
5229
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305230static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05305231 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05305232{
5233
5234 u8 bssid[6] = {0};
5235 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5236 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5237 eHalStatus status = eHAL_STATUS_SUCCESS;
5238 v_U32_t isFwrRoamEnabled = FALSE;
5239 int ret;
5240
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305241 ENTER();
5242
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305243 ret = wlan_hdd_validate_context(pHddCtx);
5244 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305245 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05305246 }
5247
5248 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
5249 data, data_len,
5250 qca_wlan_vendor_attr);
5251 if (ret){
5252 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5253 return -EINVAL;
5254 }
5255
5256 /* Parse and fetch Enable flag */
5257 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
5258 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
5259 return -EINVAL;
5260 }
5261
5262 isFwrRoamEnabled = nla_get_u32(
5263 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
5264
5265 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
5266
5267 /* Parse and fetch bssid */
5268 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
5269 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
5270 return -EINVAL;
5271 }
5272
5273 memcpy(bssid, nla_data(
5274 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
5275 sizeof(bssid));
5276 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
5277
5278 //Update roaming
5279 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305280 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05305281 return status;
5282}
5283
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305284static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
5285 struct wireless_dev *wdev, const void *data, int data_len)
5286{
5287 int ret = 0;
5288
5289 vos_ssr_protect(__func__);
5290 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
5291 vos_ssr_unprotect(__func__);
5292
5293 return ret;
5294}
5295
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305296/**
5297 * __wlan_hdd_cfg80211_setband() - set band
5298 * @wiphy: Pointer to wireless phy
5299 * @wdev: Pointer to wireless device
5300 * @data: Pointer to data
5301 * @data_len: Data length
5302 *
5303 * Return: 0 on success, negative errno on failure
5304 */
5305static int
5306__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5307 struct wireless_dev *wdev,
5308 const void *data,
5309 int data_len)
5310{
5311 struct net_device *dev = wdev->netdev;
5312 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5313 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5314 int ret;
5315 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
5316 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
5317
5318 ENTER();
5319
5320 ret = wlan_hdd_validate_context(hdd_ctx);
5321 if (0 != ret) {
5322 hddLog(LOGE, FL("HDD context is not valid"));
5323 return ret;
5324 }
5325
5326 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
5327 policy)) {
5328 hddLog(LOGE, FL("Invalid ATTR"));
5329 return -EINVAL;
5330 }
5331
5332 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
5333 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
5334 return -EINVAL;
5335 }
5336
5337 return hdd_setBand(dev,
5338 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
5339}
5340
5341/**
5342 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
5343 * @wiphy: wiphy structure pointer
5344 * @wdev: Wireless device structure pointer
5345 * @data: Pointer to the data received
5346 * @data_len: Length of @data
5347 *
5348 * Return: 0 on success; errno on failure
5349 */
5350static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5351 struct wireless_dev *wdev,
5352 const void *data,
5353 int data_len)
5354{
5355 int ret = 0;
5356
5357 vos_ssr_protect(__func__);
5358 ret = __wlan_hdd_cfg80211_setband(wiphy,
5359 wdev, data, data_len);
5360 vos_ssr_unprotect(__func__);
5361
5362 return ret;
5363}
5364
Sunil Duttc69bccb2014-05-26 21:30:20 +05305365const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
5366{
Mukul Sharma2a271632014-10-13 14:59:01 +05305367 {
5368 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5369 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
5370 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5371 WIPHY_VENDOR_CMD_NEED_NETDEV |
5372 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305373 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05305374 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305375
5376 {
5377 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5378 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
5379 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5380 WIPHY_VENDOR_CMD_NEED_NETDEV |
5381 WIPHY_VENDOR_CMD_NEED_RUNNING,
5382 .doit = wlan_hdd_cfg80211_nan_request
5383 },
5384
Sunil Duttc69bccb2014-05-26 21:30:20 +05305385#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5386 {
5387 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5388 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
5389 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5390 WIPHY_VENDOR_CMD_NEED_NETDEV |
5391 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305392 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05305393 },
5394
5395 {
5396 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5397 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
5398 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5399 WIPHY_VENDOR_CMD_NEED_NETDEV |
5400 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305401 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05305402 },
5403
5404 {
5405 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5406 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
5407 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5408 WIPHY_VENDOR_CMD_NEED_NETDEV |
5409 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305410 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05305411 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305412#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305413#ifdef WLAN_FEATURE_EXTSCAN
5414 {
5415 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5416 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
5417 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5418 WIPHY_VENDOR_CMD_NEED_NETDEV |
5419 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305420 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05305421 },
5422 {
5423 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5424 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
5425 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5426 WIPHY_VENDOR_CMD_NEED_NETDEV |
5427 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305428 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05305429 },
5430 {
5431 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5432 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
5433 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5434 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305435 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05305436 },
5437 {
5438 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5439 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
5440 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5441 WIPHY_VENDOR_CMD_NEED_NETDEV |
5442 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305443 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05305444 },
5445 {
5446 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5447 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
5448 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5449 WIPHY_VENDOR_CMD_NEED_NETDEV |
5450 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305451 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05305452 },
5453 {
5454 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5455 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
5456 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5457 WIPHY_VENDOR_CMD_NEED_NETDEV |
5458 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305459 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305460 },
5461 {
5462 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5463 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
5464 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5465 WIPHY_VENDOR_CMD_NEED_NETDEV |
5466 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305467 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305468 },
5469 {
5470 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5471 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
5472 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5473 WIPHY_VENDOR_CMD_NEED_NETDEV |
5474 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305475 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305476 },
5477 {
5478 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5479 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
5480 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5481 WIPHY_VENDOR_CMD_NEED_NETDEV |
5482 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305483 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305484 },
5485#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305486/*EXT TDLS*/
5487 {
5488 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5489 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
5490 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5491 WIPHY_VENDOR_CMD_NEED_NETDEV |
5492 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305493 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05305494 },
5495 {
5496 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5497 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
5498 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5499 WIPHY_VENDOR_CMD_NEED_NETDEV |
5500 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305501 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05305502 },
5503 {
5504 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5505 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
5506 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5507 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305508 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05305509 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05305510 {
5511 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5512 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
5513 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5514 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305515 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05305516 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05305517 {
5518 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5519 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
5520 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5521 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305522 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05305523 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305524 {
5525 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5526 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
5527 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5528 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305529 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305530 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305531 {
5532 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5533 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
5534 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5535 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305536 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305537 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305538 {
5539 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5540 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
5541 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5542 WIPHY_VENDOR_CMD_NEED_NETDEV |
5543 WIPHY_VENDOR_CMD_NEED_RUNNING,
5544 .doit = wlan_hdd_cfg80211_setband
5545 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05305546};
5547
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005548/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05305549static const
5550struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005551{
5552#ifdef FEATURE_WLAN_CH_AVOID
5553 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05305554 .vendor_id = QCA_NL80211_VENDOR_ID,
5555 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005556 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305557#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
5558#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5559 {
5560 /* Index = 1*/
5561 .vendor_id = QCA_NL80211_VENDOR_ID,
5562 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
5563 },
5564 {
5565 /* Index = 2*/
5566 .vendor_id = QCA_NL80211_VENDOR_ID,
5567 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
5568 },
5569 {
5570 /* Index = 3*/
5571 .vendor_id = QCA_NL80211_VENDOR_ID,
5572 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
5573 },
5574 {
5575 /* Index = 4*/
5576 .vendor_id = QCA_NL80211_VENDOR_ID,
5577 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
5578 },
5579 {
5580 /* Index = 5*/
5581 .vendor_id = QCA_NL80211_VENDOR_ID,
5582 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
5583 },
5584 {
5585 /* Index = 6*/
5586 .vendor_id = QCA_NL80211_VENDOR_ID,
5587 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
5588 },
5589#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305590#ifdef WLAN_FEATURE_EXTSCAN
5591 {
5592 .vendor_id = QCA_NL80211_VENDOR_ID,
5593 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
5594 },
5595 {
5596 .vendor_id = QCA_NL80211_VENDOR_ID,
5597 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
5598 },
5599 {
5600 .vendor_id = QCA_NL80211_VENDOR_ID,
5601 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
5602 },
5603 {
5604 .vendor_id = QCA_NL80211_VENDOR_ID,
5605 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
5606 },
5607 {
5608 .vendor_id = QCA_NL80211_VENDOR_ID,
5609 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
5610 },
5611 {
5612 .vendor_id = QCA_NL80211_VENDOR_ID,
5613 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
5614 },
5615 {
5616 .vendor_id = QCA_NL80211_VENDOR_ID,
5617 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
5618 },
5619 {
5620 .vendor_id = QCA_NL80211_VENDOR_ID,
5621 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
5622 },
5623 {
5624 .vendor_id = QCA_NL80211_VENDOR_ID,
5625 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
5626 },
5627 {
5628 .vendor_id = QCA_NL80211_VENDOR_ID,
5629 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
5630 },
5631 {
5632 .vendor_id = QCA_NL80211_VENDOR_ID,
5633 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
5634 },
5635 {
5636 .vendor_id = QCA_NL80211_VENDOR_ID,
5637 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
5638 },
5639 {
5640 .vendor_id = QCA_NL80211_VENDOR_ID,
5641 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
5642 },
5643#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305644/*EXT TDLS*/
5645 {
5646 .vendor_id = QCA_NL80211_VENDOR_ID,
5647 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
5648 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305649
5650 {
5651 .vendor_id = QCA_NL80211_VENDOR_ID,
5652 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
5653 },
5654
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005655};
5656
Jeff Johnson295189b2012-06-20 16:38:30 -07005657/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305658 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305659 * This function is called by hdd_wlan_startup()
5660 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305661 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07005662 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305663struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07005664{
5665 struct wiphy *wiphy;
5666 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305667 /*
5668 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 */
5670 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
5671
5672 if (!wiphy)
5673 {
5674 /* Print error and jump into err label and free the memory */
5675 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
5676 return NULL;
5677 }
5678
Sunil Duttc69bccb2014-05-26 21:30:20 +05305679
Jeff Johnson295189b2012-06-20 16:38:30 -07005680 return wiphy;
5681}
5682
5683/*
5684 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305685 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07005686 * private ioctl to change the band value
5687 */
5688int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
5689{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305690 int i, j;
5691 eNVChannelEnabledType channelEnabledState;
5692
Jeff Johnsone7245742012-09-05 17:12:55 -07005693 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305694
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305695 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305697
5698 if (NULL == wiphy->bands[i])
5699 {
5700 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5701 __func__, i);
5702 continue;
5703 }
5704
5705 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5706 {
5707 struct ieee80211_supported_band *band = wiphy->bands[i];
5708
5709 channelEnabledState = vos_nv_getChannelEnabledState(
5710 band->channels[j].hw_value);
5711
5712 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
5713 {
Abhishek Singh678227a2014-11-04 10:52:38 +05305714 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305715 continue;
5716 }
5717 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
5718 {
5719 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5720 continue;
5721 }
5722
5723 if (NV_CHANNEL_DISABLE == channelEnabledState ||
5724 NV_CHANNEL_INVALID == channelEnabledState)
5725 {
5726 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5727 }
5728 else if (NV_CHANNEL_DFS == channelEnabledState)
5729 {
5730 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5731 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
5732 }
5733 else
5734 {
5735 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
5736 |IEEE80211_CHAN_RADAR);
5737 }
5738 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005739 }
5740 return 0;
5741}
5742/*
5743 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305744 * This function is called by hdd_wlan_startup()
5745 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07005746 * This function is used to initialize and register wiphy structure.
5747 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305748int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 struct wiphy *wiphy,
5750 hdd_config_t *pCfg
5751 )
5752{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305753 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305754 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5755
Jeff Johnsone7245742012-09-05 17:12:55 -07005756 ENTER();
5757
Jeff Johnson295189b2012-06-20 16:38:30 -07005758 /* Now bind the underlying wlan device with wiphy */
5759 set_wiphy_dev(wiphy, dev);
5760
5761 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005762
Kiet Lam6c583332013-10-14 05:37:09 +05305763#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07005764 /* the flag for the other case would be initialzed in
5765 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07005766 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05305767#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005768
Amar Singhalfddc28c2013-09-05 13:03:40 -07005769 /* This will disable updating of NL channels from passive to
5770 * active if a beacon is received on passive channel. */
5771 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -07005772
Amar Singhalfddc28c2013-09-05 13:03:40 -07005773
Amar Singhala49cbc52013-10-08 18:37:44 -07005774
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005775#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07005776 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
5777 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
5778 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07005779 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +05305780 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005781#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005782
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005783#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005784 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08005785#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005786 || pCfg->isFastRoamIniFeatureEnabled
5787#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005788#ifdef FEATURE_WLAN_ESE
5789 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005790#endif
5791 )
5792 {
5793 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
5794 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08005795#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005796#ifdef FEATURE_WLAN_TDLS
5797 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
5798 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
5799#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305800#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05305801 if (pCfg->configPNOScanSupport)
5802 {
5803 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
5804 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
5805 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
5806 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
5807 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305808#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005809
Abhishek Singh10d85972015-04-17 10:27:23 +05305810#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5811 wiphy->features |= NL80211_FEATURE_HT_IBSS;
5812#endif
5813
Amar Singhalfddc28c2013-09-05 13:03:40 -07005814#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005815 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
5816 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07005817 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005818 driver need to determine what to do with both
5819 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07005820
5821 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07005822#else
5823 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005824#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005825
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305826 wiphy->max_scan_ssids = MAX_SCAN_SSID;
5827
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05305828 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07005829
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305830 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
5831
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05305833 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
5834 | BIT(NL80211_IFTYPE_ADHOC)
5835 | BIT(NL80211_IFTYPE_P2P_CLIENT)
5836 | BIT(NL80211_IFTYPE_P2P_GO)
5837 | BIT(NL80211_IFTYPE_AP);
5838
5839 if (VOS_MONITOR_MODE == hdd_get_conparam())
5840 {
5841 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
5842 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005843
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305844 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005845 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305846#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5847 if( pCfg->enableMCC )
5848 {
5849 /* Currently, supports up to two channels */
5850 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005851
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305852 if( !pCfg->allowMCCGODiffBI )
5853 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005854
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305855 }
5856 wiphy->iface_combinations = &wlan_hdd_iface_combination;
5857 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005858#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305859 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005860
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 /* Before registering we need to update the ht capabilitied based
5862 * on ini values*/
5863 if( !pCfg->ShortGI20MhzEnable )
5864 {
5865 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5866 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5867 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5868 }
5869
5870 if( !pCfg->ShortGI40MhzEnable )
5871 {
5872 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
5873 }
5874
5875 if( !pCfg->nChannelBondingMode5GHz )
5876 {
5877 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5878 }
5879
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305880 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305881 if (true == hdd_is_5g_supported(pHddCtx))
5882 {
5883 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
5884 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305885
5886 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
5887 {
5888
5889 if (NULL == wiphy->bands[i])
5890 {
5891 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5892 __func__, i);
5893 continue;
5894 }
5895
5896 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5897 {
5898 struct ieee80211_supported_band *band = wiphy->bands[i];
5899
5900 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
5901 {
5902 // Enable social channels for P2P
5903 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
5904 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5905 else
5906 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5907 continue;
5908 }
5909 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
5910 {
5911 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5912 continue;
5913 }
5914 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005915 }
5916 /*Initialise the supported cipher suite details*/
5917 wiphy->cipher_suites = hdd_cipher_suites;
5918 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
5919
5920 /*signal strength in mBm (100*dBm) */
5921 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
5922
5923#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05305924 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07005925#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005926
Sunil Duttc69bccb2014-05-26 21:30:20 +05305927 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
5928 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005929 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
5930 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
5931
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305932 EXIT();
5933 return 0;
5934}
5935
5936/* In this function we are registering wiphy. */
5937int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
5938{
5939 ENTER();
5940 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 if (0 > wiphy_register(wiphy))
5942 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305943 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07005944 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
5945 return -EIO;
5946 }
5947
5948 EXIT();
5949 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305950}
Jeff Johnson295189b2012-06-20 16:38:30 -07005951
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305952/* In this function we are updating channel list when,
5953 regulatory domain is FCC and country code is US.
5954 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
5955 As per FCC smart phone is not a indoor device.
5956 GO should not opeate on indoor channels */
5957void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
5958{
5959 int j;
5960 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5961 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
5962 //Default counrtycode from NV at the time of wiphy initialization.
5963 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
5964 &defaultCountryCode[0]))
5965 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005966 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305967 }
5968 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
5969 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305970 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
5971 {
5972 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
5973 return;
5974 }
5975 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
5976 {
5977 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
5978 // Mark UNII -1 band channel as passive
5979 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
5980 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
5981 }
5982 }
5983}
5984
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305985/* This function registers for all frame which supplicant is interested in */
5986void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005987{
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5989 /* Register for all P2P action, public action etc frames */
5990 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5991
Jeff Johnsone7245742012-09-05 17:12:55 -07005992 ENTER();
5993
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 /* Right now we are registering these frame when driver is getting
5995 initialized. Once we will move to 2.6.37 kernel, in which we have
5996 frame register ops, we will move this code as a part of that */
5997 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305998 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6000
6001 /* GAS Initial Response */
6002 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6003 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306004
Jeff Johnson295189b2012-06-20 16:38:30 -07006005 /* GAS Comeback Request */
6006 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6007 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6008
6009 /* GAS Comeback Response */
6010 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6011 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6012
6013 /* P2P Public Action */
6014 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306015 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006016 P2P_PUBLIC_ACTION_FRAME_SIZE );
6017
6018 /* P2P Action */
6019 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6020 (v_U8_t*)P2P_ACTION_FRAME,
6021 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07006022
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05306023 /* WNM BSS Transition Request frame */
6024 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6025 (v_U8_t*)WNM_BSS_ACTION_FRAME,
6026 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006027
6028 /* WNM-Notification */
6029 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6030 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6031 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006032}
6033
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05306034void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07006035{
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6037 /* Register for all P2P action, public action etc frames */
6038 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
6039
Jeff Johnsone7245742012-09-05 17:12:55 -07006040 ENTER();
6041
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 /* Right now we are registering these frame when driver is getting
6043 initialized. Once we will move to 2.6.37 kernel, in which we have
6044 frame register ops, we will move this code as a part of that */
6045 /* GAS Initial Request */
6046
6047 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6048 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6049
6050 /* GAS Initial Response */
6051 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6052 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306053
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 /* GAS Comeback Request */
6055 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6056 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6057
6058 /* GAS Comeback Response */
6059 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6060 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6061
6062 /* P2P Public Action */
6063 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306064 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006065 P2P_PUBLIC_ACTION_FRAME_SIZE );
6066
6067 /* P2P Action */
6068 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6069 (v_U8_t*)P2P_ACTION_FRAME,
6070 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006071 /* WNM-Notification */
6072 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6073 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6074 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006075}
6076
6077#ifdef FEATURE_WLAN_WAPI
6078void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
6079 const u8 *mac_addr, u8 *key , int key_Len)
6080{
6081 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6082 tCsrRoamSetKey setKey;
6083 v_BOOL_t isConnected = TRUE;
6084 int status = 0;
6085 v_U32_t roamId= 0xFF;
6086 tANI_U8 *pKeyPtr = NULL;
6087 int n = 0;
6088
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306089 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
6090 __func__, hdd_device_modetoString(pAdapter->device_mode),
6091 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006092
Gopichand Nakkalae7480202013-02-11 15:24:22 +05306093 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006094 setKey.keyId = key_index; // Store Key ID
6095 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
6096 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
6097 setKey.paeRole = 0 ; // the PAE role
6098 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
6099 {
6100 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
6101 }
6102 else
6103 {
6104 isConnected = hdd_connIsConnected(pHddStaCtx);
6105 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
6106 }
6107 setKey.keyLength = key_Len;
6108 pKeyPtr = setKey.Key;
6109 memcpy( pKeyPtr, key, key_Len);
6110
Arif Hussain6d2a3322013-11-17 19:50:10 -08006111 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006112 __func__, key_Len);
6113 for (n = 0 ; n < key_Len; n++)
6114 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
6115 __func__,n,setKey.Key[n]);
6116
6117 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6118 if ( isConnected )
6119 {
6120 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
6121 pAdapter->sessionId, &setKey, &roamId );
6122 }
6123 if ( status != 0 )
6124 {
6125 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6126 "[%4d] sme_RoamSetKey returned ERROR status= %d",
6127 __LINE__, status );
6128 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6129 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05306130 /* Need to clear any trace of key value in the memory.
6131 * Thus zero out the memory even though it is local
6132 * variable.
6133 */
6134 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006135}
6136#endif /* FEATURE_WLAN_WAPI*/
6137
6138#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306139int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 beacon_data_t **ppBeacon,
6141 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006142#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306143int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006144 beacon_data_t **ppBeacon,
6145 struct cfg80211_beacon_data *params,
6146 int dtim_period)
6147#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306148{
Jeff Johnson295189b2012-06-20 16:38:30 -07006149 int size;
6150 beacon_data_t *beacon = NULL;
6151 beacon_data_t *old = NULL;
6152 int head_len,tail_len;
6153
Jeff Johnsone7245742012-09-05 17:12:55 -07006154 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306156 {
6157 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6158 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006159 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006161
6162 old = pAdapter->sessionCtx.ap.beacon;
6163
6164 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306165 {
6166 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6167 FL("session(%d) old and new heads points to NULL"),
6168 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006169 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306170 }
6171
6172 if (params->tail && !params->tail_len)
6173 {
6174 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6175 FL("tail_len is zero but tail is not NULL"));
6176 return -EINVAL;
6177 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006178
Jeff Johnson295189b2012-06-20 16:38:30 -07006179#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
6180 /* Kernel 3.0 is not updating dtim_period for set beacon */
6181 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306182 {
6183 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6184 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006185 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306186 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006187#endif
6188
6189 if(params->head)
6190 head_len = params->head_len;
6191 else
6192 head_len = old->head_len;
6193
6194 if(params->tail || !old)
6195 tail_len = params->tail_len;
6196 else
6197 tail_len = old->tail_len;
6198
6199 size = sizeof(beacon_data_t) + head_len + tail_len;
6200
6201 beacon = kzalloc(size, GFP_KERNEL);
6202
6203 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306204 {
6205 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6206 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006207 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306208 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006209
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006210#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 if(params->dtim_period || !old )
6212 beacon->dtim_period = params->dtim_period;
6213 else
6214 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006215#else
6216 if(dtim_period || !old )
6217 beacon->dtim_period = dtim_period;
6218 else
6219 beacon->dtim_period = old->dtim_period;
6220#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306221
Jeff Johnson295189b2012-06-20 16:38:30 -07006222 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
6223 beacon->tail = beacon->head + head_len;
6224 beacon->head_len = head_len;
6225 beacon->tail_len = tail_len;
6226
6227 if(params->head) {
6228 memcpy (beacon->head,params->head,beacon->head_len);
6229 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306230 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07006231 if(old)
6232 memcpy (beacon->head,old->head,beacon->head_len);
6233 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306234
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 if(params->tail) {
6236 memcpy (beacon->tail,params->tail,beacon->tail_len);
6237 }
6238 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306239 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 memcpy (beacon->tail,old->tail,beacon->tail_len);
6241 }
6242
6243 *ppBeacon = beacon;
6244
6245 kfree(old);
6246
6247 return 0;
6248
6249}
Jeff Johnson295189b2012-06-20 16:38:30 -07006250
6251v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
6252{
6253 int left = length;
6254 v_U8_t *ptr = pIes;
6255 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306256
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306258 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006259 elem_id = ptr[0];
6260 elem_len = ptr[1];
6261 left -= 2;
6262 if(elem_len > left)
6263 {
6264 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006265 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 eid,elem_len,left);
6267 return NULL;
6268 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306269 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006270 {
6271 return ptr;
6272 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306273
Jeff Johnson295189b2012-06-20 16:38:30 -07006274 left -= elem_len;
6275 ptr += (elem_len + 2);
6276 }
6277 return NULL;
6278}
6279
Jeff Johnson295189b2012-06-20 16:38:30 -07006280/* Check if rate is 11g rate or not */
6281static int wlan_hdd_rate_is_11g(u8 rate)
6282{
Sanjay Devnani28322e22013-06-21 16:13:40 -07006283 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006284 u8 i;
6285 for (i = 0; i < 8; i++)
6286 {
6287 if(rate == gRateArray[i])
6288 return TRUE;
6289 }
6290 return FALSE;
6291}
6292
6293/* Check for 11g rate and set proper 11g only mode */
6294static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
6295 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
6296{
6297 u8 i, num_rates = pIe[0];
6298
6299 pIe += 1;
6300 for ( i = 0; i < num_rates; i++)
6301 {
6302 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
6303 {
6304 /* If rate set have 11g rate than change the mode to 11G */
6305 *pSapHw_mode = eSAP_DOT11_MODE_11g;
6306 if (pIe[i] & BASIC_RATE_MASK)
6307 {
6308 /* If we have 11g rate as basic rate, it means mode
6309 is 11g only mode.
6310 */
6311 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
6312 *pCheckRatesfor11g = FALSE;
6313 }
6314 }
6315 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
6316 {
6317 *require_ht = TRUE;
6318 }
6319 }
6320 return;
6321}
6322
6323static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
6324{
6325 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6326 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6327 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6328 u8 checkRatesfor11g = TRUE;
6329 u8 require_ht = FALSE;
6330 u8 *pIe=NULL;
6331
6332 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
6333
6334 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
6335 pBeacon->head_len, WLAN_EID_SUPP_RATES);
6336 if (pIe != NULL)
6337 {
6338 pIe += 1;
6339 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6340 &pConfig->SapHw_mode);
6341 }
6342
6343 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6344 WLAN_EID_EXT_SUPP_RATES);
6345 if (pIe != NULL)
6346 {
6347
6348 pIe += 1;
6349 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6350 &pConfig->SapHw_mode);
6351 }
6352
6353 if( pConfig->channel > 14 )
6354 {
6355 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
6356 }
6357
6358 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6359 WLAN_EID_HT_CAPABILITY);
6360
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306361 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006362 {
6363 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
6364 if(require_ht)
6365 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
6366 }
6367}
6368
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306369static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
6370 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
6371{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006372 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306373 v_U8_t *pIe = NULL;
6374 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6375
6376 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
6377 pBeacon->tail, pBeacon->tail_len);
6378
6379 if (pIe)
6380 {
6381 ielen = pIe[1] + 2;
6382 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6383 {
6384 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
6385 }
6386 else
6387 {
6388 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
6389 return -EINVAL;
6390 }
6391 *total_ielen += ielen;
6392 }
6393 return 0;
6394}
6395
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006396static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
6397 v_U8_t *genie, v_U8_t *total_ielen)
6398{
6399 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6400 int left = pBeacon->tail_len;
6401 v_U8_t *ptr = pBeacon->tail;
6402 v_U8_t elem_id, elem_len;
6403 v_U16_t ielen = 0;
6404
6405 if ( NULL == ptr || 0 == left )
6406 return;
6407
6408 while (left >= 2)
6409 {
6410 elem_id = ptr[0];
6411 elem_len = ptr[1];
6412 left -= 2;
6413 if (elem_len > left)
6414 {
6415 hddLog( VOS_TRACE_LEVEL_ERROR,
6416 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
6417 elem_id, elem_len, left);
6418 return;
6419 }
6420 if (IE_EID_VENDOR == elem_id)
6421 {
6422 /* skipping the VSIE's which we don't want to include or
6423 * it will be included by existing code
6424 */
6425 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
6426#ifdef WLAN_FEATURE_WFD
6427 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
6428#endif
6429 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6430 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6431 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
6432 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6433 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
6434 {
6435 ielen = ptr[1] + 2;
6436 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6437 {
6438 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
6439 *total_ielen += ielen;
6440 }
6441 else
6442 {
6443 hddLog( VOS_TRACE_LEVEL_ERROR,
6444 "IE Length is too big "
6445 "IEs eid=%d elem_len=%d total_ie_lent=%d",
6446 elem_id, elem_len, *total_ielen);
6447 }
6448 }
6449 }
6450
6451 left -= elem_len;
6452 ptr += (elem_len + 2);
6453 }
6454 return;
6455}
6456
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006457#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006458static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6459 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006460#else
6461static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6462 struct cfg80211_beacon_data *params)
6463#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006464{
6465 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306466 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006467 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07006468 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006469
6470 genie = vos_mem_malloc(MAX_GENIE_LEN);
6471
6472 if(genie == NULL) {
6473
6474 return -ENOMEM;
6475 }
6476
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306477 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6478 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306480 hddLog(LOGE,
6481 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306482 ret = -EINVAL;
6483 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006484 }
6485
6486#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306487 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6488 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
6489 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306490 hddLog(LOGE,
6491 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306492 ret = -EINVAL;
6493 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006494 }
6495#endif
6496
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306497 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6498 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006499 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306500 hddLog(LOGE,
6501 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306502 ret = -EINVAL;
6503 goto done;
6504 }
6505
6506 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
6507 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006508 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006510
6511 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6512 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
6513 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6514 {
6515 hddLog(LOGE,
6516 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006517 ret = -EINVAL;
6518 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006519 }
6520
6521 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6522 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6523 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6524 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6525 ==eHAL_STATUS_FAILURE)
6526 {
6527 hddLog(LOGE,
6528 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006529 ret = -EINVAL;
6530 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006531 }
6532
6533 // Added for ProResp IE
6534 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
6535 {
6536 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
6537 u8 probe_rsp_ie_len[3] = {0};
6538 u8 counter = 0;
6539 /* Check Probe Resp Length if it is greater then 255 then Store
6540 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
6541 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
6542 Store More then 255 bytes into One Variable.
6543 */
6544 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6545 {
6546 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6547 {
6548 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6549 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6550 }
6551 else
6552 {
6553 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6554 rem_probe_resp_ie_len = 0;
6555 }
6556 }
6557
6558 rem_probe_resp_ie_len = 0;
6559
6560 if (probe_rsp_ie_len[0] > 0)
6561 {
6562 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6563 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6564 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6565 probe_rsp_ie_len[0], NULL,
6566 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6567 {
6568 hddLog(LOGE,
6569 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006570 ret = -EINVAL;
6571 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006572 }
6573 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6574 }
6575
6576 if (probe_rsp_ie_len[1] > 0)
6577 {
6578 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6579 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6580 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6581 probe_rsp_ie_len[1], NULL,
6582 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6583 {
6584 hddLog(LOGE,
6585 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006586 ret = -EINVAL;
6587 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006588 }
6589 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6590 }
6591
6592 if (probe_rsp_ie_len[2] > 0)
6593 {
6594 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6595 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6596 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6597 probe_rsp_ie_len[2], NULL,
6598 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6599 {
6600 hddLog(LOGE,
6601 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006602 ret = -EINVAL;
6603 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006604 }
6605 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6606 }
6607
6608 if (probe_rsp_ie_len[1] == 0 )
6609 {
6610 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6611 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
6612 eANI_BOOLEAN_FALSE) )
6613 {
6614 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006615 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006616 }
6617 }
6618
6619 if (probe_rsp_ie_len[2] == 0 )
6620 {
6621 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6622 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
6623 eANI_BOOLEAN_FALSE) )
6624 {
6625 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006626 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006627 }
6628 }
6629
6630 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6631 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6632 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6633 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6634 == eHAL_STATUS_FAILURE)
6635 {
6636 hddLog(LOGE,
6637 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006638 ret = -EINVAL;
6639 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006640 }
6641 }
6642 else
6643 {
6644 // Reset WNI_CFG_PROBE_RSP Flags
6645 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
6646
6647 hddLog(VOS_TRACE_LEVEL_INFO,
6648 "%s: No Probe Response IE received in set beacon",
6649 __func__);
6650 }
6651
6652 // Added for AssocResp IE
6653 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
6654 {
6655 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6656 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
6657 params->assocresp_ies_len, NULL,
6658 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6659 {
6660 hddLog(LOGE,
6661 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006662 ret = -EINVAL;
6663 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006664 }
6665
6666 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6667 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
6668 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6669 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6670 == eHAL_STATUS_FAILURE)
6671 {
6672 hddLog(LOGE,
6673 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006674 ret = -EINVAL;
6675 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 }
6677 }
6678 else
6679 {
6680 hddLog(VOS_TRACE_LEVEL_INFO,
6681 "%s: No Assoc Response IE received in set beacon",
6682 __func__);
6683
6684 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6685 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6686 eANI_BOOLEAN_FALSE) )
6687 {
6688 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006689 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006690 }
6691 }
6692
Jeff Johnsone7245742012-09-05 17:12:55 -07006693done:
Jeff Johnson295189b2012-06-20 16:38:30 -07006694 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306695 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006696}
Jeff Johnson295189b2012-06-20 16:38:30 -07006697
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306698/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006699 * FUNCTION: wlan_hdd_validate_operation_channel
6700 * called by wlan_hdd_cfg80211_start_bss() and
6701 * wlan_hdd_cfg80211_set_channel()
6702 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306703 * channel list.
6704 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07006705VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006706{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306707
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 v_U32_t num_ch = 0;
6709 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6710 u32 indx = 0;
6711 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306712 v_U8_t fValidChannel = FALSE, count = 0;
6713 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306714
Jeff Johnson295189b2012-06-20 16:38:30 -07006715 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6716
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306717 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306719 /* Validate the channel */
6720 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006721 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306722 if ( channel == rfChannels[count].channelNum )
6723 {
6724 fValidChannel = TRUE;
6725 break;
6726 }
6727 }
6728 if (fValidChannel != TRUE)
6729 {
6730 hddLog(VOS_TRACE_LEVEL_ERROR,
6731 "%s: Invalid Channel [%d]", __func__, channel);
6732 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006733 }
6734 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306735 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006736 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306737 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6738 valid_ch, &num_ch))
6739 {
6740 hddLog(VOS_TRACE_LEVEL_ERROR,
6741 "%s: failed to get valid channel list", __func__);
6742 return VOS_STATUS_E_FAILURE;
6743 }
6744 for (indx = 0; indx < num_ch; indx++)
6745 {
6746 if (channel == valid_ch[indx])
6747 {
6748 break;
6749 }
6750 }
6751
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306752 if (indx >= num_ch)
6753 {
6754 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6755 {
6756 eCsrBand band;
6757 unsigned int freq;
6758
6759 sme_GetFreqBand(hHal, &band);
6760
6761 if (eCSR_BAND_5G == band)
6762 {
6763#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
6764 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
6765 {
6766 freq = ieee80211_channel_to_frequency(channel,
6767 IEEE80211_BAND_2GHZ);
6768 }
6769 else
6770 {
6771 freq = ieee80211_channel_to_frequency(channel,
6772 IEEE80211_BAND_5GHZ);
6773 }
6774#else
6775 freq = ieee80211_channel_to_frequency(channel);
6776#endif
6777 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
6778 return VOS_STATUS_SUCCESS;
6779 }
6780 }
6781
6782 hddLog(VOS_TRACE_LEVEL_ERROR,
6783 "%s: Invalid Channel [%d]", __func__, channel);
6784 return VOS_STATUS_E_FAILURE;
6785 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006786 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306787
Jeff Johnson295189b2012-06-20 16:38:30 -07006788 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306789
Jeff Johnson295189b2012-06-20 16:38:30 -07006790}
6791
Viral Modi3a32cc52013-02-08 11:14:52 -08006792/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306793 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08006794 * This function is used to set the channel number
6795 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306796static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08006797 struct ieee80211_channel *chan,
6798 enum nl80211_channel_type channel_type
6799 )
6800{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306801 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08006802 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07006803 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08006804 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306805 hdd_context_t *pHddCtx;
6806 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006807
6808 ENTER();
6809
6810 if( NULL == dev )
6811 {
6812 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006813 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006814 return -ENODEV;
6815 }
6816 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306817
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306818 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6819 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
6820 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08006821 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306822 "%s: device_mode = %s (%d) freq = %d", __func__,
6823 hdd_device_modetoString(pAdapter->device_mode),
6824 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306825
6826 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6827 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306828 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08006829 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306830 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006831 }
6832
6833 /*
6834 * Do freq to chan conversion
6835 * TODO: for 11a
6836 */
6837
6838 channel = ieee80211_frequency_to_channel(freq);
6839
6840 /* Check freq range */
6841 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
6842 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
6843 {
6844 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006845 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08006846 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
6847 WNI_CFG_CURRENT_CHANNEL_STAMAX);
6848 return -EINVAL;
6849 }
6850
6851 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6852
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05306853 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
6854 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08006855 {
6856 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
6857 {
6858 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006859 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08006860 return -EINVAL;
6861 }
6862 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6863 "%s: set channel to [%d] for device mode =%d",
6864 __func__, channel,pAdapter->device_mode);
6865 }
6866 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08006867 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08006868 )
6869 {
6870 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6871 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
6872 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6873
6874 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
6875 {
6876 /* Link is up then return cant set channel*/
6877 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006878 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006879 return -EINVAL;
6880 }
6881
6882 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
6883 pHddStaCtx->conn_info.operationChannel = channel;
6884 pRoamProfile->ChannelInfo.ChannelList =
6885 &pHddStaCtx->conn_info.operationChannel;
6886 }
6887 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08006888 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08006889 )
6890 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306891 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6892 {
6893 if(VOS_STATUS_SUCCESS !=
6894 wlan_hdd_validate_operation_channel(pAdapter,channel))
6895 {
6896 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006897 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306898 return -EINVAL;
6899 }
6900 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6901 }
6902 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08006903 {
6904 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
6905
6906 /* If auto channel selection is configured as enable/ 1 then ignore
6907 channel set by supplicant
6908 */
6909 if ( cfg_param->apAutoChannelSelection )
6910 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306911 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
6912 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08006913 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306914 "%s: set channel to auto channel (0) for device mode =%s (%d)",
6915 __func__, hdd_device_modetoString(pAdapter->device_mode),
6916 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08006917 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306918 else
6919 {
6920 if(VOS_STATUS_SUCCESS !=
6921 wlan_hdd_validate_operation_channel(pAdapter,channel))
6922 {
6923 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006924 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306925 return -EINVAL;
6926 }
6927 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6928 }
Viral Modi3a32cc52013-02-08 11:14:52 -08006929 }
6930 }
6931 else
6932 {
6933 hddLog(VOS_TRACE_LEVEL_FATAL,
6934 "%s: Invalid device mode failed to set valid channel", __func__);
6935 return -EINVAL;
6936 }
6937 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306938 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006939}
6940
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306941static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
6942 struct net_device *dev,
6943 struct ieee80211_channel *chan,
6944 enum nl80211_channel_type channel_type
6945 )
6946{
6947 int ret;
6948
6949 vos_ssr_protect(__func__);
6950 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
6951 vos_ssr_unprotect(__func__);
6952
6953 return ret;
6954}
6955
Jeff Johnson295189b2012-06-20 16:38:30 -07006956#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
6957static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6958 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006959#else
6960static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6961 struct cfg80211_beacon_data *params,
6962 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05306963 enum nl80211_hidden_ssid hidden_ssid,
6964 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006965#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006966{
6967 tsap_Config_t *pConfig;
6968 beacon_data_t *pBeacon = NULL;
6969 struct ieee80211_mgmt *pMgmt_frame;
6970 v_U8_t *pIe=NULL;
6971 v_U16_t capab_info;
6972 eCsrAuthType RSNAuthType;
6973 eCsrEncryptionType RSNEncryptType;
6974 eCsrEncryptionType mcRSNEncryptType;
6975 int status = VOS_STATUS_SUCCESS;
6976 tpWLAN_SAPEventCB pSapEventCallback;
6977 hdd_hostapd_state_t *pHostapdState;
6978 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
6979 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306980 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306982 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006983 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08006984 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05306985 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07006986 v_BOOL_t MFPCapable = VOS_FALSE;
6987 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05306988 v_BOOL_t sapEnable11AC =
6989 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07006990 ENTER();
6991
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306992 iniConfig = pHddCtx->cfg_ini;
6993
Jeff Johnson295189b2012-06-20 16:38:30 -07006994 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
6995
6996 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6997
6998 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6999
7000 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
7001
7002 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
7003
7004 //channel is already set in the set_channel Call back
7005 //pConfig->channel = pCommitConfig->channel;
7006
7007 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307008 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
7010
7011 pConfig->dtim_period = pBeacon->dtim_period;
7012
Arif Hussain6d2a3322013-11-17 19:50:10 -08007013 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07007014 pConfig->dtim_period);
7015
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08007016 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07007017 {
7018 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007019 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05307020 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
7021 {
7022 tANI_BOOLEAN restartNeeded;
7023 pConfig->ieee80211d = 1;
7024 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
7025 sme_setRegInfo(hHal, pConfig->countryCode);
7026 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
7027 }
7028 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07007029 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07007030 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007031 pConfig->ieee80211d = 1;
7032 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
7033 sme_setRegInfo(hHal, pConfig->countryCode);
7034 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07007035 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007036 else
7037 {
7038 pConfig->ieee80211d = 0;
7039 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307040 /*
7041 * If auto channel is configured i.e. channel is 0,
7042 * so skip channel validation.
7043 */
7044 if( AUTO_CHANNEL_SELECT != pConfig->channel )
7045 {
7046 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
7047 {
7048 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007049 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307050 return -EINVAL;
7051 }
7052 }
7053 else
7054 {
7055 if(1 != pHddCtx->is_dynamic_channel_range_set)
7056 {
7057 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
7058 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
7059 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
7060 }
7061 pHddCtx->is_dynamic_channel_range_set = 0;
7062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007063 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007064 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007065 {
7066 pConfig->ieee80211d = 0;
7067 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307068
7069#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7070 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7071 pConfig->authType = eSAP_OPEN_SYSTEM;
7072 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7073 pConfig->authType = eSAP_SHARED_KEY;
7074 else
7075 pConfig->authType = eSAP_AUTO_SWITCH;
7076#else
7077 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7078 pConfig->authType = eSAP_OPEN_SYSTEM;
7079 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7080 pConfig->authType = eSAP_SHARED_KEY;
7081 else
7082 pConfig->authType = eSAP_AUTO_SWITCH;
7083#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007084
7085 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307086
7087 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07007088 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
7089
7090 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
7091
7092 /*Set wps station to configured*/
7093 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
7094
7095 if(pIe)
7096 {
7097 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
7098 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007099 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07007100 return -EINVAL;
7101 }
7102 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
7103 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007104 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07007105 /* Check 15 bit of WPS IE as it contain information for wps state
7106 * WPS state
7107 */
7108 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
7109 {
7110 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
7111 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
7112 {
7113 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
7114 }
7115 }
7116 }
7117 else
7118 {
7119 pConfig->wps_state = SAP_WPS_DISABLED;
7120 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307121 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07007122
c_hpothufe599e92014-06-16 11:38:55 +05307123 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7124 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7125 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
7126 eCSR_ENCRYPT_TYPE_NONE;
7127
Jeff Johnson295189b2012-06-20 16:38:30 -07007128 pConfig->RSNWPAReqIELength = 0;
7129 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307130 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007131 WLAN_EID_RSN);
7132 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307133 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007134 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7135 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7136 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307137 /* The actual processing may eventually be more extensive than
7138 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07007139 * by the app.
7140 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307141 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007142 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7143 &RSNEncryptType,
7144 &mcRSNEncryptType,
7145 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007146 &MFPCapable,
7147 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007148 pConfig->pRSNWPAReqIE[1]+2,
7149 pConfig->pRSNWPAReqIE );
7150
7151 if( VOS_STATUS_SUCCESS == status )
7152 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307153 /* Now copy over all the security attributes you have
7154 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007155 * */
7156 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7157 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7158 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7159 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307160 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007161 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007162 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7163 }
7164 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307165
Jeff Johnson295189b2012-06-20 16:38:30 -07007166 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7167 pBeacon->tail, pBeacon->tail_len);
7168
7169 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
7170 {
7171 if (pConfig->pRSNWPAReqIE)
7172 {
7173 /*Mixed mode WPA/WPA2*/
7174 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
7175 pConfig->RSNWPAReqIELength += pIe[1] + 2;
7176 }
7177 else
7178 {
7179 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7180 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7181 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307182 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007183 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7184 &RSNEncryptType,
7185 &mcRSNEncryptType,
7186 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007187 &MFPCapable,
7188 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007189 pConfig->pRSNWPAReqIE[1]+2,
7190 pConfig->pRSNWPAReqIE );
7191
7192 if( VOS_STATUS_SUCCESS == status )
7193 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307194 /* Now copy over all the security attributes you have
7195 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007196 * */
7197 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7198 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7199 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7200 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307201 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007202 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007203 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7204 }
7205 }
7206 }
7207
Jeff Johnson4416a782013-03-25 14:17:50 -07007208 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
7209 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
7210 return -EINVAL;
7211 }
7212
Jeff Johnson295189b2012-06-20 16:38:30 -07007213 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
7214
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007215#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007216 if (params->ssid != NULL)
7217 {
7218 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
7219 pConfig->SSIDinfo.ssid.length = params->ssid_len;
7220 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7221 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7222 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007223#else
7224 if (ssid != NULL)
7225 {
7226 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
7227 pConfig->SSIDinfo.ssid.length = ssid_len;
7228 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7229 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7230 }
7231#endif
7232
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307233 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07007234 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307235
Jeff Johnson295189b2012-06-20 16:38:30 -07007236 /* default value */
7237 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
7238 pConfig->num_accept_mac = 0;
7239 pConfig->num_deny_mac = 0;
7240
7241 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7242 pBeacon->tail, pBeacon->tail_len);
7243
7244 /* pIe for black list is following form:
7245 type : 1 byte
7246 length : 1 byte
7247 OUI : 4 bytes
7248 acl type : 1 byte
7249 no of mac addr in black list: 1 byte
7250 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307251 */
7252 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007253 {
7254 pConfig->SapMacaddr_acl = pIe[6];
7255 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007256 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007257 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307258 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
7259 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007260 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7261 for (i = 0; i < pConfig->num_deny_mac; i++)
7262 {
7263 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7264 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 }
7267 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7268 pBeacon->tail, pBeacon->tail_len);
7269
7270 /* pIe for white list is following form:
7271 type : 1 byte
7272 length : 1 byte
7273 OUI : 4 bytes
7274 acl type : 1 byte
7275 no of mac addr in white list: 1 byte
7276 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307277 */
7278 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007279 {
7280 pConfig->SapMacaddr_acl = pIe[6];
7281 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007282 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007283 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307284 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
7285 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007286 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7287 for (i = 0; i < pConfig->num_accept_mac; i++)
7288 {
7289 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7290 acl_entry++;
7291 }
7292 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307293
Jeff Johnson295189b2012-06-20 16:38:30 -07007294 wlan_hdd_set_sapHwmode(pHostapdAdapter);
7295
Jeff Johnsone7245742012-09-05 17:12:55 -07007296#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007297 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307298 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
7299 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05307300 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
7301 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007302 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
7303 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307304 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
7305 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07007306 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307307 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007308 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307309 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007310
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307311 /* If ACS disable and selected channel <= 14
7312 * OR
7313 * ACS enabled and ACS operating band is choosen as 2.4
7314 * AND
7315 * VHT in 2.4G Disabled
7316 * THEN
7317 * Fallback to 11N mode
7318 */
7319 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
7320 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05307321 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307322 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007323 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307324 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
7325 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007326 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
7327 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007328 }
7329#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307330
Jeff Johnson295189b2012-06-20 16:38:30 -07007331 // ht_capab is not what the name conveys,this is used for protection bitmap
7332 pConfig->ht_capab =
7333 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
7334
7335 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
7336 {
7337 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
7338 return -EINVAL;
7339 }
7340
7341 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307342 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07007343 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
7344 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307345 pConfig->obssProtEnabled =
7346 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07007347
Chet Lanctot8cecea22014-02-11 19:09:36 -08007348#ifdef WLAN_FEATURE_11W
7349 pConfig->mfpCapable = MFPCapable;
7350 pConfig->mfpRequired = MFPRequired;
7351 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
7352 pConfig->mfpCapable, pConfig->mfpRequired);
7353#endif
7354
Arif Hussain6d2a3322013-11-17 19:50:10 -08007355 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07007356 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007357 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
7358 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
7359 (int)pConfig->channel);
7360 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
7361 pConfig->SapHw_mode, pConfig->privacy,
7362 pConfig->authType);
7363 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
7364 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
7365 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
7366 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07007367
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307368 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007369 {
7370 //Bss already started. just return.
7371 //TODO Probably it should update some beacon params.
7372 hddLog( LOGE, "Bss Already started...Ignore the request");
7373 EXIT();
7374 return 0;
7375 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307376
Agarwal Ashish51325b52014-06-16 16:50:49 +05307377 if (vos_max_concurrent_connections_reached()) {
7378 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7379 return -EINVAL;
7380 }
7381
Jeff Johnson295189b2012-06-20 16:38:30 -07007382 pConfig->persona = pHostapdAdapter->device_mode;
7383
Peng Xu2446a892014-09-05 17:21:18 +05307384 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
7385 if ( NULL != psmeConfig)
7386 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307387 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05307388 sme_GetConfigParam(hHal, psmeConfig);
7389 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307390#ifdef WLAN_FEATURE_AP_HT40_24G
7391 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
7392 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
7393 && pHddCtx->cfg_ini->apHT40_24GEnabled)
7394 {
7395 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
7396 sme_UpdateConfig (hHal, psmeConfig);
7397 }
7398#endif
Peng Xu2446a892014-09-05 17:21:18 +05307399 vos_mem_free(psmeConfig);
7400 }
Peng Xuafc34e32014-09-25 13:23:55 +05307401 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05307402
Jeff Johnson295189b2012-06-20 16:38:30 -07007403 pSapEventCallback = hdd_hostapd_SAPEventCB;
7404 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
7405 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
7406 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007407 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007408 return -EINVAL;
7409 }
7410
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307411 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07007412 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
7413
7414 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307415
Jeff Johnson295189b2012-06-20 16:38:30 -07007416 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307417 {
7418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007419 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07007420 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007421 VOS_ASSERT(0);
7422 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307423
Jeff Johnson295189b2012-06-20 16:38:30 -07007424 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05307425 /* Initialize WMM configuation */
7426 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307427 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007428
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007429#ifdef WLAN_FEATURE_P2P_DEBUG
7430 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
7431 {
7432 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
7433 {
7434 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7435 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007436 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007437 }
7438 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
7439 {
7440 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7441 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007442 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007443 }
7444 }
7445#endif
7446
Jeff Johnson295189b2012-06-20 16:38:30 -07007447 pHostapdState->bCommit = TRUE;
7448 EXIT();
7449
7450 return 0;
7451}
7452
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007453#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307454static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307455 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007456 struct beacon_parameters *params)
7457{
7458 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307459 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307460 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007461
7462 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307463
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307464 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7465 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
7466 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307467 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
7468 hdd_device_modetoString(pAdapter->device_mode),
7469 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007470
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307471 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7472 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307473 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007474 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307475 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007476 }
7477
Agarwal Ashish51325b52014-06-16 16:50:49 +05307478 if (vos_max_concurrent_connections_reached()) {
7479 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7480 return -EINVAL;
7481 }
7482
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307483 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007484 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007485 )
7486 {
7487 beacon_data_t *old,*new;
7488
7489 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307490
Jeff Johnson295189b2012-06-20 16:38:30 -07007491 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307492 {
7493 hddLog(VOS_TRACE_LEVEL_WARN,
7494 FL("already beacon info added to session(%d)"),
7495 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007496 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307497 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007498
7499 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7500
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307501 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07007502 {
7503 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007504 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007505 return -EINVAL;
7506 }
7507
7508 pAdapter->sessionCtx.ap.beacon = new;
7509
7510 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7511 }
7512
7513 EXIT();
7514 return status;
7515}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307516
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307517static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
7518 struct net_device *dev,
7519 struct beacon_parameters *params)
7520{
7521 int ret;
7522
7523 vos_ssr_protect(__func__);
7524 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
7525 vos_ssr_unprotect(__func__);
7526
7527 return ret;
7528}
7529
7530static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007531 struct net_device *dev,
7532 struct beacon_parameters *params)
7533{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307534 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307535 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7536 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307537 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007538
7539 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307540
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307541 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7542 TRACE_CODE_HDD_CFG80211_SET_BEACON,
7543 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
7544 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7545 __func__, hdd_device_modetoString(pAdapter->device_mode),
7546 pAdapter->device_mode);
7547
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307548 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7549 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307550 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007551 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307552 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007553 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307554
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307555 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007556 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307557 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007558 {
7559 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307560
Jeff Johnson295189b2012-06-20 16:38:30 -07007561 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307562
Jeff Johnson295189b2012-06-20 16:38:30 -07007563 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307564 {
7565 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7566 FL("session(%d) old and new heads points to NULL"),
7567 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007568 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307569 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007570
7571 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7572
7573 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307574 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007575 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007576 return -EINVAL;
7577 }
7578
7579 pAdapter->sessionCtx.ap.beacon = new;
7580
7581 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7582 }
7583
7584 EXIT();
7585 return status;
7586}
7587
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307588static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
7589 struct net_device *dev,
7590 struct beacon_parameters *params)
7591{
7592 int ret;
7593
7594 vos_ssr_protect(__func__);
7595 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
7596 vos_ssr_unprotect(__func__);
7597
7598 return ret;
7599}
7600
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007601#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7602
7603#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307604static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007605 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007606#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307607static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007608 struct net_device *dev)
7609#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007610{
7611 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07007612 hdd_context_t *pHddCtx = NULL;
7613 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307614 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307615 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007616
7617 ENTER();
7618
7619 if (NULL == pAdapter)
7620 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307621 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007622 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007623 return -ENODEV;
7624 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007625
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307626 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7627 TRACE_CODE_HDD_CFG80211_STOP_AP,
7628 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307629 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7630 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307631 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007632 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307633 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07007634 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007635
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007636 pScanInfo = &pHddCtx->scan_info;
7637
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307638 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7639 __func__, hdd_device_modetoString(pAdapter->device_mode),
7640 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007641
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307642 ret = wlan_hdd_scan_abort(pAdapter);
7643
Girish Gowli4bf7a632014-06-12 13:42:11 +05307644 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07007645 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307646 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7647 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307648
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307649 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07007650 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307651 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7652 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08007653
Jeff Johnsone7245742012-09-05 17:12:55 -07007654 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307655 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07007656 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307657 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07007658 }
7659
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05307660 /* Delete all associated STAs before stopping AP/P2P GO */
7661 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05307662 hdd_hostapd_stop(dev);
7663
Jeff Johnson295189b2012-06-20 16:38:30 -07007664 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007665 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007666 )
7667 {
7668 beacon_data_t *old;
7669
7670 old = pAdapter->sessionCtx.ap.beacon;
7671
7672 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307673 {
7674 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7675 FL("session(%d) beacon data points to NULL"),
7676 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007677 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007679
Jeff Johnson295189b2012-06-20 16:38:30 -07007680 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007681
7682 mutex_lock(&pHddCtx->sap_lock);
7683 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7684 {
Jeff Johnson4416a782013-03-25 14:17:50 -07007685 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007686 {
7687 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7688
7689 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
7690
7691 if (!VOS_IS_STATUS_SUCCESS(status))
7692 {
7693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007694 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007695 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307696 }
7697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007698 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307699 /* BSS stopped, clear the active sessions for this device mode */
7700 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007701 }
7702 mutex_unlock(&pHddCtx->sap_lock);
7703
7704 if(status != VOS_STATUS_SUCCESS)
7705 {
7706 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007707 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007708 return -EINVAL;
7709 }
7710
Jeff Johnson4416a782013-03-25 14:17:50 -07007711 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007712 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
7713 ==eHAL_STATUS_FAILURE)
7714 {
7715 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007716 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007717 }
7718
Jeff Johnson4416a782013-03-25 14:17:50 -07007719 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007720 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7721 eANI_BOOLEAN_FALSE) )
7722 {
7723 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007724 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007725 }
7726
7727 // Reset WNI_CFG_PROBE_RSP Flags
7728 wlan_hdd_reset_prob_rspies(pAdapter);
7729
7730 pAdapter->sessionCtx.ap.beacon = NULL;
7731 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007732#ifdef WLAN_FEATURE_P2P_DEBUG
7733 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
7734 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
7735 {
7736 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
7737 "GO got removed");
7738 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
7739 }
7740#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007741 }
7742 EXIT();
7743 return status;
7744}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007745
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307746#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7747static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
7748 struct net_device *dev)
7749{
7750 int ret;
7751
7752 vos_ssr_protect(__func__);
7753 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
7754 vos_ssr_unprotect(__func__);
7755
7756 return ret;
7757}
7758#else
7759static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
7760 struct net_device *dev)
7761{
7762 int ret;
7763
7764 vos_ssr_protect(__func__);
7765 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
7766 vos_ssr_unprotect(__func__);
7767
7768 return ret;
7769}
7770#endif
7771
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007772#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
7773
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307774static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307775 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007776 struct cfg80211_ap_settings *params)
7777{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307778 hdd_adapter_t *pAdapter;
7779 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307780 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007781
7782 ENTER();
7783
Girish Gowlib143d7a2015-02-18 19:39:55 +05307784 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007785 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307786 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05307787 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307788 return -ENODEV;
7789 }
7790
7791 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7792 if (NULL == pAdapter)
7793 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307794 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307795 "%s: HDD adapter is Null", __func__);
7796 return -ENODEV;
7797 }
7798
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307799 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7800 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
7801 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307802 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
7803 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307804 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307805 "%s: HDD adapter magic is invalid", __func__);
7806 return -ENODEV;
7807 }
7808
7809 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307810 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307811 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307812 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307813 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307814 }
7815
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307816 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
7817 __func__, hdd_device_modetoString(pAdapter->device_mode),
7818 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307819
7820 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007821 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007822 )
7823 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307824 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007825
7826 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307827
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007828 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307829 {
7830 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7831 FL("already beacon info added to session(%d)"),
7832 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007833 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307834 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007835
Girish Gowlib143d7a2015-02-18 19:39:55 +05307836#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7837 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7838 &new,
7839 &params->beacon);
7840#else
7841 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7842 &new,
7843 &params->beacon,
7844 params->dtim_period);
7845#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007846
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307847 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007848 {
7849 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307850 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007851 return -EINVAL;
7852 }
7853 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08007854#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07007855 wlan_hdd_cfg80211_set_channel(wiphy, dev,
7856#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
7857 params->channel, params->channel_type);
7858#else
7859 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
7860#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08007861#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007862 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307863 params->ssid_len, params->hidden_ssid,
7864 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007865 }
7866
7867 EXIT();
7868 return status;
7869}
7870
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307871static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
7872 struct net_device *dev,
7873 struct cfg80211_ap_settings *params)
7874{
7875 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007876
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307877 vos_ssr_protect(__func__);
7878 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
7879 vos_ssr_unprotect(__func__);
7880
7881 return ret;
7882}
7883
7884static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007885 struct net_device *dev,
7886 struct cfg80211_beacon_data *params)
7887{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307888 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307889 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307890 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007891
7892 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307893
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307894 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7895 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
7896 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007897 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007898 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307899
7900 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7901 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307902 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007903 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307904 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007905 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007906
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307907 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007908 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307909 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007910 {
7911 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307912
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007913 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307914
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007915 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307916 {
7917 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7918 FL("session(%d) beacon data points to NULL"),
7919 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007920 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307921 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007922
7923 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
7924
7925 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307926 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007927 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007928 return -EINVAL;
7929 }
7930
7931 pAdapter->sessionCtx.ap.beacon = new;
7932
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307933 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
7934 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007935 }
7936
7937 EXIT();
7938 return status;
7939}
7940
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307941static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
7942 struct net_device *dev,
7943 struct cfg80211_beacon_data *params)
7944{
7945 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007946
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307947 vos_ssr_protect(__func__);
7948 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
7949 vos_ssr_unprotect(__func__);
7950
7951 return ret;
7952}
7953
7954#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007955
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307956static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007957 struct net_device *dev,
7958 struct bss_parameters *params)
7959{
7960 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307961 hdd_context_t *pHddCtx;
7962 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007963
7964 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307965
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307966 if (NULL == pAdapter)
7967 {
7968 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7969 "%s: HDD adapter is Null", __func__);
7970 return -ENODEV;
7971 }
7972 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307973 ret = wlan_hdd_validate_context(pHddCtx);
7974 if (0 != ret)
7975 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307976 return ret;
7977 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307978 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7979 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
7980 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307981 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7982 __func__, hdd_device_modetoString(pAdapter->device_mode),
7983 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007984
7985 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007986 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307987 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007988 {
7989 /* ap_isolate == -1 means that in change bss, upper layer doesn't
7990 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307991 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07007992 {
7993 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307994 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007995 }
7996
7997 EXIT();
7998 return 0;
7999}
8000
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308001static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
8002 struct net_device *dev,
8003 struct bss_parameters *params)
8004{
8005 int ret;
8006
8007 vos_ssr_protect(__func__);
8008 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
8009 vos_ssr_unprotect(__func__);
8010
8011 return ret;
8012}
Kiet Lam10841362013-11-01 11:36:50 +05308013/* FUNCTION: wlan_hdd_change_country_code_cd
8014* to wait for contry code completion
8015*/
8016void* wlan_hdd_change_country_code_cb(void *pAdapter)
8017{
8018 hdd_adapter_t *call_back_pAdapter = pAdapter;
8019 complete(&call_back_pAdapter->change_country_code);
8020 return NULL;
8021}
8022
Jeff Johnson295189b2012-06-20 16:38:30 -07008023/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308024 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07008025 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
8026 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308027int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008028 struct net_device *ndev,
8029 enum nl80211_iftype type,
8030 u32 *flags,
8031 struct vif_params *params
8032 )
8033{
8034 struct wireless_dev *wdev;
8035 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008036 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07008037 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008038 tCsrRoamProfile *pRoamProfile = NULL;
8039 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308040 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 eMib_dot11DesiredBssType connectedBssType;
8042 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308043 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008044
8045 ENTER();
8046
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308047 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008048 {
8049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8050 "%s: Adapter context is null", __func__);
8051 return VOS_STATUS_E_FAILURE;
8052 }
8053
8054 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8055 if (!pHddCtx)
8056 {
8057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8058 "%s: HDD context is null", __func__);
8059 return VOS_STATUS_E_FAILURE;
8060 }
8061
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308062 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8063 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
8064 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308065 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308066 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07008067 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308068 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008069 }
8070
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308071 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8072 __func__, hdd_device_modetoString(pAdapter->device_mode),
8073 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008074
Agarwal Ashish51325b52014-06-16 16:50:49 +05308075 if (vos_max_concurrent_connections_reached()) {
8076 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
8077 return -EINVAL;
8078 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308079 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07008080 wdev = ndev->ieee80211_ptr;
8081
8082#ifdef WLAN_BTAMP_FEATURE
8083 if((NL80211_IFTYPE_P2P_CLIENT == type)||
8084 (NL80211_IFTYPE_ADHOC == type)||
8085 (NL80211_IFTYPE_AP == type)||
8086 (NL80211_IFTYPE_P2P_GO == type))
8087 {
8088 pHddCtx->isAmpAllowed = VOS_FALSE;
8089 // stop AMP traffic
8090 status = WLANBAP_StopAmp();
8091 if(VOS_STATUS_SUCCESS != status )
8092 {
8093 pHddCtx->isAmpAllowed = VOS_TRUE;
8094 hddLog(VOS_TRACE_LEVEL_FATAL,
8095 "%s: Failed to stop AMP", __func__);
8096 return -EINVAL;
8097 }
8098 }
8099#endif //WLAN_BTAMP_FEATURE
8100 /* Reset the current device mode bit mask*/
8101 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
8102
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05308103 /* Notify Mode change in case of concurrency.
8104 * Below function invokes TDLS teardown Functionality Since TDLS is
8105 * not Supported in case of concurrency i.e Once P2P session
8106 * is detected disable offchannel and teardown TDLS links
8107 */
8108 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
8109
Jeff Johnson295189b2012-06-20 16:38:30 -07008110 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008111 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07008112 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07008113 )
8114 {
8115 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008116 if (!pWextState)
8117 {
8118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8119 "%s: pWextState is null", __func__);
8120 return VOS_STATUS_E_FAILURE;
8121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008122 pRoamProfile = &pWextState->roamProfile;
8123 LastBSSType = pRoamProfile->BSSType;
8124
8125 switch (type)
8126 {
8127 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008128 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008129 hddLog(VOS_TRACE_LEVEL_INFO,
8130 "%s: setting interface Type to INFRASTRUCTURE", __func__);
8131 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07008132#ifdef WLAN_FEATURE_11AC
8133 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
8134 {
8135 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
8136 }
8137#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308138 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07008139 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008140 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008141 //Check for sub-string p2p to confirm its a p2p interface
8142 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308143 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008144 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8145 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8146 }
8147 else
8148 {
8149 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008150 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008151 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008152 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05308153
Jeff Johnson295189b2012-06-20 16:38:30 -07008154 case NL80211_IFTYPE_ADHOC:
8155 hddLog(VOS_TRACE_LEVEL_INFO,
8156 "%s: setting interface Type to ADHOC", __func__);
8157 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
8158 pRoamProfile->phyMode =
8159 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07008160 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008161 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +05308162 hdd_set_ibss_ops( pAdapter );
8163 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +05308164
8165 status = hdd_sta_id_hash_attach(pAdapter);
8166 if (VOS_STATUS_SUCCESS != status) {
8167 hddLog(VOS_TRACE_LEVEL_ERROR,
8168 FL("Failed to initialize hash for IBSS"));
8169 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008170 break;
8171
8172 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008173 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008174 {
8175 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8176 "%s: setting interface Type to %s", __func__,
8177 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
8178
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008179 //Cancel any remain on channel for GO mode
8180 if (NL80211_IFTYPE_P2P_GO == type)
8181 {
8182 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
8183 }
Mohit Khanna0f232092012-09-11 14:46:08 -07008184 if (NL80211_IFTYPE_AP == type)
8185 {
8186 /* As Loading WLAN Driver one interface being created for p2p device
8187 * address. This will take one HW STA and the max number of clients
8188 * that can connect to softAP will be reduced by one. so while changing
8189 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
8190 * interface as it is not required in SoftAP mode.
8191 */
8192
8193 // Get P2P Adapter
8194 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
8195
8196 if (pP2pAdapter)
8197 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05308198 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +05308199 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07008200 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
8201 }
8202 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05308203 //Disable IMPS & BMPS for SAP/GO
8204 if(VOS_STATUS_E_FAILURE ==
8205 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
8206 {
8207 //Fail to Exit BMPS
8208 VOS_ASSERT(0);
8209 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05308210
8211 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
8212
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308213#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07008214
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308215 /* A Mutex Lock is introduced while changing the mode to
8216 * protect the concurrent access for the Adapters by TDLS
8217 * module.
8218 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308219 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308220#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008221 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +05308222 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008223 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07008224 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8225 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308226#ifdef FEATURE_WLAN_TDLS
8227 mutex_unlock(&pHddCtx->tdls_lock);
8228#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008229 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
8230 (pConfig->apRandomBssidEnabled))
8231 {
8232 /* To meet Android requirements create a randomized
8233 MAC address of the form 02:1A:11:Fx:xx:xx */
8234 get_random_bytes(&ndev->dev_addr[3], 3);
8235 ndev->dev_addr[0] = 0x02;
8236 ndev->dev_addr[1] = 0x1A;
8237 ndev->dev_addr[2] = 0x11;
8238 ndev->dev_addr[3] |= 0xF0;
8239 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
8240 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08008241 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
8242 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008243 }
8244
Jeff Johnson295189b2012-06-20 16:38:30 -07008245 hdd_set_ap_ops( pAdapter->dev );
8246
Kiet Lam10841362013-11-01 11:36:50 +05308247 /* This is for only SAP mode where users can
8248 * control country through ini.
8249 * P2P GO follows station country code
8250 * acquired during the STA scanning. */
8251 if((NL80211_IFTYPE_AP == type) &&
8252 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
8253 {
8254 int status = 0;
8255 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
8256 "%s: setting country code from INI ", __func__);
8257 init_completion(&pAdapter->change_country_code);
8258 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
8259 (void *)(tSmeChangeCountryCallback)
8260 wlan_hdd_change_country_code_cb,
8261 pConfig->apCntryCode, pAdapter,
8262 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05308263 eSIR_FALSE,
8264 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05308265 if (eHAL_STATUS_SUCCESS == status)
8266 {
8267 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308268 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05308269 &pAdapter->change_country_code,
8270 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308271 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05308272 {
8273 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308274 FL("SME Timed out while setting country code %ld"),
8275 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08008276
8277 if (pHddCtx->isLogpInProgress)
8278 {
8279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8280 "%s: LOGP in Progress. Ignore!!!", __func__);
8281 return -EAGAIN;
8282 }
Kiet Lam10841362013-11-01 11:36:50 +05308283 }
8284 }
8285 else
8286 {
8287 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008288 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05308289 return -EINVAL;
8290 }
8291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008292 status = hdd_init_ap_mode(pAdapter);
8293 if(status != VOS_STATUS_SUCCESS)
8294 {
8295 hddLog(VOS_TRACE_LEVEL_FATAL,
8296 "%s: Error initializing the ap mode", __func__);
8297 return -EINVAL;
8298 }
8299 hdd_set_conparam(1);
8300
Nirav Shah7e3c8132015-06-22 23:51:42 +05308301 status = hdd_sta_id_hash_attach(pAdapter);
8302 if (VOS_STATUS_SUCCESS != status)
8303 {
8304 hddLog(VOS_TRACE_LEVEL_ERROR,
8305 FL("Failed to initialize hash for AP"));
8306 return -EINVAL;
8307 }
8308
Jeff Johnson295189b2012-06-20 16:38:30 -07008309 /*interface type changed update in wiphy structure*/
8310 if(wdev)
8311 {
8312 wdev->iftype = type;
8313 pHddCtx->change_iface = type;
8314 }
8315 else
8316 {
8317 hddLog(VOS_TRACE_LEVEL_ERROR,
8318 "%s: ERROR !!!! Wireless dev is NULL", __func__);
8319 return -EINVAL;
8320 }
8321 goto done;
8322 }
8323
8324 default:
8325 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8326 __func__);
8327 return -EOPNOTSUPP;
8328 }
8329 }
8330 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008331 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07008332 )
8333 {
8334 switch(type)
8335 {
8336 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008337 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008338 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05308339
8340 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308341#ifdef FEATURE_WLAN_TDLS
8342
8343 /* A Mutex Lock is introduced while changing the mode to
8344 * protect the concurrent access for the Adapters by TDLS
8345 * module.
8346 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308347 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308348#endif
c_hpothu002231a2015-02-05 14:58:51 +05308349 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008350 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008351 //Check for sub-string p2p to confirm its a p2p interface
8352 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008353 {
8354 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8355 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8356 }
8357 else
8358 {
8359 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008360 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008361 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008362 hdd_set_conparam(0);
8363 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008364 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
8365 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308366#ifdef FEATURE_WLAN_TDLS
8367 mutex_unlock(&pHddCtx->tdls_lock);
8368#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05308369 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008370 if( VOS_STATUS_SUCCESS != status )
8371 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07008372 /* In case of JB, for P2P-GO, only change interface will be called,
8373 * This is the right place to enable back bmps_imps()
8374 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308375 if (pHddCtx->hdd_wlan_suspended)
8376 {
8377 hdd_set_pwrparams(pHddCtx);
8378 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008379 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008380 goto done;
8381 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008382 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008383 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008384 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8385 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008386 goto done;
8387 default:
8388 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8389 __func__);
8390 return -EOPNOTSUPP;
8391
8392 }
8393
8394 }
8395 else
8396 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308397 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
8398 __func__, hdd_device_modetoString(pAdapter->device_mode),
8399 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008400 return -EOPNOTSUPP;
8401 }
8402
8403
8404 if(pRoamProfile)
8405 {
8406 if ( LastBSSType != pRoamProfile->BSSType )
8407 {
8408 /*interface type changed update in wiphy structure*/
8409 wdev->iftype = type;
8410
8411 /*the BSS mode changed, We need to issue disconnect
8412 if connected or in IBSS disconnect state*/
8413 if ( hdd_connGetConnectedBssType(
8414 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
8415 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
8416 {
8417 /*need to issue a disconnect to CSR.*/
8418 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8419 if( eHAL_STATUS_SUCCESS ==
8420 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8421 pAdapter->sessionId,
8422 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
8423 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308424 ret = wait_for_completion_interruptible_timeout(
8425 &pAdapter->disconnect_comp_var,
8426 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8427 if (ret <= 0)
8428 {
8429 hddLog(VOS_TRACE_LEVEL_ERROR,
8430 FL("wait on disconnect_comp_var failed %ld"), ret);
8431 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008432 }
8433 }
8434 }
8435 }
8436
8437done:
8438 /*set bitmask based on updated value*/
8439 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07008440
8441 /* Only STA mode support TM now
8442 * all other mode, TM feature should be disabled */
8443 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
8444 (~VOS_STA & pHddCtx->concurrency_mode) )
8445 {
8446 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
8447 }
8448
Jeff Johnson295189b2012-06-20 16:38:30 -07008449#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308450 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05308451 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07008452 {
8453 //we are ok to do AMP
8454 pHddCtx->isAmpAllowed = VOS_TRUE;
8455 }
8456#endif //WLAN_BTAMP_FEATURE
8457 EXIT();
8458 return 0;
8459}
8460
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308461/*
8462 * FUNCTION: wlan_hdd_cfg80211_change_iface
8463 * wrapper function to protect the actual implementation from SSR.
8464 */
8465int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
8466 struct net_device *ndev,
8467 enum nl80211_iftype type,
8468 u32 *flags,
8469 struct vif_params *params
8470 )
8471{
8472 int ret;
8473
8474 vos_ssr_protect(__func__);
8475 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
8476 vos_ssr_unprotect(__func__);
8477
8478 return ret;
8479}
8480
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008481#ifdef FEATURE_WLAN_TDLS
8482static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
8483 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
8484{
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008485 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008486 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308487 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308488 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308489 hdd_adapter_t *pAdapter;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008490
8491 ENTER();
8492
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308493 if (!dev) {
8494 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
8495 return -EINVAL;
8496 }
8497
8498 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8499 if (!pAdapter) {
8500 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
8501 return -EINVAL;
8502 }
8503
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308504 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008505 {
8506 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8507 "Invalid arguments");
8508 return -EINVAL;
8509 }
Hoonki Lee27511902013-03-14 18:19:06 -07008510
8511 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
8512 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
8513 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308514 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -07008515 "%s: TDLS mode is disabled OR not enabled in FW."
8516 MAC_ADDRESS_STR " Request declined.",
8517 __func__, MAC_ADDR_ARRAY(mac));
8518 return -ENOTSUPP;
8519 }
8520
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008521 if (pHddCtx->isLogpInProgress)
8522 {
8523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8524 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05308525 wlan_hdd_tdls_set_link_status(pAdapter,
8526 mac,
8527 eTDLS_LINK_IDLE,
8528 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008529 return -EBUSY;
8530 }
8531
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308532 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05308533 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008534
8535 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308536 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008537 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
8538 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308539 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008540 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008541 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308542 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008543
8544 /* in add station, we accept existing valid staId if there is */
8545 if ((0 == update) &&
8546 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
8547 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008548 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308549 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008550 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008551 " link_status %d. staId %d. add station ignored.",
8552 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
8553 return 0;
8554 }
8555 /* in change station, we accept only when staId is valid */
8556 if ((1 == update) &&
8557 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
8558 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
8559 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308560 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008561 "%s: " MAC_ADDRESS_STR
8562 " link status %d. staId %d. change station %s.",
8563 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
8564 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
8565 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008566 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008567
8568 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05308569 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008570 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008571 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8572 "%s: " MAC_ADDRESS_STR
8573 " TDLS setup is ongoing. Request declined.",
8574 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07008575 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008576 }
8577
8578 /* first to check if we reached to maximum supported TDLS peer.
8579 TODO: for now, return -EPERM looks working fine,
8580 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308581 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
8582 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008583 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008584 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8585 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308586 " TDLS Max peer already connected. Request declined."
8587 " Num of peers (%d), Max allowed (%d).",
8588 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
8589 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008590 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008591 }
8592 else
8593 {
8594 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308595 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008596 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008597 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008598 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8599 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
8600 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008601 return -EPERM;
8602 }
8603 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008604 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05308605 wlan_hdd_tdls_set_link_status(pAdapter,
8606 mac,
8607 eTDLS_LINK_CONNECTING,
8608 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008609
Jeff Johnsond75fe012013-04-06 10:53:06 -07008610 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308611 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008612 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008614 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008615 if(StaParams->htcap_present)
8616 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008618 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008620 "ht_capa->extended_capabilities: %0x",
8621 StaParams->HTCap.extendedHtCapInfo);
8622 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008624 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008626 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008627 if(StaParams->vhtcap_present)
8628 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008630 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
8631 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
8632 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
8633 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008634 {
8635 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008636 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008637 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008639 "[%d]: %x ", i, StaParams->supported_rates[i]);
8640 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07008641 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308642 else if ((1 == update) && (NULL == StaParams))
8643 {
8644 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8645 "%s : update is true, but staParams is NULL. Error!", __func__);
8646 return -EPERM;
8647 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008648
8649 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
8650
8651 if (!update)
8652 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308653 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008654 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308655 if (ret != eHAL_STATUS_SUCCESS) {
8656 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to add TDLS peer STA"));
8657 return -EPERM;
8658 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008659 }
8660 else
8661 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308662 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008663 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308664 if (ret != eHAL_STATUS_SUCCESS) {
8665 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
8666 return -EPERM;
8667 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008668 }
8669
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308670 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008671 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
8672
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308673 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008674 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308676 "%s: timeout waiting for tdls add station indication %ld",
8677 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008678 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008679 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308680
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008681 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
8682 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008684 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008685 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008686 }
8687
8688 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008689
8690error:
Atul Mittal115287b2014-07-08 13:26:33 +05308691 wlan_hdd_tdls_set_link_status(pAdapter,
8692 mac,
8693 eTDLS_LINK_IDLE,
8694 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008695 return -EPERM;
8696
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008697}
8698#endif
8699
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308700static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008701 struct net_device *dev,
8702 u8 *mac,
8703 struct station_parameters *params)
8704{
8705 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308706 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308707 hdd_context_t *pHddCtx;
8708 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008709 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308710 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008711#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008712 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008713 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308714 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008715#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008716
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308717 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308718
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308719 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308720 if ((NULL == pAdapter))
8721 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308723 "invalid adapter ");
8724 return -EINVAL;
8725 }
8726
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308727 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8728 TRACE_CODE_HDD_CHANGE_STATION,
8729 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05308730 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308731
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308732 ret = wlan_hdd_validate_context(pHddCtx);
8733 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +05308734 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308735 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308736 }
8737
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308738 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8739
8740 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008741 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8743 "invalid HDD station context");
8744 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008745 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008746 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
8747
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008748 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
8749 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07008750 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008751 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07008752 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308753 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008754 WLANTL_STA_AUTHENTICATED);
8755
Gopichand Nakkala29149562013-05-10 21:43:41 +05308756 if (status != VOS_STATUS_SUCCESS)
8757 {
8758 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8759 "%s: Not able to change TL state to AUTHENTICATED", __func__);
8760 return -EINVAL;
8761 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008762 }
8763 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07008764 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
8765 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308766#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008767 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
8768 StaParams.capability = params->capability;
8769 StaParams.uapsd_queues = params->uapsd_queues;
8770 StaParams.max_sp = params->max_sp;
8771
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308772 /* Convert (first channel , number of channels) tuple to
8773 * the total list of channels. This goes with the assumption
8774 * that if the first channel is < 14, then the next channels
8775 * are an incremental of 1 else an incremental of 4 till the number
8776 * of channels.
8777 */
8778 if (0 != params->supported_channels_len) {
8779 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
8780 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
8781 {
8782 int wifi_chan_index;
8783 StaParams.supported_channels[j] = params->supported_channels[i];
8784 wifi_chan_index =
8785 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
8786 no_of_channels = params->supported_channels[i+1];
8787 for(k=1; k <= no_of_channels; k++)
8788 {
8789 StaParams.supported_channels[j+1] =
8790 StaParams.supported_channels[j] + wifi_chan_index;
8791 j+=1;
8792 }
8793 }
8794 StaParams.supported_channels_len = j;
8795 }
8796 vos_mem_copy(StaParams.supported_oper_classes,
8797 params->supported_oper_classes,
8798 params->supported_oper_classes_len);
8799 StaParams.supported_oper_classes_len =
8800 params->supported_oper_classes_len;
8801
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008802 if (0 != params->ext_capab_len)
8803 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
8804 sizeof(StaParams.extn_capability));
8805
8806 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008807 {
8808 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008809 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008810 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008811
8812 StaParams.supported_rates_len = params->supported_rates_len;
8813
8814 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
8815 * The supported_rates array , for all the structures propogating till Add Sta
8816 * to the firmware has to be modified , if the supplicant (ieee80211) is
8817 * modified to send more rates.
8818 */
8819
8820 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
8821 */
8822 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
8823 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
8824
8825 if (0 != StaParams.supported_rates_len) {
8826 int i = 0;
8827 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
8828 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008829 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008830 "Supported Rates with Length %d", StaParams.supported_rates_len);
8831 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008832 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008833 "[%d]: %0x", i, StaParams.supported_rates[i]);
8834 }
8835
8836 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008837 {
8838 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008839 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008840 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008841
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008842 if (0 != params->ext_capab_len ) {
8843 /*Define A Macro : TODO Sunil*/
8844 if ((1<<4) & StaParams.extn_capability[3]) {
8845 isBufSta = 1;
8846 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308847 /* TDLS Channel Switching Support */
8848 if ((1<<6) & StaParams.extn_capability[3]) {
8849 isOffChannelSupported = 1;
8850 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008851 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308852 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
8853 &StaParams, isBufSta,
8854 isOffChannelSupported);
8855
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308856 if (VOS_STATUS_SUCCESS != status) {
8857 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8858 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
8859 return -EINVAL;
8860 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008861 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
8862
8863 if (VOS_STATUS_SUCCESS != status) {
8864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8865 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
8866 return -EINVAL;
8867 }
8868 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008869#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05308870 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008871 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008872 return status;
8873}
8874
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308875static int wlan_hdd_change_station(struct wiphy *wiphy,
8876 struct net_device *dev,
8877 u8 *mac,
8878 struct station_parameters *params)
8879{
8880 int ret;
8881
8882 vos_ssr_protect(__func__);
8883 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
8884 vos_ssr_unprotect(__func__);
8885
8886 return ret;
8887}
8888
Jeff Johnson295189b2012-06-20 16:38:30 -07008889/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308890 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008891 * This function is used to initialize the key information
8892 */
8893#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308894static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008895 struct net_device *ndev,
8896 u8 key_index, bool pairwise,
8897 const u8 *mac_addr,
8898 struct key_params *params
8899 )
8900#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308901static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008902 struct net_device *ndev,
8903 u8 key_index, const u8 *mac_addr,
8904 struct key_params *params
8905 )
8906#endif
8907{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008908 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07008909 tCsrRoamSetKey setKey;
8910 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308911 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008912 v_U32_t roamId= 0xFF;
8913 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008914 hdd_hostapd_state_t *pHostapdState;
8915 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008916 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308917 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008918
8919 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308920
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308921 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8922 TRACE_CODE_HDD_CFG80211_ADD_KEY,
8923 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308924 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8925 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308926 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008927 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308928 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008929 }
8930
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308931 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8932 __func__, hdd_device_modetoString(pAdapter->device_mode),
8933 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008934
8935 if (CSR_MAX_NUM_KEY <= key_index)
8936 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008937 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008938 key_index);
8939
8940 return -EINVAL;
8941 }
8942
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008943 if (CSR_MAX_KEY_LEN < params->key_len)
8944 {
8945 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
8946 params->key_len);
8947
8948 return -EINVAL;
8949 }
8950
8951 hddLog(VOS_TRACE_LEVEL_INFO,
8952 "%s: called with key index = %d & key length %d",
8953 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07008954
8955 /*extract key idx, key len and key*/
8956 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8957 setKey.keyId = key_index;
8958 setKey.keyLength = params->key_len;
8959 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
8960
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008961 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07008962 {
8963 case WLAN_CIPHER_SUITE_WEP40:
8964 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
8965 break;
8966
8967 case WLAN_CIPHER_SUITE_WEP104:
8968 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
8969 break;
8970
8971 case WLAN_CIPHER_SUITE_TKIP:
8972 {
8973 u8 *pKey = &setKey.Key[0];
8974 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
8975
8976 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
8977
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008978 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07008979
8980 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008981 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008982 |--------------|----------|----------|
8983 <---16bytes---><--8bytes--><--8bytes-->
8984
8985 */
8986 /*Sme expects the 32 bytes key to be in the below order
8987
8988 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008989 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008990 |--------------|----------|----------|
8991 <---16bytes---><--8bytes--><--8bytes-->
8992 */
8993 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008994 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07008995
8996 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008997 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07008998
8999 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009000 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009001
9002
9003 break;
9004 }
9005
9006 case WLAN_CIPHER_SUITE_CCMP:
9007 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
9008 break;
9009
9010#ifdef FEATURE_WLAN_WAPI
9011 case WLAN_CIPHER_SUITE_SMS4:
9012 {
9013 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9014 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
9015 params->key, params->key_len);
9016 return 0;
9017 }
9018#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009019
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009020#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009021 case WLAN_CIPHER_SUITE_KRK:
9022 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
9023 break;
9024#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009025
9026#ifdef WLAN_FEATURE_11W
9027 case WLAN_CIPHER_SUITE_AES_CMAC:
9028 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07009029 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07009030#endif
9031
Jeff Johnson295189b2012-06-20 16:38:30 -07009032 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009033 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07009034 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309035 status = -EOPNOTSUPP;
9036 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009037 }
9038
9039 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
9040 __func__, setKey.encType);
9041
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009042 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07009043#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9044 (!pairwise)
9045#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009046 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07009047#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009048 )
9049 {
9050 /* set group key*/
9051 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9052 "%s- %d: setting Broadcast key",
9053 __func__, __LINE__);
9054 setKey.keyDirection = eSIR_RX_ONLY;
9055 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9056 }
9057 else
9058 {
9059 /* set pairwise key*/
9060 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9061 "%s- %d: setting pairwise key",
9062 __func__, __LINE__);
9063 setKey.keyDirection = eSIR_TX_RX;
9064 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9065 }
9066 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
9067 {
9068 setKey.keyDirection = eSIR_TX_RX;
9069 /*Set the group key*/
9070 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9071 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009072
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009073 if ( 0 != status )
9074 {
9075 hddLog(VOS_TRACE_LEVEL_ERROR,
9076 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309077 status = -EINVAL;
9078 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009079 }
9080 /*Save the keys here and call sme_RoamSetKey for setting
9081 the PTK after peer joins the IBSS network*/
9082 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
9083 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309084 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009085 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05309086 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
9087 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
9088 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009089 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009090 if( pHostapdState->bssState == BSS_START )
9091 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009092 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9093 vos_status = wlan_hdd_check_ula_done(pAdapter);
9094
9095 if ( vos_status != VOS_STATUS_SUCCESS )
9096 {
9097 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9098 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9099 __LINE__, vos_status );
9100
9101 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9102
9103 status = -EINVAL;
9104 goto end;
9105 }
9106
Jeff Johnson295189b2012-06-20 16:38:30 -07009107 status = WLANSAP_SetKeySta( pVosContext, &setKey);
9108
9109 if ( status != eHAL_STATUS_SUCCESS )
9110 {
9111 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9112 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9113 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309114 status = -EINVAL;
9115 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009116 }
9117 }
9118
9119 /* Saving WEP keys */
9120 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
9121 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
9122 {
9123 //Save the wep key in ap context. Issue setkey after the BSS is started.
9124 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9125 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
9126 }
9127 else
9128 {
9129 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009130 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009131 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
9132 }
9133 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009134 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9135 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009136 {
9137 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9138 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9139
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309140#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9141 if (!pairwise)
9142#else
9143 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9144#endif
9145 {
9146 /* set group key*/
9147 if (pHddStaCtx->roam_info.deferKeyComplete)
9148 {
9149 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9150 "%s- %d: Perform Set key Complete",
9151 __func__, __LINE__);
9152 hdd_PerformRoamSetKeyComplete(pAdapter);
9153 }
9154 }
9155
Jeff Johnson295189b2012-06-20 16:38:30 -07009156 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
9157
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08009158 pWextState->roamProfile.Keys.defaultIndex = key_index;
9159
9160
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009161 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009162 params->key, params->key_len);
9163
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309164
Jeff Johnson295189b2012-06-20 16:38:30 -07009165 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9166
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309167 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009168 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309169 __func__, setKey.peerMac[0], setKey.peerMac[1],
9170 setKey.peerMac[2], setKey.peerMac[3],
9171 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009172 setKey.keyDirection);
9173
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009174 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +05309175
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009176 if ( vos_status != VOS_STATUS_SUCCESS )
9177 {
9178 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009179 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9180 __LINE__, vos_status );
9181
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009182 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009183
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009184 status = -EINVAL;
9185 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009186
9187 }
9188
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009189#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309190 /* The supplicant may attempt to set the PTK once pre-authentication
9191 is done. Save the key in the UMAC and include it in the ADD BSS
9192 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009193 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309194 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009195 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309196 hddLog(VOS_TRACE_LEVEL_INFO_MED,
9197 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309198 status = 0;
9199 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309200 }
9201 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
9202 {
9203 hddLog(VOS_TRACE_LEVEL_ERROR,
9204 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309205 status = -EINVAL;
9206 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009207 }
9208#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07009209
9210 /* issue set key request to SME*/
9211 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9212 pAdapter->sessionId, &setKey, &roamId );
9213
9214 if ( 0 != status )
9215 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309216 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009217 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
9218 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309219 status = -EINVAL;
9220 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009221 }
9222
9223
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309224 /* in case of IBSS as there was no information available about WEP keys during
9225 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07009226 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309227 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
9228 !( ( IW_AUTH_KEY_MGMT_802_1X
9229 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07009230 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
9231 )
9232 &&
9233 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
9234 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
9235 )
9236 )
9237 {
9238 setKey.keyDirection = eSIR_RX_ONLY;
9239 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9240
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309241 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009242 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309243 __func__, setKey.peerMac[0], setKey.peerMac[1],
9244 setKey.peerMac[2], setKey.peerMac[3],
9245 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009246 setKey.keyDirection);
9247
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309248 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009249 pAdapter->sessionId, &setKey, &roamId );
9250
9251 if ( 0 != status )
9252 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309253 hddLog(VOS_TRACE_LEVEL_ERROR,
9254 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009255 __func__, status);
9256 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309257 status = -EINVAL;
9258 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009259 }
9260 }
9261 }
9262
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309263end:
9264 /* Need to clear any trace of key value in the memory.
9265 * Thus zero out the memory even though it is local
9266 * variable.
9267 */
9268 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309269 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309270 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009271}
9272
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309273#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9274static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9275 struct net_device *ndev,
9276 u8 key_index, bool pairwise,
9277 const u8 *mac_addr,
9278 struct key_params *params
9279 )
9280#else
9281static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9282 struct net_device *ndev,
9283 u8 key_index, const u8 *mac_addr,
9284 struct key_params *params
9285 )
9286#endif
9287{
9288 int ret;
9289 vos_ssr_protect(__func__);
9290#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9291 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
9292 mac_addr, params);
9293#else
9294 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
9295 params);
9296#endif
9297 vos_ssr_unprotect(__func__);
9298
9299 return ret;
9300}
9301
Jeff Johnson295189b2012-06-20 16:38:30 -07009302/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309303 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009304 * This function is used to get the key information
9305 */
9306#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309307static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309308 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009309 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309310 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009311 const u8 *mac_addr, void *cookie,
9312 void (*callback)(void *cookie, struct key_params*)
9313 )
9314#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309315static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309316 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009317 struct net_device *ndev,
9318 u8 key_index, const u8 *mac_addr, void *cookie,
9319 void (*callback)(void *cookie, struct key_params*)
9320 )
9321#endif
9322{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309323 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309324 hdd_wext_state_t *pWextState = NULL;
9325 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009326 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309327 hdd_context_t *pHddCtx;
9328 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009329
9330 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309331
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309332 if (NULL == pAdapter)
9333 {
9334 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9335 "%s: HDD adapter is Null", __func__);
9336 return -ENODEV;
9337 }
9338
9339 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9340 ret = wlan_hdd_validate_context(pHddCtx);
9341 if (0 != ret)
9342 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309343 return ret;
9344 }
9345
9346 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9347 pRoamProfile = &(pWextState->roamProfile);
9348
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309349 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9350 __func__, hdd_device_modetoString(pAdapter->device_mode),
9351 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309352
Jeff Johnson295189b2012-06-20 16:38:30 -07009353 memset(&params, 0, sizeof(params));
9354
9355 if (CSR_MAX_NUM_KEY <= key_index)
9356 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309357 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07009358 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009360
9361 switch(pRoamProfile->EncryptionType.encryptionType[0])
9362 {
9363 case eCSR_ENCRYPT_TYPE_NONE:
9364 params.cipher = IW_AUTH_CIPHER_NONE;
9365 break;
9366
9367 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
9368 case eCSR_ENCRYPT_TYPE_WEP40:
9369 params.cipher = WLAN_CIPHER_SUITE_WEP40;
9370 break;
9371
9372 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
9373 case eCSR_ENCRYPT_TYPE_WEP104:
9374 params.cipher = WLAN_CIPHER_SUITE_WEP104;
9375 break;
9376
9377 case eCSR_ENCRYPT_TYPE_TKIP:
9378 params.cipher = WLAN_CIPHER_SUITE_TKIP;
9379 break;
9380
9381 case eCSR_ENCRYPT_TYPE_AES:
9382 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
9383 break;
9384
9385 default:
9386 params.cipher = IW_AUTH_CIPHER_NONE;
9387 break;
9388 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309389
c_hpothuaaf19692014-05-17 17:01:48 +05309390 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9391 TRACE_CODE_HDD_CFG80211_GET_KEY,
9392 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309393
Jeff Johnson295189b2012-06-20 16:38:30 -07009394 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
9395 params.seq_len = 0;
9396 params.seq = NULL;
9397 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
9398 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309399 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009400 return 0;
9401}
9402
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309403#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9404static int wlan_hdd_cfg80211_get_key(
9405 struct wiphy *wiphy,
9406 struct net_device *ndev,
9407 u8 key_index, bool pairwise,
9408 const u8 *mac_addr, void *cookie,
9409 void (*callback)(void *cookie, struct key_params*)
9410 )
9411#else
9412static int wlan_hdd_cfg80211_get_key(
9413 struct wiphy *wiphy,
9414 struct net_device *ndev,
9415 u8 key_index, const u8 *mac_addr, void *cookie,
9416 void (*callback)(void *cookie, struct key_params*)
9417 )
9418#endif
9419{
9420 int ret;
9421
9422 vos_ssr_protect(__func__);
9423#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9424 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
9425 mac_addr, cookie, callback);
9426#else
9427 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
9428 callback);
9429#endif
9430 vos_ssr_unprotect(__func__);
9431
9432 return ret;
9433}
9434
Jeff Johnson295189b2012-06-20 16:38:30 -07009435/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309436 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009437 * This function is used to delete the key information
9438 */
9439#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309440static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009441 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309442 u8 key_index,
9443 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009444 const u8 *mac_addr
9445 )
9446#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309447static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009448 struct net_device *ndev,
9449 u8 key_index,
9450 const u8 *mac_addr
9451 )
9452#endif
9453{
9454 int status = 0;
9455
9456 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309457 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009458 //it is observed that this is invalidating peer
9459 //key index whenever re-key is done. This is affecting data link.
9460 //It should be ok to ignore del_key.
9461#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309462 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
9463 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009464 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
9465 tCsrRoamSetKey setKey;
9466 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309467
Jeff Johnson295189b2012-06-20 16:38:30 -07009468 ENTER();
9469
9470 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
9471 __func__,pAdapter->device_mode);
9472
9473 if (CSR_MAX_NUM_KEY <= key_index)
9474 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309475 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009476 key_index);
9477
9478 return -EINVAL;
9479 }
9480
9481 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9482 setKey.keyId = key_index;
9483
9484 if (mac_addr)
9485 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9486 else
9487 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
9488
9489 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
9490
9491 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009492 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309493 )
9494 {
9495
9496 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07009497 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9498 if( pHostapdState->bssState == BSS_START)
9499 {
9500 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309501
Jeff Johnson295189b2012-06-20 16:38:30 -07009502 if ( status != eHAL_STATUS_SUCCESS )
9503 {
9504 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9505 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9506 __LINE__, status );
9507 }
9508 }
9509 }
9510 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309511 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07009512 )
9513 {
9514 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9515
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309516 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9517
9518 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009519 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309520 __func__, setKey.peerMac[0], setKey.peerMac[1],
9521 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07009522 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309523 if(pAdapter->sessionCtx.station.conn_info.connState ==
9524 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07009525 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309526 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009527 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309528
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 if ( 0 != status )
9530 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309531 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009532 "%s: sme_RoamSetKey failure, returned %d",
9533 __func__, status);
9534 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9535 return -EINVAL;
9536 }
9537 }
9538 }
9539#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07009540 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 return status;
9542}
9543
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309544#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9545static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9546 struct net_device *ndev,
9547 u8 key_index,
9548 bool pairwise,
9549 const u8 *mac_addr
9550 )
9551#else
9552static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9553 struct net_device *ndev,
9554 u8 key_index,
9555 const u8 *mac_addr
9556 )
9557#endif
9558{
9559 int ret;
9560
9561 vos_ssr_protect(__func__);
9562#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9563 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
9564 mac_addr);
9565#else
9566 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
9567#endif
9568 vos_ssr_unprotect(__func__);
9569
9570 return ret;
9571}
9572
Jeff Johnson295189b2012-06-20 16:38:30 -07009573/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309574 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009575 * This function is used to set the default tx key index
9576 */
9577#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309578static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009579 struct net_device *ndev,
9580 u8 key_index,
9581 bool unicast, bool multicast)
9582#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309583static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009584 struct net_device *ndev,
9585 u8 key_index)
9586#endif
9587{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309588 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309589 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05309590 hdd_wext_state_t *pWextState;
9591 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309592 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009593
9594 ENTER();
9595
Gopichand Nakkala29149562013-05-10 21:43:41 +05309596 if ((NULL == pAdapter))
9597 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05309599 "invalid adapter");
9600 return -EINVAL;
9601 }
9602
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309603 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9604 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
9605 pAdapter->sessionId, key_index));
9606
Gopichand Nakkala29149562013-05-10 21:43:41 +05309607 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9608 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9609
9610 if ((NULL == pWextState) || (NULL == pHddStaCtx))
9611 {
9612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9613 "invalid Wext state or HDD context");
9614 return -EINVAL;
9615 }
9616
Arif Hussain6d2a3322013-11-17 19:50:10 -08009617 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009618 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309619
Jeff Johnson295189b2012-06-20 16:38:30 -07009620 if (CSR_MAX_NUM_KEY <= key_index)
9621 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309622 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009623 key_index);
9624
9625 return -EINVAL;
9626 }
9627
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309628 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9629 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309630 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009631 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309632 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009633 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309634
Jeff Johnson295189b2012-06-20 16:38:30 -07009635 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07009636 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309637 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009638 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05309639 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08009640 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309641 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08009642 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009643 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309644 {
9645 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07009646 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309647
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 tCsrRoamSetKey setKey;
9649 v_U32_t roamId= 0xFF;
9650 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309651
9652 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009653 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309654
Jeff Johnson295189b2012-06-20 16:38:30 -07009655 Keys->defaultIndex = (u8)key_index;
9656 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9657 setKey.keyId = key_index;
9658 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309659
9660 vos_mem_copy(&setKey.Key[0],
9661 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009662 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309663
Gopichand Nakkala29149562013-05-10 21:43:41 +05309664 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309665
9666 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07009667 &pHddStaCtx->conn_info.bssId[0],
9668 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309669
Gopichand Nakkala29149562013-05-10 21:43:41 +05309670 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
9671 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
9672 eCSR_ENCRYPT_TYPE_WEP104)
9673 {
9674 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
9675 even though ap is configured for WEP-40 encryption. In this canse the key length
9676 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
9677 type(104) and switching encryption type to 40*/
9678 pWextState->roamProfile.EncryptionType.encryptionType[0] =
9679 eCSR_ENCRYPT_TYPE_WEP40;
9680 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
9681 eCSR_ENCRYPT_TYPE_WEP40;
9682 }
9683
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309684 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07009685 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309686
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309688 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009689 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309690
Jeff Johnson295189b2012-06-20 16:38:30 -07009691 if ( 0 != status )
9692 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309693 hddLog(VOS_TRACE_LEVEL_ERROR,
9694 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009695 status);
9696 return -EINVAL;
9697 }
9698 }
9699 }
9700
9701 /* In SoftAp mode setting key direction for default mode */
9702 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
9703 {
9704 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
9705 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
9706 (eCSR_ENCRYPT_TYPE_AES !=
9707 pWextState->roamProfile.EncryptionType.encryptionType[0])
9708 )
9709 {
9710 /* Saving key direction for default key index to TX default */
9711 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9712 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
9713 }
9714 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309715 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009716 return status;
9717}
9718
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309719#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9720static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9721 struct net_device *ndev,
9722 u8 key_index,
9723 bool unicast, bool multicast)
9724#else
9725static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9726 struct net_device *ndev,
9727 u8 key_index)
9728#endif
9729{
9730 int ret;
9731 vos_ssr_protect(__func__);
9732#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9733 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
9734 multicast);
9735#else
9736 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
9737#endif
9738 vos_ssr_unprotect(__func__);
9739
9740 return ret;
9741}
9742
Jeff Johnson295189b2012-06-20 16:38:30 -07009743/*
9744 * FUNCTION: wlan_hdd_cfg80211_inform_bss
9745 * This function is used to inform the BSS details to nl80211 interface.
9746 */
9747static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
9748 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
9749{
9750 struct net_device *dev = pAdapter->dev;
9751 struct wireless_dev *wdev = dev->ieee80211_ptr;
9752 struct wiphy *wiphy = wdev->wiphy;
9753 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
9754 int chan_no;
9755 int ie_length;
9756 const char *ie;
9757 unsigned int freq;
9758 struct ieee80211_channel *chan;
9759 int rssi = 0;
9760 struct cfg80211_bss *bss = NULL;
9761
Jeff Johnson295189b2012-06-20 16:38:30 -07009762 if( NULL == pBssDesc )
9763 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009764 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009765 return bss;
9766 }
9767
9768 chan_no = pBssDesc->channelId;
9769 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
9770 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
9771
9772 if( NULL == ie )
9773 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009774 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009775 return bss;
9776 }
9777
9778#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
9779 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
9780 {
9781 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9782 }
9783 else
9784 {
9785 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9786 }
9787#else
9788 freq = ieee80211_channel_to_frequency(chan_no);
9789#endif
9790
9791 chan = __ieee80211_get_channel(wiphy, freq);
9792
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05309793 if (!chan) {
9794 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
9795 return NULL;
9796 }
9797
Abhishek Singhaee43942014-06-16 18:55:47 +05309798 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07009799
Abhishek Singhaee43942014-06-16 18:55:47 +05309800 return cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309801 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07009802 pBssDesc->capabilityInfo,
9803 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05309804 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07009805}
9806
9807
9808
9809/*
9810 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
9811 * This function is used to inform the BSS details to nl80211 interface.
9812 */
9813struct cfg80211_bss*
9814wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
9815 tSirBssDescription *bss_desc
9816 )
9817{
9818 /*
9819 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
9820 already exists in bss data base of cfg80211 for that particular BSS ID.
9821 Using cfg80211_inform_bss_frame to update the bss entry instead of
9822 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
9823 now there is no possibility to get the mgmt(probe response) frame from PE,
9824 converting bss_desc to ieee80211_mgmt(probe response) and passing to
9825 cfg80211_inform_bss_frame.
9826 */
9827 struct net_device *dev = pAdapter->dev;
9828 struct wireless_dev *wdev = dev->ieee80211_ptr;
9829 struct wiphy *wiphy = wdev->wiphy;
9830 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009831#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9832 qcom_ie_age *qie_age = NULL;
9833 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
9834#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009835 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009836#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009837 const char *ie =
9838 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
9839 unsigned int freq;
9840 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309841 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009842 struct cfg80211_bss *bss_status = NULL;
9843 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
9844 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07009845 hdd_context_t *pHddCtx;
9846 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07009847#ifdef WLAN_OPEN_SOURCE
9848 struct timespec ts;
9849#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009850
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309851
Wilson Yangf80a0542013-10-07 13:02:37 -07009852 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9853 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -07009854 if (0 != status)
9855 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009856 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009857 }
9858
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309859 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07009860 if (!mgmt)
9861 {
9862 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9863 "%s: memory allocation failed ", __func__);
9864 return NULL;
9865 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009866
Jeff Johnson295189b2012-06-20 16:38:30 -07009867 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07009868
9869#ifdef WLAN_OPEN_SOURCE
9870 /* Android does not want the timestamp from the frame.
9871 Instead it wants a monotonic increasing value */
9872 get_monotonic_boottime(&ts);
9873 mgmt->u.probe_resp.timestamp =
9874 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
9875#else
9876 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07009877 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
9878 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07009879
9880#endif
9881
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
9883 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009884
9885#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9886 /* GPS Requirement: need age ie per entry. Using vendor specific. */
9887 /* Assuming this is the last IE, copy at the end */
9888 ie_length -=sizeof(qcom_ie_age);
9889 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
9890 qie_age->element_id = QCOM_VENDOR_IE_ID;
9891 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
9892 qie_age->oui_1 = QCOM_OUI1;
9893 qie_age->oui_2 = QCOM_OUI2;
9894 qie_age->oui_3 = QCOM_OUI3;
9895 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
9896 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
9897#endif
9898
Jeff Johnson295189b2012-06-20 16:38:30 -07009899 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05309900 if (bss_desc->fProbeRsp)
9901 {
9902 mgmt->frame_control |=
9903 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
9904 }
9905 else
9906 {
9907 mgmt->frame_control |=
9908 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
9909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009910
9911#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309912 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009913 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
9914 {
9915 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9916 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309917 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
9919
9920 {
9921 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9922 }
9923 else
9924 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309925 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
9926 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07009927 kfree(mgmt);
9928 return NULL;
9929 }
9930#else
9931 freq = ieee80211_channel_to_frequency(chan_no);
9932#endif
9933 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009934 /*when the band is changed on the fly using the GUI, three things are done
9935 * 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)
9936 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
9937 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
9938 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
9939 * and discards the channels correponding to previous band and calls back with zero bss results.
9940 * 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
9941 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
9942 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
9943 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
9944 * So drop the bss and continue to next bss.
9945 */
9946 if(chan == NULL)
9947 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309948 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07009949 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009950 return NULL;
9951 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +05309952 /*To keep the rssi icon of the connected AP in the scan window
9953 *and the rssi icon of the wireless networks in sync
9954 * */
9955 if (( eConnectionState_Associated ==
9956 pAdapter->sessionCtx.station.conn_info.connState ) &&
9957 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
9958 pAdapter->sessionCtx.station.conn_info.bssId,
9959 WNI_CFG_BSSID_LEN)) &&
9960 (pHddCtx->hdd_wlan_suspended == FALSE))
9961 {
9962 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
9963 rssi = (pAdapter->rssi * 100);
9964 }
9965 else
9966 {
9967 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
9968 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009969
Nirav Shah20ac06f2013-12-12 18:14:06 +05309970 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +05309971 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
9972 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +05309973
Jeff Johnson295189b2012-06-20 16:38:30 -07009974 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
9975 frame_len, rssi, GFP_KERNEL);
9976 kfree(mgmt);
9977 return bss_status;
9978}
9979
9980/*
9981 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
9982 * This function is used to update the BSS data base of CFG8011
9983 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309984struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07009985 tCsrRoamInfo *pRoamInfo
9986 )
9987{
9988 tCsrRoamConnectedProfile roamProfile;
9989 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9990 struct cfg80211_bss *bss = NULL;
9991
9992 ENTER();
9993
9994 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
9995 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
9996
9997 if (NULL != roamProfile.pBssDesc)
9998 {
Girish Gowlif4b68022014-08-28 23:18:57 +05309999 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10000 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010001
10002 if (NULL == bss)
10003 {
10004 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
10005 __func__);
10006 }
10007
10008 sme_RoamFreeConnectProfile(hHal, &roamProfile);
10009 }
10010 else
10011 {
10012 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
10013 __func__);
10014 }
10015 return bss;
10016}
10017
10018/*
10019 * FUNCTION: wlan_hdd_cfg80211_update_bss
10020 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010021static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
10022 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070010023 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010024{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010025 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010026 tCsrScanResultInfo *pScanResult;
10027 eHalStatus status = 0;
10028 tScanResultHandle pResult;
10029 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070010030 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010031 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070010032 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010033
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010034 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10035 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
10036 NO_SESSION, pAdapter->sessionId));
10037
Wilson Yangf80a0542013-10-07 13:02:37 -070010038 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10039
10040 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -070010041 {
Wilson Yangf80a0542013-10-07 13:02:37 -070010042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10043 "%s:LOGP in Progress. Ignore!!!",__func__);
10044 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010045 }
10046
Wilson Yangf80a0542013-10-07 13:02:37 -070010047
10048 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +053010049 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -070010050 {
10051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10052 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
10053 return VOS_STATUS_E_PERM;
10054 }
10055
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010056 if (pAdapter->request != NULL)
10057 {
10058 if ((pAdapter->request->n_ssids == 1)
10059 && (pAdapter->request->ssids != NULL)
10060 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
10061 is_p2p_scan = true;
10062 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010063 /*
10064 * start getting scan results and populate cgf80211 BSS database
10065 */
10066 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
10067
10068 /* no scan results */
10069 if (NULL == pResult)
10070 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010071 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
10072 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053010073 wlan_hdd_get_frame_logs(pAdapter,
10074 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070010075 return status;
10076 }
10077
10078 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
10079
10080 while (pScanResult)
10081 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010082 /*
10083 * cfg80211_inform_bss() is not updating ie field of bss entry, if
10084 * entry already exists in bss data base of cfg80211 for that
10085 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
10086 * bss entry instead of cfg80211_inform_bss, But this call expects
10087 * mgmt packet as input. As of now there is no possibility to get
10088 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070010089 * ieee80211_mgmt(probe response) and passing to c
10090 * fg80211_inform_bss_frame.
10091 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010092 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
10093 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
10094 {
10095 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Non P2P BSS skipped: =%s:"),
10096 pScanResult->ssId.ssId);
10097 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10098 continue; //Skip the non p2p bss entries
10099 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010100 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10101 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010102
Jeff Johnson295189b2012-06-20 16:38:30 -070010103
10104 if (NULL == bss_status)
10105 {
10106 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010107 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010108 }
10109 else
10110 {
Yue Maf49ba872013-08-19 12:04:25 -070010111 cfg80211_put_bss(
10112#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10113 wiphy,
10114#endif
10115 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010116 }
10117
10118 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10119 }
10120
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010121 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010122 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010123 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010124}
10125
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010126void
10127hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
10128{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010129 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080010130 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010131} /****** end hddPrintMacAddr() ******/
10132
10133void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010134hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010135{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010136 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010137 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010138 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
10139 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
10140 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010141} /****** end hddPrintPmkId() ******/
10142
10143//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
10144//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
10145
10146//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
10147//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
10148
10149#define dump_bssid(bssid) \
10150 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010151 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
10152 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010153 }
10154
10155#define dump_pmkid(pMac, pmkid) \
10156 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010157 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
10158 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010159 }
10160
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070010161#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010162/*
10163 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
10164 * This function is used to notify the supplicant of a new PMKSA candidate.
10165 */
10166int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010167 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010168 int index, bool preauth )
10169{
Jeff Johnsone7245742012-09-05 17:12:55 -070010170#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010171 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010172 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010173
10174 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070010175 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010176
10177 if( NULL == pRoamInfo )
10178 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010179 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010180 return -EINVAL;
10181 }
10182
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010183 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
10184 {
10185 dump_bssid(pRoamInfo->bssid);
10186 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010187 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010188 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010189#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010190 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010191}
10192#endif //FEATURE_WLAN_LFR
10193
Yue Maef608272013-04-08 23:09:17 -070010194#ifdef FEATURE_WLAN_LFR_METRICS
10195/*
10196 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
10197 * 802.11r/LFR metrics reporting function to report preauth initiation
10198 *
10199 */
10200#define MAX_LFR_METRICS_EVENT_LENGTH 100
10201VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
10202 tCsrRoamInfo *pRoamInfo)
10203{
10204 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10205 union iwreq_data wrqu;
10206
10207 ENTER();
10208
10209 if (NULL == pAdapter)
10210 {
10211 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10212 return VOS_STATUS_E_FAILURE;
10213 }
10214
10215 /* create the event */
10216 memset(&wrqu, 0, sizeof(wrqu));
10217 memset(metrics_notification, 0, sizeof(metrics_notification));
10218
10219 wrqu.data.pointer = metrics_notification;
10220 wrqu.data.length = scnprintf(metrics_notification,
10221 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
10222 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10223
10224 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10225
10226 EXIT();
10227
10228 return VOS_STATUS_SUCCESS;
10229}
10230
10231/*
10232 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
10233 * 802.11r/LFR metrics reporting function to report preauth completion
10234 * or failure
10235 */
10236VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
10237 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
10238{
10239 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10240 union iwreq_data wrqu;
10241
10242 ENTER();
10243
10244 if (NULL == pAdapter)
10245 {
10246 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10247 return VOS_STATUS_E_FAILURE;
10248 }
10249
10250 /* create the event */
10251 memset(&wrqu, 0, sizeof(wrqu));
10252 memset(metrics_notification, 0, sizeof(metrics_notification));
10253
10254 scnprintf(metrics_notification, sizeof(metrics_notification),
10255 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
10256 MAC_ADDR_ARRAY(pRoamInfo->bssid));
10257
10258 if (1 == preauth_status)
10259 strncat(metrics_notification, " TRUE", 5);
10260 else
10261 strncat(metrics_notification, " FALSE", 6);
10262
10263 wrqu.data.pointer = metrics_notification;
10264 wrqu.data.length = strlen(metrics_notification);
10265
10266 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10267
10268 EXIT();
10269
10270 return VOS_STATUS_SUCCESS;
10271}
10272
10273/*
10274 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
10275 * 802.11r/LFR metrics reporting function to report handover initiation
10276 *
10277 */
10278VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
10279 tCsrRoamInfo *pRoamInfo)
10280{
10281 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10282 union iwreq_data wrqu;
10283
10284 ENTER();
10285
10286 if (NULL == pAdapter)
10287 {
10288 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10289 return VOS_STATUS_E_FAILURE;
10290 }
10291
10292 /* create the event */
10293 memset(&wrqu, 0, sizeof(wrqu));
10294 memset(metrics_notification, 0, sizeof(metrics_notification));
10295
10296 wrqu.data.pointer = metrics_notification;
10297 wrqu.data.length = scnprintf(metrics_notification,
10298 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
10299 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10300
10301 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10302
10303 EXIT();
10304
10305 return VOS_STATUS_SUCCESS;
10306}
10307#endif
10308
Jeff Johnson295189b2012-06-20 16:38:30 -070010309/*
10310 * FUNCTION: hdd_cfg80211_scan_done_callback
10311 * scanning callback function, called after finishing scan
10312 *
10313 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010314static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070010315 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
10316{
10317 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010318 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070010319 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010320 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010321 struct cfg80211_scan_request *req = NULL;
10322 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010323 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010324 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010325 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010326 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010327
10328 ENTER();
10329
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010330 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053010331 if (NULL == pHddCtx) {
10332 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010333 goto allow_suspend;
10334 }
10335
10336 pScanInfo = &pHddCtx->scan_info;
10337
Jeff Johnson295189b2012-06-20 16:38:30 -070010338 hddLog(VOS_TRACE_LEVEL_INFO,
10339 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080010340 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010341 __func__, halHandle, pContext, (int) scanId, (int) status);
10342
Kiet Lamac06e2c2013-10-23 16:25:07 +053010343 pScanInfo->mScanPendingCounter = 0;
10344
Jeff Johnson295189b2012-06-20 16:38:30 -070010345 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010346 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070010347 &pScanInfo->scan_req_completion_event,
10348 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010349 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070010350 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010351 hddLog(VOS_TRACE_LEVEL_ERROR,
10352 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070010353 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010354 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010355 }
10356
Yue Maef608272013-04-08 23:09:17 -070010357 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010358 {
10359 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010360 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010361 }
10362
10363 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010364 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070010365 {
10366 hddLog(VOS_TRACE_LEVEL_INFO,
10367 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010368 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070010369 (int) scanId);
10370 }
10371
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010372 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010373 pAdapter);
10374
10375 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010376 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010377
10378
10379 /* If any client wait scan result through WEXT
10380 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010381 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070010382 {
10383 /* The other scan request waiting for current scan finish
10384 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010385 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010386 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010387 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070010388 }
10389 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010390 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010391 {
10392 struct net_device *dev = pAdapter->dev;
10393 union iwreq_data wrqu;
10394 int we_event;
10395 char *msg;
10396
10397 memset(&wrqu, '\0', sizeof(wrqu));
10398 we_event = SIOCGIWSCAN;
10399 msg = NULL;
10400 wireless_send_event(dev, we_event, &wrqu, msg);
10401 }
10402 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010403 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010404
10405 /* Get the Scan Req */
10406 req = pAdapter->request;
10407
10408 if (!req)
10409 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010410 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010411 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010412 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010413 }
10414
Jeff Johnson295189b2012-06-20 16:38:30 -070010415 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070010416 /* Scan is no longer pending */
10417 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010418
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010419 /* last_scan_timestamp is used to decide if new scan
10420 * is needed or not on station interface. If last station
10421 * scan time and new station scan time is less then
10422 * last_scan_timestamp ; driver will return cached scan.
10423 */
10424 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
10425 {
10426 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
10427
10428 if ( req->n_channels )
10429 {
10430 for (i = 0; i < req->n_channels ; i++ )
10431 {
10432 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
10433 }
10434 /* store no of channel scanned */
10435 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
10436 }
10437
10438 }
10439
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070010440 /*
10441 * cfg80211_scan_done informing NL80211 about completion
10442 * of scanning
10443 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010444 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
10445 {
10446 aborted = true;
10447 }
10448 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080010449 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070010450
Siddharth Bhal76972212014-10-15 16:22:51 +053010451 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
10452 /* Generate new random mac addr for next scan */
10453 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
10454 hdd_processSpoofMacAddrRequest(pHddCtx);
10455 }
10456
Jeff Johnsone7245742012-09-05 17:12:55 -070010457allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010458 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010459 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070010460
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010461 /* Acquire wakelock to handle the case where APP's tries to suspend
10462 * immediatly after the driver gets connect request(i.e after scan)
10463 * from supplicant, this result in app's is suspending and not able
10464 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010465 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010466
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010467#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010468 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010469#endif
10470
Jeff Johnson295189b2012-06-20 16:38:30 -070010471 EXIT();
10472 return 0;
10473}
10474
10475/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053010476 * FUNCTION: hdd_isConnectionInProgress
10477 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010478 *
10479 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010480v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010481{
10482 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10483 hdd_station_ctx_t *pHddStaCtx = NULL;
10484 hdd_adapter_t *pAdapter = NULL;
10485 VOS_STATUS status = 0;
10486 v_U8_t staId = 0;
10487 v_U8_t *staMac = NULL;
10488
c_hpothu9b781ba2013-12-30 20:57:45 +053010489 if (TRUE == pHddCtx->btCoexModeSet)
10490 {
10491 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053010492 FL("BTCoex Mode operation in progress"));
10493 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053010494 }
10495
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010496 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10497
10498 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10499 {
10500 pAdapter = pAdapterNode->pAdapter;
10501
10502 if( pAdapter )
10503 {
10504 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010505 "%s: Adapter with device mode %s (%d) exists",
10506 __func__, hdd_device_modetoString(pAdapter->device_mode),
10507 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010508 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053010509 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10510 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
10511 (eConnectionState_Connecting ==
10512 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
10513 {
10514 hddLog(VOS_TRACE_LEVEL_ERROR,
10515 "%s: %p(%d) Connection is in progress", __func__,
10516 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10517 return VOS_TRUE;
10518 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010519 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053010520 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010521 {
10522 hddLog(VOS_TRACE_LEVEL_ERROR,
10523 "%s: %p(%d) Reassociation is in progress", __func__,
10524 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10525 return VOS_TRUE;
10526 }
10527 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010528 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10529 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010530 {
10531 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10532 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010533 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010534 {
10535 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
10536 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010537 "%s: client " MAC_ADDRESS_STR
10538 " is in the middle of WPS/EAPOL exchange.", __func__,
10539 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010540 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010541 }
10542 }
10543 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
10544 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
10545 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010546 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10547 ptSapContext pSapCtx = NULL;
10548 pSapCtx = VOS_GET_SAP_CB(pVosContext);
10549 if(pSapCtx == NULL){
10550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10551 FL("psapCtx is NULL"));
10552 return VOS_FALSE;
10553 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010554 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
10555 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010556 if ((pSapCtx->aStaInfo[staId].isUsed) &&
10557 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010558 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010559 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010560
10561 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010562 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
10563 "middle of WPS/EAPOL exchange.", __func__,
10564 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010565 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010566 }
10567 }
10568 }
10569 }
10570 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10571 pAdapterNode = pNext;
10572 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053010573 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010574}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010575
10576/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010577 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070010578 * this scan respond to scan trigger and update cfg80211 scan database
10579 * later, scan dump command can be used to recieve scan results
10580 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010581int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010582#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10583 struct net_device *dev,
10584#endif
10585 struct cfg80211_scan_request *request)
10586{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010587 hdd_adapter_t *pAdapter = NULL;
10588 hdd_context_t *pHddCtx = NULL;
10589 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010590 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010591 tCsrScanRequest scanRequest;
10592 tANI_U8 *channelList = NULL, i;
10593 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010594 int status;
10595 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010596 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010597 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053010598 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010599 bool is_p2p_scan = false;
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010600 v_S7_t rssi=0;
10601 hdd_station_ctx_t *pHddStaCtx=NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010602
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010603#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
10604 struct net_device *dev = NULL;
10605 if (NULL == request)
10606 {
10607 hddLog(VOS_TRACE_LEVEL_ERROR,
10608 "%s: scan req param null", __func__);
10609 return -EINVAL;
10610 }
10611 dev = request->wdev->netdev;
10612#endif
10613
10614 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
10615 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
10616 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10617
Jeff Johnson295189b2012-06-20 16:38:30 -070010618 ENTER();
10619
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010620 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10621 __func__, hdd_device_modetoString(pAdapter->device_mode),
10622 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010623
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010624 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010625 if (0 != status)
10626 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010627 return status;
10628 }
10629
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010630 if (NULL == pwextBuf)
10631 {
10632 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
10633 __func__);
10634 return -EIO;
10635 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010636 cfg_param = pHddCtx->cfg_ini;
10637 pScanInfo = &pHddCtx->scan_info;
10638
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010639 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10640 if ( (pHddStaCtx != NULL) && (TRUE == hdd_connIsConnected(pHddStaCtx)))
10641 {
10642 wlan_hdd_get_roam_rssi(pAdapter, &rssi);
10643 hddLog(VOS_TRACE_LEVEL_INFO, FL("rssi: %d"), rssi);
10644 }
10645
Jeff Johnson295189b2012-06-20 16:38:30 -070010646#ifdef WLAN_BTAMP_FEATURE
10647 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010648 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070010649 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010650 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010651 "%s: No scanning when AMP is on", __func__);
10652 return -EOPNOTSUPP;
10653 }
10654#endif
10655 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010656 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010657 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010658 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010659 "%s: Not scanning on device_mode = %s (%d)",
10660 __func__, hdd_device_modetoString(pAdapter->device_mode),
10661 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010662 return -EOPNOTSUPP;
10663 }
10664
10665 if (TRUE == pScanInfo->mScanPending)
10666 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010667 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
10668 {
10669 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
10670 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010671 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010672 }
10673
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010674 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070010675 //Channel and action frame is pending
10676 //Otherwise Cancel Remain On Channel and allow Scan
10677 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010678 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070010679 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010680 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010681 return -EBUSY;
10682 }
10683
Jeff Johnson295189b2012-06-20 16:38:30 -070010684 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
10685 {
10686 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080010687 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010688 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010689 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010690 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
10691 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010692 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010693 "%s: MAX TM Level Scan not allowed", __func__);
10694 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010695 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010696 }
10697 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
10698
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010699 /* Check if scan is allowed at this point of time.
10700 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010701 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010702 {
10703 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
10704 return -EBUSY;
10705 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010706
Jeff Johnson295189b2012-06-20 16:38:30 -070010707 vos_mem_zero( &scanRequest, sizeof(scanRequest));
10708
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010709 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
10710 (int)request->n_ssids);
10711
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010712
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010713 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
10714 * Becasue of this, driver is assuming that this is not wildcard scan and so
10715 * is not aging out the scan results.
10716 */
10717 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070010718 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010719 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010720 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010721
10722 if ((request->ssids) && (0 < request->n_ssids))
10723 {
10724 tCsrSSIDInfo *SsidInfo;
10725 int j;
10726 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
10727 /* Allocate num_ssid tCsrSSIDInfo structure */
10728 SsidInfo = scanRequest.SSIDs.SSIDList =
10729 ( tCsrSSIDInfo *)vos_mem_malloc(
10730 request->n_ssids*sizeof(tCsrSSIDInfo));
10731
10732 if(NULL == scanRequest.SSIDs.SSIDList)
10733 {
10734 hddLog(VOS_TRACE_LEVEL_ERROR,
10735 "%s: memory alloc failed SSIDInfo buffer", __func__);
10736 return -ENOMEM;
10737 }
10738
10739 /* copy all the ssid's and their length */
10740 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
10741 {
10742 /* get the ssid length */
10743 SsidInfo->SSID.length = request->ssids[j].ssid_len;
10744 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
10745 SsidInfo->SSID.length);
10746 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
10747 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
10748 j, SsidInfo->SSID.ssId);
10749 }
10750 /* set the scan type to active */
10751 scanRequest.scanType = eSIR_ACTIVE_SCAN;
10752 }
10753 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070010754 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010755 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10756 TRACE_CODE_HDD_CFG80211_SCAN,
10757 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070010758 /* set the scan type to active */
10759 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010760 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010761 else
10762 {
10763 /*Set the scan type to default type, in this case it is ACTIVE*/
10764 scanRequest.scanType = pScanInfo->scan_mode;
10765 }
10766 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
10767 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070010768
10769 /* set BSSType to default type */
10770 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
10771
10772 /*TODO: scan the requested channels only*/
10773
10774 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010775 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070010776 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010777 hddLog(VOS_TRACE_LEVEL_WARN,
10778 "No of Scan Channels exceeded limit: %d", request->n_channels);
10779 request->n_channels = MAX_CHANNEL;
10780 }
10781
10782 hddLog(VOS_TRACE_LEVEL_INFO,
10783 "No of Scan Channels: %d", request->n_channels);
10784
10785
10786 if( request->n_channels )
10787 {
10788 char chList [(request->n_channels*5)+1];
10789 int len;
10790 channelList = vos_mem_malloc( request->n_channels );
10791 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053010792 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010793 hddLog(VOS_TRACE_LEVEL_ERROR,
10794 "%s: memory alloc failed channelList", __func__);
10795 status = -ENOMEM;
10796 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053010797 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010798
10799 for( i = 0, len = 0; i < request->n_channels ; i++ )
10800 {
10801 channelList[i] = request->channels[i]->hw_value;
10802 len += snprintf(chList+len, 5, "%d ", channelList[i]);
10803 }
10804
Nirav Shah20ac06f2013-12-12 18:14:06 +053010805 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010806 "Channel-List: %s ", chList);
10807 }
c_hpothu53512302014-04-15 18:49:53 +053010808
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010809 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
10810 scanRequest.ChannelInfo.ChannelList = channelList;
10811
10812 /* set requestType to full scan */
10813 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
10814
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010815 /* if there is back to back scan happening in driver with in
10816 * nDeferScanTimeInterval interval driver should defer new scan request
10817 * and should provide last cached scan results instead of new channel list.
10818 * This rule is not applicable if scan is p2p scan.
10819 * This condition will work only in case when last request no of channels
10820 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053010821 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053010822 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010823 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010824
Sushant Kaushik86592172015-04-27 16:35:03 +053010825 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
10826 /* if wps ie is NULL , then only defer scan */
10827 if ( pWpsIe == NULL &&
10828 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053010829 {
10830 if ( pScanInfo->last_scan_timestamp !=0 &&
10831 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
10832 {
10833 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
10834 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
10835 vos_mem_compare(pScanInfo->last_scan_channelList,
10836 channelList, pScanInfo->last_scan_numChannels))
10837 {
10838 hddLog(VOS_TRACE_LEVEL_WARN,
10839 " New and old station scan time differ is less then %u",
10840 pHddCtx->cfg_ini->nDeferScanTimeInterval);
10841
10842 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010843 pAdapter);
10844
Agarwal Ashish57e84372014-12-05 18:26:53 +053010845 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010846 "Return old cached scan as all channels and no of channels are same");
10847
Agarwal Ashish57e84372014-12-05 18:26:53 +053010848 if (0 > ret)
10849 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010850
Agarwal Ashish57e84372014-12-05 18:26:53 +053010851 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010852
10853 status = eHAL_STATUS_SUCCESS;
10854 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053010855 }
10856 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010857 }
10858
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010859 /* Flush the scan results(only p2p beacons) for STA scan and P2P
10860 * search (Flush on both full scan and social scan but not on single
10861 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
10862 */
10863
10864 /* Supplicant does single channel scan after 8-way handshake
10865 * and in that case driver shoudnt flush scan results. If
10866 * driver flushes the scan results here and unfortunately if
10867 * the AP doesnt respond to our probe req then association
10868 * fails which is not desired
10869 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010870 if ((request->n_ssids == 1)
10871 && (request->ssids != NULL)
10872 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
10873 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010874
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010875 if( is_p2p_scan ||
10876 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010877 {
10878 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
10879 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
10880 pAdapter->sessionId );
10881 }
10882
10883 if( request->ie_len )
10884 {
10885 /* save this for future association (join requires this) */
10886 /*TODO: Array needs to be converted to dynamic allocation,
10887 * as multiple ie.s can be sent in cfg80211_scan_request structure
10888 * CR 597966
10889 */
10890 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
10891 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
10892 pScanInfo->scanAddIE.length = request->ie_len;
10893
10894 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
10895 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10896 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010897 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053010898 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070010899 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010900 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
10901 memcpy( pwextBuf->roamProfile.addIEScan,
10902 request->ie, request->ie_len);
10903 }
10904 else
10905 {
10906 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
10907 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070010908 }
10909
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010910 }
10911 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
10912 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
10913
10914 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
10915 request->ie_len);
10916 if (pP2pIe != NULL)
10917 {
10918#ifdef WLAN_FEATURE_P2P_DEBUG
10919 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
10920 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
10921 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053010922 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010923 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
10924 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10925 "Go nego completed to Connection is started");
10926 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10927 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053010928 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010929 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
10930 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010931 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010932 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
10933 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10934 "Disconnected state to Connection is started");
10935 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10936 "for 4way Handshake");
10937 }
10938#endif
10939
10940 /* no_cck will be set during p2p find to disable 11b rates */
10941 if(TRUE == request->no_cck)
10942 {
10943 hddLog(VOS_TRACE_LEVEL_INFO,
10944 "%s: This is a P2P Search", __func__);
10945 scanRequest.p2pSearch = 1;
10946
10947 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053010948 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010949 /* set requestType to P2P Discovery */
10950 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
10951 }
10952
10953 /*
10954 Skip Dfs Channel in case of P2P Search
10955 if it is set in ini file
10956 */
10957 if(cfg_param->skipDfsChnlInP2pSearch)
10958 {
10959 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010960 }
10961 else
10962 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010963 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010964 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010965
Agarwal Ashish4f616132013-12-30 23:32:50 +053010966 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010967 }
10968 }
10969
10970 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
10971
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010972#ifdef FEATURE_WLAN_TDLS
10973 /* if tdls disagree scan right now, return immediately.
10974 tdls will schedule the scan when scan is allowed. (return SUCCESS)
10975 or will reject the scan if any TDLS is in progress. (return -EBUSY)
10976 */
10977 status = wlan_hdd_tdls_scan_callback (pAdapter,
10978 wiphy,
10979#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10980 dev,
10981#endif
10982 request);
10983 if(status <= 0)
10984 {
10985 if(!status)
10986 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
10987 "scan rejected %d", __func__, status);
10988 else
10989 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
10990 __func__, status);
10991
10992 return status;
10993 }
10994#endif
10995
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010996 /* acquire the wakelock to avoid the apps suspend during the scan. To
10997 * address the following issues.
10998 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
10999 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
11000 * for long time, this result in apps running at full power for long time.
11001 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
11002 * be stuck in full power because of resume BMPS
11003 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011004 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070011005
Nirav Shah20ac06f2013-12-12 18:14:06 +053011006 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
11007 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011008 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
11009 scanRequest.requestType, scanRequest.scanType,
11010 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053011011 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
11012
Siddharth Bhal76972212014-10-15 16:22:51 +053011013 if (pHddCtx->spoofMacAddr.isEnabled)
11014 {
11015 hddLog(VOS_TRACE_LEVEL_INFO,
11016 "%s: MAC Spoofing enabled for current scan", __func__);
11017 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
11018 * to fill TxBds for probe request during current scan
11019 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011020 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053011021 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011022
11023 if(status != VOS_STATUS_SUCCESS)
11024 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011025 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011026 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053011027#ifdef FEATURE_WLAN_TDLS
11028 wlan_hdd_tdls_scan_done_callback(pAdapter);
11029#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011030 goto free_mem;
11031 }
Siddharth Bhal76972212014-10-15 16:22:51 +053011032 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053011033 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070011034 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011035 pAdapter->sessionId, &scanRequest, &scanId,
11036 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070011037
Jeff Johnson295189b2012-06-20 16:38:30 -070011038 if (eHAL_STATUS_SUCCESS != status)
11039 {
11040 hddLog(VOS_TRACE_LEVEL_ERROR,
11041 "%s: sme_ScanRequest returned error %d", __func__, status);
11042 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011043 if(eHAL_STATUS_RESOURCES == status)
11044 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053011045 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
11046 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011047 status = -EBUSY;
11048 } else {
11049 status = -EIO;
11050 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011051 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053011052
11053#ifdef FEATURE_WLAN_TDLS
11054 wlan_hdd_tdls_scan_done_callback(pAdapter);
11055#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011056 goto free_mem;
11057 }
11058
11059 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053011060 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011061 pAdapter->request = request;
11062 pScanInfo->scanId = scanId;
11063
11064 complete(&pScanInfo->scan_req_completion_event);
11065
11066free_mem:
11067 if( scanRequest.SSIDs.SSIDList )
11068 {
11069 vos_mem_free(scanRequest.SSIDs.SSIDList);
11070 }
11071
11072 if( channelList )
11073 vos_mem_free( channelList );
11074
11075 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011076 return status;
11077}
11078
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011079int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
11080#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11081 struct net_device *dev,
11082#endif
11083 struct cfg80211_scan_request *request)
11084{
11085 int ret;
11086
11087 vos_ssr_protect(__func__);
11088 ret = __wlan_hdd_cfg80211_scan(wiphy,
11089#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11090 dev,
11091#endif
11092 request);
11093 vos_ssr_unprotect(__func__);
11094
11095 return ret;
11096}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011097
11098void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
11099{
11100 v_U8_t iniDot11Mode =
11101 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
11102 eHddDot11Mode hddDot11Mode = iniDot11Mode;
11103
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011104 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
11105 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011106 switch ( iniDot11Mode )
11107 {
11108 case eHDD_DOT11_MODE_AUTO:
11109 case eHDD_DOT11_MODE_11ac:
11110 case eHDD_DOT11_MODE_11ac_ONLY:
11111#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053011112 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
11113 sme_IsFeatureSupportedByFW(DOT11AC) )
11114 hddDot11Mode = eHDD_DOT11_MODE_11ac;
11115 else
11116 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011117#else
11118 hddDot11Mode = eHDD_DOT11_MODE_11n;
11119#endif
11120 break;
11121 case eHDD_DOT11_MODE_11n:
11122 case eHDD_DOT11_MODE_11n_ONLY:
11123 hddDot11Mode = eHDD_DOT11_MODE_11n;
11124 break;
11125 default:
11126 hddDot11Mode = iniDot11Mode;
11127 break;
11128 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011129#ifdef WLAN_FEATURE_AP_HT40_24G
11130 if (operationChannel > SIR_11B_CHANNEL_END)
11131#endif
11132 {
11133 /* This call decides required channel bonding mode */
11134 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011135 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
11136 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011137 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011138}
11139
Jeff Johnson295189b2012-06-20 16:38:30 -070011140/*
11141 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011142 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011143 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011144int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011145 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070011146{
11147 int status = 0;
11148 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080011149 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011150 v_U32_t roamId;
11151 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070011152 eCsrAuthType RSNAuthType;
11153
11154 ENTER();
11155
11156 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080011157 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11158
11159 status = wlan_hdd_validate_context(pHddCtx);
11160 if (status)
11161 {
Yue Mae36e3552014-03-05 17:06:20 -080011162 return status;
11163 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011164
Jeff Johnson295189b2012-06-20 16:38:30 -070011165 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
11166 {
11167 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
11168 return -EINVAL;
11169 }
11170
11171 pRoamProfile = &pWextState->roamProfile;
11172
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011173 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070011174 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011175 hdd_station_ctx_t *pHddStaCtx;
11176 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011177
Siddharth Bhalda0d1622015-04-24 15:47:49 +053011178 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
11179
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011180 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070011181 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
11182 {
11183 /*QoS not enabled in cfg file*/
11184 pRoamProfile->uapsd_mask = 0;
11185 }
11186 else
11187 {
11188 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011189 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070011190 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
11191 }
11192
11193 pRoamProfile->SSIDs.numOfSSIDs = 1;
11194 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
11195 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011196 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070011197 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
11198 ssid, ssid_len);
11199
11200 if (bssid)
11201 {
11202 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
11203 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
11204 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011205 /* Save BSSID in seperate variable as well, as RoamProfile
11206 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070011207 case of join failure we should send valid BSSID to supplicant
11208 */
11209 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
11210 WNI_CFG_BSSID_LEN);
11211 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070011212 else
11213 {
11214 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
11215 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011216
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011217 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
11218 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011219 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
11220 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011221 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011222 /*set gen ie*/
11223 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
11224 /*set auth*/
11225 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
11226 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011227#ifdef FEATURE_WLAN_WAPI
11228 if (pAdapter->wapi_info.nWapiMode)
11229 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011230 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011231 switch (pAdapter->wapi_info.wapiAuthMode)
11232 {
11233 case WAPI_AUTH_MODE_PSK:
11234 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011235 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011236 pAdapter->wapi_info.wapiAuthMode);
11237 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
11238 break;
11239 }
11240 case WAPI_AUTH_MODE_CERT:
11241 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011242 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011243 pAdapter->wapi_info.wapiAuthMode);
11244 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
11245 break;
11246 }
11247 } // End of switch
11248 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
11249 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
11250 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011251 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011252 pRoamProfile->AuthType.numEntries = 1;
11253 pRoamProfile->EncryptionType.numEntries = 1;
11254 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11255 pRoamProfile->mcEncryptionType.numEntries = 1;
11256 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11257 }
11258 }
11259#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011260#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011261 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011262 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11263 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
11264 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011265 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
11266 sizeof (tSirGtkOffloadParams));
11267 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011268 }
11269#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011270 pRoamProfile->csrPersona = pAdapter->device_mode;
11271
Jeff Johnson32d95a32012-09-10 13:15:23 -070011272 if( operatingChannel )
11273 {
11274 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
11275 pRoamProfile->ChannelInfo.numOfChannels = 1;
11276 }
Chet Lanctot186b5732013-03-18 10:26:30 -070011277 else
11278 {
11279 pRoamProfile->ChannelInfo.ChannelList = NULL;
11280 pRoamProfile->ChannelInfo.numOfChannels = 0;
11281 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011282 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
11283 {
11284 hdd_select_cbmode(pAdapter,operatingChannel);
11285 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011286
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011287 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
11288 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011289 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011290 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011291 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
11292 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011293 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11294 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053011295 {
11296 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11297 "%s: Set HDD connState to eConnectionState_Connecting",
11298 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011299 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
11300 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053011301 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011302 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011303 pAdapter->sessionId, pRoamProfile, &roamId);
11304
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011305 if ((eHAL_STATUS_SUCCESS != status) &&
11306 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11307 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011308
11309 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011310 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
11311 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
11312 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011313 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011314 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011315 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011316
11317 pRoamProfile->ChannelInfo.ChannelList = NULL;
11318 pRoamProfile->ChannelInfo.numOfChannels = 0;
11319
Jeff Johnson295189b2012-06-20 16:38:30 -070011320 }
11321 else
11322 {
11323 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
11324 return -EINVAL;
11325 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080011326 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011327 return status;
11328}
11329
11330/*
11331 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
11332 * This function is used to set the authentication type (OPEN/SHARED).
11333 *
11334 */
11335static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
11336 enum nl80211_auth_type auth_type)
11337{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011338 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011339 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11340
11341 ENTER();
11342
11343 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011344 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070011345 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011346 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011347 hddLog(VOS_TRACE_LEVEL_INFO,
11348 "%s: set authentication type to AUTOSWITCH", __func__);
11349 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
11350 break;
11351
11352 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011353#ifdef WLAN_FEATURE_VOWIFI_11R
11354 case NL80211_AUTHTYPE_FT:
11355#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011356 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011357 "%s: set authentication type to OPEN", __func__);
11358 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11359 break;
11360
11361 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011362 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011363 "%s: set authentication type to SHARED", __func__);
11364 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
11365 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011366#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011367 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011368 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011369 "%s: set authentication type to CCKM WPA", __func__);
11370 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
11371 break;
11372#endif
11373
11374
11375 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011376 hddLog(VOS_TRACE_LEVEL_ERROR,
11377 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011378 auth_type);
11379 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
11380 return -EINVAL;
11381 }
11382
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011383 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011384 pHddStaCtx->conn_info.authType;
11385 return 0;
11386}
11387
11388/*
11389 * FUNCTION: wlan_hdd_set_akm_suite
11390 * This function is used to set the key mgmt type(PSK/8021x).
11391 *
11392 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011393static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011394 u32 key_mgmt
11395 )
11396{
11397 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11398 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053011399 /* Should be in ieee802_11_defs.h */
11400#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
11401#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070011402 /*set key mgmt type*/
11403 switch(key_mgmt)
11404 {
11405 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053011406 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011407#ifdef WLAN_FEATURE_VOWIFI_11R
11408 case WLAN_AKM_SUITE_FT_PSK:
11409#endif
11410 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070011411 __func__);
11412 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
11413 break;
11414
11415 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053011416 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011417#ifdef WLAN_FEATURE_VOWIFI_11R
11418 case WLAN_AKM_SUITE_FT_8021X:
11419#endif
11420 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011421 __func__);
11422 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11423 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011424#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011425#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
11426#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
11427 case WLAN_AKM_SUITE_CCKM:
11428 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
11429 __func__);
11430 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
11431 break;
11432#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070011433#ifndef WLAN_AKM_SUITE_OSEN
11434#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
11435 case WLAN_AKM_SUITE_OSEN:
11436 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
11437 __func__);
11438 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11439 break;
11440#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011441
11442 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011443 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011444 __func__, key_mgmt);
11445 return -EINVAL;
11446
11447 }
11448 return 0;
11449}
11450
11451/*
11452 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011453 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070011454 * (NONE/WEP40/WEP104/TKIP/CCMP).
11455 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011456static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
11457 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070011458 bool ucast
11459 )
11460{
11461 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011462 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011463 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11464
11465 ENTER();
11466
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011467 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011468 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011469 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070011470 __func__, cipher);
11471 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11472 }
11473 else
11474 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011475
Jeff Johnson295189b2012-06-20 16:38:30 -070011476 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011477 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011478 {
11479 case IW_AUTH_CIPHER_NONE:
11480 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11481 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011482
Jeff Johnson295189b2012-06-20 16:38:30 -070011483 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011484 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070011485 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011486
Jeff Johnson295189b2012-06-20 16:38:30 -070011487 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011488 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070011489 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011490
Jeff Johnson295189b2012-06-20 16:38:30 -070011491 case WLAN_CIPHER_SUITE_TKIP:
11492 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
11493 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011494
Jeff Johnson295189b2012-06-20 16:38:30 -070011495 case WLAN_CIPHER_SUITE_CCMP:
11496 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11497 break;
11498#ifdef FEATURE_WLAN_WAPI
11499 case WLAN_CIPHER_SUITE_SMS4:
11500 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
11501 break;
11502#endif
11503
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011504#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011505 case WLAN_CIPHER_SUITE_KRK:
11506 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
11507 break;
11508#endif
11509 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011510 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011511 __func__, cipher);
11512 return -EOPNOTSUPP;
11513 }
11514 }
11515
11516 if (ucast)
11517 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011518 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011519 __func__, encryptionType);
11520 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11521 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011522 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011523 encryptionType;
11524 }
11525 else
11526 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011527 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011528 __func__, encryptionType);
11529 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
11530 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
11531 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
11532 }
11533
11534 return 0;
11535}
11536
11537
11538/*
11539 * FUNCTION: wlan_hdd_cfg80211_set_ie
11540 * This function is used to parse WPA/RSN IE's.
11541 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011542int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
11543 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -070011544 size_t ie_len
11545 )
11546{
11547 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11548 u8 *genie = ie;
11549 v_U16_t remLen = ie_len;
11550#ifdef FEATURE_WLAN_WAPI
11551 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
11552 u16 *tmp;
11553 v_U16_t akmsuiteCount;
11554 int *akmlist;
11555#endif
11556 ENTER();
11557
11558 /* clear previous assocAddIE */
11559 pWextState->assocAddIE.length = 0;
11560 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011561 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011562
11563 while (remLen >= 2)
11564 {
11565 v_U16_t eLen = 0;
11566 v_U8_t elementId;
11567 elementId = *genie++;
11568 eLen = *genie++;
11569 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011570
Arif Hussain6d2a3322013-11-17 19:50:10 -080011571 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070011572 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011573
11574 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070011575 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011576 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011577 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 -070011578 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011579 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011580 "%s: Invalid WPA IE", __func__);
11581 return -EINVAL;
11582 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011583 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070011584 {
11585 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011586 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011587 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011588
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011589 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011590 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011591 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
11592 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011593 VOS_ASSERT(0);
11594 return -ENOMEM;
11595 }
11596 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11597 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11598 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011599
Jeff Johnson295189b2012-06-20 16:38:30 -070011600 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
11601 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11602 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11603 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011604 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
11605 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011606 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
11607 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11608 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
11609 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
11610 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
11611 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011612 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053011613 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070011614 {
11615 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011616 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011617 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011618
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011619 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011620 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011621 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11622 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011623 VOS_ASSERT(0);
11624 return -ENOMEM;
11625 }
11626 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11627 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11628 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011629
Jeff Johnson295189b2012-06-20 16:38:30 -070011630 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11631 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11632 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011633#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011634 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
11635 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011636 /*Consider WFD IE, only for P2P Client */
11637 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
11638 {
11639 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011640 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011641 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011642
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011643 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011644 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011645 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11646 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011647 VOS_ASSERT(0);
11648 return -ENOMEM;
11649 }
11650 // WFD IE is saved to Additional IE ; it should be accumulated to handle
11651 // WPS IE + P2P IE + WFD IE
11652 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11653 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011654
Jeff Johnson295189b2012-06-20 16:38:30 -070011655 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11656 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11657 }
11658#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011659 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011660 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011661 HS20_OUI_TYPE_SIZE)) )
11662 {
11663 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011664 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011665 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011666
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011667 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011668 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011669 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11670 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011671 VOS_ASSERT(0);
11672 return -ENOMEM;
11673 }
11674 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11675 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011676
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011677 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11678 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11679 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011680 /* Appending OSEN Information Element in Assiciation Request */
11681 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
11682 OSEN_OUI_TYPE_SIZE)) )
11683 {
11684 v_U16_t curAddIELen = pWextState->assocAddIE.length;
11685 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
11686 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011687
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011688 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011689 {
11690 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11691 "Need bigger buffer space");
11692 VOS_ASSERT(0);
11693 return -ENOMEM;
11694 }
11695 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11696 pWextState->assocAddIE.length += eLen + 2;
11697
11698 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
11699 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11700 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11701 }
11702
Abhishek Singh4322e622015-06-10 15:42:54 +053011703 /* Update only for WPA IE */
11704 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
11705 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011706
11707 /* populating as ADDIE in beacon frames */
11708 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11709 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
11710 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
11711 {
11712 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11713 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
11714 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11715 {
11716 hddLog(LOGE,
11717 "Coldn't pass "
11718 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
11719 }
11720 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
11721 else
11722 hddLog(LOGE,
11723 "Could not pass on "
11724 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
11725
11726 /* IBSS mode doesn't contain params->proberesp_ies still
11727 beaconIE's need to be populated in probe response frames */
11728 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
11729 {
11730 u16 rem_probe_resp_ie_len = eLen + 2;
11731 u8 probe_rsp_ie_len[3] = {0};
11732 u8 counter = 0;
11733
11734 /* Check Probe Resp Length if it is greater then 255 then
11735 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
11736 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
11737 not able Store More then 255 bytes into One Variable */
11738
11739 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
11740 {
11741 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
11742 {
11743 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
11744 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
11745 }
11746 else
11747 {
11748 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
11749 rem_probe_resp_ie_len = 0;
11750 }
11751 }
11752
11753 rem_probe_resp_ie_len = 0;
11754
11755 if (probe_rsp_ie_len[0] > 0)
11756 {
11757 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11758 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
11759 (tANI_U8*)(genie - 2),
11760 probe_rsp_ie_len[0], NULL,
11761 eANI_BOOLEAN_FALSE)
11762 == eHAL_STATUS_FAILURE)
11763 {
11764 hddLog(LOGE,
11765 "Could not pass"
11766 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
11767 }
11768 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
11769 }
11770
11771 if (probe_rsp_ie_len[1] > 0)
11772 {
11773 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11774 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
11775 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11776 probe_rsp_ie_len[1], NULL,
11777 eANI_BOOLEAN_FALSE)
11778 == eHAL_STATUS_FAILURE)
11779 {
11780 hddLog(LOGE,
11781 "Could not pass"
11782 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
11783 }
11784 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
11785 }
11786
11787 if (probe_rsp_ie_len[2] > 0)
11788 {
11789 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11790 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
11791 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11792 probe_rsp_ie_len[2], NULL,
11793 eANI_BOOLEAN_FALSE)
11794 == eHAL_STATUS_FAILURE)
11795 {
11796 hddLog(LOGE,
11797 "Could not pass"
11798 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
11799 }
11800 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
11801 }
11802
11803 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11804 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
11805 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11806 {
11807 hddLog(LOGE,
11808 "Could not pass"
11809 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
11810 }
11811 }
11812 else
11813 {
11814 // Reset WNI_CFG_PROBE_RSP Flags
11815 wlan_hdd_reset_prob_rspies(pAdapter);
11816
11817 hddLog(VOS_TRACE_LEVEL_INFO,
11818 "%s: No Probe Response IE received in set beacon",
11819 __func__);
11820 }
11821 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070011822 break;
11823 case DOT11F_EID_RSN:
11824 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
11825 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11826 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
11827 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
11828 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
11829 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053011830
11831 /* Appending Extended Capabilities with Interworking bit set
11832 * in Assoc Req.
11833 *
11834 * In assoc req this EXT Cap will only be taken into account if
11835 * interworkingService bit is set to 1. Currently
11836 * driver is only interested in interworkingService capability
11837 * from supplicant. If in future any other EXT Cap info is
11838 * required from supplicat, it needs to be handled while
11839 * sending Assoc Req in LIM.
11840 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011841 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011842 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011843 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011844 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011845 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011846
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011847 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011848 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011849 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11850 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011851 VOS_ASSERT(0);
11852 return -ENOMEM;
11853 }
11854 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11855 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011856
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011857 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11858 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11859 break;
11860 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011861#ifdef FEATURE_WLAN_WAPI
11862 case WLAN_EID_WAPI:
11863 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011864 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070011865 pAdapter->wapi_info.nWapiMode);
11866 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011867 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070011868 akmsuiteCount = WPA_GET_LE16(tmp);
11869 tmp = tmp + 1;
11870 akmlist = (int *)(tmp);
11871 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
11872 {
11873 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
11874 }
11875 else
11876 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011877 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070011878 VOS_ASSERT(0);
11879 return -EINVAL;
11880 }
11881
11882 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
11883 {
11884 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011885 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011886 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011887 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011888 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011889 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011890 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011891 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011892 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
11893 }
11894 break;
11895#endif
11896 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011897 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011898 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011899 /* when Unknown IE is received we should break and continue
11900 * to the next IE in the buffer instead we were returning
11901 * so changing this to break */
11902 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011903 }
11904 genie += eLen;
11905 remLen -= eLen;
11906 }
11907 EXIT();
11908 return 0;
11909}
11910
11911/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053011912 * FUNCTION: hdd_isWPAIEPresent
11913 * Parse the received IE to find the WPA IE
11914 *
11915 */
11916static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
11917{
11918 v_U8_t eLen = 0;
11919 v_U16_t remLen = ie_len;
11920 v_U8_t elementId = 0;
11921
11922 while (remLen >= 2)
11923 {
11924 elementId = *ie++;
11925 eLen = *ie++;
11926 remLen -= 2;
11927 if (eLen > remLen)
11928 {
11929 hddLog(VOS_TRACE_LEVEL_ERROR,
11930 "%s: IE length is wrong %d", __func__, eLen);
11931 return FALSE;
11932 }
11933 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
11934 {
11935 /* OUI - 0x00 0X50 0XF2
11936 WPA Information Element - 0x01
11937 WPA version - 0x01*/
11938 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
11939 return TRUE;
11940 }
11941 ie += eLen;
11942 remLen -= eLen;
11943 }
11944 return FALSE;
11945}
11946
11947/*
Jeff Johnson295189b2012-06-20 16:38:30 -070011948 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011949 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070011950 * parameters during connect operation.
11951 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011952int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011953 struct cfg80211_connect_params *req
11954 )
11955{
11956 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011957 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011958 ENTER();
11959
11960 /*set wpa version*/
11961 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11962
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011963 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011964 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053011965 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011966 {
11967 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
11968 }
11969 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
11970 {
11971 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
11972 }
11973 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011974
11975 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011976 pWextState->wpaVersion);
11977
11978 /*set authentication type*/
11979 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
11980
11981 if (0 > status)
11982 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011983 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011984 "%s: failed to set authentication type ", __func__);
11985 return status;
11986 }
11987
11988 /*set key mgmt type*/
11989 if (req->crypto.n_akm_suites)
11990 {
11991 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
11992 if (0 > status)
11993 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011994 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070011995 __func__);
11996 return status;
11997 }
11998 }
11999
12000 /*set pairwise cipher type*/
12001 if (req->crypto.n_ciphers_pairwise)
12002 {
12003 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
12004 req->crypto.ciphers_pairwise[0], true);
12005 if (0 > status)
12006 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012007 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012008 "%s: failed to set unicast cipher type", __func__);
12009 return status;
12010 }
12011 }
12012 else
12013 {
12014 /*Reset previous cipher suite to none*/
12015 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
12016 if (0 > status)
12017 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012018 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012019 "%s: failed to set unicast cipher type", __func__);
12020 return status;
12021 }
12022 }
12023
12024 /*set group cipher type*/
12025 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
12026 false);
12027
12028 if (0 > status)
12029 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012030 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070012031 __func__);
12032 return status;
12033 }
12034
Chet Lanctot186b5732013-03-18 10:26:30 -070012035#ifdef WLAN_FEATURE_11W
12036 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
12037#endif
12038
Jeff Johnson295189b2012-06-20 16:38:30 -070012039 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
12040 if (req->ie_len)
12041 {
12042 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
12043 if ( 0 > status)
12044 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012045 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012046 __func__);
12047 return status;
12048 }
12049 }
12050
12051 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012052 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012053 {
12054 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
12055 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
12056 )
12057 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012058 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070012059 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
12060 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012061 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012062 __func__);
12063 return -EOPNOTSUPP;
12064 }
12065 else
12066 {
12067 u8 key_len = req->key_len;
12068 u8 key_idx = req->key_idx;
12069
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012070 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012071 && (CSR_MAX_NUM_KEY > key_idx)
12072 )
12073 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012074 hddLog(VOS_TRACE_LEVEL_INFO,
12075 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012076 __func__, key_idx, key_len);
12077 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012078 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012079 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012080 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070012081 (u8)key_len;
12082 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
12083 }
12084 }
12085 }
12086 }
12087
12088 return status;
12089}
12090
12091/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012092 * FUNCTION: wlan_hdd_try_disconnect
12093 * This function is used to disconnect from previous
12094 * connection
12095 */
12096static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
12097{
12098 long ret = 0;
12099 hdd_station_ctx_t *pHddStaCtx;
12100 eMib_dot11DesiredBssType connectedBssType;
12101
12102 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12103
12104 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
12105
12106 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
12107 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
12108 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
12109 {
12110 /* Issue disconnect to CSR */
12111 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12112 if( eHAL_STATUS_SUCCESS ==
12113 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12114 pAdapter->sessionId,
12115 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
12116 {
12117 ret = wait_for_completion_interruptible_timeout(
12118 &pAdapter->disconnect_comp_var,
12119 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12120 if (0 >= ret)
12121 {
12122 hddLog(LOGE, FL("Failed to receive disconnect event"));
12123 return -EALREADY;
12124 }
12125 }
12126 }
12127 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
12128 {
12129 ret = wait_for_completion_interruptible_timeout(
12130 &pAdapter->disconnect_comp_var,
12131 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12132 if (0 >= ret)
12133 {
12134 hddLog(LOGE, FL("Failed to receive disconnect event"));
12135 return -EALREADY;
12136 }
12137 }
12138
12139 return 0;
12140}
12141
12142/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053012143 * FUNCTION: __wlan_hdd_cfg80211_connect
12144 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070012145 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012146static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012147 struct net_device *ndev,
12148 struct cfg80211_connect_params *req
12149 )
12150{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012151 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012152 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012153 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053012154 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012155
12156 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012157
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012158 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12159 TRACE_CODE_HDD_CFG80211_CONNECT,
12160 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012161 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012162 "%s: device_mode = %s (%d)", __func__,
12163 hdd_device_modetoString(pAdapter->device_mode),
12164 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012165
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012166 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012167 if (!pHddCtx)
12168 {
12169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12170 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053012171 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012172 }
12173
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012174 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012175 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012176 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012177 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012178 }
12179
Agarwal Ashish51325b52014-06-16 16:50:49 +053012180 if (vos_max_concurrent_connections_reached()) {
12181 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12182 return -ECONNREFUSED;
12183 }
12184
Jeff Johnson295189b2012-06-20 16:38:30 -070012185#ifdef WLAN_BTAMP_FEATURE
12186 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012187 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070012188 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012189 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012190 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080012191 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012192 }
12193#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012194
12195 //If Device Mode is Station Concurrent Sessions Exit BMps
12196 //P2P Mode will be taken care in Open/close adapter
12197 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012198 (vos_concurrent_open_sessions_running())) {
12199 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
12200 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012201 }
12202
12203 /*Try disconnecting if already in connected state*/
12204 status = wlan_hdd_try_disconnect(pAdapter);
12205 if ( 0 > status)
12206 {
12207 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12208 " connection"));
12209 return -EALREADY;
12210 }
12211
Jeff Johnson295189b2012-06-20 16:38:30 -070012212 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012213 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070012214
12215 if ( 0 > status)
12216 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012217 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070012218 __func__);
12219 return status;
12220 }
Mohit Khanna765234a2012-09-11 15:08:35 -070012221 if ( req->channel )
12222 {
12223 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
12224 req->ssid_len, req->bssid,
12225 req->channel->hw_value);
12226 }
12227 else
12228 {
12229 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012230 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070012231 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012232
Sushant Kaushikd7083982015-03-18 14:33:24 +053012233 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012234 {
12235 //ReEnable BMPS if disabled
12236 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
12237 (NULL != pHddCtx))
12238 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012239 if (pHddCtx->hdd_wlan_suspended)
12240 {
12241 hdd_set_pwrparams(pHddCtx);
12242 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012243 //ReEnable Bmps and Imps back
12244 hdd_enable_bmps_imps(pHddCtx);
12245 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053012246 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012247 return status;
12248 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012249 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012250 EXIT();
12251 return status;
12252}
12253
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012254static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
12255 struct net_device *ndev,
12256 struct cfg80211_connect_params *req)
12257{
12258 int ret;
12259 vos_ssr_protect(__func__);
12260 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
12261 vos_ssr_unprotect(__func__);
12262
12263 return ret;
12264}
Jeff Johnson295189b2012-06-20 16:38:30 -070012265
12266/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012267 * FUNCTION: wlan_hdd_disconnect
12268 * This function is used to issue a disconnect request to SME
12269 */
12270int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
12271{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012272 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012273 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012274 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012275 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012276
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012277 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012278
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012279 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012280 if (0 != status)
12281 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012282 return status;
12283 }
12284
Sushant Kaushikb4834d22015-07-15 15:29:05 +053012285 if (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)
12286 {
12287 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
12288 pAdapter->sessionId);
12289 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012290 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012291
Agarwal Ashish47d18112014-08-04 19:55:07 +053012292 /* Need to apply spin lock before decreasing active sessions
12293 * as there can be chance for double decrement if context switch
12294 * Calls hdd_DisConnectHandler.
12295 */
12296
12297 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012298 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
12299 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012300 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
12301 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053012302 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
12303 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012304
Abhishek Singhf4669da2014-05-26 15:07:49 +053012305 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053012306 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
12307
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012308 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012309
Mihir Shete182a0b22014-08-18 16:08:48 +053012310 /*
12311 * stop tx queues before deleting STA/BSS context from the firmware.
12312 * tx has to be disabled because the firmware can get busy dropping
12313 * the tx frames after BSS/STA has been deleted and will not send
12314 * back a response resulting in WDI timeout
12315 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053012316 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053012317 netif_tx_disable(pAdapter->dev);
12318 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012319
Mihir Shete182a0b22014-08-18 16:08:48 +053012320 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012321 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12322 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012323 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
12324 {
12325 hddLog(VOS_TRACE_LEVEL_INFO,
12326 FL("status = %d, already disconnected"),
12327 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012328
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012329 }
12330 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012331 {
12332 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012333 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012334 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012335 result = -EINVAL;
12336 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012337 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012338 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012339 &pAdapter->disconnect_comp_var,
12340 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012341 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012342 {
12343 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012344 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012345 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012346 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012347 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012348 {
12349 hddLog(VOS_TRACE_LEVEL_ERROR,
12350 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012351 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012352 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012353disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012354 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12355 FL("Set HDD connState to eConnectionState_NotConnected"));
12356 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
12357
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012358 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012359 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012360}
12361
12362
12363/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012364 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070012365 * This function is used to issue a disconnect request to SME
12366 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012367static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012368 struct net_device *dev,
12369 u16 reason
12370 )
12371{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012372 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012373 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012374 tCsrRoamProfile *pRoamProfile;
12375 hdd_station_ctx_t *pHddStaCtx;
12376 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012377#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012378 tANI_U8 staIdx;
12379#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012380
Jeff Johnson295189b2012-06-20 16:38:30 -070012381 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012382
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012383 if (!pAdapter) {
12384 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
12385 return -EINVAL;
12386 }
12387
12388 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12389 if (!pHddStaCtx) {
12390 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
12391 return -EINVAL;
12392 }
12393
12394 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12395 status = wlan_hdd_validate_context(pHddCtx);
12396 if (0 != status)
12397 {
12398 return status;
12399 }
12400
12401 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
12402
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012403 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12404 TRACE_CODE_HDD_CFG80211_DISCONNECT,
12405 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012406 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
12407 __func__, hdd_device_modetoString(pAdapter->device_mode),
12408 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012409
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012410 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
12411 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070012412
Jeff Johnson295189b2012-06-20 16:38:30 -070012413 if (NULL != pRoamProfile)
12414 {
12415 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012416 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
12417 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070012418 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012419 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070012420 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012421 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012422 switch(reason)
12423 {
12424 case WLAN_REASON_MIC_FAILURE:
12425 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
12426 break;
12427
12428 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
12429 case WLAN_REASON_DISASSOC_AP_BUSY:
12430 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
12431 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
12432 break;
12433
12434 case WLAN_REASON_PREV_AUTH_NOT_VALID:
12435 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053012436 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070012437 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
12438 break;
12439
Jeff Johnson295189b2012-06-20 16:38:30 -070012440 default:
12441 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
12442 break;
12443 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012444 pScanInfo = &pHddCtx->scan_info;
12445 if (pScanInfo->mScanPending)
12446 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012447 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012448 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053012449 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012450 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012451 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012452
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012453#ifdef FEATURE_WLAN_TDLS
12454 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012455 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012456 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012457 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
12458 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012459 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012460 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012461 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012463 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012464 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012465 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012466 status = sme_DeleteTdlsPeerSta(
12467 WLAN_HDD_GET_HAL_CTX(pAdapter),
12468 pAdapter->sessionId,
12469 mac);
12470 if (status != eHAL_STATUS_SUCCESS) {
12471 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
12472 return -EPERM;
12473 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012474 }
12475 }
12476#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012477 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012478 status = wlan_hdd_disconnect(pAdapter, reasonCode);
12479 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070012480 {
12481 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012482 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012483 __func__, (int)status );
12484 return -EINVAL;
12485 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012486 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012487 else
12488 {
12489 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
12490 "called while in %d state", __func__,
12491 pHddStaCtx->conn_info.connState);
12492 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012493 }
12494 else
12495 {
12496 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
12497 }
12498
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012499 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012500 return status;
12501}
12502
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012503static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
12504 struct net_device *dev,
12505 u16 reason
12506 )
12507{
12508 int ret;
12509 vos_ssr_protect(__func__);
12510 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
12511 vos_ssr_unprotect(__func__);
12512
12513 return ret;
12514}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012515
Jeff Johnson295189b2012-06-20 16:38:30 -070012516/*
12517 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012518 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012519 * settings in IBSS mode.
12520 */
12521static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012522 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012523 struct cfg80211_ibss_params *params
12524 )
12525{
12526 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012527 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012528 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
12529 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012530
Jeff Johnson295189b2012-06-20 16:38:30 -070012531 ENTER();
12532
12533 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070012534 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070012535
12536 if (params->ie_len && ( NULL != params->ie) )
12537 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012538 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12539 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012540 {
12541 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12542 encryptionType = eCSR_ENCRYPT_TYPE_AES;
12543 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012544 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012545 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012546 tDot11fIEWPA dot11WPAIE;
12547 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012548 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012549
Wilson Yang00256342013-10-10 23:13:38 -070012550 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012551 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12552 params->ie_len, DOT11F_EID_WPA);
12553 if ( NULL != ie )
12554 {
12555 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12556 // Unpack the WPA IE
12557 //Skip past the EID byte and length byte - and four byte WiFi OUI
12558 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
12559 &ie[2+4],
12560 ie[1] - 4,
12561 &dot11WPAIE);
12562 /*Extract the multicast cipher, the encType for unicast
12563 cipher for wpa-none is none*/
12564 encryptionType =
12565 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
12566 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012567 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012568
Jeff Johnson295189b2012-06-20 16:38:30 -070012569 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
12570
12571 if (0 > status)
12572 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012573 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 __func__);
12575 return status;
12576 }
12577 }
12578
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012579 pWextState->roamProfile.AuthType.authType[0] =
12580 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012581 eCSR_AUTH_TYPE_OPEN_SYSTEM;
12582
12583 if (params->privacy)
12584 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012585 /* Security enabled IBSS, At this time there is no information available
12586 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070012587 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012588 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070012589 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012590 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070012591 *enable privacy bit in beacons */
12592
12593 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
12594 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012595 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
12596 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012597 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
12598 pWextState->roamProfile.EncryptionType.numEntries = 1;
12599 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012600 return status;
12601}
12602
12603/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012604 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012605 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012606 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012607static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012608 struct net_device *dev,
12609 struct cfg80211_ibss_params *params
12610 )
12611{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012612 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012613 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12614 tCsrRoamProfile *pRoamProfile;
12615 int status;
krunal sonie9002db2013-11-25 14:24:17 -080012616 bool alloc_bssid = VOS_FALSE;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012617 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12618 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012619
12620 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012621
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012622 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12623 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
12624 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012625 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012626 "%s: device_mode = %s (%d)", __func__,
12627 hdd_device_modetoString(pAdapter->device_mode),
12628 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012629
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012630 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012631 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012632 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012633 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012634 }
12635
12636 if (NULL == pWextState)
12637 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012638 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012639 __func__);
12640 return -EIO;
12641 }
12642
Agarwal Ashish51325b52014-06-16 16:50:49 +053012643 if (vos_max_concurrent_connections_reached()) {
12644 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12645 return -ECONNREFUSED;
12646 }
12647
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012648 /*Try disconnecting if already in connected state*/
12649 status = wlan_hdd_try_disconnect(pAdapter);
12650 if ( 0 > status)
12651 {
12652 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12653 " IBSS connection"));
12654 return -EALREADY;
12655 }
12656
Jeff Johnson295189b2012-06-20 16:38:30 -070012657 pRoamProfile = &pWextState->roamProfile;
12658
12659 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
12660 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012661 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012662 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012663 return -EINVAL;
12664 }
12665
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012666 /* BSSID is provided by upper layers hence no need to AUTO generate */
12667 if (NULL != params->bssid) {
12668 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12669 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
12670 hddLog (VOS_TRACE_LEVEL_ERROR,
12671 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12672 return -EIO;
12673 }
12674 }
krunal sonie9002db2013-11-25 14:24:17 -080012675 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
12676 {
12677 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12678 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
12679 {
12680 hddLog (VOS_TRACE_LEVEL_ERROR,
12681 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12682 return -EIO;
12683 }
Sachin Ahuja46ff4912015-03-23 22:48:43 +053012684 params->bssid = vos_mem_malloc(VOS_MAC_ADDR_SIZE);
krunal sonie9002db2013-11-25 14:24:17 -080012685 if (!params->bssid)
12686 {
12687 hddLog (VOS_TRACE_LEVEL_ERROR,
12688 "%s:Failed memory allocation", __func__);
12689 return -EIO;
12690 }
12691 vos_mem_copy((v_U8_t *)params->bssid,
12692 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
12693 VOS_MAC_ADDR_SIZE);
12694 alloc_bssid = VOS_TRUE;
12695 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012696
Jeff Johnson295189b2012-06-20 16:38:30 -070012697 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070012698 if (NULL !=
12699#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12700 params->chandef.chan)
12701#else
12702 params->channel)
12703#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012704 {
12705 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012706 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12707 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
12708 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12709 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012710
12711 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012712 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070012713 ieee80211_frequency_to_channel(
12714#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12715 params->chandef.chan->center_freq);
12716#else
12717 params->channel->center_freq);
12718#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012719
12720 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
12721 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070012722 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012723 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
12724 __func__);
12725 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070012726 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012727
12728 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012729 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012730 if (channelNum == validChan[indx])
12731 {
12732 break;
12733 }
12734 }
12735 if (indx >= numChans)
12736 {
12737 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012738 __func__, channelNum);
12739 return -EINVAL;
12740 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012741 /* Set the Operational Channel */
12742 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
12743 channelNum);
12744 pRoamProfile->ChannelInfo.numOfChannels = 1;
12745 pHddStaCtx->conn_info.operationChannel = channelNum;
12746 pRoamProfile->ChannelInfo.ChannelList =
12747 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070012748 }
12749
12750 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012751 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070012752 if (status < 0)
12753 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012754 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070012755 __func__);
12756 return status;
12757 }
12758
12759 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012760 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012761 params->ssid_len, params->bssid,
12762 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070012763
12764 if (0 > status)
12765 {
12766 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
12767 return status;
12768 }
12769
krunal sonie9002db2013-11-25 14:24:17 -080012770 if (NULL != params->bssid &&
12771 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
12772 alloc_bssid == VOS_TRUE)
12773 {
12774 vos_mem_free(params->bssid);
12775 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012776 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012777 return 0;
12778}
12779
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012780static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
12781 struct net_device *dev,
12782 struct cfg80211_ibss_params *params
12783 )
12784{
12785 int ret = 0;
12786
12787 vos_ssr_protect(__func__);
12788 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
12789 vos_ssr_unprotect(__func__);
12790
12791 return ret;
12792}
12793
Jeff Johnson295189b2012-06-20 16:38:30 -070012794/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012795 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012796 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012797 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012798static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012799 struct net_device *dev
12800 )
12801{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012802 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012803 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12804 tCsrRoamProfile *pRoamProfile;
12805 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012806 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012807
12808 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012809
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012810 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12811 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
12812 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012813 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012814 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012815 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012816 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012817 }
12818
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012819 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
12820 hdd_device_modetoString(pAdapter->device_mode),
12821 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012822 if (NULL == pWextState)
12823 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012824 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012825 __func__);
12826 return -EIO;
12827 }
12828
12829 pRoamProfile = &pWextState->roamProfile;
12830
12831 /* Issue disconnect only if interface type is set to IBSS */
12832 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
12833 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012834 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070012835 __func__);
12836 return -EINVAL;
12837 }
12838
12839 /* Issue Disconnect request */
12840 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12841 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
12842 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
12843
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012844 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012845 return 0;
12846}
12847
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012848static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
12849 struct net_device *dev
12850 )
12851{
12852 int ret = 0;
12853
12854 vos_ssr_protect(__func__);
12855 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
12856 vos_ssr_unprotect(__func__);
12857
12858 return ret;
12859}
12860
Jeff Johnson295189b2012-06-20 16:38:30 -070012861/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012862 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070012863 * This function is used to set the phy parameters
12864 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
12865 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012866static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012867 u32 changed)
12868{
12869 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
12870 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012871 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012872
12873 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012874
12875 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012876 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
12877 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012878
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012879 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012880 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012881 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012882 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012883 }
12884
Jeff Johnson295189b2012-06-20 16:38:30 -070012885 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
12886 {
12887 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
12888 WNI_CFG_RTS_THRESHOLD_STAMAX :
12889 wiphy->rts_threshold;
12890
12891 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012892 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070012893 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012894 hddLog(VOS_TRACE_LEVEL_ERROR,
12895 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012896 __func__, rts_threshold);
12897 return -EINVAL;
12898 }
12899
12900 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
12901 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012902 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012903 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012904 hddLog(VOS_TRACE_LEVEL_ERROR,
12905 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012906 __func__, rts_threshold);
12907 return -EIO;
12908 }
12909
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012910 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012911 rts_threshold);
12912 }
12913
12914 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
12915 {
12916 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
12917 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
12918 wiphy->frag_threshold;
12919
12920 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012921 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012922 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012923 hddLog(VOS_TRACE_LEVEL_ERROR,
12924 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012925 frag_threshold);
12926 return -EINVAL;
12927 }
12928
12929 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
12930 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012931 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012932 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012933 hddLog(VOS_TRACE_LEVEL_ERROR,
12934 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012935 __func__, frag_threshold);
12936 return -EIO;
12937 }
12938
12939 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
12940 frag_threshold);
12941 }
12942
12943 if ((changed & WIPHY_PARAM_RETRY_SHORT)
12944 || (changed & WIPHY_PARAM_RETRY_LONG))
12945 {
12946 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
12947 wiphy->retry_short :
12948 wiphy->retry_long;
12949
12950 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
12951 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
12952 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012953 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012954 __func__, retry_value);
12955 return -EINVAL;
12956 }
12957
12958 if (changed & WIPHY_PARAM_RETRY_SHORT)
12959 {
12960 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
12961 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012962 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012963 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012964 hddLog(VOS_TRACE_LEVEL_ERROR,
12965 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012966 __func__, retry_value);
12967 return -EIO;
12968 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012969 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012970 __func__, retry_value);
12971 }
12972 else if (changed & WIPHY_PARAM_RETRY_SHORT)
12973 {
12974 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
12975 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012976 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012977 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012978 hddLog(VOS_TRACE_LEVEL_ERROR,
12979 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012980 __func__, retry_value);
12981 return -EIO;
12982 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012983 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012984 __func__, retry_value);
12985 }
12986 }
12987
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012988 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012989 return 0;
12990}
12991
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012992static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
12993 u32 changed)
12994{
12995 int ret;
12996
12997 vos_ssr_protect(__func__);
12998 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
12999 vos_ssr_unprotect(__func__);
13000
13001 return ret;
13002}
13003
Jeff Johnson295189b2012-06-20 16:38:30 -070013004/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013005 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013006 * This function is used to set the txpower
13007 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013008static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013009#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13010 struct wireless_dev *wdev,
13011#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013012#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013013 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013014#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013015 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013016#endif
13017 int dbm)
13018{
13019 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013020 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013021 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
13022 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013023 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013024
13025 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013026
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013027 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13028 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
13029 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013030 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013031 if (0 != status)
13032 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013033 return status;
13034 }
13035
13036 hHal = pHddCtx->hHal;
13037
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013038 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
13039 dbm, ccmCfgSetCallback,
13040 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013041 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013042 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013043 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
13044 return -EIO;
13045 }
13046
13047 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
13048 dbm);
13049
13050 switch(type)
13051 {
13052 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
13053 /* Fall through */
13054 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
13055 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
13056 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013057 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
13058 __func__);
13059 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070013060 }
13061 break;
13062 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013063 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070013064 __func__);
13065 return -EOPNOTSUPP;
13066 break;
13067 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013068 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
13069 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070013070 return -EIO;
13071 }
13072
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013073 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013074 return 0;
13075}
13076
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013077static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
13078#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13079 struct wireless_dev *wdev,
13080#endif
13081#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13082 enum tx_power_setting type,
13083#else
13084 enum nl80211_tx_power_setting type,
13085#endif
13086 int dbm)
13087{
13088 int ret;
13089 vos_ssr_protect(__func__);
13090 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
13091#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13092 wdev,
13093#endif
13094#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13095 type,
13096#else
13097 type,
13098#endif
13099 dbm);
13100 vos_ssr_unprotect(__func__);
13101
13102 return ret;
13103}
13104
Jeff Johnson295189b2012-06-20 16:38:30 -070013105/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013106 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013107 * This function is used to read the txpower
13108 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013109static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013110#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13111 struct wireless_dev *wdev,
13112#endif
13113 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070013114{
13115
13116 hdd_adapter_t *pAdapter;
13117 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013118 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013119
Jeff Johnsone7245742012-09-05 17:12:55 -070013120 ENTER();
13121
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013122 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013123 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013124 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013125 *dbm = 0;
13126 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013127 }
13128
Jeff Johnson295189b2012-06-20 16:38:30 -070013129 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
13130 if (NULL == pAdapter)
13131 {
13132 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
13133 return -ENOENT;
13134 }
13135
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053013136 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13137 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
13138 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070013139 wlan_hdd_get_classAstats(pAdapter);
13140 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
13141
Jeff Johnsone7245742012-09-05 17:12:55 -070013142 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013143 return 0;
13144}
13145
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013146static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
13147#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13148 struct wireless_dev *wdev,
13149#endif
13150 int *dbm)
13151{
13152 int ret;
13153
13154 vos_ssr_protect(__func__);
13155 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
13156#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13157 wdev,
13158#endif
13159 dbm);
13160 vos_ssr_unprotect(__func__);
13161
13162 return ret;
13163}
13164
13165
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013166static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070013167 u8* mac, struct station_info *sinfo)
13168{
13169 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13170 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13171 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053013172 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013173
13174 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
13175 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070013176
13177 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
13178 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
13179 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
13180 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
13181 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
13182 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
13183 tANI_U16 maxRate = 0;
13184 tANI_U16 myRate;
13185 tANI_U16 currentRate = 0;
13186 tANI_U8 maxSpeedMCS = 0;
13187 tANI_U8 maxMCSIdx = 0;
13188 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053013189 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013190 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013191 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013192
Leo Chang6f8870f2013-03-26 18:11:36 -070013193#ifdef WLAN_FEATURE_11AC
13194 tANI_U32 vht_mcs_map;
13195 eDataRate11ACMaxMcs vhtMaxMcs;
13196#endif /* WLAN_FEATURE_11AC */
13197
Jeff Johnsone7245742012-09-05 17:12:55 -070013198 ENTER();
13199
Jeff Johnson295189b2012-06-20 16:38:30 -070013200 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
13201 (0 == ssidlen))
13202 {
13203 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
13204 " Invalid ssidlen, %d", __func__, ssidlen);
13205 /*To keep GUI happy*/
13206 return 0;
13207 }
13208
Mukul Sharma811205f2014-07-09 21:07:30 +053013209 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
13210 {
13211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13212 "%s: Roaming in progress, so unable to proceed this request", __func__);
13213 return 0;
13214 }
13215
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013216 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013217 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013218 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013219 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013220 }
13221
Jeff Johnson295189b2012-06-20 16:38:30 -070013222
Kiet Lam3b17fc82013-09-27 05:24:08 +053013223 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
13224 sinfo->filled |= STATION_INFO_SIGNAL;
13225
c_hpothu09f19542014-05-30 21:53:31 +053013226 wlan_hdd_get_station_stats(pAdapter);
13227 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
13228
13229 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053013230 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
13231 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053013232 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053013233 {
13234 rate_flags = pAdapter->maxRateFlags;
13235 }
c_hpothu44ff4e02014-05-08 00:13:57 +053013236
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 //convert to the UI units of 100kbps
13238 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
13239
13240#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070013241 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 -070013242 sinfo->signal,
13243 pCfg->reportMaxLinkSpeed,
13244 myRate,
13245 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013246 (int) pCfg->linkSpeedRssiMid,
13247 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070013248 (int) rate_flags,
13249 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013250#endif //LINKSPEED_DEBUG_ENABLED
13251
13252 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
13253 {
13254 // we do not want to necessarily report the current speed
13255 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
13256 {
13257 // report the max possible speed
13258 rssidx = 0;
13259 }
13260 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
13261 {
13262 // report the max possible speed with RSSI scaling
13263 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
13264 {
13265 // report the max possible speed
13266 rssidx = 0;
13267 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013268 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070013269 {
13270 // report middle speed
13271 rssidx = 1;
13272 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013273 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
13274 {
13275 // report middle speed
13276 rssidx = 2;
13277 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013278 else
13279 {
13280 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013281 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070013282 }
13283 }
13284 else
13285 {
13286 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
13287 hddLog(VOS_TRACE_LEVEL_ERROR,
13288 "%s: Invalid value for reportMaxLinkSpeed: %u",
13289 __func__, pCfg->reportMaxLinkSpeed);
13290 rssidx = 0;
13291 }
13292
13293 maxRate = 0;
13294
13295 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013296 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
13297 OperationalRates, &ORLeng))
13298 {
13299 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13300 /*To keep GUI happy*/
13301 return 0;
13302 }
13303
Jeff Johnson295189b2012-06-20 16:38:30 -070013304 for (i = 0; i < ORLeng; i++)
13305 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013306 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013307 {
13308 /* Validate Rate Set */
13309 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
13310 {
13311 currentRate = supported_data_rate[j].supported_rate[rssidx];
13312 break;
13313 }
13314 }
13315 /* Update MAX rate */
13316 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13317 }
13318
13319 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013320 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
13321 ExtendedRates, &ERLeng))
13322 {
13323 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13324 /*To keep GUI happy*/
13325 return 0;
13326 }
13327
Jeff Johnson295189b2012-06-20 16:38:30 -070013328 for (i = 0; i < ERLeng; i++)
13329 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013330 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013331 {
13332 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
13333 {
13334 currentRate = supported_data_rate[j].supported_rate[rssidx];
13335 break;
13336 }
13337 }
13338 /* Update MAX rate */
13339 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13340 }
c_hpothu79aab322014-07-14 21:11:01 +053013341
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013342 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053013343 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013344 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053013345 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070013346 {
c_hpothu79aab322014-07-14 21:11:01 +053013347 if (rate_flags & eHAL_TX_RATE_VHT80)
13348 mode = 2;
13349 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
13350 mode = 1;
13351 else
13352 mode = 0;
13353
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013354 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
13355 MCSRates, &MCSLeng))
13356 {
13357 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13358 /*To keep GUI happy*/
13359 return 0;
13360 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013361 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070013362#ifdef WLAN_FEATURE_11AC
13363 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013364 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070013365 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013366 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013367 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070013368 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070013369 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013370 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013371 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013372 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070013373 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013374 maxMCSIdx = 7;
13375 }
13376 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
13377 {
13378 maxMCSIdx = 8;
13379 }
13380 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
13381 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013382 //VHT20 is supporting 0~8
13383 if (rate_flags & eHAL_TX_RATE_VHT20)
13384 maxMCSIdx = 8;
13385 else
13386 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070013387 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013388
c_hpothu79aab322014-07-14 21:11:01 +053013389 if (0 != rssidx)/*check for scaled */
13390 {
13391 //get middle rate MCS index if rssi=1/2
13392 for (i=0; i <= maxMCSIdx; i++)
13393 {
13394 if (sinfo->signal <= rssiMcsTbl[mode][i])
13395 {
13396 maxMCSIdx = i;
13397 break;
13398 }
13399 }
13400 }
13401
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013402 if (rate_flags & eHAL_TX_RATE_VHT80)
13403 {
13404 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
13405 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
13406 }
13407 else if (rate_flags & eHAL_TX_RATE_VHT40)
13408 {
13409 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
13410 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
13411 }
13412 else if (rate_flags & eHAL_TX_RATE_VHT20)
13413 {
13414 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
13415 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
13416 }
13417
Leo Chang6f8870f2013-03-26 18:11:36 -070013418 maxSpeedMCS = 1;
13419 if (currentRate > maxRate)
13420 {
13421 maxRate = currentRate;
13422 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013423
Leo Chang6f8870f2013-03-26 18:11:36 -070013424 }
13425 else
13426#endif /* WLAN_FEATURE_11AC */
13427 {
13428 if (rate_flags & eHAL_TX_RATE_HT40)
13429 {
13430 rateFlag |= 1;
13431 }
13432 if (rate_flags & eHAL_TX_RATE_SGI)
13433 {
13434 rateFlag |= 2;
13435 }
13436
Girish Gowli01abcee2014-07-31 20:18:55 +053013437 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053013438 if (rssidx == 1 || rssidx == 2)
13439 {
13440 //get middle rate MCS index if rssi=1/2
13441 for (i=0; i <= 7; i++)
13442 {
13443 if (sinfo->signal <= rssiMcsTbl[mode][i])
13444 {
13445 temp = i+1;
13446 break;
13447 }
13448 }
13449 }
c_hpothu79aab322014-07-14 21:11:01 +053013450
13451 for (i = 0; i < MCSLeng; i++)
13452 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013453 for (j = 0; j < temp; j++)
13454 {
13455 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
13456 {
13457 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013458 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013459 break;
13460 }
13461 }
13462 if ((j < temp) && (currentRate > maxRate))
13463 {
13464 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070013465 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013466 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013467 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013468 }
13469 }
13470
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013471 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
13472 {
13473 maxRate = myRate;
13474 maxSpeedMCS = 1;
13475 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13476 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013477 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053013478 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070013479 {
13480 maxRate = myRate;
13481 if (rate_flags & eHAL_TX_RATE_LEGACY)
13482 {
13483 maxSpeedMCS = 0;
13484 }
13485 else
13486 {
13487 maxSpeedMCS = 1;
13488 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13489 }
13490 }
13491
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013492 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070013493 {
13494 sinfo->txrate.legacy = maxRate;
13495#ifdef LINKSPEED_DEBUG_ENABLED
13496 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
13497#endif //LINKSPEED_DEBUG_ENABLED
13498 }
13499 else
13500 {
13501 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070013502#ifdef WLAN_FEATURE_11AC
13503 sinfo->txrate.nss = 1;
13504 if (rate_flags & eHAL_TX_RATE_VHT80)
13505 {
13506 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013507 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070013508 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013509 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070013510 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013511 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13512 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13513 }
13514 else if (rate_flags & eHAL_TX_RATE_VHT20)
13515 {
13516 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13517 }
13518#endif /* WLAN_FEATURE_11AC */
13519 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
13520 {
13521 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13522 if (rate_flags & eHAL_TX_RATE_HT40)
13523 {
13524 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13525 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013526 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013527 if (rate_flags & eHAL_TX_RATE_SGI)
13528 {
13529 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13530 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013531
Jeff Johnson295189b2012-06-20 16:38:30 -070013532#ifdef LINKSPEED_DEBUG_ENABLED
13533 pr_info("Reporting MCS rate %d flags %x\n",
13534 sinfo->txrate.mcs,
13535 sinfo->txrate.flags );
13536#endif //LINKSPEED_DEBUG_ENABLED
13537 }
13538 }
13539 else
13540 {
13541 // report current rate instead of max rate
13542
13543 if (rate_flags & eHAL_TX_RATE_LEGACY)
13544 {
13545 //provide to the UI in units of 100kbps
13546 sinfo->txrate.legacy = myRate;
13547#ifdef LINKSPEED_DEBUG_ENABLED
13548 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
13549#endif //LINKSPEED_DEBUG_ENABLED
13550 }
13551 else
13552 {
13553 //must be MCS
13554 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013555#ifdef WLAN_FEATURE_11AC
13556 sinfo->txrate.nss = 1;
13557 if (rate_flags & eHAL_TX_RATE_VHT80)
13558 {
13559 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13560 }
13561 else
13562#endif /* WLAN_FEATURE_11AC */
13563 {
13564 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13565 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013566 if (rate_flags & eHAL_TX_RATE_SGI)
13567 {
13568 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13569 }
13570 if (rate_flags & eHAL_TX_RATE_HT40)
13571 {
13572 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13573 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013574#ifdef WLAN_FEATURE_11AC
13575 else if (rate_flags & eHAL_TX_RATE_VHT80)
13576 {
13577 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
13578 }
13579#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070013580#ifdef LINKSPEED_DEBUG_ENABLED
13581 pr_info("Reporting actual MCS rate %d flags %x\n",
13582 sinfo->txrate.mcs,
13583 sinfo->txrate.flags );
13584#endif //LINKSPEED_DEBUG_ENABLED
13585 }
13586 }
13587 sinfo->filled |= STATION_INFO_TX_BITRATE;
13588
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013589 sinfo->tx_packets =
13590 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
13591 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
13592 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
13593 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
13594
13595 sinfo->tx_retries =
13596 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
13597 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
13598 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
13599 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
13600
13601 sinfo->tx_failed =
13602 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
13603 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
13604 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
13605 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
13606
13607 sinfo->filled |=
13608 STATION_INFO_TX_PACKETS |
13609 STATION_INFO_TX_RETRIES |
13610 STATION_INFO_TX_FAILED;
13611
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013612 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13613 TRACE_CODE_HDD_CFG80211_GET_STA,
13614 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013615 EXIT();
13616 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013617}
13618
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013619static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13620 u8* mac, struct station_info *sinfo)
13621{
13622 int ret;
13623
13624 vos_ssr_protect(__func__);
13625 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
13626 vos_ssr_unprotect(__func__);
13627
13628 return ret;
13629}
13630
13631static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070013632 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070013633{
13634 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013635 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013636 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013637 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013638
Jeff Johnsone7245742012-09-05 17:12:55 -070013639 ENTER();
13640
Jeff Johnson295189b2012-06-20 16:38:30 -070013641 if (NULL == pAdapter)
13642 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013643 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013644 return -ENODEV;
13645 }
13646
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013647 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13648 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
13649 pAdapter->sessionId, timeout));
13650
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013651 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013652 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013653 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013654 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013655 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013656 }
13657
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013658 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
13659 (TRUE == pHddCtx->hdd_wlan_suspended) &&
13660 (pHddCtx->cfg_ini->fhostArpOffload) &&
13661 (eConnectionState_Associated ==
13662 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13663 {
Amar Singhald53568e2013-09-26 11:03:45 -070013664
13665 hddLog(VOS_TRACE_LEVEL_INFO,
13666 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053013667 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013668 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13669 {
13670 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013671 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013672 __func__, vos_status);
13673 }
13674 }
13675
Jeff Johnson295189b2012-06-20 16:38:30 -070013676 /**The get power cmd from the supplicant gets updated by the nl only
13677 *on successful execution of the function call
13678 *we are oppositely mapped w.r.t mode in the driver
13679 **/
13680 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
13681
13682 if (VOS_STATUS_E_FAILURE == vos_status)
13683 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013684 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13685 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013686 return -EINVAL;
13687 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013688 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013689 return 0;
13690}
13691
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013692static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
13693 struct net_device *dev, bool mode, int timeout)
13694{
13695 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013696
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013697 vos_ssr_protect(__func__);
13698 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
13699 vos_ssr_unprotect(__func__);
13700
13701 return ret;
13702}
Jeff Johnson295189b2012-06-20 16:38:30 -070013703#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013704static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
13705 struct net_device *netdev,
13706 u8 key_index)
13707{
13708 ENTER();
13709 return 0;
13710}
13711
Jeff Johnson295189b2012-06-20 16:38:30 -070013712static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013713 struct net_device *netdev,
13714 u8 key_index)
13715{
13716 int ret;
13717 vos_ssr_protect(__func__);
13718 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
13719 vos_ssr_unprotect(__func__);
13720 return ret;
13721}
13722#endif //LINUX_VERSION_CODE
13723
13724#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13725static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13726 struct net_device *dev,
13727 struct ieee80211_txq_params *params)
13728{
13729 ENTER();
13730 return 0;
13731}
13732#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13733static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13734 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013735{
Jeff Johnsone7245742012-09-05 17:12:55 -070013736 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070013737 return 0;
13738}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013739#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070013740
13741#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13742static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013743 struct net_device *dev,
13744 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013745{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013746 int ret;
13747
13748 vos_ssr_protect(__func__);
13749 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
13750 vos_ssr_unprotect(__func__);
13751 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013752}
13753#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13754static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
13755 struct ieee80211_txq_params *params)
13756{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013757 int ret;
13758
13759 vos_ssr_protect(__func__);
13760 ret = __wlan_hdd_set_txq_params(wiphy, params);
13761 vos_ssr_unprotect(__func__);
13762 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013763}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013764#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013765
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013766static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013767 struct net_device *dev,
13768 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070013769{
13770 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013771 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013772 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013773 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013774 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013775 v_CONTEXT_t pVosContext = NULL;
13776 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013777
Jeff Johnsone7245742012-09-05 17:12:55 -070013778 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013779
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013780 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070013781 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013782 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 return -EINVAL;
13784 }
13785
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013786 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13787 TRACE_CODE_HDD_CFG80211_DEL_STA,
13788 pAdapter->sessionId, pAdapter->device_mode));
13789
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013790 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13791 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013792 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013793 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013794 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013795 }
13796
Jeff Johnson295189b2012-06-20 16:38:30 -070013797 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013798 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013799 )
13800 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013801 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13802 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13803 if(pSapCtx == NULL){
13804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13805 FL("psapCtx is NULL"));
13806 return -ENOENT;
13807 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013808 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070013809 {
13810 v_U16_t i;
13811 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
13812 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013813 if ((pSapCtx->aStaInfo[i].isUsed) &&
13814 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013816 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013817 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013818 ETHER_ADDR_LEN);
13819
Jeff Johnson295189b2012-06-20 16:38:30 -070013820 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013821 "%s: Delete STA with MAC::"
13822 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013823 __func__,
13824 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
13825 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070013826 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013827 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013828 }
13829 }
13830 }
13831 else
13832 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013833
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013834 vos_status = hdd_softap_GetStaId(pAdapter,
13835 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013836 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13837 {
13838 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013839 "%s: Skip this DEL STA as this is not used::"
13840 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013841 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013842 return -ENOENT;
13843 }
13844
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013845 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013846 {
13847 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013848 "%s: Skip this DEL STA as deauth is in progress::"
13849 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013850 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013851 return -ENOENT;
13852 }
13853
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013854 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013855
Jeff Johnson295189b2012-06-20 16:38:30 -070013856 hddLog(VOS_TRACE_LEVEL_INFO,
13857 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013858 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013859 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013860 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013861
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013862 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013863 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13864 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013865 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013866 hddLog(VOS_TRACE_LEVEL_INFO,
13867 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013868 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013869 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013870 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013871 return -ENOENT;
13872 }
13873
Jeff Johnson295189b2012-06-20 16:38:30 -070013874 }
13875 }
13876
13877 EXIT();
13878
13879 return 0;
13880}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013881
13882#ifdef CFG80211_DEL_STA_V2
13883static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13884 struct net_device *dev,
13885 struct station_del_parameters *param)
13886#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013887static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13888 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013889#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013890{
13891 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013892 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070013893
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013894 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013895
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013896#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013897 if (NULL == param) {
13898 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013899 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013900 return -EINVAL;
13901 }
13902
13903 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
13904 param->subtype, &delStaParams);
13905
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013906#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053013907 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013908 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013909#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013910 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
13911
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013912 vos_ssr_unprotect(__func__);
13913
13914 return ret;
13915}
13916
13917static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013918 struct net_device *dev, u8 *mac, struct station_parameters *params)
13919{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013920 hdd_adapter_t *pAdapter;
13921 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013922 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013923#ifdef FEATURE_WLAN_TDLS
13924 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013925
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013926 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013927
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013928 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13929 if (NULL == pAdapter)
13930 {
13931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13932 "%s: Adapter is NULL",__func__);
13933 return -EINVAL;
13934 }
13935 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13936 status = wlan_hdd_validate_context(pHddCtx);
13937 if (0 != status)
13938 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013939 return status;
13940 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013941
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013942 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13943 TRACE_CODE_HDD_CFG80211_ADD_STA,
13944 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013945 mask = params->sta_flags_mask;
13946
13947 set = params->sta_flags_set;
13948
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053013949 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013950 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
13951 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013952
13953 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
13954 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013955 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013956 }
13957 }
13958#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013959 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013960 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013961}
13962
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013963static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
13964 struct net_device *dev, u8 *mac, struct station_parameters *params)
13965{
13966 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013967
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013968 vos_ssr_protect(__func__);
13969 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
13970 vos_ssr_unprotect(__func__);
13971
13972 return ret;
13973}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013974#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070013975
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013976static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070013977 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013978{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013979 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13980 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013981 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013982 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013983 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013984 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070013985
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013986 ENTER();
13987
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013988 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013989 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013990 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013991 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013992 return -EINVAL;
13993 }
13994
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013995 if (!pmksa) {
13996 hddLog(LOGE, FL("pmksa is NULL"));
13997 return -EINVAL;
13998 }
13999
14000 if (!pmksa->bssid || !pmksa->pmkid) {
14001 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
14002 pmksa->bssid, pmksa->pmkid);
14003 return -EINVAL;
14004 }
14005
14006 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
14007 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14008
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014009 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14010 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014011 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014012 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014013 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014014 }
14015
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014016 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014017 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14018
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014019 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
14020 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014021
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014022 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014023 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014024 &pmk_id, 1, FALSE);
14025
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014026 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14027 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
14028 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014029
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014030 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014031 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014032}
14033
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014034static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
14035 struct cfg80211_pmksa *pmksa)
14036{
14037 int ret;
14038
14039 vos_ssr_protect(__func__);
14040 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
14041 vos_ssr_unprotect(__func__);
14042
14043 return ret;
14044}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014045
Wilson Yang6507c4e2013-10-01 20:11:19 -070014046
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014047static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070014048 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014049{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014050 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14051 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014052 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014053 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014054
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014055 ENTER();
14056
Wilson Yang6507c4e2013-10-01 20:11:19 -070014057 /* Validate pAdapter */
14058 if (NULL == pAdapter)
14059 {
14060 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
14061 return -EINVAL;
14062 }
14063
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014064 if (!pmksa) {
14065 hddLog(LOGE, FL("pmksa is NULL"));
14066 return -EINVAL;
14067 }
14068
14069 if (!pmksa->bssid) {
14070 hddLog(LOGE, FL("pmksa->bssid is NULL"));
14071 return -EINVAL;
14072 }
14073
Kiet Lam98c46a12014-10-31 15:34:57 -070014074 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
14075 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14076
Wilson Yang6507c4e2013-10-01 20:11:19 -070014077 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14078 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014079 if (0 != status)
14080 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014081 return status;
14082 }
14083
14084 /*Retrieve halHandle*/
14085 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14086
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014087 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14088 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
14089 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014090 /* Delete the PMKID CSR cache */
14091 if (eHAL_STATUS_SUCCESS !=
14092 sme_RoamDelPMKIDfromCache(halHandle,
14093 pAdapter->sessionId, pmksa->bssid, FALSE)) {
14094 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
14095 MAC_ADDR_ARRAY(pmksa->bssid));
14096 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014097 }
14098
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014099 EXIT();
14100 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014101}
14102
Wilson Yang6507c4e2013-10-01 20:11:19 -070014103
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014104static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
14105 struct cfg80211_pmksa *pmksa)
14106{
14107 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014108
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014109 vos_ssr_protect(__func__);
14110 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
14111 vos_ssr_unprotect(__func__);
14112
14113 return ret;
14114
14115}
14116
14117static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014118{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014119 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14120 tHalHandle halHandle;
14121 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014122 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014123
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014124 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070014125
14126 /* Validate pAdapter */
14127 if (NULL == pAdapter)
14128 {
14129 hddLog(VOS_TRACE_LEVEL_ERROR,
14130 "%s: Invalid Adapter" ,__func__);
14131 return -EINVAL;
14132 }
14133
14134 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14135 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014136 if (0 != status)
14137 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014138 return status;
14139 }
14140
14141 /*Retrieve halHandle*/
14142 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14143
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014144 /* Flush the PMKID cache in CSR */
14145 if (eHAL_STATUS_SUCCESS !=
14146 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
14147 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
14148 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014149 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014150 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080014151 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014152}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014153
14154static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
14155{
14156 int ret;
14157
14158 vos_ssr_protect(__func__);
14159 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
14160 vos_ssr_unprotect(__func__);
14161
14162 return ret;
14163}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014164#endif
14165
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014166#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014167static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14168 struct net_device *dev,
14169 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014170{
14171 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14172 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014173 hdd_context_t *pHddCtx;
14174 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014175
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014176 ENTER();
14177
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014178 if (NULL == pAdapter)
14179 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014180 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014181 return -ENODEV;
14182 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014183 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14184 ret = wlan_hdd_validate_context(pHddCtx);
14185 if (0 != ret)
14186 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014187 return ret;
14188 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014189 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014190 if (NULL == pHddStaCtx)
14191 {
14192 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
14193 return -EINVAL;
14194 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014195
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014196 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14197 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
14198 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014199 // Added for debug on reception of Re-assoc Req.
14200 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
14201 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014202 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014203 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080014204 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014205 }
14206
14207#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080014208 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014209 ftie->ie_len);
14210#endif
14211
14212 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014213 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14214 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014215 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014216
14217 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014218 return 0;
14219}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014220
14221static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14222 struct net_device *dev,
14223 struct cfg80211_update_ft_ies_params *ftie)
14224{
14225 int ret;
14226
14227 vos_ssr_protect(__func__);
14228 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
14229 vos_ssr_unprotect(__func__);
14230
14231 return ret;
14232}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014233#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014234
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014235#ifdef FEATURE_WLAN_SCAN_PNO
14236
14237void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
14238 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
14239{
14240 int ret;
14241 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
14242 hdd_context_t *pHddCtx;
14243
Nirav Shah80830bf2013-12-31 16:35:12 +053014244 ENTER();
14245
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014246 if (NULL == pAdapter)
14247 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014248 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014249 "%s: HDD adapter is Null", __func__);
14250 return ;
14251 }
14252
14253 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14254 if (NULL == pHddCtx)
14255 {
14256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14257 "%s: HDD context is Null!!!", __func__);
14258 return ;
14259 }
14260
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014261 spin_lock(&pHddCtx->schedScan_lock);
14262 if (TRUE == pHddCtx->isWiphySuspended)
14263 {
14264 pHddCtx->isSchedScanUpdatePending = TRUE;
14265 spin_unlock(&pHddCtx->schedScan_lock);
14266 hddLog(VOS_TRACE_LEVEL_INFO,
14267 "%s: Update cfg80211 scan database after it resume", __func__);
14268 return ;
14269 }
14270 spin_unlock(&pHddCtx->schedScan_lock);
14271
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014272 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
14273
14274 if (0 > ret)
14275 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
14276
14277 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014278 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14279 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014280}
14281
14282/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014283 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014284 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014285 */
14286static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
14287{
14288 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
14289 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014290 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014291 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14292 int status = 0;
14293 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
14294
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014295 /* The current firmware design does not allow PNO during any
14296 * active sessions. Hence, determine the active sessions
14297 * and return a failure.
14298 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014299 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
14300 {
14301 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014302 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014303
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014304 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
14305 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
14306 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
14307 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
14308 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053014309 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014310 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014311 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014312 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014313 }
14314 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14315 pAdapterNode = pNext;
14316 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014317 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014318}
14319
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014320void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
14321{
14322 hdd_adapter_t *pAdapter = callbackContext;
14323 hdd_context_t *pHddCtx;
14324
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014325 ENTER();
14326
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014327 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
14328 {
14329 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14330 FL("Invalid adapter or adapter has invalid magic"));
14331 return;
14332 }
14333
14334 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14335 if (0 != wlan_hdd_validate_context(pHddCtx))
14336 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014337 return;
14338 }
14339
c_hpothub53c45d2014-08-18 16:53:14 +053014340 if (VOS_STATUS_SUCCESS != status)
14341 {
14342 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014343 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053014344 pHddCtx->isPnoEnable = FALSE;
14345 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014346
14347 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
14348 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014349 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014350}
14351
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014352/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014353 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
14354 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014355 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014356static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014357 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14358{
14359 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014360 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014361 hdd_context_t *pHddCtx;
14362 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014363 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053014364 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
14365 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014366 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14367 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014368 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014369 hdd_config_t *pConfig = NULL;
14370 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014371
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014372 ENTER();
14373
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014374 if (NULL == pAdapter)
14375 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014376 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014377 "%s: HDD adapter is Null", __func__);
14378 return -ENODEV;
14379 }
14380
14381 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014382 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014383
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014384 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014385 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014386 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014387 }
14388
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014389 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014390 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14391 if (NULL == hHal)
14392 {
14393 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14394 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014395 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014396 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014397 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14398 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
14399 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053014400 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014401 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053014402 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014403 {
14404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14405 "%s: aborting the existing scan is unsuccessfull", __func__);
14406 return -EBUSY;
14407 }
14408
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014409 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014410 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014412 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014413 return -EBUSY;
14414 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014415
c_hpothu37f21312014-04-09 21:49:54 +053014416 if (TRUE == pHddCtx->isPnoEnable)
14417 {
14418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14419 FL("already PNO is enabled"));
14420 return -EBUSY;
14421 }
c_hpothu225aa7c2014-10-22 17:45:13 +053014422
14423 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
14424 {
14425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14426 "%s: abort ROC failed ", __func__);
14427 return -EBUSY;
14428 }
14429
c_hpothu37f21312014-04-09 21:49:54 +053014430 pHddCtx->isPnoEnable = TRUE;
14431
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014432 pnoRequest.enable = 1; /*Enable PNO */
14433 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014434
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014435 if (( !pnoRequest.ucNetworksCount ) ||
14436 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014437 {
14438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014439 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014440 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014441 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014442 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014443 goto error;
14444 }
14445
14446 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
14447 {
14448 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014449 "%s: Incorrect number of channels %d",
14450 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014451 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014452 goto error;
14453 }
14454
14455 /* Framework provides one set of channels(all)
14456 * common for all saved profile */
14457 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14458 channels_allowed, &num_channels_allowed))
14459 {
14460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14461 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014462 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014463 goto error;
14464 }
14465 /* Checking each channel against allowed channel list */
14466 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053014467 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014468 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014469 char chList [(request->n_channels*5)+1];
14470 int len;
14471 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014472 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014473 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014474 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014475 if (request->channels[i]->hw_value == channels_allowed[indx])
14476 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014477 if ((!pConfig->enableDFSPnoChnlScan) &&
14478 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
14479 {
14480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14481 "%s : Dropping DFS channel : %d",
14482 __func__,channels_allowed[indx]);
14483 num_ignore_dfs_ch++;
14484 break;
14485 }
14486
Nirav Shah80830bf2013-12-31 16:35:12 +053014487 valid_ch[num_ch++] = request->channels[i]->hw_value;
14488 len += snprintf(chList+len, 5, "%d ",
14489 request->channels[i]->hw_value);
14490 break ;
14491 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014492 }
14493 }
Nirav Shah80830bf2013-12-31 16:35:12 +053014494 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014495
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014496 /*If all channels are DFS and dropped, then ignore the PNO request*/
14497 if (num_ignore_dfs_ch == request->n_channels)
14498 {
14499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14500 "%s : All requested channels are DFS channels", __func__);
14501 ret = -EINVAL;
14502 goto error;
14503 }
14504 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014505
14506 pnoRequest.aNetworks =
14507 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14508 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014509 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014510 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14511 FL("failed to allocate memory aNetworks %u"),
14512 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14513 goto error;
14514 }
14515 vos_mem_zero(pnoRequest.aNetworks,
14516 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14517
14518 /* Filling per profile params */
14519 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
14520 {
14521 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014522 request->match_sets[i].ssid.ssid_len;
14523
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014524 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
14525 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014526 {
14527 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014528 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014529 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014530 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014531 goto error;
14532 }
14533
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014534 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014535 request->match_sets[i].ssid.ssid,
14536 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14538 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014539 i, pnoRequest.aNetworks[i].ssId.ssId);
14540 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
14541 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
14542 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014543
14544 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014545 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
14546 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014547
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014548 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014549 }
14550
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014551 for (i = 0; i < request->n_ssids; i++)
14552 {
14553 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014554 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014555 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014556 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014557 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014558 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014559 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014560 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014561 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014562 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014563 break;
14564 }
14565 j++;
14566 }
14567 }
14568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14569 "Number of hidden networks being Configured = %d",
14570 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080014572 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014573
14574 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14575 if (pnoRequest.p24GProbeTemplate == NULL)
14576 {
14577 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14578 FL("failed to allocate memory p24GProbeTemplate %u"),
14579 SIR_PNO_MAX_PB_REQ_SIZE);
14580 goto error;
14581 }
14582
14583 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14584 if (pnoRequest.p5GProbeTemplate == NULL)
14585 {
14586 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14587 FL("failed to allocate memory p5GProbeTemplate %u"),
14588 SIR_PNO_MAX_PB_REQ_SIZE);
14589 goto error;
14590 }
14591
14592 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14593 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14594
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053014595 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
14596 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014597 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014598 pnoRequest.us24GProbeTemplateLen = request->ie_len;
14599 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
14600 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014601
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014602 pnoRequest.us5GProbeTemplateLen = request->ie_len;
14603 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
14604 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014605 }
14606
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014607 /* Driver gets only one time interval which is hardcoded in
14608 * supplicant for 10000ms. Taking power consumption into account 6 timers
14609 * will be used, Timervalue is increased exponentially i.e 10,20,40,
14610 * 80,160,320 secs. And number of scan cycle for each timer
14611 * is configurable through INI param gPNOScanTimerRepeatValue.
14612 * If it is set to 0 only one timer will be used and PNO scan cycle
14613 * will be repeated after each interval specified by supplicant
14614 * till PNO is disabled.
14615 */
14616 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014617 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014618 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014619 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014620 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
14621
14622 tempInterval = (request->interval)/1000;
14623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14624 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
14625 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014626 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014627 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014628 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014629 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014630 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014631 tempInterval *= 2;
14632 }
14633 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014634 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014635
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014636 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014637
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014638 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014639 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
14640 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014641 pAdapter->pno_req_status = 0;
14642
Nirav Shah80830bf2013-12-31 16:35:12 +053014643 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14644 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014645 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
14646 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053014647
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014648 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014649 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014650 hdd_cfg80211_sched_scan_done_callback, pAdapter);
14651 if (eHAL_STATUS_SUCCESS != status)
14652 {
14653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014654 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014655 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014656 goto error;
14657 }
14658
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014659 ret = wait_for_completion_timeout(
14660 &pAdapter->pno_comp_var,
14661 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
14662 if (0 >= ret)
14663 {
14664 // Did not receive the response for PNO enable in time.
14665 // Assuming the PNO enable was success.
14666 // Returning error from here, because we timeout, results
14667 // in side effect of Wifi (Wifi Setting) not to work.
14668 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14669 FL("Timed out waiting for PNO to be Enabled"));
14670 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014671 }
14672
14673 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053014674 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014675
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014676error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014677 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14678 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053014679 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014680 if (pnoRequest.aNetworks)
14681 vos_mem_free(pnoRequest.aNetworks);
14682 if (pnoRequest.p24GProbeTemplate)
14683 vos_mem_free(pnoRequest.p24GProbeTemplate);
14684 if (pnoRequest.p5GProbeTemplate)
14685 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014686
14687 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014688 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014689}
14690
14691/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014692 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
14693 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014694 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014695static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
14696 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14697{
14698 int ret;
14699
14700 vos_ssr_protect(__func__);
14701 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
14702 vos_ssr_unprotect(__func__);
14703
14704 return ret;
14705}
14706
14707/*
14708 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
14709 * Function to disable PNO
14710 */
14711static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014712 struct net_device *dev)
14713{
14714 eHalStatus status = eHAL_STATUS_FAILURE;
14715 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14716 hdd_context_t *pHddCtx;
14717 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014718 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014719 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014720
14721 ENTER();
14722
14723 if (NULL == pAdapter)
14724 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014726 "%s: HDD adapter is Null", __func__);
14727 return -ENODEV;
14728 }
14729
14730 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014731
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014732 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014733 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014734 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014735 "%s: HDD context is Null", __func__);
14736 return -ENODEV;
14737 }
14738
14739 /* The return 0 is intentional when isLogpInProgress and
14740 * isLoadUnloadInProgress. We did observe a crash due to a return of
14741 * failure in sched_scan_stop , especially for a case where the unload
14742 * of the happens at the same time. The function __cfg80211_stop_sched_scan
14743 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
14744 * success. If it returns a failure , then its next invocation due to the
14745 * clean up of the second interface will have the dev pointer corresponding
14746 * to the first one leading to a crash.
14747 */
14748 if (pHddCtx->isLogpInProgress)
14749 {
14750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14751 "%s: LOGP in Progress. Ignore!!!", __func__);
14752 return ret;
14753 }
14754
Mihir Shete18156292014-03-11 15:38:30 +053014755 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014756 {
14757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14758 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14759 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014760 }
14761
14762 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14763 if (NULL == hHal)
14764 {
14765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14766 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014767 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014768 }
14769
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014770 pnoRequest.enable = 0; /* Disable PNO */
14771 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014772
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014773 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14774 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
14775 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014776 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014777 pAdapter->sessionId,
14778 NULL, pAdapter);
14779 if (eHAL_STATUS_SUCCESS != status)
14780 {
14781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14782 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014783 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014784 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014785 }
c_hpothu37f21312014-04-09 21:49:54 +053014786 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014787
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014788error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014789 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014790 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014791
14792 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014793 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014794}
14795
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014796/*
14797 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
14798 * NL interface to disable PNO
14799 */
14800static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
14801 struct net_device *dev)
14802{
14803 int ret;
14804
14805 vos_ssr_protect(__func__);
14806 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
14807 vos_ssr_unprotect(__func__);
14808
14809 return ret;
14810}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014811#endif /*FEATURE_WLAN_SCAN_PNO*/
14812
14813
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014814#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014815#if TDLS_MGMT_VERSION2
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014816static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014817 u8 *peer, u8 action_code, u8 dialog_token,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014818 u16 status_code, u32 peer_capability, const u8 *buf, size_t len)
14819#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014820static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014821 u8 *peer, u8 action_code, u8 dialog_token,
14822 u16 status_code, const u8 *buf, size_t len)
14823#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014824{
14825
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014826 hdd_adapter_t *pAdapter;
14827 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014828 u8 peerMac[6];
14829 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070014830 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080014831 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070014832 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014833 int ret;
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014834#if !(TDLS_MGMT_VERSION2)
14835 u32 peer_capability = 0;
14836#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014837 tANI_U16 numCurrTdlsPeers;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014838
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014839 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14840 if (NULL == pAdapter)
14841 {
14842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14843 "%s: Adapter is NULL",__func__);
14844 return -EINVAL;
14845 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014846 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14847 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
14848 pAdapter->sessionId, action_code));
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014849 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014850 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014851 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014852 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014853 "Invalid arguments");
14854 return -EINVAL;
14855 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014856 if (pHddCtx->isLogpInProgress)
14857 {
14858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14859 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053014860 wlan_hdd_tdls_set_link_status(pAdapter,
14861 peer,
14862 eTDLS_LINK_IDLE,
14863 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014864 return -EBUSY;
14865 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014866 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
14867 {
14868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14869 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14870 return -EAGAIN;
14871 }
Hoonki Lee27511902013-03-14 18:19:06 -070014872 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014873 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014874 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070014875 "%s: TDLS mode is disabled OR not enabled in FW."
14876 MAC_ADDRESS_STR " action %d declined.",
14877 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014878 return -ENOTSUPP;
14879 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014880
Hoonki Lee27511902013-03-14 18:19:06 -070014881 /* other than teardown frame, other mgmt frames are not sent if disabled */
14882 if (SIR_MAC_TDLS_TEARDOWN != action_code)
14883 {
14884 /* if tdls_mode is disabled to respond to peer's request */
14885 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
14886 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014887 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070014888 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014889 " TDLS mode is disabled. action %d declined.",
14890 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070014891
14892 return -ENOTSUPP;
14893 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053014894
14895 if (vos_max_concurrent_connections_reached())
14896 {
14897 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
14898 return -EINVAL;
14899 }
Hoonki Lee27511902013-03-14 18:19:06 -070014900 }
14901
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014902 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
14903 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053014904 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014905 {
14906 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014907 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014908 " TDLS setup is ongoing. action %d declined.",
14909 __func__, MAC_ADDR_ARRAY(peer), action_code);
14910 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014911 }
14912 }
14913
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014914 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
14915 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080014916 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014917 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
14918 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080014919 {
14920 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
14921 we return error code at 'add_station()'. Hence we have this
14922 check again in addtion to add_station().
14923 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014924 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080014925 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014926 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14927 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014928 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
14929 __func__, MAC_ADDR_ARRAY(peer), action_code,
14930 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053014931 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080014932 }
14933 else
14934 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014935 /* maximum reached. tweak to send error code to peer and return
14936 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080014937 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014938 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14939 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014940 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
14941 __func__, MAC_ADDR_ARRAY(peer), status_code,
14942 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070014943 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014944 /* fall through to send setup resp with failure status
14945 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080014946 }
14947 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014948 else
14949 {
14950 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053014951 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014952 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014953 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014954 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014955 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
14956 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014957 return -EPERM;
14958 }
14959 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014960 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014961 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014962
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014963 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053014964 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014965 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
14966 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014967
Hoonki Leea34dd892013-02-05 22:56:02 -080014968 /*Except teardown responder will not be used so just make 0*/
14969 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014970 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080014971 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014972
14973 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053014974 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014975
14976 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
14977 responder = pTdlsPeer->is_responder;
14978 else
Hoonki Leea34dd892013-02-05 22:56:02 -080014979 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014980 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053014981 "%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 -070014982 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
14983 dialog_token, status_code, len);
14984 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080014985 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014986 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014987
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014988 /* For explicit trigger of DIS_REQ come out of BMPS for
14989 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070014990 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014991 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
14992 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070014993 {
14994 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
14995 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014996 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014997 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014998 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
14999 if (status != VOS_STATUS_SUCCESS) {
15000 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
15001 }
Hoonki Lee14621352013-04-16 17:51:19 -070015002 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015003 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
15004 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED)) {
15005 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
15006 }
15007 }
Hoonki Lee14621352013-04-16 17:51:19 -070015008 }
15009
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015010 /* make sure doesn't call send_mgmt() while it is pending */
15011 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
15012 {
15013 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015014 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015015 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015016 ret = -EBUSY;
15017 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015018 }
15019
15020 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015021 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
15022
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015023 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053015024 peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015025
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015026 if (VOS_STATUS_SUCCESS != status)
15027 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015028 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15029 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015030 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015031 ret = -EINVAL;
15032 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015033 }
15034
Hoonki Leed37cbb32013-04-20 00:31:14 -070015035 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
15036 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
15037
15038 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015039 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070015040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070015041 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070015042 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015043 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080015044
15045 if (pHddCtx->isLogpInProgress)
15046 {
15047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15048 "%s: LOGP in Progress. Ignore!!!", __func__);
15049 return -EAGAIN;
15050 }
15051
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015052 ret = -EINVAL;
15053 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015054 }
15055
Gopichand Nakkala05922802013-03-14 12:23:19 -070015056 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070015057 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015058 ret = max_sta_failed;
15059 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070015060 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015061
Hoonki Leea34dd892013-02-05 22:56:02 -080015062 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
15063 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015064 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE)) {
15065 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15066 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015067 }
15068 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
15069 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015070 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE)) {
15071 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15072 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015073 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015074
15075 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015076
15077tx_failed:
15078 /* add_station will be called before sending TDLS_SETUP_REQ and
15079 * TDLS_SETUP_RSP and as part of add_station driver will enable
15080 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
15081 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
15082 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
15083 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
15084 */
15085
15086 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
15087 (SIR_MAC_TDLS_SETUP_RSP == action_code))
15088 wlan_hdd_tdls_check_bmps(pAdapter);
15089 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015090}
15091
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015092#if TDLS_MGMT_VERSION2
15093static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15094 u8 *peer, u8 action_code, u8 dialog_token,
15095 u16 status_code, u32 peer_capability,
15096 const u8 *buf, size_t len)
15097#else
15098static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15099 u8 *peer, u8 action_code, u8 dialog_token,
15100 u16 status_code, const u8 *buf, size_t len)
15101#endif
15102{
15103 int ret;
15104
15105 vos_ssr_protect(__func__);
15106#if TDLS_MGMT_VERSION2
15107 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, dialog_token,
15108 status_code, peer_capability, buf, len);
15109#else
15110 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, dialog_token,
15111 status_code, buf, len);
15112#endif
15113 vos_ssr_unprotect(__func__);
15114
15115 return ret;
15116}
Atul Mittal115287b2014-07-08 13:26:33 +053015117
15118int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
15119 u8 *peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015120 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053015121 cfg80211_exttdls_callback callback)
15122{
15123
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015124 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053015125 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015126 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053015127 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15128 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
15129 __func__, MAC_ADDR_ARRAY(peer));
15130
15131 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15132 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15133
15134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015135 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15136 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15137 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015138 return -ENOTSUPP;
15139 }
15140
15141 /* To cater the requirement of establishing the TDLS link
15142 * irrespective of the data traffic , get an entry of TDLS peer.
15143 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015144 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015145 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
15146 if (pTdlsPeer == NULL) {
15147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15148 "%s: peer " MAC_ADDRESS_STR " not existing",
15149 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015150 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015151 return -EINVAL;
15152 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015153 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015154
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015155 /* check FW TDLS Off Channel capability */
15156 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015157 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015158 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015159 {
15160 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
15161 pTdlsPeer->peerParams.global_operating_class =
15162 tdls_peer_params->global_operating_class;
15163 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
15164 pTdlsPeer->peerParams.min_bandwidth_kbps =
15165 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015166 /* check configured channel is valid, non dfs and
15167 * not current operating channel */
15168 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
15169 tdls_peer_params->channel)) &&
15170 (pHddStaCtx) &&
15171 (tdls_peer_params->channel !=
15172 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015173 {
15174 pTdlsPeer->isOffChannelConfigured = TRUE;
15175 }
15176 else
15177 {
15178 pTdlsPeer->isOffChannelConfigured = FALSE;
15179 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15180 "%s: Configured Tdls Off Channel is not valid", __func__);
15181
15182 }
15183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015184 "%s: tdls_off_channel %d isOffChannelConfigured %d "
15185 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015186 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015187 pTdlsPeer->isOffChannelConfigured,
15188 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015189 }
15190 else
15191 {
15192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015193 "%s: TDLS off channel FW capability %d, "
15194 "host capab %d or Invalid TDLS Peer Params", __func__,
15195 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
15196 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015197 }
15198
Atul Mittal115287b2014-07-08 13:26:33 +053015199 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
15200
15201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15202 " %s TDLS Add Force Peer Failed",
15203 __func__);
15204 return -EINVAL;
15205 }
15206 /*EXT TDLS*/
15207
15208 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
15209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15210 " %s TDLS set callback Failed",
15211 __func__);
15212 return -EINVAL;
15213 }
15214
15215 return(0);
15216
15217}
15218
15219int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter, u8 *peer)
15220{
15221
15222 hddTdlsPeer_t *pTdlsPeer;
15223 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15224 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15225 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
15226 __func__, MAC_ADDR_ARRAY(peer));
15227
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015228 if (0 != wlan_hdd_validate_context(pHddCtx)) {
15229 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
15230 return -EINVAL;
15231 }
15232
Atul Mittal115287b2014-07-08 13:26:33 +053015233 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15234 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15235
15236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015237 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15238 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15239 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015240 return -ENOTSUPP;
15241 }
15242
15243
15244 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15245
15246 if ( NULL == pTdlsPeer ) {
15247 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015248 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053015249 __func__, MAC_ADDR_ARRAY(peer));
15250 return -EINVAL;
15251 }
15252 else {
15253 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
15254 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015255 /* if channel switch is configured, reset
15256 the channel for this peer */
15257 if (TRUE == pTdlsPeer->isOffChannelConfigured)
15258 {
15259 pTdlsPeer->peerParams.channel = 0;
15260 pTdlsPeer->isOffChannelConfigured = FALSE;
15261 }
Atul Mittal115287b2014-07-08 13:26:33 +053015262 }
15263
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015264 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
15265 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053015266 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015267 }
Atul Mittal115287b2014-07-08 13:26:33 +053015268
15269 /*EXT TDLS*/
15270
15271 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
15272
15273 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15274 " %s TDLS set callback Failed",
15275 __func__);
15276 return -EINVAL;
15277 }
15278 return(0);
15279
15280}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015281static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015282 u8 *peer, enum nl80211_tdls_operation oper)
15283{
15284 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15285 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015286 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015287 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015288
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015289 ENTER();
15290
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015291 if (!pAdapter) {
15292 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15293 return -EINVAL;
15294 }
15295
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015296 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15297 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
15298 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015299 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015300 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015301 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070015302 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015303 return -EINVAL;
15304 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015305
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015306 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015307 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015308 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015309 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015310 }
15311
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015312
15313 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015314 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015315 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015316 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015317 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
15318 "Cannot process TDLS commands",
15319 pHddCtx->cfg_ini->fEnableTDLSSupport,
15320 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015321 return -ENOTSUPP;
15322 }
15323
15324 switch (oper) {
15325 case NL80211_TDLS_ENABLE_LINK:
15326 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015327 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015328 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015329 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053015330 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015331 tANI_U16 numCurrTdlsPeers = 0;
15332 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015333 tANI_U8 suppChannelLen = 0;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015334
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15336 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
15337 __func__, MAC_ADDR_ARRAY(peer));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015338 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015339 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015340 if ( NULL == pTdlsPeer ) {
15341 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15342 " (oper %d) not exsting. ignored",
15343 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15344 return -EINVAL;
15345 }
15346
15347 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15348 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15349 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15350 "NL80211_TDLS_ENABLE_LINK");
15351
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070015352 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
15353 {
15354 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
15355 MAC_ADDRESS_STR " failed",
15356 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
15357 return -EINVAL;
15358 }
15359
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015360 /* before starting tdls connection, set tdls
15361 * off channel established status to default value */
15362 pTdlsPeer->isOffChannelEstablished = FALSE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015363 /* TDLS Off Channel, Disable tdls channel switch,
15364 when there are more than one tdls link */
15365 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053015366 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015367 {
15368 /* get connected peer and send disable tdls off chan */
15369 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015370 if ((connPeer) &&
15371 (connPeer->isOffChannelSupported == TRUE) &&
15372 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015373 {
15374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15375 "%s: More then one peer connected, Disable "
15376 "TDLS channel switch", __func__);
15377
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015378 connPeer->isOffChannelEstablished = FALSE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015379 ret = sme_SendTdlsChanSwitchReq(
15380 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015381 pAdapter->sessionId,
15382 connPeer->peerMac,
15383 connPeer->peerParams.channel,
15384 TDLS_OFF_CHANNEL_BW_OFFSET,
15385 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015386 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015387 hddLog(VOS_TRACE_LEVEL_ERROR,
15388 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015389 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015390 }
15391 else
15392 {
15393 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15394 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015395 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015396 "isOffChannelConfigured %d",
15397 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015398 (connPeer ? (connPeer->isOffChannelSupported)
15399 : -1),
15400 (connPeer ? (connPeer->isOffChannelConfigured)
15401 : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015402 }
15403 }
15404
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015405 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015406 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015407 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053015408
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015409 if (0 != wlan_hdd_tdls_get_link_establish_params(
15410 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015411 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015412 return -EINVAL;
15413 }
15414 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015415
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015416 ret = sme_SendTdlsLinkEstablishParams(
15417 WLAN_HDD_GET_HAL_CTX(pAdapter),
15418 pAdapter->sessionId, peer,
15419 &tdlsLinkEstablishParams);
15420 if (ret != VOS_STATUS_SUCCESS) {
15421 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
15422 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015423 /* Send TDLS peer UAPSD capabilities to the firmware and
15424 * register with the TL on after the response for this operation
15425 * is received .
15426 */
15427 ret = wait_for_completion_interruptible_timeout(
15428 &pAdapter->tdls_link_establish_req_comp,
15429 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
15430 if (ret <= 0)
15431 {
15432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015433 FL("Link Establish Request Failed Status %ld"),
15434 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015435 return -EINVAL;
15436 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015437 }
Atul Mittal115287b2014-07-08 13:26:33 +053015438 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15439 eTDLS_LINK_CONNECTED,
15440 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015441 staDesc.ucSTAId = pTdlsPeer->staId;
15442 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015443 ret = WLANTL_UpdateTdlsSTAClient(
15444 pHddCtx->pvosContext,
15445 &staDesc);
15446 if (ret != VOS_STATUS_SUCCESS) {
15447 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
15448 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053015449
Gopichand Nakkala471708b2013-06-04 20:03:01 +053015450 /* Mark TDLS client Authenticated .*/
15451 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
15452 pTdlsPeer->staId,
15453 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015454 if (VOS_STATUS_SUCCESS == status)
15455 {
Hoonki Lee14621352013-04-16 17:51:19 -070015456 if (pTdlsPeer->is_responder == 0)
15457 {
15458 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
15459
15460 wlan_hdd_tdls_timer_restart(pAdapter,
15461 &pTdlsPeer->initiatorWaitTimeoutTimer,
15462 WAIT_TIME_TDLS_INITIATOR);
15463 /* suspend initiator TX until it receives direct packet from the
15464 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015465 ret = WLANTL_SuspendDataTx(
15466 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15467 &staId, NULL);
15468 if (ret != VOS_STATUS_SUCCESS) {
15469 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
15470 }
Hoonki Lee14621352013-04-16 17:51:19 -070015471 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015472
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015473 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015474 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015475 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015476 suppChannelLen =
15477 tdlsLinkEstablishParams.supportedChannelsLen;
15478
15479 if ((suppChannelLen > 0) &&
15480 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
15481 {
15482 tANI_U8 suppPeerChannel = 0;
15483 int i = 0;
15484 for (i = 0U; i < suppChannelLen; i++)
15485 {
15486 suppPeerChannel =
15487 tdlsLinkEstablishParams.supportedChannels[i];
15488
15489 pTdlsPeer->isOffChannelSupported = FALSE;
15490 if (suppPeerChannel ==
15491 pTdlsPeer->peerParams.channel)
15492 {
15493 pTdlsPeer->isOffChannelSupported = TRUE;
15494 break;
15495 }
15496 }
15497 }
15498 else
15499 {
15500 pTdlsPeer->isOffChannelSupported = FALSE;
15501 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015502 }
15503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15504 "%s: TDLS channel switch request for channel "
15505 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015506 "%d isOffChannelSupported %d", __func__,
15507 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015508 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015509 suppChannelLen,
15510 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015511
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015512 /* TDLS Off Channel, Enable tdls channel switch,
15513 when their is only one tdls link and it supports */
15514 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15515 if ((numCurrTdlsPeers == 1) &&
15516 (TRUE == pTdlsPeer->isOffChannelSupported) &&
15517 (TRUE == pTdlsPeer->isOffChannelConfigured))
15518 {
15519 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15520 "%s: Send TDLS channel switch request for channel %d",
15521 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015522
15523 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015524 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
15525 pAdapter->sessionId,
15526 pTdlsPeer->peerMac,
15527 pTdlsPeer->peerParams.channel,
15528 TDLS_OFF_CHANNEL_BW_OFFSET,
15529 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015530 if (ret != VOS_STATUS_SUCCESS) {
15531 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
15532 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015533 }
15534 else
15535 {
15536 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15537 "%s: TDLS channel switch request not sent"
15538 " numCurrTdlsPeers %d "
15539 "isOffChannelSupported %d "
15540 "isOffChannelConfigured %d",
15541 __func__, numCurrTdlsPeers,
15542 pTdlsPeer->isOffChannelSupported,
15543 pTdlsPeer->isOffChannelConfigured);
15544 }
15545
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015546 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015547 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015548
15549 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015550 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
15551 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015552 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015553 int ac;
15554 uint8 ucAc[4] = { WLANTL_AC_VO,
15555 WLANTL_AC_VI,
15556 WLANTL_AC_BK,
15557 WLANTL_AC_BE };
15558 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
15559 for(ac=0; ac < 4; ac++)
15560 {
15561 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15562 pTdlsPeer->staId, ucAc[ac],
15563 tlTid[ac], tlTid[ac], 0, 0,
15564 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015565 if (status != VOS_STATUS_SUCCESS) {
15566 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
15567 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015568 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015569 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015570 }
15571
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015572 }
15573 break;
15574 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080015575 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015576 tANI_U16 numCurrTdlsPeers = 0;
15577 hddTdlsPeer_t *connPeer = NULL;
15578
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15580 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
15581 __func__, MAC_ADDR_ARRAY(peer));
15582
Sunil Dutt41de4e22013-11-14 18:09:02 +053015583 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15584
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015585
Sunil Dutt41de4e22013-11-14 18:09:02 +053015586 if ( NULL == pTdlsPeer ) {
15587 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15588 " (oper %d) not exsting. ignored",
15589 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15590 return -EINVAL;
15591 }
15592
15593 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15594 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15595 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15596 "NL80211_TDLS_DISABLE_LINK");
15597
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015598 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080015599 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015600 long status;
15601
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015602 /* set tdls off channel status to false for this peer */
15603 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053015604 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15605 eTDLS_LINK_TEARING,
15606 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
15607 eTDLS_LINK_UNSPECIFIED:
15608 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015609 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
15610
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015611 status = sme_DeleteTdlsPeerSta(
15612 WLAN_HDD_GET_HAL_CTX(pAdapter),
15613 pAdapter->sessionId, peer );
15614 if (status != VOS_STATUS_SUCCESS) {
15615 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15616 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015617
15618 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
15619 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053015620 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053015621 eTDLS_LINK_IDLE,
15622 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015623 if (status <= 0)
15624 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15626 "%s: Del station failed status %ld",
15627 __func__, status);
15628 return -EPERM;
15629 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015630
15631 /* TDLS Off Channel, Enable tdls channel switch,
15632 when their is only one tdls link and it supports */
15633 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15634 if (numCurrTdlsPeers == 1)
15635 {
15636 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15637 if ((connPeer) &&
15638 (connPeer->isOffChannelSupported == TRUE) &&
15639 (connPeer->isOffChannelConfigured == TRUE))
15640 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015641 connPeer->isOffChannelEstablished = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015642 status = sme_SendTdlsChanSwitchReq(
15643 WLAN_HDD_GET_HAL_CTX(pAdapter),
15644 pAdapter->sessionId,
15645 connPeer->peerMac,
15646 connPeer->peerParams.channel,
15647 TDLS_OFF_CHANNEL_BW_OFFSET,
15648 TDLS_CHANNEL_SWITCH_ENABLE);
15649 if (status != VOS_STATUS_SUCCESS) {
15650 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
15651 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015652 }
15653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15654 "%s: TDLS channel switch "
15655 "isOffChannelSupported %d "
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015656 "isOffChannelConfigured %d "
15657 "isOffChannelEstablished %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015658 __func__,
15659 (connPeer ? connPeer->isOffChannelSupported : -1),
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015660 (connPeer ? connPeer->isOffChannelConfigured : -1),
15661 (connPeer ? connPeer->isOffChannelEstablished : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015662 }
15663 else
15664 {
15665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15666 "%s: TDLS channel switch request not sent "
15667 "numCurrTdlsPeers %d ",
15668 __func__, numCurrTdlsPeers);
15669 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015670 }
15671 else
15672 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15674 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080015675 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015676 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015677 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015678 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015679 {
Atul Mittal115287b2014-07-08 13:26:33 +053015680 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015681
Atul Mittal115287b2014-07-08 13:26:33 +053015682 if (0 != status)
15683 {
15684 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015685 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053015686 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015687 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053015688 break;
15689 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015690 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015691 {
Atul Mittal115287b2014-07-08 13:26:33 +053015692 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
15693 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015694 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053015695 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015696
Atul Mittal115287b2014-07-08 13:26:33 +053015697 if (0 != status)
15698 {
15699 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015700 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053015701 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053015702 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053015703 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015704 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015705 case NL80211_TDLS_DISCOVERY_REQ:
15706 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015707 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015708 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015709 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015710 return -ENOTSUPP;
15711 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15713 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015714 return -ENOTSUPP;
15715 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015716
15717 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015718 return 0;
15719}
Chilam NG571c65a2013-01-19 12:27:36 +053015720
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015721static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
15722 u8 *peer, enum nl80211_tdls_operation oper)
15723{
15724 int ret;
15725
15726 vos_ssr_protect(__func__);
15727 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
15728 vos_ssr_unprotect(__func__);
15729
15730 return ret;
15731}
15732
Chilam NG571c65a2013-01-19 12:27:36 +053015733int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
15734 struct net_device *dev, u8 *peer)
15735{
Arif Hussaina7c8e412013-11-20 11:06:42 -080015736 hddLog(VOS_TRACE_LEVEL_INFO,
15737 "tdls send discover req: "MAC_ADDRESS_STR,
15738 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053015739
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015740#if TDLS_MGMT_VERSION2
15741 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15742 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
15743#else
Chilam NG571c65a2013-01-19 12:27:36 +053015744 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15745 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015746#endif
Chilam NG571c65a2013-01-19 12:27:36 +053015747}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015748#endif
15749
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015750#ifdef WLAN_FEATURE_GTK_OFFLOAD
15751/*
15752 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
15753 * Callback rountine called upon receiving response for
15754 * get offload info
15755 */
15756void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
15757 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
15758{
15759
15760 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015761 tANI_U8 tempReplayCounter[8];
15762 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015763
15764 ENTER();
15765
15766 if (NULL == pAdapter)
15767 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053015768 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015769 "%s: HDD adapter is Null", __func__);
15770 return ;
15771 }
15772
15773 if (NULL == pGtkOffloadGetInfoRsp)
15774 {
15775 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15776 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
15777 return ;
15778 }
15779
15780 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
15781 {
15782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15783 "%s: wlan Failed to get replay counter value",
15784 __func__);
15785 return ;
15786 }
15787
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015788 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15789 /* Update replay counter */
15790 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
15791 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
15792
15793 {
15794 /* changing from little to big endian since supplicant
15795 * works on big endian format
15796 */
15797 int i;
15798 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
15799
15800 for (i = 0; i < 8; i++)
15801 {
15802 tempReplayCounter[7-i] = (tANI_U8)p[i];
15803 }
15804 }
15805
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015806 /* Update replay counter to NL */
15807 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015808 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015809}
15810
15811/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015812 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015813 * This function is used to offload GTK rekeying job to the firmware.
15814 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015815int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015816 struct cfg80211_gtk_rekey_data *data)
15817{
15818 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15819 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
15820 hdd_station_ctx_t *pHddStaCtx;
15821 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015822 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015823 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015824 eHalStatus status = eHAL_STATUS_FAILURE;
15825
15826 ENTER();
15827
15828 if (NULL == pAdapter)
15829 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015830 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015831 "%s: HDD adapter is Null", __func__);
15832 return -ENODEV;
15833 }
15834
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015835 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15836 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
15837 pAdapter->sessionId, pAdapter->device_mode));
15838
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015839 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015840 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015841 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015842 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015843 }
15844
15845 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15846 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
15847 if (NULL == hHal)
15848 {
15849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15850 "%s: HAL context is Null!!!", __func__);
15851 return -EAGAIN;
15852 }
15853
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015854 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
15855 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
15856 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
15857 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015858 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015859 {
15860 /* changing from big to little endian since driver
15861 * works on little endian format
15862 */
15863 tANI_U8 *p =
15864 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
15865 int i;
15866
15867 for (i = 0; i < 8; i++)
15868 {
15869 p[7-i] = data->replay_ctr[i];
15870 }
15871 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015872
15873 if (TRUE == pHddCtx->hdd_wlan_suspended)
15874 {
15875 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015876 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
15877 sizeof (tSirGtkOffloadParams));
15878 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015879 pAdapter->sessionId);
15880
15881 if (eHAL_STATUS_SUCCESS != status)
15882 {
15883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15884 "%s: sme_SetGTKOffload failed, returned %d",
15885 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053015886
15887 /* Need to clear any trace of key value in the memory.
15888 * Thus zero out the memory even though it is local
15889 * variable.
15890 */
15891 vos_mem_zero(&hddGtkOffloadReqParams,
15892 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015893 return status;
15894 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15896 "%s: sme_SetGTKOffload successfull", __func__);
15897 }
15898 else
15899 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15901 "%s: wlan not suspended GTKOffload request is stored",
15902 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015903 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015904
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053015905 /* Need to clear any trace of key value in the memory.
15906 * Thus zero out the memory even though it is local
15907 * variable.
15908 */
15909 vos_mem_zero(&hddGtkOffloadReqParams,
15910 sizeof(hddGtkOffloadReqParams));
15911
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015912 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015913 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015914}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015915
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015916int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
15917 struct cfg80211_gtk_rekey_data *data)
15918{
15919 int ret;
15920
15921 vos_ssr_protect(__func__);
15922 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
15923 vos_ssr_unprotect(__func__);
15924
15925 return ret;
15926}
15927#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015928/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015929 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015930 * This function is used to set access control policy
15931 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015932static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
15933 struct net_device *dev,
15934 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015935{
15936 int i;
15937 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15938 hdd_hostapd_state_t *pHostapdState;
15939 tsap_Config_t *pConfig;
15940 v_CONTEXT_t pVosContext = NULL;
15941 hdd_context_t *pHddCtx;
15942 int status;
15943
15944 ENTER();
15945
15946 if (NULL == pAdapter)
15947 {
15948 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15949 "%s: HDD adapter is Null", __func__);
15950 return -ENODEV;
15951 }
15952
15953 if (NULL == params)
15954 {
15955 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15956 "%s: params is Null", __func__);
15957 return -EINVAL;
15958 }
15959
15960 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15961 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015962 if (0 != status)
15963 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015964 return status;
15965 }
15966
15967 pVosContext = pHddCtx->pvosContext;
15968 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
15969
15970 if (NULL == pHostapdState)
15971 {
15972 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15973 "%s: pHostapdState is Null", __func__);
15974 return -EINVAL;
15975 }
15976
15977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
15978 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053015979 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15980 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
15981 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015982
15983 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
15984 {
15985 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
15986
15987 /* default value */
15988 pConfig->num_accept_mac = 0;
15989 pConfig->num_deny_mac = 0;
15990
15991 /**
15992 * access control policy
15993 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
15994 * listed in hostapd.deny file.
15995 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
15996 * listed in hostapd.accept file.
15997 */
15998 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
15999 {
16000 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
16001 }
16002 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
16003 {
16004 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
16005 }
16006 else
16007 {
16008 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16009 "%s:Acl Policy : %d is not supported",
16010 __func__, params->acl_policy);
16011 return -ENOTSUPP;
16012 }
16013
16014 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
16015 {
16016 pConfig->num_accept_mac = params->n_acl_entries;
16017 for (i = 0; i < params->n_acl_entries; i++)
16018 {
16019 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16020 "** Add ACL MAC entry %i in WhiletList :"
16021 MAC_ADDRESS_STR, i,
16022 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16023
16024 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
16025 sizeof(qcmacaddr));
16026 }
16027 }
16028 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
16029 {
16030 pConfig->num_deny_mac = params->n_acl_entries;
16031 for (i = 0; i < params->n_acl_entries; i++)
16032 {
16033 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16034 "** Add ACL MAC entry %i in BlackList :"
16035 MAC_ADDRESS_STR, i,
16036 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16037
16038 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
16039 sizeof(qcmacaddr));
16040 }
16041 }
16042
16043 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
16044 {
16045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16046 "%s: SAP Set Mac Acl fail", __func__);
16047 return -EINVAL;
16048 }
16049 }
16050 else
16051 {
16052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053016053 "%s: Invalid device_mode = %s (%d)",
16054 __func__, hdd_device_modetoString(pAdapter->device_mode),
16055 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016056 return -EINVAL;
16057 }
16058
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016059 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016060 return 0;
16061}
16062
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016063static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16064 struct net_device *dev,
16065 const struct cfg80211_acl_data *params)
16066{
16067 int ret;
16068 vos_ssr_protect(__func__);
16069 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
16070 vos_ssr_unprotect(__func__);
16071
16072 return ret;
16073}
16074
Leo Chang9056f462013-08-01 19:21:11 -070016075#ifdef WLAN_NL80211_TESTMODE
16076#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070016077void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070016078(
16079 void *pAdapter,
16080 void *indCont
16081)
16082{
Leo Changd9df8aa2013-09-26 13:32:26 -070016083 tSirLPHBInd *lphbInd;
16084 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053016085 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070016086
16087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016088 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070016089
c_hpothu73f35e62014-04-18 13:40:08 +053016090 if (pAdapter == NULL)
16091 {
16092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16093 "%s: pAdapter is NULL\n",__func__);
16094 return;
16095 }
16096
Leo Chang9056f462013-08-01 19:21:11 -070016097 if (NULL == indCont)
16098 {
16099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016100 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070016101 return;
16102 }
16103
c_hpothu73f35e62014-04-18 13:40:08 +053016104 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070016105 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070016106 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053016107 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070016108 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070016109 GFP_ATOMIC);
16110 if (!skb)
16111 {
16112 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16113 "LPHB timeout, NL buffer alloc fail");
16114 return;
16115 }
16116
Leo Changac3ba772013-10-07 09:47:04 -070016117 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070016118 {
16119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16120 "WLAN_HDD_TM_ATTR_CMD put fail");
16121 goto nla_put_failure;
16122 }
Leo Changac3ba772013-10-07 09:47:04 -070016123 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070016124 {
16125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16126 "WLAN_HDD_TM_ATTR_TYPE put fail");
16127 goto nla_put_failure;
16128 }
Leo Changac3ba772013-10-07 09:47:04 -070016129 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070016130 sizeof(tSirLPHBInd), lphbInd))
16131 {
16132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16133 "WLAN_HDD_TM_ATTR_DATA put fail");
16134 goto nla_put_failure;
16135 }
Leo Chang9056f462013-08-01 19:21:11 -070016136 cfg80211_testmode_event(skb, GFP_ATOMIC);
16137 return;
16138
16139nla_put_failure:
16140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16141 "NLA Put fail");
16142 kfree_skb(skb);
16143
16144 return;
16145}
16146#endif /* FEATURE_WLAN_LPHB */
16147
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016148static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070016149{
16150 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
16151 int err = 0;
16152#ifdef FEATURE_WLAN_LPHB
16153 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070016154 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016155
16156 ENTER();
16157
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016158 err = wlan_hdd_validate_context(pHddCtx);
16159 if (0 != err)
16160 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016161 return err;
16162 }
Leo Chang9056f462013-08-01 19:21:11 -070016163#endif /* FEATURE_WLAN_LPHB */
16164
16165 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
16166 if (err)
16167 {
16168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16169 "%s Testmode INV ATTR", __func__);
16170 return err;
16171 }
16172
16173 if (!tb[WLAN_HDD_TM_ATTR_CMD])
16174 {
16175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16176 "%s Testmode INV CMD", __func__);
16177 return -EINVAL;
16178 }
16179
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016180 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16181 TRACE_CODE_HDD_CFG80211_TESTMODE,
16182 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070016183 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
16184 {
16185#ifdef FEATURE_WLAN_LPHB
16186 /* Low Power Heartbeat configuration request */
16187 case WLAN_HDD_TM_CMD_WLAN_HB:
16188 {
16189 int buf_len;
16190 void *buf;
16191 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080016192 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070016193
16194 if (!tb[WLAN_HDD_TM_ATTR_DATA])
16195 {
16196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16197 "%s Testmode INV DATA", __func__);
16198 return -EINVAL;
16199 }
16200
16201 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
16202 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080016203
16204 hb_params_temp =(tSirLPHBReq *)buf;
16205 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
16206 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
16207 return -EINVAL;
16208
Leo Chang9056f462013-08-01 19:21:11 -070016209 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
16210 if (NULL == hb_params)
16211 {
16212 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16213 "%s Request Buffer Alloc Fail", __func__);
16214 return -EINVAL;
16215 }
16216
16217 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070016218 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
16219 hb_params,
16220 wlan_hdd_cfg80211_lphb_ind_handler);
16221 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070016222 {
Leo Changd9df8aa2013-09-26 13:32:26 -070016223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16224 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070016225 vos_mem_free(hb_params);
16226 }
Leo Chang9056f462013-08-01 19:21:11 -070016227 return 0;
16228 }
16229#endif /* FEATURE_WLAN_LPHB */
16230 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16232 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070016233 return -EOPNOTSUPP;
16234 }
16235
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016236 EXIT();
16237 return err;
Leo Chang9056f462013-08-01 19:21:11 -070016238}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016239
16240static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
16241{
16242 int ret;
16243
16244 vos_ssr_protect(__func__);
16245 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
16246 vos_ssr_unprotect(__func__);
16247
16248 return ret;
16249}
Leo Chang9056f462013-08-01 19:21:11 -070016250#endif /* CONFIG_NL80211_TESTMODE */
16251
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016252static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016253 struct net_device *dev,
16254 int idx, struct survey_info *survey)
16255{
16256 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16257 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053016258 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016259 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053016260 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016261 v_S7_t snr,rssi;
16262 int status, i, j, filled = 0;
16263
16264 ENTER();
16265
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016266 if (NULL == pAdapter)
16267 {
16268 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16269 "%s: HDD adapter is Null", __func__);
16270 return -ENODEV;
16271 }
16272
16273 if (NULL == wiphy)
16274 {
16275 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16276 "%s: wiphy is Null", __func__);
16277 return -ENODEV;
16278 }
16279
16280 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16281 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016282 if (0 != status)
16283 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016284 return status;
16285 }
16286
Mihir Sheted9072e02013-08-21 17:02:29 +053016287 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16288
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016289 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053016290 0 != pAdapter->survey_idx ||
16291 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016292 {
16293 /* The survey dump ops when implemented completely is expected to
16294 * return a survey of all channels and the ops is called by the
16295 * kernel with incremental values of the argument 'idx' till it
16296 * returns -ENONET. But we can only support the survey for the
16297 * operating channel for now. survey_idx is used to track
16298 * that the ops is called only once and then return -ENONET for
16299 * the next iteration
16300 */
16301 pAdapter->survey_idx = 0;
16302 return -ENONET;
16303 }
16304
Mukul Sharma9d5233b2015-06-11 20:28:20 +053016305 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
16306 {
16307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16308 "%s: Roaming in progress, hence return ", __func__);
16309 return -ENONET;
16310 }
16311
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016312 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16313
16314 wlan_hdd_get_snr(pAdapter, &snr);
16315 wlan_hdd_get_rssi(pAdapter, &rssi);
16316
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016317 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16318 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
16319 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016320 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
16321 hdd_wlan_get_freq(channel, &freq);
16322
16323
16324 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
16325 {
16326 if (NULL == wiphy->bands[i])
16327 {
16328 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
16329 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
16330 continue;
16331 }
16332
16333 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
16334 {
16335 struct ieee80211_supported_band *band = wiphy->bands[i];
16336
16337 if (band->channels[j].center_freq == (v_U16_t)freq)
16338 {
16339 survey->channel = &band->channels[j];
16340 /* The Rx BDs contain SNR values in dB for the received frames
16341 * while the supplicant expects noise. So we calculate and
16342 * return the value of noise (dBm)
16343 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
16344 */
16345 survey->noise = rssi - snr;
16346 survey->filled = SURVEY_INFO_NOISE_DBM;
16347 filled = 1;
16348 }
16349 }
16350 }
16351
16352 if (filled)
16353 pAdapter->survey_idx = 1;
16354 else
16355 {
16356 pAdapter->survey_idx = 0;
16357 return -ENONET;
16358 }
16359
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016360 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016361 return 0;
16362}
16363
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016364static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
16365 struct net_device *dev,
16366 int idx, struct survey_info *survey)
16367{
16368 int ret;
16369
16370 vos_ssr_protect(__func__);
16371 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
16372 vos_ssr_unprotect(__func__);
16373
16374 return ret;
16375}
16376
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016377/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016378 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016379 * this is called when cfg80211 driver resume
16380 * driver updates latest sched_scan scan result(if any) to cfg80211 database
16381 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016382int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016383{
16384 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16385 hdd_adapter_t *pAdapter;
16386 hdd_adapter_list_node_t *pAdapterNode, *pNext;
16387 VOS_STATUS status = VOS_STATUS_SUCCESS;
16388
16389 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016390
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016391 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016392 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016393 return 0;
16394 }
16395
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016396 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
16397 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016398 spin_lock(&pHddCtx->schedScan_lock);
16399 pHddCtx->isWiphySuspended = FALSE;
16400 if (TRUE != pHddCtx->isSchedScanUpdatePending)
16401 {
16402 spin_unlock(&pHddCtx->schedScan_lock);
16403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16404 "%s: Return resume is not due to PNO indication", __func__);
16405 return 0;
16406 }
16407 // Reset flag to avoid updatating cfg80211 data old results again
16408 pHddCtx->isSchedScanUpdatePending = FALSE;
16409 spin_unlock(&pHddCtx->schedScan_lock);
16410
16411 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
16412
16413 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
16414 {
16415 pAdapter = pAdapterNode->pAdapter;
16416 if ( (NULL != pAdapter) &&
16417 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
16418 {
16419 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016420 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16422 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016423 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016424 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016425 {
16426 /* Acquire wakelock to handle the case where APP's tries to
16427 * suspend immediately after updating the scan results. Whis
16428 * results in app's is in suspended state and not able to
16429 * process the connect request to AP
16430 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053016431 hdd_prevent_suspend_timeout(2000,
16432 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016433 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016434 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016435
16436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16437 "%s : cfg80211 scan result database updated", __func__);
16438
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016439 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016440 return 0;
16441
16442 }
16443 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16444 pAdapterNode = pNext;
16445 }
16446
16447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16448 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016449 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016450 return 0;
16451}
16452
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016453int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
16454{
16455 int ret;
16456
16457 vos_ssr_protect(__func__);
16458 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
16459 vos_ssr_unprotect(__func__);
16460
16461 return ret;
16462}
16463
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016464/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016465 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016466 * this is called when cfg80211 driver suspends
16467 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016468int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016469 struct cfg80211_wowlan *wow)
16470{
16471 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016472 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016473
16474 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016475
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016476 ret = wlan_hdd_validate_context(pHddCtx);
16477 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016478 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016479 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016480 }
16481
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016482
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016483 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16484 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
16485 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016486 pHddCtx->isWiphySuspended = TRUE;
16487
16488 EXIT();
16489
16490 return 0;
16491}
16492
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016493int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
16494 struct cfg80211_wowlan *wow)
16495{
16496 int ret;
16497
16498 vos_ssr_protect(__func__);
16499 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
16500 vos_ssr_unprotect(__func__);
16501
16502 return ret;
16503}
Jeff Johnson295189b2012-06-20 16:38:30 -070016504/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016505static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070016506{
16507 .add_virtual_intf = wlan_hdd_add_virtual_intf,
16508 .del_virtual_intf = wlan_hdd_del_virtual_intf,
16509 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
16510 .change_station = wlan_hdd_change_station,
16511#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
16512 .add_beacon = wlan_hdd_cfg80211_add_beacon,
16513 .del_beacon = wlan_hdd_cfg80211_del_beacon,
16514 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016515#else
16516 .start_ap = wlan_hdd_cfg80211_start_ap,
16517 .change_beacon = wlan_hdd_cfg80211_change_beacon,
16518 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070016519#endif
16520 .change_bss = wlan_hdd_cfg80211_change_bss,
16521 .add_key = wlan_hdd_cfg80211_add_key,
16522 .get_key = wlan_hdd_cfg80211_get_key,
16523 .del_key = wlan_hdd_cfg80211_del_key,
16524 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016525#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070016526 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016527#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016528 .scan = wlan_hdd_cfg80211_scan,
16529 .connect = wlan_hdd_cfg80211_connect,
16530 .disconnect = wlan_hdd_cfg80211_disconnect,
16531 .join_ibss = wlan_hdd_cfg80211_join_ibss,
16532 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
16533 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
16534 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
16535 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070016536 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
16537 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053016538 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070016539#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16540 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
16541 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
16542 .set_txq_params = wlan_hdd_set_txq_params,
16543#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016544 .get_station = wlan_hdd_cfg80211_get_station,
16545 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
16546 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016547 .add_station = wlan_hdd_cfg80211_add_station,
16548#ifdef FEATURE_WLAN_LFR
16549 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
16550 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
16551 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
16552#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016553#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
16554 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
16555#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016556#ifdef FEATURE_WLAN_TDLS
16557 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
16558 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
16559#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016560#ifdef WLAN_FEATURE_GTK_OFFLOAD
16561 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
16562#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016563#ifdef FEATURE_WLAN_SCAN_PNO
16564 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
16565 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
16566#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016567 .resume = wlan_hdd_cfg80211_resume_wlan,
16568 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016569 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070016570#ifdef WLAN_NL80211_TESTMODE
16571 .testmode_cmd = wlan_hdd_cfg80211_testmode,
16572#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016573 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070016574};
16575