blob: b036882ac6800995e5df01eda232f46de9e786ae [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,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530622#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
623 NULL,
624#endif
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800625 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530626 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800627 GFP_KERNEL);
628 if (!vendor_event)
629 {
630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
631 "%s: cfg80211_vendor_event_alloc failed", __func__);
632 return -1;
633 }
634
635 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
636 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
637
638 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
639
640 EXIT();
641 return 0;
642}
643#endif /* FEATURE_WLAN_CH_AVOID */
644
Srinivas Dasari030bad32015-02-18 23:23:54 +0530645/*
646 * FUNCTION: __wlan_hdd_cfg80211_nan_request
647 * This is called when wlan driver needs to send vendor specific
648 * nan request event.
649 */
650static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
651 struct wireless_dev *wdev,
652 const void *data, int data_len)
653{
654 tNanRequestReq nan_req;
655 VOS_STATUS status;
656 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530657 struct net_device *dev = wdev->netdev;
658 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
659 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530660 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
661
662 if (0 == data_len)
663 {
664 hddLog(VOS_TRACE_LEVEL_ERROR,
665 FL("NAN - Invalid Request, length = 0"));
666 return ret_val;
667 }
668
669 if (NULL == data)
670 {
671 hddLog(VOS_TRACE_LEVEL_ERROR,
672 FL("NAN - Invalid Request, data is NULL"));
673 return ret_val;
674 }
675
676 status = wlan_hdd_validate_context(pHddCtx);
677 if (0 != status)
678 {
679 hddLog(VOS_TRACE_LEVEL_ERROR,
680 FL("HDD context is not valid"));
681 return -EINVAL;
682 }
683
684 hddLog(LOG1, FL("Received NAN command"));
685 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
686 (tANI_U8 *)data, data_len);
687
688 /* check the NAN Capability */
689 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
690 {
691 hddLog(VOS_TRACE_LEVEL_ERROR,
692 FL("NAN is not supported by Firmware"));
693 return -EINVAL;
694 }
695
696 nan_req.request_data_len = data_len;
697 nan_req.request_data = data;
698
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530699 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530700 if (VOS_STATUS_SUCCESS == status)
701 {
702 ret_val = 0;
703 }
704 return ret_val;
705}
706
707/*
708 * FUNCTION: wlan_hdd_cfg80211_nan_request
709 * Wrapper to protect the nan vendor command from ssr
710 */
711static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
712 struct wireless_dev *wdev,
713 const void *data, int data_len)
714{
715 int ret;
716
717 vos_ssr_protect(__func__);
718 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
719 vos_ssr_unprotect(__func__);
720
721 return ret;
722}
723
724/*
725 * FUNCTION: wlan_hdd_cfg80211_nan_callback
726 * This is a callback function and it gets called
727 * when we need to report nan response event to
728 * upper layers.
729 */
730static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
731{
732 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
733 struct sk_buff *vendor_event;
734 int status;
735 tSirNanEvent *data;
736
737 ENTER();
738 if (NULL == msg)
739 {
740 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
741 FL(" msg received here is null"));
742 return;
743 }
744 data = msg;
745
746 status = wlan_hdd_validate_context(pHddCtx);
747
748 if (0 != status)
749 {
750 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
751 FL("HDD context is not valid"));
752 return;
753 }
754
755 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530756#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
757 NULL,
758#endif
Srinivas Dasari030bad32015-02-18 23:23:54 +0530759 data->event_data_len +
760 NLMSG_HDRLEN,
761 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
762 GFP_KERNEL);
763
764 if (!vendor_event)
765 {
766 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
767 FL("cfg80211_vendor_event_alloc failed"));
768 return;
769 }
770 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
771 data->event_data_len, data->event_data))
772 {
773 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
774 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
775 kfree_skb(vendor_event);
776 return;
777 }
778 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
779 EXIT();
780}
781
782/*
783 * FUNCTION: wlan_hdd_cfg80211_nan_init
784 * This function is called to register the callback to sme layer
785 */
786inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
787{
788 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
789}
790
791
Sunil Duttc69bccb2014-05-26 21:30:20 +0530792#ifdef WLAN_FEATURE_LINK_LAYER_STATS
793
794static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
795 struct sk_buff *vendor_event)
796{
797 if (nla_put_u8(vendor_event,
798 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
799 stats->rate.preamble) ||
800 nla_put_u8(vendor_event,
801 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
802 stats->rate.nss) ||
803 nla_put_u8(vendor_event,
804 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
805 stats->rate.bw) ||
806 nla_put_u8(vendor_event,
807 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
808 stats->rate.rateMcsIdx) ||
809 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
810 stats->rate.bitrate ) ||
811 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
812 stats->txMpdu ) ||
813 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
814 stats->rxMpdu ) ||
815 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
816 stats->mpduLost ) ||
817 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
818 stats->retries) ||
819 nla_put_u32(vendor_event,
820 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
821 stats->retriesShort ) ||
822 nla_put_u32(vendor_event,
823 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
824 stats->retriesLong))
825 {
826 hddLog(VOS_TRACE_LEVEL_ERROR,
827 FL("QCA_WLAN_VENDOR_ATTR put fail"));
828 return FALSE;
829 }
830 return TRUE;
831}
832
833static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
834 struct sk_buff *vendor_event)
835{
836 u32 i = 0;
837 struct nlattr *rateInfo;
838 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
839 stats->type) ||
840 nla_put(vendor_event,
841 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
842 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
843 nla_put_u32(vendor_event,
844 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
845 stats->capabilities) ||
846 nla_put_u32(vendor_event,
847 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
848 stats->numRate))
849 {
850 hddLog(VOS_TRACE_LEVEL_ERROR,
851 FL("QCA_WLAN_VENDOR_ATTR put fail"));
852 goto error;
853 }
854
855 rateInfo = nla_nest_start(vendor_event,
856 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530857 if(!rateInfo)
858 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530859 for (i = 0; i < stats->numRate; i++)
860 {
861 struct nlattr *rates;
862 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
863 stats->rateStats +
864 (i * sizeof(tSirWifiRateStat)));
865 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530866 if(!rates)
867 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530868
869 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
870 {
871 hddLog(VOS_TRACE_LEVEL_ERROR,
872 FL("QCA_WLAN_VENDOR_ATTR put fail"));
873 return FALSE;
874 }
875 nla_nest_end(vendor_event, rates);
876 }
877 nla_nest_end(vendor_event, rateInfo);
878
879 return TRUE;
880error:
881 return FALSE;
882}
883
884static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
885 struct sk_buff *vendor_event)
886{
887 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
888 stats->ac ) ||
889 nla_put_u32(vendor_event,
890 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
891 stats->txMpdu ) ||
892 nla_put_u32(vendor_event,
893 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
894 stats->rxMpdu ) ||
895 nla_put_u32(vendor_event,
896 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
897 stats->txMcast ) ||
898 nla_put_u32(vendor_event,
899 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
900 stats->rxMcast ) ||
901 nla_put_u32(vendor_event,
902 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
903 stats->rxAmpdu ) ||
904 nla_put_u32(vendor_event,
905 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
906 stats->txAmpdu ) ||
907 nla_put_u32(vendor_event,
908 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
909 stats->mpduLost )||
910 nla_put_u32(vendor_event,
911 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
912 stats->retries ) ||
913 nla_put_u32(vendor_event,
914 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
915 stats->retriesShort ) ||
916 nla_put_u32(vendor_event,
917 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
918 stats->retriesLong ) ||
919 nla_put_u32(vendor_event,
920 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
921 stats->contentionTimeMin ) ||
922 nla_put_u32(vendor_event,
923 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
924 stats->contentionTimeMax ) ||
925 nla_put_u32(vendor_event,
926 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
927 stats->contentionTimeAvg ) ||
928 nla_put_u32(vendor_event,
929 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
930 stats->contentionNumSamples ))
931 {
932 hddLog(VOS_TRACE_LEVEL_ERROR,
933 FL("QCA_WLAN_VENDOR_ATTR put fail") );
934 return FALSE;
935 }
936 return TRUE;
937}
938
939static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
940 struct sk_buff *vendor_event)
941{
Dino Myclec8f3f332014-07-21 16:48:27 +0530942 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530943 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
944 nla_put(vendor_event,
945 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
946 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
947 nla_put_u32(vendor_event,
948 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
949 stats->state ) ||
950 nla_put_u32(vendor_event,
951 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
952 stats->roaming ) ||
953 nla_put_u32(vendor_event,
954 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
955 stats->capabilities ) ||
956 nla_put(vendor_event,
957 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
958 strlen(stats->ssid), stats->ssid) ||
959 nla_put(vendor_event,
960 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
961 WNI_CFG_BSSID_LEN, stats->bssid) ||
962 nla_put(vendor_event,
963 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
964 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
965 nla_put(vendor_event,
966 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
967 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
968 )
969 {
970 hddLog(VOS_TRACE_LEVEL_ERROR,
971 FL("QCA_WLAN_VENDOR_ATTR put fail") );
972 return FALSE;
973 }
974 return TRUE;
975}
976
Dino Mycle3b9536d2014-07-09 22:05:24 +0530977static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
978 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530979 struct sk_buff *vendor_event)
980{
981 int i = 0;
982 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530983 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
984 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530985 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530986
Sunil Duttc69bccb2014-05-26 21:30:20 +0530987 if (FALSE == put_wifi_interface_info(
988 &pWifiIfaceStat->info,
989 vendor_event))
990 {
991 hddLog(VOS_TRACE_LEVEL_ERROR,
992 FL("QCA_WLAN_VENDOR_ATTR put fail") );
993 return FALSE;
994
995 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530996 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
997 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
998 if (NULL == pWifiIfaceStatTL)
999 {
1000 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
1001 return FALSE;
1002 }
1003
Srinivas Dasaria8a304f2014-11-15 16:13:37 +05301004 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
1005 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
1006 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
1007 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1008
1009 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1010 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1011 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1012 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301013
1014 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1015 {
1016 if (VOS_STATUS_SUCCESS ==
1017 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1018 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1019 {
1020 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1021 * obtained from TL structure
1022 */
1023
1024 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1025 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301026 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1027
Srinivas Dasari98947432014-11-07 19:41:24 +05301028 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1029 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1030 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1031 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1032 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1033 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1034 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1035 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301036
Srinivas Dasari98947432014-11-07 19:41:24 +05301037 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1038 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1039 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1040 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1041 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1042 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1043 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1044 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301045
Srinivas Dasari98947432014-11-07 19:41:24 +05301046 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1047 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1048 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1049 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1050 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1051 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1052 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1053 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301054 }
1055 else
1056 {
1057 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1058 }
1059
Dino Mycle3b9536d2014-07-09 22:05:24 +05301060 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1061 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1062 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1063 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1064 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1065 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1066 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1067 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1068 }
1069 else
1070 {
1071 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1072 }
1073
1074
Sunil Duttc69bccb2014-05-26 21:30:20 +05301075
1076 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301077 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1078 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_IFACE) ||
1079 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301080 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1081 pWifiIfaceStat->beaconRx) ||
1082 nla_put_u32(vendor_event,
1083 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1084 pWifiIfaceStat->mgmtRx) ||
1085 nla_put_u32(vendor_event,
1086 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1087 pWifiIfaceStat->mgmtActionRx) ||
1088 nla_put_u32(vendor_event,
1089 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1090 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301091 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301092 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1093 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301094 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301095 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1096 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301097 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301098 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1099 pWifiIfaceStat->rssiAck))
1100 {
1101 hddLog(VOS_TRACE_LEVEL_ERROR,
1102 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301103 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301104 return FALSE;
1105 }
1106
1107 wmmInfo = nla_nest_start(vendor_event,
1108 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301109 if(!wmmInfo)
1110 {
1111 vos_mem_free(pWifiIfaceStatTL);
1112 return FALSE;
1113 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301114 for (i = 0; i < WIFI_AC_MAX; i++)
1115 {
1116 struct nlattr *wmmStats;
1117 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301118 if(!wmmStats)
1119 {
1120 vos_mem_free(pWifiIfaceStatTL);
1121 return FALSE;
1122 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301123 if (FALSE == put_wifi_wmm_ac_stat(
1124 &pWifiIfaceStat->AccessclassStats[i],
1125 vendor_event))
1126 {
1127 hddLog(VOS_TRACE_LEVEL_ERROR,
1128 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301129 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301130 return FALSE;
1131 }
1132
1133 nla_nest_end(vendor_event, wmmStats);
1134 }
1135 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301136 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301137 return TRUE;
1138}
1139
1140static tSirWifiInterfaceMode
1141 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1142{
1143 switch (deviceMode)
1144 {
1145 case WLAN_HDD_INFRA_STATION:
1146 return WIFI_INTERFACE_STA;
1147 case WLAN_HDD_SOFTAP:
1148 return WIFI_INTERFACE_SOFTAP;
1149 case WLAN_HDD_P2P_CLIENT:
1150 return WIFI_INTERFACE_P2P_CLIENT;
1151 case WLAN_HDD_P2P_GO:
1152 return WIFI_INTERFACE_P2P_GO;
1153 case WLAN_HDD_IBSS:
1154 return WIFI_INTERFACE_IBSS;
1155 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301156 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301157 }
1158}
1159
1160static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1161 tpSirWifiInterfaceInfo pInfo)
1162{
1163 v_U8_t *staMac = NULL;
1164 hdd_station_ctx_t *pHddStaCtx;
1165 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1166 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1167
1168 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1169
1170 vos_mem_copy(pInfo->macAddr,
1171 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1172
1173 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1174 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1175 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1176 {
1177 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1178 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1179 {
1180 pInfo->state = WIFI_DISCONNECTED;
1181 }
1182 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1183 {
1184 hddLog(VOS_TRACE_LEVEL_ERROR,
1185 "%s: Session ID %d, Connection is in progress", __func__,
1186 pAdapter->sessionId);
1187 pInfo->state = WIFI_ASSOCIATING;
1188 }
1189 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1190 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1191 {
1192 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1193 hddLog(VOS_TRACE_LEVEL_ERROR,
1194 "%s: client " MAC_ADDRESS_STR
1195 " is in the middle of WPS/EAPOL exchange.", __func__,
1196 MAC_ADDR_ARRAY(staMac));
1197 pInfo->state = WIFI_AUTHENTICATING;
1198 }
1199 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1200 {
1201 pInfo->state = WIFI_ASSOCIATED;
1202 vos_mem_copy(pInfo->bssid,
1203 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1204 vos_mem_copy(pInfo->ssid,
1205 pHddStaCtx->conn_info.SSID.SSID.ssId,
1206 pHddStaCtx->conn_info.SSID.SSID.length);
1207 //NULL Terminate the string.
1208 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1209 }
1210 }
1211 vos_mem_copy(pInfo->countryStr,
1212 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1213
1214 vos_mem_copy(pInfo->apCountryStr,
1215 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1216
1217 return TRUE;
1218}
1219
1220/*
1221 * hdd_link_layer_process_peer_stats () - This function is called after
1222 * receiving Link Layer Peer statistics from FW.This function converts
1223 * the firmware data to the NL data and sends the same to the kernel/upper
1224 * layers.
1225 */
1226static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1227 v_VOID_t *pData)
1228{
1229 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1230 tpSirWifiRateStat pWifiRateStat;
1231 tpSirWifiPeerStat pWifiPeerStat;
1232 tpSirWifiPeerInfo pWifiPeerInfo;
1233 struct nlattr *peerInfo;
1234 struct sk_buff *vendor_event;
1235 int status, i;
1236
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301237 ENTER();
1238
Sunil Duttc69bccb2014-05-26 21:30:20 +05301239 status = wlan_hdd_validate_context(pHddCtx);
1240 if (0 != status)
1241 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301242 return;
1243 }
1244
1245 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1246
1247 hddLog(VOS_TRACE_LEVEL_INFO,
1248 "LL_STATS_PEER_ALL : numPeers %u",
1249 pWifiPeerStat->numPeers);
1250 {
1251 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1252 {
1253 pWifiPeerInfo = (tpSirWifiPeerInfo)
1254 ((uint8 *)pWifiPeerStat->peerInfo +
1255 ( i * sizeof(tSirWifiPeerInfo)));
1256
Dasari Srinivas1be0c4e2014-10-19 13:03:41 +05301257 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) {
1258 pWifiPeerInfo->type = WIFI_PEER_AP;
1259 }
1260 if (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) {
1261 pWifiPeerInfo->type = WIFI_PEER_P2P_GO;
1262 }
1263
Sunil Duttc69bccb2014-05-26 21:30:20 +05301264 hddLog(VOS_TRACE_LEVEL_INFO,
1265 " %d) LL_STATS Channel Stats "
1266 " Peer Type %u "
1267 " peerMacAddress %pM "
1268 " capabilities 0x%x "
1269 " numRate %u ",
1270 i,
1271 pWifiPeerInfo->type,
1272 pWifiPeerInfo->peerMacAddress,
1273 pWifiPeerInfo->capabilities,
1274 pWifiPeerInfo->numRate);
1275 {
1276 int j;
1277 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1278 {
1279 pWifiRateStat = (tpSirWifiRateStat)
1280 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1281 ( j * sizeof(tSirWifiRateStat)));
1282
1283 hddLog(VOS_TRACE_LEVEL_INFO,
1284 " peer Rate Stats "
1285 " preamble %u "
1286 " nss %u "
1287 " bw %u "
1288 " rateMcsIdx %u "
1289 " reserved %u "
1290 " bitrate %u "
1291 " txMpdu %u "
1292 " rxMpdu %u "
1293 " mpduLost %u "
1294 " retries %u "
1295 " retriesShort %u "
1296 " retriesLong %u",
1297 pWifiRateStat->rate.preamble,
1298 pWifiRateStat->rate.nss,
1299 pWifiRateStat->rate.bw,
1300 pWifiRateStat->rate.rateMcsIdx,
1301 pWifiRateStat->rate.reserved,
1302 pWifiRateStat->rate.bitrate,
1303 pWifiRateStat->txMpdu,
1304 pWifiRateStat->rxMpdu,
1305 pWifiRateStat->mpduLost,
1306 pWifiRateStat->retries,
1307 pWifiRateStat->retriesShort,
1308 pWifiRateStat->retriesLong);
1309 }
1310 }
1311 }
1312 }
1313
1314 /*
1315 * Allocate a size of 4096 for the peer stats comprising
1316 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1317 * sizeof (tSirWifiRateStat).Each field is put with an
1318 * NL attribute.The size of 4096 is considered assuming
1319 * that number of rates shall not exceed beyond 50 with
1320 * the sizeof (tSirWifiRateStat) being 32.
1321 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301322 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1323 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301324 if (!vendor_event)
1325 {
1326 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301327 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301328 __func__);
1329 return;
1330 }
1331 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301332 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1333 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_PEER) ||
1334 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301335 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1336 pWifiPeerStat->numPeers))
1337 {
1338 hddLog(VOS_TRACE_LEVEL_ERROR,
1339 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1340 kfree_skb(vendor_event);
1341 return;
1342 }
1343
1344 peerInfo = nla_nest_start(vendor_event,
1345 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301346 if(!peerInfo)
1347 {
1348 hddLog(VOS_TRACE_LEVEL_ERROR,
1349 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1350 __func__);
1351 kfree_skb(vendor_event);
1352 return;
1353 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301354
1355 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1356 pWifiPeerStat->peerInfo);
1357
1358 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1359 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301360 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301361 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301362
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301363 if(!peers)
1364 {
1365 hddLog(VOS_TRACE_LEVEL_ERROR,
1366 "%s: peer stats put fail",
1367 __func__);
1368 kfree_skb(vendor_event);
1369 return;
1370 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301371 if (FALSE == put_wifi_peer_info(
1372 pWifiPeerInfo, vendor_event))
1373 {
1374 hddLog(VOS_TRACE_LEVEL_ERROR,
1375 "%s: put_wifi_peer_info put fail", __func__);
1376 kfree_skb(vendor_event);
1377 return;
1378 }
1379
1380 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1381 pWifiPeerStat->peerInfo +
1382 (i * sizeof(tSirWifiPeerInfo)) +
1383 (numRate * sizeof (tSirWifiRateStat)));
1384 nla_nest_end(vendor_event, peers);
1385 }
1386 nla_nest_end(vendor_event, peerInfo);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301387 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301388 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301389}
1390
1391/*
1392 * hdd_link_layer_process_iface_stats () - This function is called after
1393 * receiving Link Layer Interface statistics from FW.This function converts
1394 * the firmware data to the NL data and sends the same to the kernel/upper
1395 * layers.
1396 */
1397static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1398 v_VOID_t *pData)
1399{
1400 tpSirWifiIfaceStat pWifiIfaceStat;
1401 struct sk_buff *vendor_event;
1402 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1403 int status;
1404
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301405 ENTER();
1406
Sunil Duttc69bccb2014-05-26 21:30:20 +05301407 status = wlan_hdd_validate_context(pHddCtx);
1408 if (0 != status)
1409 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301410 return;
1411 }
1412 /*
1413 * Allocate a size of 4096 for the interface stats comprising
1414 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1415 * assuming that all these fit with in the limit.Please take
1416 * a call on the limit based on the data requirements on
1417 * interface statistics.
1418 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301419 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1420 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301421 if (!vendor_event)
1422 {
1423 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301424 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301425 return;
1426 }
1427
1428 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1429
Dino Mycle3b9536d2014-07-09 22:05:24 +05301430
1431 if (FALSE == hdd_get_interface_info( pAdapter,
1432 &pWifiIfaceStat->info))
1433 {
1434 hddLog(VOS_TRACE_LEVEL_ERROR,
1435 FL("hdd_get_interface_info get fail") );
1436 kfree_skb(vendor_event);
1437 return;
1438 }
1439
1440 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1441 vendor_event))
1442 {
1443 hddLog(VOS_TRACE_LEVEL_ERROR,
1444 FL("put_wifi_iface_stats fail") );
1445 kfree_skb(vendor_event);
1446 return;
1447 }
1448
Sunil Duttc69bccb2014-05-26 21:30:20 +05301449 hddLog(VOS_TRACE_LEVEL_INFO,
1450 "WMI_LINK_STATS_IFACE Data");
1451
1452 hddLog(VOS_TRACE_LEVEL_INFO,
1453 "LL_STATS_IFACE: "
1454 " Mode %u "
1455 " MAC %pM "
1456 " State %u "
1457 " Roaming %u "
1458 " capabilities 0x%x "
1459 " SSID %s "
1460 " BSSID %pM",
1461 pWifiIfaceStat->info.mode,
1462 pWifiIfaceStat->info.macAddr,
1463 pWifiIfaceStat->info.state,
1464 pWifiIfaceStat->info.roaming,
1465 pWifiIfaceStat->info.capabilities,
1466 pWifiIfaceStat->info.ssid,
1467 pWifiIfaceStat->info.bssid);
1468
1469 hddLog(VOS_TRACE_LEVEL_INFO,
1470 " AP country str: %c%c%c",
1471 pWifiIfaceStat->info.apCountryStr[0],
1472 pWifiIfaceStat->info.apCountryStr[1],
1473 pWifiIfaceStat->info.apCountryStr[2]);
1474
1475
1476 hddLog(VOS_TRACE_LEVEL_INFO,
1477 " Country Str Association: %c%c%c",
1478 pWifiIfaceStat->info.countryStr[0],
1479 pWifiIfaceStat->info.countryStr[1],
1480 pWifiIfaceStat->info.countryStr[2]);
1481
1482 hddLog(VOS_TRACE_LEVEL_INFO,
1483 " beaconRx %u "
1484 " mgmtRx %u "
1485 " mgmtActionRx %u "
1486 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301487 " rssiMgmt %d "
1488 " rssiData %d "
1489 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301490 pWifiIfaceStat->beaconRx,
1491 pWifiIfaceStat->mgmtRx,
1492 pWifiIfaceStat->mgmtActionRx,
1493 pWifiIfaceStat->mgmtActionTx,
1494 pWifiIfaceStat->rssiMgmt,
1495 pWifiIfaceStat->rssiData,
1496 pWifiIfaceStat->rssiAck );
1497
1498
1499 {
1500 int i;
1501 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1502 {
1503 hddLog(VOS_TRACE_LEVEL_INFO,
1504
1505 " %d) LL_STATS IFACE: "
1506 " ac: %u txMpdu: %u "
1507 " rxMpdu: %u txMcast: %u "
1508 " rxMcast: %u rxAmpdu: %u "
1509 " txAmpdu: %u mpduLost: %u "
1510 " retries: %u retriesShort: %u "
1511 " retriesLong: %u contentionTimeMin: %u "
1512 " contentionTimeMax: %u contentionTimeAvg: %u "
1513 " contentionNumSamples: %u",
1514 i,
1515 pWifiIfaceStat->AccessclassStats[i].ac,
1516 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1517 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1518 pWifiIfaceStat->AccessclassStats[i].txMcast,
1519 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1520 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1521 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1522 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1523 pWifiIfaceStat->AccessclassStats[i].retries,
1524 pWifiIfaceStat->
1525 AccessclassStats[i].retriesShort,
1526 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1527 pWifiIfaceStat->
1528 AccessclassStats[i].contentionTimeMin,
1529 pWifiIfaceStat->
1530 AccessclassStats[i].contentionTimeMax,
1531 pWifiIfaceStat->
1532 AccessclassStats[i].contentionTimeAvg,
1533 pWifiIfaceStat->
1534 AccessclassStats[i].contentionNumSamples);
1535
1536 }
1537 }
1538
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301539 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301540
1541 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301542}
1543
1544/*
1545 * hdd_link_layer_process_radio_stats () - This function is called after
1546 * receiving Link Layer Radio statistics from FW.This function converts
1547 * the firmware data to the NL data and sends the same to the kernel/upper
1548 * layers.
1549 */
1550static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1551 v_VOID_t *pData)
1552{
1553 int status, i;
1554 tpSirWifiRadioStat pWifiRadioStat;
1555 tpSirWifiChannelStats pWifiChannelStats;
1556 struct sk_buff *vendor_event;
1557 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1558 struct nlattr *chList;
1559
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301560 ENTER();
1561
Sunil Duttc69bccb2014-05-26 21:30:20 +05301562 status = wlan_hdd_validate_context(pHddCtx);
1563 if (0 != status)
1564 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301565 return;
1566 }
1567 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1568
1569 hddLog(VOS_TRACE_LEVEL_INFO,
1570 "LL_STATS_RADIO"
1571 " radio is %d onTime is %u "
1572 " txTime is %u rxTime is %u "
1573 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301574 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301575 " onTimePnoScan is %u onTimeHs20 is %u "
1576 " numChannels is %u",
1577 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1578 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1579 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301580 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301581 pWifiRadioStat->onTimeRoamScan,
1582 pWifiRadioStat->onTimePnoScan,
1583 pWifiRadioStat->onTimeHs20,
1584 pWifiRadioStat->numChannels);
1585 /*
1586 * Allocate a size of 4096 for the Radio stats comprising
1587 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1588 * (tSirWifiChannelStats).Each channel data is put with an
1589 * NL attribute.The size of 4096 is considered assuming that
1590 * number of channels shall not exceed beyond 60 with the
1591 * sizeof (tSirWifiChannelStats) being 24 bytes.
1592 */
1593
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301594 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1595 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301596 if (!vendor_event)
1597 {
1598 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301599 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301600 return;
1601 }
1602
1603 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301604 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1605 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_RADIO) ||
1606 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301607 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1608 pWifiRadioStat->radio) ||
1609 nla_put_u32(vendor_event,
1610 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1611 pWifiRadioStat->onTime) ||
1612 nla_put_u32(vendor_event,
1613 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1614 pWifiRadioStat->txTime) ||
1615 nla_put_u32(vendor_event,
1616 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1617 pWifiRadioStat->rxTime) ||
1618 nla_put_u32(vendor_event,
1619 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1620 pWifiRadioStat->onTimeScan) ||
1621 nla_put_u32(vendor_event,
1622 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1623 pWifiRadioStat->onTimeNbd) ||
1624 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301625 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1626 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301627 nla_put_u32(vendor_event,
1628 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1629 pWifiRadioStat->onTimeRoamScan) ||
1630 nla_put_u32(vendor_event,
1631 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1632 pWifiRadioStat->onTimePnoScan) ||
1633 nla_put_u32(vendor_event,
1634 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1635 pWifiRadioStat->onTimeHs20) ||
1636 nla_put_u32(vendor_event,
1637 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1638 pWifiRadioStat->numChannels))
1639 {
1640 hddLog(VOS_TRACE_LEVEL_ERROR,
1641 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1642 kfree_skb(vendor_event);
1643 return ;
1644 }
1645
1646 chList = nla_nest_start(vendor_event,
1647 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301648 if(!chList)
1649 {
1650 hddLog(VOS_TRACE_LEVEL_ERROR,
1651 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1652 __func__);
1653 kfree_skb(vendor_event);
1654 return;
1655 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301656 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1657 {
1658 struct nlattr *chInfo;
1659
1660 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1661 pWifiRadioStat->channels +
1662 (i * sizeof(tSirWifiChannelStats)));
1663
1664 hddLog(VOS_TRACE_LEVEL_INFO,
1665 " %d) Channel Info"
1666 " width is %u "
1667 " CenterFreq %u "
1668 " CenterFreq0 %u "
1669 " CenterFreq1 %u "
1670 " onTime %u "
1671 " ccaBusyTime %u",
1672 i,
1673 pWifiChannelStats->channel.width,
1674 pWifiChannelStats->channel.centerFreq,
1675 pWifiChannelStats->channel.centerFreq0,
1676 pWifiChannelStats->channel.centerFreq1,
1677 pWifiChannelStats->onTime,
1678 pWifiChannelStats->ccaBusyTime);
1679
1680
1681 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301682 if(!chInfo)
1683 {
1684 hddLog(VOS_TRACE_LEVEL_ERROR,
1685 "%s: failed to put chInfo",
1686 __func__);
1687 kfree_skb(vendor_event);
1688 return;
1689 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301690
1691 if (nla_put_u32(vendor_event,
1692 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1693 pWifiChannelStats->channel.width) ||
1694 nla_put_u32(vendor_event,
1695 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1696 pWifiChannelStats->channel.centerFreq) ||
1697 nla_put_u32(vendor_event,
1698 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1699 pWifiChannelStats->channel.centerFreq0) ||
1700 nla_put_u32(vendor_event,
1701 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1702 pWifiChannelStats->channel.centerFreq1) ||
1703 nla_put_u32(vendor_event,
1704 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1705 pWifiChannelStats->onTime) ||
1706 nla_put_u32(vendor_event,
1707 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1708 pWifiChannelStats->ccaBusyTime))
1709 {
1710 hddLog(VOS_TRACE_LEVEL_ERROR,
1711 FL("cfg80211_vendor_event_alloc failed") );
1712 kfree_skb(vendor_event);
1713 return ;
1714 }
1715 nla_nest_end(vendor_event, chInfo);
1716 }
1717 nla_nest_end(vendor_event, chList);
1718
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301719 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301720
1721 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301722 return;
1723}
1724
1725/*
1726 * hdd_link_layer_stats_ind_callback () - This function is called after
1727 * receiving Link Layer indications from FW.This callback converts the firmware
1728 * data to the NL data and send the same to the kernel/upper layers.
1729 */
1730static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1731 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301732 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301733{
Dino Mycled3d50022014-07-07 12:58:25 +05301734 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1735 hdd_adapter_t *pAdapter = NULL;
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301736 struct hdd_ll_stats_context *context;
Dino Mycled3d50022014-07-07 12:58:25 +05301737 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301738 int status;
1739
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301740 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301741
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301742 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301743 if (0 != status)
1744 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301745 return;
1746 }
1747
Dino Mycled3d50022014-07-07 12:58:25 +05301748 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1749 if (NULL == pAdapter)
1750 {
1751 hddLog(VOS_TRACE_LEVEL_ERROR,
1752 FL(" MAC address %pM does not exist with host"),
1753 macAddr);
1754 return;
1755 }
1756
Sunil Duttc69bccb2014-05-26 21:30:20 +05301757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301758 "%s: Interface: %s LLStats indType: %d", __func__,
1759 pAdapter->dev->name, indType);
1760
Sunil Duttc69bccb2014-05-26 21:30:20 +05301761 switch (indType)
1762 {
1763 case SIR_HAL_LL_STATS_RESULTS_RSP:
1764 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301765 hddLog(VOS_TRACE_LEVEL_INFO,
1766 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1767 hddLog(VOS_TRACE_LEVEL_INFO,
1768 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1769 linkLayerStatsResults->paramId);
1770 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301771 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1772 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301773 hddLog(VOS_TRACE_LEVEL_INFO,
1774 "LL_STATS RESULTS RESPONSE respId = %u",
1775 linkLayerStatsResults->respId);
1776 hddLog(VOS_TRACE_LEVEL_INFO,
1777 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1778 linkLayerStatsResults->moreResultToFollow);
1779 hddLog(VOS_TRACE_LEVEL_INFO,
1780 "LL_STATS RESULTS RESPONSE result = %p",
1781 linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301782 spin_lock(&hdd_context_lock);
1783 context = &pHddCtx->ll_stats_context;
1784 /* validate response received from target */
1785 if ((context->request_id != linkLayerStatsResults->respId) ||
1786 !(context->request_bitmap & linkLayerStatsResults->paramId))
1787 {
1788 spin_unlock(&hdd_context_lock);
1789 hddLog(LOGE,
1790 FL("Error : Request id %d response id %d request bitmap 0x%x"
1791 "response bitmap 0x%x"),
1792 context->request_id, linkLayerStatsResults->respId,
1793 context->request_bitmap, linkLayerStatsResults->paramId);
1794 return;
1795 }
1796 spin_unlock(&hdd_context_lock);
1797
Sunil Duttc69bccb2014-05-26 21:30:20 +05301798 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1799 {
1800 hdd_link_layer_process_radio_stats(pAdapter,
1801 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301802 spin_lock(&hdd_context_lock);
1803 context->request_bitmap &= ~(WMI_LINK_STATS_RADIO);
1804 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301805 }
1806 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1807 {
1808 hdd_link_layer_process_iface_stats(pAdapter,
1809 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301810 spin_lock(&hdd_context_lock);
1811 context->request_bitmap &= ~(WMI_LINK_STATS_IFACE);
1812 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301813 }
1814 else if ( linkLayerStatsResults->paramId &
1815 WMI_LINK_STATS_ALL_PEER )
1816 {
1817 hdd_link_layer_process_peer_stats(pAdapter,
1818 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301819 spin_lock(&hdd_context_lock);
1820 context->request_bitmap &= ~(WMI_LINK_STATS_ALL_PEER);
1821 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301822 } /* WMI_LINK_STATS_ALL_PEER */
1823 else
1824 {
1825 hddLog(VOS_TRACE_LEVEL_ERROR,
1826 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1827 }
1828
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301829 spin_lock(&hdd_context_lock);
1830 /* complete response event if all requests are completed */
1831 if (0 == context->request_bitmap)
1832 complete(&context->response_event);
1833 spin_unlock(&hdd_context_lock);
1834
Sunil Duttc69bccb2014-05-26 21:30:20 +05301835 break;
1836 }
1837 default:
1838 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1839 break;
1840 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301841
1842 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301843 return;
1844}
1845
1846const struct
1847nla_policy
1848qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1849{
1850 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1851 { .type = NLA_U32 },
1852 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1853 { .type = NLA_U32 },
1854};
1855
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301856static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1857 struct wireless_dev *wdev,
1858 const void *data,
1859 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301860{
1861 int status;
1862 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301863 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301864 struct net_device *dev = wdev->netdev;
1865 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1866 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1867
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301868 ENTER();
1869
Sunil Duttc69bccb2014-05-26 21:30:20 +05301870 status = wlan_hdd_validate_context(pHddCtx);
1871 if (0 != status)
1872 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301873 return -EINVAL;
1874 }
1875
1876 if (NULL == pAdapter)
1877 {
1878 hddLog(VOS_TRACE_LEVEL_ERROR,
1879 FL("HDD adapter is Null"));
1880 return -ENODEV;
1881 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301882 /* check the LLStats Capability */
1883 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1884 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1885 {
1886 hddLog(VOS_TRACE_LEVEL_ERROR,
1887 FL("Link Layer Statistics not supported by Firmware"));
1888 return -EINVAL;
1889 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301890
1891 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1892 (struct nlattr *)data,
1893 data_len, qca_wlan_vendor_ll_set_policy))
1894 {
1895 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1896 return -EINVAL;
1897 }
1898 if (!tb_vendor
1899 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1900 {
1901 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1902 return -EINVAL;
1903 }
1904 if (!tb_vendor[
1905 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1906 {
1907 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1908 return -EINVAL;
1909 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301910 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301911 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301912
Dino Mycledf0a5d92014-07-04 09:41:55 +05301913 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301914 nla_get_u32(
1915 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1916
Dino Mycledf0a5d92014-07-04 09:41:55 +05301917 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301918 nla_get_u32(
1919 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1920
Dino Mycled3d50022014-07-07 12:58:25 +05301921 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1922 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301923
1924
1925 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301926 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301927 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301928 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301929 hddLog(VOS_TRACE_LEVEL_INFO,
1930 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301931 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301932 hddLog(VOS_TRACE_LEVEL_INFO,
1933 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301934 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301935
1936 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1937 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301938 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301939 {
1940 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1941 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301942 return -EINVAL;
1943
1944 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301945
Sunil Duttc69bccb2014-05-26 21:30:20 +05301946 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301947 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301948 {
1949 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1950 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301951 return -EINVAL;
1952 }
1953
1954 pAdapter->isLinkLayerStatsSet = 1;
1955
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301956 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301957 return 0;
1958}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301959static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1960 struct wireless_dev *wdev,
1961 const void *data,
1962 int data_len)
1963{
1964 int ret = 0;
1965
1966 vos_ssr_protect(__func__);
1967 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1968 vos_ssr_unprotect(__func__);
1969
1970 return ret;
1971}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301972
1973const struct
1974nla_policy
1975qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1976{
1977 /* Unsigned 32bit value provided by the caller issuing the GET stats
1978 * command. When reporting
1979 * the stats results, the driver uses the same value to indicate
1980 * which GET request the results
1981 * correspond to.
1982 */
1983 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1984
1985 /* Unsigned 32bit value . bit mask to identify what statistics are
1986 requested for retrieval */
1987 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1988};
1989
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301990static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1991 struct wireless_dev *wdev,
1992 const void *data,
1993 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301994{
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301995 unsigned long rc;
1996 struct hdd_ll_stats_context *context;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301997 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1998 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301999 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302000 struct net_device *dev = wdev->netdev;
2001 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mukul Sharma10313ba2015-07-29 19:14:39 +05302002 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302003 int status;
2004
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302005 ENTER();
2006
Sunil Duttc69bccb2014-05-26 21:30:20 +05302007 status = wlan_hdd_validate_context(pHddCtx);
2008 if (0 != status)
2009 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302010 return -EINVAL ;
2011 }
2012
2013 if (NULL == pAdapter)
2014 {
2015 hddLog(VOS_TRACE_LEVEL_FATAL,
2016 "%s: HDD adapter is Null", __func__);
2017 return -ENODEV;
2018 }
Mukul Sharma10313ba2015-07-29 19:14:39 +05302019
2020 if (pHddStaCtx == NULL)
2021 {
2022 hddLog(VOS_TRACE_LEVEL_FATAL,
2023 "%s: HddStaCtx is Null", __func__);
2024 return -ENODEV;
2025 }
2026
Dino Mycledf0a5d92014-07-04 09:41:55 +05302027 /* check the LLStats Capability */
2028 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2029 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2030 {
2031 hddLog(VOS_TRACE_LEVEL_ERROR,
2032 FL("Link Layer Statistics not supported by Firmware"));
2033 return -EINVAL;
2034 }
2035
Sunil Duttc69bccb2014-05-26 21:30:20 +05302036
2037 if (!pAdapter->isLinkLayerStatsSet)
2038 {
2039 hddLog(VOS_TRACE_LEVEL_FATAL,
2040 "%s: isLinkLayerStatsSet : %d",
2041 __func__, pAdapter->isLinkLayerStatsSet);
2042 return -EINVAL;
2043 }
2044
Mukul Sharma10313ba2015-07-29 19:14:39 +05302045 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
2046 {
2047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2048 "%s: Roaming in progress, so unable to proceed this request", __func__);
2049 return -EBUSY;
2050 }
2051
Sunil Duttc69bccb2014-05-26 21:30:20 +05302052 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2053 (struct nlattr *)data,
2054 data_len, qca_wlan_vendor_ll_get_policy))
2055 {
2056 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2057 return -EINVAL;
2058 }
2059
2060 if (!tb_vendor
2061 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2062 {
2063 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2064 return -EINVAL;
2065 }
2066
2067 if (!tb_vendor
2068 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2069 {
2070 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
2071 return -EINVAL;
2072 }
2073
Sunil Duttc69bccb2014-05-26 21:30:20 +05302074
Dino Mycledf0a5d92014-07-04 09:41:55 +05302075 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302076 nla_get_u32( tb_vendor[
2077 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05302078 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302079 nla_get_u32( tb_vendor[
2080 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
2081
Dino Mycled3d50022014-07-07 12:58:25 +05302082 vos_mem_copy(linkLayerStatsGetReq.macAddr,
2083 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302084
2085 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302086 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302087 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302088 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302089 hddLog(VOS_TRACE_LEVEL_INFO,
2090 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302091 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302092
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302093 spin_lock(&hdd_context_lock);
2094 context = &pHddCtx->ll_stats_context;
2095 context->request_id = linkLayerStatsGetReq.reqId;
2096 context->request_bitmap = linkLayerStatsGetReq.paramIdMask;
2097 INIT_COMPLETION(context->response_event);
2098 spin_unlock(&hdd_context_lock);
2099
Sunil Duttc69bccb2014-05-26 21:30:20 +05302100 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302101 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302102 {
2103 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2104 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302105 return -EINVAL;
2106 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302107
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302108 rc = wait_for_completion_timeout(&context->response_event,
2109 msecs_to_jiffies(WLAN_WAIT_TIME_LL_STATS));
2110 if (!rc)
2111 {
2112 hddLog(LOGE,
2113 FL("Target response timed out request id %d request bitmap 0x%x"),
2114 context->request_id, context->request_bitmap);
2115 return -ETIMEDOUT;
2116 }
2117
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302118 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302119 return 0;
2120}
2121
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302122static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2123 struct wireless_dev *wdev,
2124 const void *data,
2125 int data_len)
2126{
2127 int ret = 0;
2128
2129 vos_ssr_protect(__func__);
2130 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
2131 vos_ssr_unprotect(__func__);
2132
2133 return ret;
2134}
2135
Sunil Duttc69bccb2014-05-26 21:30:20 +05302136const struct
2137nla_policy
2138qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
2139{
2140 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
2141 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
2142 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
2143 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
2144};
2145
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302146static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2147 struct wireless_dev *wdev,
2148 const void *data,
2149 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302150{
2151 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2152 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302153 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302154 struct net_device *dev = wdev->netdev;
2155 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2156 u32 statsClearReqMask;
2157 u8 stopReq;
2158 int status;
2159
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302160 ENTER();
2161
Sunil Duttc69bccb2014-05-26 21:30:20 +05302162 status = wlan_hdd_validate_context(pHddCtx);
2163 if (0 != status)
2164 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302165 return -EINVAL;
2166 }
2167
2168 if (NULL == pAdapter)
2169 {
2170 hddLog(VOS_TRACE_LEVEL_FATAL,
2171 "%s: HDD adapter is Null", __func__);
2172 return -ENODEV;
2173 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302174 /* check the LLStats Capability */
2175 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2176 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2177 {
2178 hddLog(VOS_TRACE_LEVEL_ERROR,
2179 FL("Enable LLStats Capability"));
2180 return -EINVAL;
2181 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302182
2183 if (!pAdapter->isLinkLayerStatsSet)
2184 {
2185 hddLog(VOS_TRACE_LEVEL_FATAL,
2186 "%s: isLinkLayerStatsSet : %d",
2187 __func__, pAdapter->isLinkLayerStatsSet);
2188 return -EINVAL;
2189 }
2190
2191 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2192 (struct nlattr *)data,
2193 data_len, qca_wlan_vendor_ll_clr_policy))
2194 {
2195 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2196 return -EINVAL;
2197 }
2198
2199 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2200
2201 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2202 {
2203 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2204 return -EINVAL;
2205
2206 }
2207
Sunil Duttc69bccb2014-05-26 21:30:20 +05302208
Dino Mycledf0a5d92014-07-04 09:41:55 +05302209 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302210 nla_get_u32(
2211 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2212
Dino Mycledf0a5d92014-07-04 09:41:55 +05302213 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302214 nla_get_u8(
2215 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2216
2217 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302218 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302219
Dino Mycled3d50022014-07-07 12:58:25 +05302220 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2221 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302222
2223 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302224 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302225 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302226 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302227 hddLog(VOS_TRACE_LEVEL_INFO,
2228 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302229 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302230 hddLog(VOS_TRACE_LEVEL_INFO,
2231 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302232 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302233
2234 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302235 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302236 {
2237 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302238 hdd_station_ctx_t *pHddStaCtx;
2239
2240 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2241 if (VOS_STATUS_SUCCESS !=
2242 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2243 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2244 {
2245 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2246 "WLANTL_ClearInterfaceStats Failed", __func__);
2247 return -EINVAL;
2248 }
2249 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2250 (statsClearReqMask & WIFI_STATS_IFACE)) {
2251 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2252 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2253 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2254 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2255 }
2256
Sunil Duttc69bccb2014-05-26 21:30:20 +05302257 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2258 2 * sizeof(u32) +
2259 NLMSG_HDRLEN);
2260
2261 if (temp_skbuff != NULL)
2262 {
2263
2264 if (nla_put_u32(temp_skbuff,
2265 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2266 statsClearReqMask) ||
2267 nla_put_u32(temp_skbuff,
2268 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2269 stopReq))
2270 {
2271 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2272 kfree_skb(temp_skbuff);
2273 return -EINVAL;
2274 }
2275 /* If the ask is to stop the stats collection as part of clear
2276 * (stopReq = 1) , ensure that no further requests of get
2277 * go to the firmware by having isLinkLayerStatsSet set to 0.
2278 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302279 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302280 * case the firmware is just asked to clear the statistics.
2281 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302282 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302283 pAdapter->isLinkLayerStatsSet = 0;
2284 return cfg80211_vendor_cmd_reply(temp_skbuff);
2285 }
2286 return -ENOMEM;
2287 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302288
2289 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302290 return -EINVAL;
2291}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302292static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2293 struct wireless_dev *wdev,
2294 const void *data,
2295 int data_len)
2296{
2297 int ret = 0;
2298
2299 vos_ssr_protect(__func__);
2300 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2301 vos_ssr_unprotect(__func__);
2302
2303 return ret;
2304
2305
2306}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302307#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2308
Dino Mycle6fb96c12014-06-10 11:52:40 +05302309#ifdef WLAN_FEATURE_EXTSCAN
2310static const struct nla_policy
2311wlan_hdd_extscan_config_policy
2312 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2313{
2314 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2315 { .type = NLA_U32 },
2316 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2317 { .type = NLA_U32 },
2318 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2319 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2320 { .type = NLA_U32 },
2321 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2322 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2323
2324 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2325 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2326 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2327 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2328 { .type = NLA_U8 },
2329 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2330 { .type = NLA_U32 },
2331 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2332 { .type = NLA_U32 },
2333 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2334 { .type = NLA_U32 },
2335 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] =
2336 { .type = NLA_U8 },
2337 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2338 { .type = NLA_U8 },
2339 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2340 { .type = NLA_U8 },
2341
2342 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2343 { .type = NLA_U32 },
2344 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2345 { .type = NLA_UNSPEC },
2346 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2347 { .type = NLA_S32 },
2348 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2349 { .type = NLA_S32 },
2350 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2351 { .type = NLA_U32 },
2352 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2353 { .type = NLA_U32 },
2354 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] =
2355 { .type = NLA_U32 },
2356 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]
2357 = { .type = NLA_U32 },
2358 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] =
2359 { .type = NLA_U32 },
2360 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type =
2361 NLA_U32 },
2362};
2363
2364static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg)
2365{
2366 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2367 struct sk_buff *skb = NULL;
2368 tpSirEXTScanCapabilitiesEvent pData =
2369 (tpSirEXTScanCapabilitiesEvent) pMsg;
2370
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302371 ENTER();
2372
2373 if (wlan_hdd_validate_context(pHddCtx))
2374 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302375 return;
2376 }
2377
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302378 if (!pMsg)
2379 {
2380 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2381 return;
2382 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302383 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302384#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2385 NULL,
2386#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302387 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2388 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
2389 GFP_KERNEL);
2390
2391 if (!skb) {
2392 hddLog(VOS_TRACE_LEVEL_ERROR,
2393 FL("cfg80211_vendor_event_alloc failed"));
2394 return;
2395 }
2396
2397 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2398 hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize);
2399 hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets);
2400 hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan);
2401 hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)",
2402 pData->maxRssiSampleSize);
2403 hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)",
2404 pData->maxScanReportingThreshold);
2405 hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs);
2406 hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)",
2407 pData->maxSignificantWifiChangeAPs);
2408 hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)",
2409 pData->maxBsidHistoryEntries);
2410
2411 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2412 pData->requestId) ||
2413 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) ||
2414 nla_put_u32(skb,
2415 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
2416 pData->scanCacheSize) ||
2417 nla_put_u32(skb,
2418 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
2419 pData->scanBuckets) ||
2420 nla_put_u32(skb,
2421 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
2422 pData->maxApPerScan) ||
2423 nla_put_u32(skb,
2424 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
2425 pData->maxRssiSampleSize) ||
2426 nla_put_u32(skb,
2427 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
2428 pData->maxScanReportingThreshold) ||
2429 nla_put_u32(skb,
2430 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS,
2431 pData->maxHotlistAPs) ||
2432 nla_put_u32(skb,
2433 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
2434 pData->maxSignificantWifiChangeAPs) ||
2435 nla_put_u32(skb,
2436 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
2437 pData->maxBsidHistoryEntries)) {
2438 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2439 goto nla_put_failure;
2440 }
2441
2442 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302443 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302444 return;
2445
2446nla_put_failure:
2447 kfree_skb(skb);
2448 return;
2449}
2450
2451
2452static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2453{
2454 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2455 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2456 struct sk_buff *skb = NULL;
2457 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
2458
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302459 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302460
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302461 if (wlan_hdd_validate_context(pHddCtx)){
2462 return;
2463 }
2464 if (!pMsg)
2465 {
2466 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302467 return;
2468 }
2469
2470 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302471#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2472 NULL,
2473#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302474 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2475 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
2476 GFP_KERNEL);
2477
2478 if (!skb) {
2479 hddLog(VOS_TRACE_LEVEL_ERROR,
2480 FL("cfg80211_vendor_event_alloc failed"));
2481 return;
2482 }
2483 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2484 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2485 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2486
2487 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2488 pData->requestId) ||
2489 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2490 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2491 goto nla_put_failure;
2492 }
2493
2494 /*
2495 * Store the Request ID for comparing with the requestID obtained
2496 * in other requests.HDD shall return a failure is the extscan_stop
2497 * request is issued with a different requestId as that of the
2498 * extscan_start request. Also, This requestId shall be used while
2499 * indicating the full scan results to the upper layers.
2500 * The requestId is stored with the assumption that the firmware
2501 * shall return the ext scan start request's requestId in ext scan
2502 * start response.
2503 */
2504 if (pData->status == 0)
2505 pMac->sme.extScanStartReqId = pData->requestId;
2506
2507
2508 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302509 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302510 return;
2511
2512nla_put_failure:
2513 kfree_skb(skb);
2514 return;
2515}
2516
2517
2518static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2519{
2520 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2521 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2522 struct sk_buff *skb = NULL;
2523
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302524 ENTER();
2525
2526 if (wlan_hdd_validate_context(pHddCtx)){
2527 return;
2528 }
2529 if (!pMsg)
2530 {
2531 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302532 return;
2533 }
2534
2535 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302536#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2537 NULL,
2538#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302539 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2540 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2541 GFP_KERNEL);
2542
2543 if (!skb) {
2544 hddLog(VOS_TRACE_LEVEL_ERROR,
2545 FL("cfg80211_vendor_event_alloc failed"));
2546 return;
2547 }
2548 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2549 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2550
2551 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2552 pData->requestId) ||
2553 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2554 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2555 goto nla_put_failure;
2556 }
2557
2558 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302559 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302560 return;
2561
2562nla_put_failure:
2563 kfree_skb(skb);
2564 return;
2565}
2566
2567
2568static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2569 void *pMsg)
2570{
2571 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2572 struct sk_buff *skb = NULL;
2573 tpSirEXTScanSetBssidHotListRspParams pData =
2574 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2575
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302576 ENTER();
2577
2578 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302579 return;
2580 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302581 if (!pMsg)
2582 {
2583 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2584 return;
2585 }
2586
Dino Mycle6fb96c12014-06-10 11:52:40 +05302587 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302588#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2589 NULL,
2590#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302591 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2592 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2593 GFP_KERNEL);
2594
2595 if (!skb) {
2596 hddLog(VOS_TRACE_LEVEL_ERROR,
2597 FL("cfg80211_vendor_event_alloc failed"));
2598 return;
2599 }
2600 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2601 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2602 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2603
2604 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2605 pData->requestId) ||
2606 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2607 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2608 goto nla_put_failure;
2609 }
2610
2611 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302612 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302613 return;
2614
2615nla_put_failure:
2616 kfree_skb(skb);
2617 return;
2618}
2619
2620static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2621 void *pMsg)
2622{
2623 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2624 struct sk_buff *skb = NULL;
2625 tpSirEXTScanResetBssidHotlistRspParams pData =
2626 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2627
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302628 ENTER();
2629
2630 if (wlan_hdd_validate_context(pHddCtx)) {
2631 return;
2632 }
2633 if (!pMsg)
2634 {
2635 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302636 return;
2637 }
2638
2639 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302640#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2641 NULL,
2642#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302643 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2644 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2645 GFP_KERNEL);
2646
2647 if (!skb) {
2648 hddLog(VOS_TRACE_LEVEL_ERROR,
2649 FL("cfg80211_vendor_event_alloc failed"));
2650 return;
2651 }
2652 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2653 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2654
2655 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2656 pData->requestId) ||
2657 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2658 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2659 goto nla_put_failure;
2660 }
2661
2662 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302663 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302664 return;
2665
2666nla_put_failure:
2667 kfree_skb(skb);
2668 return;
2669}
2670
2671
2672static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2673 void *pMsg)
2674{
2675 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2676 struct sk_buff *skb = NULL;
2677 tpSirEXTScanSetSignificantChangeRspParams pData =
2678 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2679
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302680 ENTER();
2681
2682 if (wlan_hdd_validate_context(pHddCtx)) {
2683 return;
2684 }
2685 if (!pMsg)
2686 {
2687 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302688 return;
2689 }
2690
2691 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302692#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2693 NULL,
2694#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302695 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2696 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2697 GFP_KERNEL);
2698
2699 if (!skb) {
2700 hddLog(VOS_TRACE_LEVEL_ERROR,
2701 FL("cfg80211_vendor_event_alloc failed"));
2702 return;
2703 }
2704 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2705 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2706 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2707
2708 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2709 pData->requestId) ||
2710 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2711 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2712 goto nla_put_failure;
2713 }
2714
2715 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302716 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302717 return;
2718
2719nla_put_failure:
2720 kfree_skb(skb);
2721 return;
2722}
2723
2724
2725static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2726 void *pMsg)
2727{
2728 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2729 struct sk_buff *skb = NULL;
2730 tpSirEXTScanResetSignificantChangeRspParams pData =
2731 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2732
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302733 ENTER();
2734
2735 if (wlan_hdd_validate_context(pHddCtx)) {
2736 return;
2737 }
2738 if (!pMsg)
2739 {
2740 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302741 return;
2742 }
2743
2744 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302745#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2746 NULL,
2747#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302748 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2749 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2750 GFP_KERNEL);
2751
2752 if (!skb) {
2753 hddLog(VOS_TRACE_LEVEL_ERROR,
2754 FL("cfg80211_vendor_event_alloc failed"));
2755 return;
2756 }
2757 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2758 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2759 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2760
2761 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2762 pData->requestId) ||
2763 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2764 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2765 goto nla_put_failure;
2766 }
2767
2768 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302769 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302770 return;
2771
2772nla_put_failure:
2773 kfree_skb(skb);
2774 return;
2775}
2776
2777static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2778 void *pMsg)
2779{
2780 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2781 struct sk_buff *skb = NULL;
2782 tANI_U32 i = 0, j, resultsPerEvent;
2783 tANI_S32 totalResults;
2784 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2785 tpSirWifiScanResult pSirWifiScanResult;
2786
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302787 ENTER();
2788
2789 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302790 return;
2791 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302792 if (!pMsg)
2793 {
2794 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2795 return;
2796 }
2797
Dino Mycle6fb96c12014-06-10 11:52:40 +05302798 totalResults = pData->numOfAps;
2799 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2800 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2801 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2802
2803 do{
2804 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2805 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2806 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2807
2808 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302809#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2810 NULL,
2811#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302812 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2813 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2814 GFP_KERNEL);
2815
2816 if (!skb) {
2817 hddLog(VOS_TRACE_LEVEL_ERROR,
2818 FL("cfg80211_vendor_event_alloc failed"));
2819 return;
2820 }
2821
2822 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2823
2824 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2825 pData->requestId) ||
2826 nla_put_u32(skb,
2827 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2828 resultsPerEvent)) {
2829 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2830 goto fail;
2831 }
2832 if (nla_put_u8(skb,
2833 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2834 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2835 {
2836 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2837 goto fail;
2838 }
2839
2840 if (resultsPerEvent) {
2841 struct nlattr *aps;
2842
2843 aps = nla_nest_start(skb,
2844 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2845 if (!aps)
2846 {
2847 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2848 goto fail;
2849 }
2850
2851 for (j = 0; j < resultsPerEvent; j++, i++) {
2852 struct nlattr *ap;
2853 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2854 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2855
2856 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2857 "Ssid (%s)"
2858 "Bssid: %pM "
2859 "Channel (%u)"
2860 "Rssi (%d)"
2861 "RTT (%u)"
2862 "RTT_SD (%u)",
2863 i,
2864 pSirWifiScanResult->ts,
2865 pSirWifiScanResult->ssid,
2866 pSirWifiScanResult->bssid,
2867 pSirWifiScanResult->channel,
2868 pSirWifiScanResult->rssi,
2869 pSirWifiScanResult->rtt,
2870 pSirWifiScanResult->rtt_sd);
2871
2872 ap = nla_nest_start(skb, j + 1);
2873 if (!ap)
2874 {
2875 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2876 goto fail;
2877 }
2878
2879 if (nla_put_u64(skb,
2880 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2881 pSirWifiScanResult->ts) )
2882 {
2883 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2884 goto fail;
2885 }
2886 if (nla_put(skb,
2887 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2888 sizeof(pSirWifiScanResult->ssid),
2889 pSirWifiScanResult->ssid) )
2890 {
2891 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2892 goto fail;
2893 }
2894 if (nla_put(skb,
2895 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2896 sizeof(pSirWifiScanResult->bssid),
2897 pSirWifiScanResult->bssid) )
2898 {
2899 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2900 goto fail;
2901 }
2902 if (nla_put_u32(skb,
2903 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2904 pSirWifiScanResult->channel) )
2905 {
2906 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2907 goto fail;
2908 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302909 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302910 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2911 pSirWifiScanResult->rssi) )
2912 {
2913 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2914 goto fail;
2915 }
2916 if (nla_put_u32(skb,
2917 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2918 pSirWifiScanResult->rtt) )
2919 {
2920 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2921 goto fail;
2922 }
2923 if (nla_put_u32(skb,
2924 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2925 pSirWifiScanResult->rtt_sd))
2926 {
2927 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2928 goto fail;
2929 }
2930
2931 nla_nest_end(skb, ap);
2932 }
2933 nla_nest_end(skb, aps);
2934
2935 }
2936 cfg80211_vendor_event(skb, GFP_KERNEL);
2937 } while (totalResults > 0);
2938
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302939 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302940 return;
2941fail:
2942 kfree_skb(skb);
2943 return;
2944}
2945
2946static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2947 void *pMsg)
2948{
2949 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2950 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2951 struct sk_buff *skb = NULL;
2952 tANI_U32 i;
2953
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302954 ENTER();
2955
2956 if (wlan_hdd_validate_context(pHddCtx)) {
2957 return;
2958 }
2959 if (!pMsg)
2960 {
2961 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302962 return;
2963 }
2964
2965 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302966#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2967 NULL,
2968#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302969 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2970 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
2971 GFP_KERNEL);
2972
2973 if (!skb) {
2974 hddLog(VOS_TRACE_LEVEL_ERROR,
2975 FL("cfg80211_vendor_event_alloc failed"));
2976 return;
2977 }
2978 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2979 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2980 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2981 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2982
2983 for (i = 0; i < pData->numOfAps; i++) {
2984 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2985 "Ssid (%s) "
2986 "Bssid (" MAC_ADDRESS_STR ") "
2987 "Channel (%u) "
2988 "Rssi (%d) "
2989 "RTT (%u) "
2990 "RTT_SD (%u) ",
2991 i,
2992 pData->ap[i].ts,
2993 pData->ap[i].ssid,
2994 MAC_ADDR_ARRAY(pData->ap[i].bssid),
2995 pData->ap[i].channel,
2996 pData->ap[i].rssi,
2997 pData->ap[i].rtt,
2998 pData->ap[i].rtt_sd);
2999 }
3000
3001 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3002 pData->requestId) ||
3003 nla_put_u32(skb,
3004 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3005 pData->numOfAps)) {
3006 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3007 goto fail;
3008 }
3009 if (pData->numOfAps) {
3010 struct nlattr *aps;
3011
3012 aps = nla_nest_start(skb,
3013 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3014 if (!aps)
3015 goto fail;
3016
3017 for (i = 0; i < pData->numOfAps; i++) {
3018 struct nlattr *ap;
3019
3020 ap = nla_nest_start(skb, i + 1);
3021 if (!ap)
3022 goto fail;
3023
3024 if (nla_put_u64(skb,
3025 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3026 pData->ap[i].ts) ||
3027 nla_put(skb,
3028 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3029 sizeof(pData->ap[i].ssid),
3030 pData->ap[i].ssid) ||
3031 nla_put(skb,
3032 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3033 sizeof(pData->ap[i].bssid),
3034 pData->ap[i].bssid) ||
3035 nla_put_u32(skb,
3036 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3037 pData->ap[i].channel) ||
3038 nla_put_s32(skb,
3039 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
3040 pData->ap[i].rssi) ||
3041 nla_put_u32(skb,
3042 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3043 pData->ap[i].rtt) ||
3044 nla_put_u32(skb,
3045 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3046 pData->ap[i].rtt_sd))
3047 goto fail;
3048
3049 nla_nest_end(skb, ap);
3050 }
3051 nla_nest_end(skb, aps);
3052
3053 if (nla_put_u8(skb,
3054 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3055 pData->moreData))
3056 goto fail;
3057 }
3058
3059 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303060 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303061 return;
3062
3063fail:
3064 kfree_skb(skb);
3065 return;
3066
3067}
3068static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
3069 void *pMsg)
3070{
3071 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3072 struct sk_buff *skb = NULL;
3073 tANI_U32 i, j;
3074 tpSirWifiSignificantChangeEvent pData =
3075 (tpSirWifiSignificantChangeEvent) pMsg;
3076
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303077 ENTER();
3078
3079 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303080 return;
3081 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303082 if (!pMsg)
3083 {
3084 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3085 return;
3086 }
3087
Dino Mycle6fb96c12014-06-10 11:52:40 +05303088 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303089#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3090 NULL,
3091#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303092 EXTSCAN_EVENT_BUF_SIZE,
3093 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
3094 GFP_KERNEL);
3095
3096 if (!skb) {
3097 hddLog(VOS_TRACE_LEVEL_ERROR,
3098 FL("cfg80211_vendor_event_alloc failed"));
3099 return;
3100 }
3101 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3102 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3103 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
3104 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
3105 pData->numSigRssiBss);
3106 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
3107
3108 for (i = 0; i < pData->numSigRssiBss; i++) {
3109 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
3110 " num RSSI %u ",
3111 i, pData->sigRssiResult[i].bssid,
3112 pData->sigRssiResult[i].channel,
3113 pData->sigRssiResult[i].numRssi);
3114
3115 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
3116
3117 hddLog(VOS_TRACE_LEVEL_INFO,
3118 " [%d]",
Dino Myclec8f3f332014-07-21 16:48:27 +05303119 pData->sigRssiResult[i].rssi[j]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303120
3121 }
3122 }
3123
3124
3125 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3126 pData->requestId) ||
3127 nla_put_u32(skb,
3128 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3129 pData->numSigRssiBss)) {
3130 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3131 goto fail;
3132 }
3133
3134 if (pData->numSigRssiBss) {
3135 struct nlattr *aps;
3136 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3137 if (!aps)
3138 goto fail;
3139 for (i = 0; i < pData->numSigRssiBss; i++) {
3140 struct nlattr *ap;
3141
3142 ap = nla_nest_start(skb, i);
3143 if (!ap)
3144 goto fail;
3145 if (nla_put(skb,
3146 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
3147 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
3148 nla_put_u32(skb,
3149 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
3150 pData->sigRssiResult[i].channel) ||
3151 nla_put_u32(skb,
3152 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
3153 pData->sigRssiResult[i].numRssi) ||
3154 nla_put(skb,
3155 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
3156 sizeof(s32) * pData->sigRssiResult[i].numRssi,
3157 pData->sigRssiResult[i].rssi))
3158 goto fail;
3159 nla_nest_end(skb, ap);
3160 }
3161 nla_nest_end(skb, aps);
3162 if (nla_put_u8(skb,
3163 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3164 pData->moreData))
3165 goto fail;
3166 }
3167 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303168 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303169 return;
3170fail:
3171 kfree_skb(skb);
3172 return;
3173}
3174
3175static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3176 void *pMsg)
3177{
3178 struct sk_buff *skb;
3179 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3180 tpSirWifiFullScanResultEvent pData =
3181 (tpSirWifiFullScanResultEvent) (pMsg);
3182
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303183 ENTER();
3184
3185 if (wlan_hdd_validate_context(pHddCtx)) {
3186 return;
3187 }
3188 if (!pMsg)
3189 {
3190 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303191 return;
3192 }
3193
3194 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303195#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3196 NULL,
3197#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303198 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3199 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3200 GFP_KERNEL);
3201
3202 if (!skb) {
3203 hddLog(VOS_TRACE_LEVEL_ERROR,
3204 FL("cfg80211_vendor_event_alloc failed"));
3205 return;
3206 }
3207
3208 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3209 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3210 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3211 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3212 "Ssid (%s)"
3213 "Bssid (" MAC_ADDRESS_STR ")"
3214 "Channel (%u)"
3215 "Rssi (%d)"
3216 "RTT (%u)"
3217 "RTT_SD (%u)"),
3218 pData->ap.ts,
3219 pData->ap.ssid,
3220 MAC_ADDR_ARRAY(pData->ap.bssid),
3221 pData->ap.channel,
3222 pData->ap.rssi,
3223 pData->ap.rtt,
3224 pData->ap.rtt_sd);
3225 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3226 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3227 pData->requestId) ||
3228 nla_put_u64(skb,
3229 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3230 pData->ap.ts) ||
3231 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3232 sizeof(pData->ap.ssid),
3233 pData->ap.ssid) ||
3234 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3235 WNI_CFG_BSSID_LEN,
3236 pData->ap.bssid) ||
3237 nla_put_u32(skb,
3238 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3239 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303240 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303241 pData->ap.rssi) ||
3242 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3243 pData->ap.rtt) ||
3244 nla_put_u32(skb,
3245 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3246 pData->ap.rtt_sd) ||
3247 nla_put_u16(skb,
3248 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3249 pData->ap.beaconPeriod) ||
3250 nla_put_u16(skb,
3251 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3252 pData->ap.capability) ||
3253 nla_put_u32(skb,
3254 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3255 pData->ieLength))
3256 {
3257 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3258 goto nla_put_failure;
3259 }
3260 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3261 pData->ieLength,
3262 pData->ie))
3263 {
3264 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3265 goto nla_put_failure;
3266 }
3267
3268 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303269 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303270 return;
3271
3272nla_put_failure:
3273 kfree_skb(skb);
3274 return;
3275}
3276
3277static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3278 void *pMsg)
3279{
3280 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3281 struct sk_buff *skb = NULL;
3282 tpSirEXTScanResultsAvailableIndParams pData =
3283 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3284
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303285 ENTER();
3286
3287 if (wlan_hdd_validate_context(pHddCtx)){
3288 return;
3289 }
3290 if (!pMsg)
3291 {
3292 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303293 return;
3294 }
3295
3296 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303297#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3298 NULL,
3299#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303300 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3301 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3302 GFP_KERNEL);
3303
3304 if (!skb) {
3305 hddLog(VOS_TRACE_LEVEL_ERROR,
3306 FL("cfg80211_vendor_event_alloc failed"));
3307 return;
3308 }
3309
3310 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3311 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3312 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3313 pData->numResultsAvailable);
3314 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3315 pData->requestId) ||
3316 nla_put_u32(skb,
3317 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3318 pData->numResultsAvailable)) {
3319 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3320 goto nla_put_failure;
3321 }
3322
3323 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303324 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303325 return;
3326
3327nla_put_failure:
3328 kfree_skb(skb);
3329 return;
3330}
3331
3332static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3333{
3334 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3335 struct sk_buff *skb = NULL;
3336 tpSirEXTScanProgressIndParams pData =
3337 (tpSirEXTScanProgressIndParams) pMsg;
3338
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303339 ENTER();
3340
3341 if (wlan_hdd_validate_context(pHddCtx)){
3342 return;
3343 }
3344 if (!pMsg)
3345 {
3346 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303347 return;
3348 }
3349
3350 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303351#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3352 NULL,
3353#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303354 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3355 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3356 GFP_KERNEL);
3357
3358 if (!skb) {
3359 hddLog(VOS_TRACE_LEVEL_ERROR,
3360 FL("cfg80211_vendor_event_alloc failed"));
3361 return;
3362 }
3363 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3364 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3365 pData->extScanEventType);
3366 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3367 pData->status);
3368
3369 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3370 pData->extScanEventType) ||
3371 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303372 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3373 pData->requestId) ||
3374 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303375 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3376 pData->status)) {
3377 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3378 goto nla_put_failure;
3379 }
3380
3381 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303382 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303383 return;
3384
3385nla_put_failure:
3386 kfree_skb(skb);
3387 return;
3388}
3389
3390void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3391 void *pMsg)
3392{
3393 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3394
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303395 ENTER();
3396
Dino Mycle6fb96c12014-06-10 11:52:40 +05303397 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303398 return;
3399 }
3400
3401 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3402
3403
3404 switch(evType) {
3405 case SIR_HAL_EXTSCAN_START_RSP:
3406 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3407 break;
3408
3409 case SIR_HAL_EXTSCAN_STOP_RSP:
3410 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3411 break;
3412 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3413 /* There is no need to send this response to upper layer
3414 Just log the message */
3415 hddLog(VOS_TRACE_LEVEL_INFO,
3416 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3417 break;
3418 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3419 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3420 break;
3421
3422 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3423 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3424 break;
3425
3426 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
3427 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
3428 break;
3429
3430 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
3431 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
3432 break;
3433 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
3434 wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg);
3435 break;
3436 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3437 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3438 break;
3439 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3440 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3441 break;
3442 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3443 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3444 break;
3445 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3446 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3447 break;
3448 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
3449 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
3450 break;
3451 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3452 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3453 break;
3454 default:
3455 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3456 break;
3457 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303458 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303459}
3460
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303461static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3462 struct wireless_dev *wdev,
3463 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303464{
Dino Myclee8843b32014-07-04 14:21:45 +05303465 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303466 struct net_device *dev = wdev->netdev;
3467 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3468 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3469 struct nlattr
3470 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3471 eHalStatus status;
3472
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303473 ENTER();
3474
Dino Mycle6fb96c12014-06-10 11:52:40 +05303475 status = wlan_hdd_validate_context(pHddCtx);
3476 if (0 != status)
3477 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303478 return -EINVAL;
3479 }
Dino Myclee8843b32014-07-04 14:21:45 +05303480 /* check the EXTScan Capability */
3481 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3482 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3483 {
3484 hddLog(VOS_TRACE_LEVEL_ERROR,
3485 FL("EXTScan not enabled/supported by Firmware"));
3486 return -EINVAL;
3487 }
3488
Dino Mycle6fb96c12014-06-10 11:52:40 +05303489 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3490 data, dataLen,
3491 wlan_hdd_extscan_config_policy)) {
3492 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3493 return -EINVAL;
3494 }
3495
3496 /* Parse and fetch request Id */
3497 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3498 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3499 return -EINVAL;
3500 }
3501
Dino Mycle6fb96c12014-06-10 11:52:40 +05303502
Dino Myclee8843b32014-07-04 14:21:45 +05303503 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303504 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303505 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303506
Dino Myclee8843b32014-07-04 14:21:45 +05303507 reqMsg.sessionId = pAdapter->sessionId;
3508 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303509
Dino Myclee8843b32014-07-04 14:21:45 +05303510 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303511 if (!HAL_STATUS_SUCCESS(status)) {
3512 hddLog(VOS_TRACE_LEVEL_ERROR,
3513 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303514 return -EINVAL;
3515 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303516 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303517 return 0;
3518}
3519
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303520static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3521 struct wireless_dev *wdev,
3522 const void *data, int dataLen)
3523{
3524 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303525
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303526 vos_ssr_protect(__func__);
3527 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3528 vos_ssr_unprotect(__func__);
3529
3530 return ret;
3531}
3532
3533static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3534 struct wireless_dev *wdev,
3535 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303536{
Dino Myclee8843b32014-07-04 14:21:45 +05303537 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303538 struct net_device *dev = wdev->netdev;
3539 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3540 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3541 struct nlattr
3542 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3543 eHalStatus status;
3544
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303545 ENTER();
3546
Dino Mycle6fb96c12014-06-10 11:52:40 +05303547 status = wlan_hdd_validate_context(pHddCtx);
3548 if (0 != status)
3549 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303550 return -EINVAL;
3551 }
Dino Myclee8843b32014-07-04 14:21:45 +05303552 /* check the EXTScan Capability */
3553 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3554 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3555 {
3556 hddLog(VOS_TRACE_LEVEL_ERROR,
3557 FL("EXTScan not enabled/supported by Firmware"));
3558 return -EINVAL;
3559 }
3560
Dino Mycle6fb96c12014-06-10 11:52:40 +05303561 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3562 data, dataLen,
3563 wlan_hdd_extscan_config_policy)) {
3564 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3565 return -EINVAL;
3566 }
3567 /* Parse and fetch request Id */
3568 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3569 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3570 return -EINVAL;
3571 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303572
Dino Myclee8843b32014-07-04 14:21:45 +05303573 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303574 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3575
Dino Myclee8843b32014-07-04 14:21:45 +05303576 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303577
Dino Myclee8843b32014-07-04 14:21:45 +05303578 reqMsg.sessionId = pAdapter->sessionId;
3579 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303580
3581 /* Parse and fetch flush parameter */
3582 if (!tb
3583 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3584 {
3585 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3586 goto failed;
3587 }
Dino Myclee8843b32014-07-04 14:21:45 +05303588 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303589 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3590
Dino Myclee8843b32014-07-04 14:21:45 +05303591 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303592
Dino Myclee8843b32014-07-04 14:21:45 +05303593 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303594 if (!HAL_STATUS_SUCCESS(status)) {
3595 hddLog(VOS_TRACE_LEVEL_ERROR,
3596 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303597 return -EINVAL;
3598 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303599 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303600 return 0;
3601
3602failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303603 return -EINVAL;
3604}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303605static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3606 struct wireless_dev *wdev,
3607 const void *data, int dataLen)
3608{
3609 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303610
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303611 vos_ssr_protect(__func__);
3612 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3613 vos_ssr_unprotect(__func__);
3614
3615 return ret;
3616}
3617
3618static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303619 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303620 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303621{
3622 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3623 struct net_device *dev = wdev->netdev;
3624 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3625 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3626 struct nlattr
3627 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3628 struct nlattr
3629 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3630 struct nlattr *apTh;
3631 eHalStatus status;
3632 tANI_U8 i = 0;
3633 int rem;
3634
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303635 ENTER();
3636
Dino Mycle6fb96c12014-06-10 11:52:40 +05303637 status = wlan_hdd_validate_context(pHddCtx);
3638 if (0 != status)
3639 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303640 return -EINVAL;
3641 }
Dino Myclee8843b32014-07-04 14:21:45 +05303642 /* check the EXTScan Capability */
3643 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3644 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3645 {
3646 hddLog(VOS_TRACE_LEVEL_ERROR,
3647 FL("EXTScan not enabled/supported by Firmware"));
3648 return -EINVAL;
3649 }
3650
Dino Mycle6fb96c12014-06-10 11:52:40 +05303651 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3652 data, dataLen,
3653 wlan_hdd_extscan_config_policy)) {
3654 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3655 return -EINVAL;
3656 }
3657
3658 /* Parse and fetch request Id */
3659 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3660 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3661 return -EINVAL;
3662 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303663 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3664 vos_mem_malloc(sizeof(*pReqMsg));
3665 if (!pReqMsg) {
3666 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3667 return -ENOMEM;
3668 }
3669
Dino Myclee8843b32014-07-04 14:21:45 +05303670
Dino Mycle6fb96c12014-06-10 11:52:40 +05303671 pReqMsg->requestId = nla_get_u32(
3672 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3673 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3674
3675 /* Parse and fetch number of APs */
3676 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3677 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3678 goto fail;
3679 }
3680
3681 pReqMsg->sessionId = pAdapter->sessionId;
3682 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3683
3684 pReqMsg->numAp = nla_get_u32(
3685 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3686 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3687
3688 nla_for_each_nested(apTh,
3689 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3690 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3691 nla_data(apTh), nla_len(apTh),
3692 NULL)) {
3693 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3694 goto fail;
3695 }
3696
3697 /* Parse and fetch MAC address */
3698 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3699 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3700 goto fail;
3701 }
3702 memcpy(pReqMsg->ap[i].bssid, nla_data(
3703 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3704 sizeof(tSirMacAddr));
3705 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3706
3707 /* Parse and fetch low RSSI */
3708 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3709 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3710 goto fail;
3711 }
3712 pReqMsg->ap[i].low = nla_get_s32(
3713 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3714 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3715
3716 /* Parse and fetch high RSSI */
3717 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3718 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3719 goto fail;
3720 }
3721 pReqMsg->ap[i].high = nla_get_s32(
3722 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3723 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3724 pReqMsg->ap[i].high);
3725
3726 /* Parse and fetch channel */
3727 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3728 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3729 goto fail;
3730 }
3731 pReqMsg->ap[i].channel = nla_get_u32(
3732 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3733 hddLog(VOS_TRACE_LEVEL_INFO,
3734 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3735 i++;
3736 }
3737 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3738 if (!HAL_STATUS_SUCCESS(status)) {
3739 hddLog(VOS_TRACE_LEVEL_ERROR,
3740 FL("sme_SetBssHotlist failed(err=%d)"), status);
3741 vos_mem_free(pReqMsg);
3742 return -EINVAL;
3743 }
3744
Dino Myclee8843b32014-07-04 14:21:45 +05303745 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303746 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303747 return 0;
3748
3749fail:
3750 vos_mem_free(pReqMsg);
3751 return -EINVAL;
3752}
3753
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303754static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3755 struct wireless_dev *wdev,
3756 const void *data, int dataLen)
3757{
3758 int ret = 0;
3759
3760 vos_ssr_protect(__func__);
3761 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3762 dataLen);
3763 vos_ssr_unprotect(__func__);
3764
3765 return ret;
3766}
3767
3768static int __wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303769 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303770 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303771{
3772 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3773 struct net_device *dev = wdev->netdev;
3774 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3775 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3776 struct nlattr
3777 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3778 struct nlattr
3779 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3780 struct nlattr *apTh;
3781 eHalStatus status;
3782 int i = 0;
3783 int rem;
3784
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303785 ENTER();
3786
Dino Mycle6fb96c12014-06-10 11:52:40 +05303787 status = wlan_hdd_validate_context(pHddCtx);
3788 if (0 != status)
3789 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303790 return -EINVAL;
3791 }
Dino Myclee8843b32014-07-04 14:21:45 +05303792 /* check the EXTScan Capability */
3793 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3794 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3795 {
3796 hddLog(VOS_TRACE_LEVEL_ERROR,
3797 FL("EXTScan not enabled/supported by Firmware"));
3798 return -EINVAL;
3799 }
3800
Dino Mycle6fb96c12014-06-10 11:52:40 +05303801 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3802 data, dataLen,
3803 wlan_hdd_extscan_config_policy)) {
3804 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3805 return -EINVAL;
3806 }
3807
3808 /* Parse and fetch request Id */
3809 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3810 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3811 return -EINVAL;
3812 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303813 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303814 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303815 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303816 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3817 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303818 }
3819
Dino Myclee8843b32014-07-04 14:21:45 +05303820
3821
Dino Mycle6fb96c12014-06-10 11:52:40 +05303822 pReqMsg->requestId = nla_get_u32(
3823 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3824 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3825
3826 /* Parse and fetch RSSI sample size */
3827 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3828 {
3829 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3830 goto fail;
3831 }
3832 pReqMsg->rssiSampleSize = nla_get_u32(
3833 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3834 hddLog(VOS_TRACE_LEVEL_INFO,
3835 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3836
3837 /* Parse and fetch lost AP sample size */
3838 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3839 {
3840 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3841 goto fail;
3842 }
3843 pReqMsg->lostApSampleSize = nla_get_u32(
3844 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3845 hddLog(VOS_TRACE_LEVEL_INFO,
3846 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3847 /* Parse and fetch minimum Breaching */
3848 if (!tb
3849 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3850 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3851 goto fail;
3852 }
3853 pReqMsg->minBreaching = nla_get_u32(
3854 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3855 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3856
3857 /* Parse and fetch number of APs */
3858 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3859 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3860 goto fail;
3861 }
3862 pReqMsg->numAp = nla_get_u32(
3863 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3864 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3865
3866 pReqMsg->sessionId = pAdapter->sessionId;
3867 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3868
3869 nla_for_each_nested(apTh,
3870 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3871 if(nla_parse(tb2,
3872 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3873 nla_data(apTh), nla_len(apTh),
3874 NULL)) {
3875 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3876 goto fail;
3877 }
3878
3879 /* Parse and fetch MAC address */
3880 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3881 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3882 goto fail;
3883 }
3884 memcpy(pReqMsg->ap[i].bssid, nla_data(
3885 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3886 sizeof(tSirMacAddr));
3887
3888 /* Parse and fetch low RSSI */
3889 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3890 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3891 goto fail;
3892 }
3893 pReqMsg->ap[i].low = nla_get_s32(
3894 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3895 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3896
3897 /* Parse and fetch high RSSI */
3898 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3899 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3900 goto fail;
3901 }
3902 pReqMsg->ap[i].high = nla_get_s32(
3903 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3904 hddLog(VOS_TRACE_LEVEL_INFO,
3905 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
3906
3907 /* Parse and fetch channel */
3908 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3909 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3910 goto fail;
3911 }
3912 pReqMsg->ap[i].channel = nla_get_u32(
3913 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3914 hddLog(VOS_TRACE_LEVEL_INFO,
3915 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3916 i++;
3917 }
3918
3919 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
3920 if (!HAL_STATUS_SUCCESS(status)) {
3921 hddLog(VOS_TRACE_LEVEL_ERROR,
3922 FL("sme_SetSignificantChange failed(err=%d)"), status);
3923 vos_mem_free(pReqMsg);
3924 return -EINVAL;
3925 }
Dino Myclee8843b32014-07-04 14:21:45 +05303926 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303927 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303928 return 0;
3929
3930fail:
3931 vos_mem_free(pReqMsg);
3932 return -EINVAL;
3933}
3934
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303935static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
3936 struct wireless_dev *wdev,
3937 const void *data, int dataLen)
3938{
3939 int ret = 0;
3940
3941 vos_ssr_protect(__func__);
3942 ret = __wlan_hdd_cfg80211_extscan_set_significant_change(wiphy, wdev, data,
3943 dataLen);
3944 vos_ssr_unprotect(__func__);
3945
3946 return ret;
3947}
3948
3949static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303950 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303951 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303952{
3953 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3954 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3955 tANI_U8 numChannels = 0;
3956 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3957 tANI_U32 requestId;
3958 tWifiBand wifiBand;
3959 eHalStatus status;
3960 struct sk_buff *replySkb;
3961 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303962 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303963
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303964 ENTER();
3965
Dino Mycle6fb96c12014-06-10 11:52:40 +05303966 status = wlan_hdd_validate_context(pHddCtx);
3967 if (0 != status)
3968 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303969 return -EINVAL;
3970 }
Dino Myclee8843b32014-07-04 14:21:45 +05303971
Dino Mycle6fb96c12014-06-10 11:52:40 +05303972 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3973 data, dataLen,
3974 wlan_hdd_extscan_config_policy)) {
3975 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3976 return -EINVAL;
3977 }
3978
3979 /* Parse and fetch request Id */
3980 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3981 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3982 return -EINVAL;
3983 }
3984 requestId = nla_get_u32(
3985 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3986 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3987
3988 /* Parse and fetch wifi band */
3989 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3990 {
3991 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3992 return -EINVAL;
3993 }
3994 wifiBand = nla_get_u32(
3995 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3996 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3997
3998 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
3999 wifiBand, ChannelList,
4000 &numChannels);
4001 if (eHAL_STATUS_SUCCESS != status) {
4002 hddLog(VOS_TRACE_LEVEL_ERROR,
4003 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
4004 return -EINVAL;
4005 }
4006 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
4007 for (i = 0; i < numChannels; i++)
4008 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
4009
4010 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
4011 sizeof(u32) * numChannels +
4012 NLMSG_HDRLEN);
4013
4014 if (!replySkb) {
4015 hddLog(VOS_TRACE_LEVEL_ERROR,
4016 FL("valid channels: buffer alloc fail"));
4017 return -EINVAL;
4018 }
4019 if (nla_put_u32(replySkb,
4020 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
4021 numChannels) ||
4022 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
4023 sizeof(u32) * numChannels, ChannelList)) {
4024
4025 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4026 kfree_skb(replySkb);
4027 return -EINVAL;
4028 }
4029
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304030 ret = cfg80211_vendor_cmd_reply(replySkb);
4031
4032 EXIT();
4033 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304034}
4035
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304036static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
4037 struct wireless_dev *wdev,
4038 const void *data, int dataLen)
4039{
4040 int ret = 0;
4041
4042 vos_ssr_protect(__func__);
4043 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
4044 dataLen);
4045 vos_ssr_unprotect(__func__);
4046
4047 return ret;
4048}
4049
4050static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304051 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304052 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304053{
Dino Myclee8843b32014-07-04 14:21:45 +05304054 tpSirEXTScanStartReqParams pReqMsg = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304055 struct net_device *dev = wdev->netdev;
4056 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4057 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4058 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4059 struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4060 struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4061 struct nlattr *buckets;
4062 struct nlattr *channels;
4063 int rem1;
4064 int rem2;
4065 eHalStatus status;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304066 tANI_U32 j = 0, index = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304067
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304068 ENTER();
4069
Dino Mycle6fb96c12014-06-10 11:52:40 +05304070 status = wlan_hdd_validate_context(pHddCtx);
4071 if (0 != status)
4072 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304073 return -EINVAL;
4074 }
Dino Myclee8843b32014-07-04 14:21:45 +05304075 /* check the EXTScan Capability */
4076 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4077 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4078 {
4079 hddLog(VOS_TRACE_LEVEL_ERROR,
4080 FL("EXTScan not enabled/supported by Firmware"));
4081 return -EINVAL;
4082 }
4083
Dino Mycle6fb96c12014-06-10 11:52:40 +05304084 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4085 data, dataLen,
4086 wlan_hdd_extscan_config_policy)) {
4087 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4088 return -EINVAL;
4089 }
4090
4091 /* Parse and fetch request Id */
4092 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4093 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4094 return -EINVAL;
4095 }
4096
Dino Myclee8843b32014-07-04 14:21:45 +05304097 pReqMsg = (tpSirEXTScanStartReqParams)
4098 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304099 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304100 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4101 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304102 }
4103
4104 pReqMsg->requestId = nla_get_u32(
4105 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4106 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4107
4108 pReqMsg->sessionId = pAdapter->sessionId;
4109 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4110
4111 /* Parse and fetch base period */
4112 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) {
4113 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4114 goto fail;
4115 }
4116 pReqMsg->basePeriod = nla_get_u32(
4117 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]);
4118 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4119 pReqMsg->basePeriod);
4120
4121 /* Parse and fetch max AP per scan */
4122 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) {
4123 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4124 goto fail;
4125 }
4126 pReqMsg->maxAPperScan = nla_get_u32(
4127 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]);
4128 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4129 pReqMsg->maxAPperScan);
4130
4131 /* Parse and fetch report threshold */
4132 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) {
4133 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4134 goto fail;
4135 }
4136 pReqMsg->reportThreshold = nla_get_u8(
4137 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]);
4138 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
4139 pReqMsg->reportThreshold);
4140
4141 /* Parse and fetch number of buckets */
4142 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) {
4143 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4144 goto fail;
4145 }
4146 pReqMsg->numBuckets = nla_get_u8(
4147 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]);
4148 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4149 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4150 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4151 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4152 }
4153 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4154 pReqMsg->numBuckets);
4155 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4156 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4157 goto fail;
4158 }
4159
4160 nla_for_each_nested(buckets,
4161 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4162 if(nla_parse(bucket,
4163 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4164 nla_data(buckets), nla_len(buckets), NULL)) { //policy
4165 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4166 goto fail;
4167 }
4168
4169 /* Parse and fetch bucket spec */
4170 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4171 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed"));
4172 goto fail;
4173 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304174
4175 pReqMsg->buckets[index].bucket = nla_get_u8(
4176 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4177
4178 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"),
4179 pReqMsg->buckets[index].bucket);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304180
4181 /* Parse and fetch wifi band */
4182 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4183 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4184 goto fail;
4185 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304186 pReqMsg->buckets[index].band = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304187 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4188 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304189 pReqMsg->buckets[index].band);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304190
4191 /* Parse and fetch period */
4192 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4193 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed"));
4194 goto fail;
4195 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304196 pReqMsg->buckets[index].period = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304197 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4198 hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304199 pReqMsg->buckets[index].period);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304200
4201 /* Parse and fetch report events */
4202 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4203 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed"));
4204 goto fail;
4205 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304206 pReqMsg->buckets[index].reportEvents = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304207 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4208 hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304209 pReqMsg->buckets[index].reportEvents);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304210
4211 /* Parse and fetch number of channels */
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304212 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS])
4213 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304214 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed"));
4215 goto fail;
4216 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304217 pReqMsg->buckets[index].numChannels = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304218 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4219 hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304220 pReqMsg->buckets[index].numChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304221
4222 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4223 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed"));
4224 goto fail;
4225 }
4226
4227 j = 0;
4228 nla_for_each_nested(channels,
4229 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4230 if(nla_parse(channel,
4231 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4232 nla_data(channels), nla_len(channels),
4233 NULL)) { //wlan_hdd_extscan_config_policy here
4234 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4235 goto fail;
4236 }
4237
4238 /* Parse and fetch channel */
4239 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4240 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4241 goto fail;
4242 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304243 pReqMsg->buckets[index].channels[j].channel = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304244 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4245 hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304246 pReqMsg->buckets[index].channels[j].channel);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304247
4248 /* Parse and fetch dwell time */
4249 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4250 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed"));
4251 goto fail;
4252 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304253 pReqMsg->buckets[index].channels[j].dwellTimeMs = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304254 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4255 hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304256 pReqMsg->buckets[index].channels[j].dwellTimeMs);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304257
4258 /* Parse and fetch channel spec passive */
4259 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4260 hddLog(VOS_TRACE_LEVEL_ERROR,
4261 FL("attr channel spec passive failed"));
4262 goto fail;
4263 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304264 pReqMsg->buckets[index].channels[j].passive = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304265 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4266 hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304267 pReqMsg->buckets[index].channels[j].passive);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304268 j++;
4269 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304270 index++;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304271 }
4272 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4273 if (!HAL_STATUS_SUCCESS(status)) {
4274 hddLog(VOS_TRACE_LEVEL_ERROR,
4275 FL("sme_EXTScanStart failed(err=%d)"), status);
4276 vos_mem_free(pReqMsg);
4277 return -EINVAL;
4278 }
4279
Dino Myclee8843b32014-07-04 14:21:45 +05304280 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304281 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304282 return 0;
4283
4284fail:
4285 vos_mem_free(pReqMsg);
4286 return -EINVAL;
4287}
4288
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304289static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4290 struct wireless_dev *wdev,
4291 const void *data, int dataLen)
4292{
4293 int ret = 0;
4294
4295 vos_ssr_protect(__func__);
4296 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4297 vos_ssr_unprotect(__func__);
4298
4299 return ret;
4300}
4301
4302static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304303 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304304 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304305{
Dino Myclee8843b32014-07-04 14:21:45 +05304306 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304307 struct net_device *dev = wdev->netdev;
4308 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4309 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4310 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4311 eHalStatus status;
4312
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304313 ENTER();
4314
Dino Mycle6fb96c12014-06-10 11:52:40 +05304315 status = wlan_hdd_validate_context(pHddCtx);
4316 if (0 != status)
4317 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304318 return -EINVAL;
4319 }
Dino Myclee8843b32014-07-04 14:21:45 +05304320 /* check the EXTScan Capability */
4321 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4322 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4323 {
4324 hddLog(VOS_TRACE_LEVEL_ERROR,
4325 FL("EXTScan not enabled/supported by Firmware"));
4326 return -EINVAL;
4327 }
4328
Dino Mycle6fb96c12014-06-10 11:52:40 +05304329 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4330 data, dataLen,
4331 wlan_hdd_extscan_config_policy)) {
4332 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4333 return -EINVAL;
4334 }
4335
4336 /* Parse and fetch request Id */
4337 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4338 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4339 return -EINVAL;
4340 }
4341
Dino Myclee8843b32014-07-04 14:21:45 +05304342 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304343 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304344 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304345
Dino Myclee8843b32014-07-04 14:21:45 +05304346 reqMsg.sessionId = pAdapter->sessionId;
4347 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304348
Dino Myclee8843b32014-07-04 14:21:45 +05304349 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304350 if (!HAL_STATUS_SUCCESS(status)) {
4351 hddLog(VOS_TRACE_LEVEL_ERROR,
4352 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304353 return -EINVAL;
4354 }
4355
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304356 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304357 return 0;
4358}
4359
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304360static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4361 struct wireless_dev *wdev,
4362 const void *data, int dataLen)
4363{
4364 int ret = 0;
4365
4366 vos_ssr_protect(__func__);
4367 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4368 vos_ssr_unprotect(__func__);
4369
4370 return ret;
4371}
4372
4373static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304374 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304375 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304376{
Dino Myclee8843b32014-07-04 14:21:45 +05304377 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304378 struct net_device *dev = wdev->netdev;
4379 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4380 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4381 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4382 eHalStatus status;
4383
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304384 ENTER();
4385
Dino Mycle6fb96c12014-06-10 11:52:40 +05304386 status = wlan_hdd_validate_context(pHddCtx);
4387 if (0 != status)
4388 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304389 return -EINVAL;
4390 }
Dino Myclee8843b32014-07-04 14:21:45 +05304391 /* check the EXTScan Capability */
4392 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4393 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4394 {
4395 hddLog(VOS_TRACE_LEVEL_ERROR,
4396 FL("EXTScan not enabled/supported by Firmware"));
4397 return -EINVAL;
4398 }
4399
Dino Mycle6fb96c12014-06-10 11:52:40 +05304400 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4401 data, dataLen,
4402 wlan_hdd_extscan_config_policy)) {
4403 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4404 return -EINVAL;
4405 }
4406
4407 /* Parse and fetch request Id */
4408 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4409 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4410 return -EINVAL;
4411 }
4412
Dino Myclee8843b32014-07-04 14:21:45 +05304413 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304414 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304415 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304416
Dino Myclee8843b32014-07-04 14:21:45 +05304417 reqMsg.sessionId = pAdapter->sessionId;
4418 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304419
Dino Myclee8843b32014-07-04 14:21:45 +05304420 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304421 if (!HAL_STATUS_SUCCESS(status)) {
4422 hddLog(VOS_TRACE_LEVEL_ERROR,
4423 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304424 return -EINVAL;
4425 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304426 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304427 return 0;
4428}
4429
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304430static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4431 struct wireless_dev *wdev,
4432 const void *data, int dataLen)
4433{
4434 int ret = 0;
4435
4436 vos_ssr_protect(__func__);
4437 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4438 vos_ssr_unprotect(__func__);
4439
4440 return ret;
4441}
4442
4443static int __wlan_hdd_cfg80211_extscan_reset_significant_change(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304444 struct wiphy *wiphy,
4445 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304446 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304447{
Dino Myclee8843b32014-07-04 14:21:45 +05304448 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304449 struct net_device *dev = wdev->netdev;
4450 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4451 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4452 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4453 eHalStatus status;
4454
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304455 ENTER();
4456
Dino Mycle6fb96c12014-06-10 11:52:40 +05304457 status = wlan_hdd_validate_context(pHddCtx);
4458 if (0 != status)
4459 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304460 return -EINVAL;
4461 }
Dino Myclee8843b32014-07-04 14:21:45 +05304462 /* check the EXTScan Capability */
4463 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4464 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4465 {
4466 hddLog(VOS_TRACE_LEVEL_ERROR,
4467 FL("EXTScan not enabled/supported by Firmware"));
4468 return -EINVAL;
4469 }
4470
Dino Mycle6fb96c12014-06-10 11:52:40 +05304471 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4472 data, dataLen,
4473 wlan_hdd_extscan_config_policy)) {
4474 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4475 return -EINVAL;
4476 }
4477
4478 /* Parse and fetch request Id */
4479 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4480 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4481 return -EINVAL;
4482 }
4483
Dino Mycle6fb96c12014-06-10 11:52:40 +05304484
Dino Myclee8843b32014-07-04 14:21:45 +05304485 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304486 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304487 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304488
Dino Myclee8843b32014-07-04 14:21:45 +05304489 reqMsg.sessionId = pAdapter->sessionId;
4490 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304491
Dino Myclee8843b32014-07-04 14:21:45 +05304492 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304493 if (!HAL_STATUS_SUCCESS(status)) {
4494 hddLog(VOS_TRACE_LEVEL_ERROR,
4495 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304496 return -EINVAL;
4497 }
4498
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304499 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304500 return 0;
4501}
4502
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304503static int wlan_hdd_cfg80211_extscan_reset_significant_change(
4504 struct wiphy *wiphy,
4505 struct wireless_dev *wdev,
4506 const void *data, int dataLen)
4507{
4508 int ret = 0;
4509
4510 vos_ssr_protect(__func__);
4511 ret = __wlan_hdd_cfg80211_extscan_reset_significant_change(wiphy,
4512 wdev, data,
4513 dataLen);
4514 vos_ssr_unprotect(__func__);
4515
4516 return ret;
4517}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304518#endif /* WLAN_FEATURE_EXTSCAN */
4519
Atul Mittal115287b2014-07-08 13:26:33 +05304520/*EXT TDLS*/
4521static const struct nla_policy
4522wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4523{
4524 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4525 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4526 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4527 {.type = NLA_S32 },
4528 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4529 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4530
4531};
4532
4533static const struct nla_policy
4534wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4535{
4536 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4537
4538};
4539
4540static const struct nla_policy
4541wlan_hdd_tdls_config_state_change_policy[
4542 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4543{
4544 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4545 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4546 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304547 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4548 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4549 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304550
4551};
4552
4553static const struct nla_policy
4554wlan_hdd_tdls_config_get_status_policy[
4555 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4556{
4557 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4558 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4559 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304560 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4561 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4562 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304563
4564};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304565
4566static const struct nla_policy
4567wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4568{
4569 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4570};
4571
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304572static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304573 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304574 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304575 int data_len)
4576{
4577
4578 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4579 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4580
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304581 ENTER();
4582
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304583 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304584 return -EINVAL;
4585 }
4586 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05304587 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304588 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304589 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304590 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05304591 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304592 return -ENOTSUPP;
4593 }
4594
4595 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4596 data, data_len, wlan_hdd_mac_config)) {
4597 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4598 return -EINVAL;
4599 }
4600
4601 /* Parse and fetch mac address */
4602 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4603 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4604 return -EINVAL;
4605 }
4606
4607 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4608 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4609 VOS_MAC_ADDR_LAST_3_BYTES);
4610
Siddharth Bhal76972212014-10-15 16:22:51 +05304611 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4612
4613 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304614 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4615 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304616 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4617 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4618 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4619 {
4620 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4621 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4622 VOS_MAC_ADDRESS_LEN);
4623 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304624 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304625
Siddharth Bhal76972212014-10-15 16:22:51 +05304626 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
4627 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304628 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4629 }
4630
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304631 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304632 return 0;
4633}
4634
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304635static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4636 struct wireless_dev *wdev,
4637 const void *data,
4638 int data_len)
4639{
4640 int ret = 0;
4641
4642 vos_ssr_protect(__func__);
4643 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
4644 vos_ssr_unprotect(__func__);
4645
4646 return ret;
4647}
4648
4649static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304650 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304651 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304652 int data_len)
4653{
4654 u8 peer[6] = {0};
4655 struct net_device *dev = wdev->netdev;
4656 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4657 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4658 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4659 eHalStatus ret;
4660 tANI_S32 state;
4661 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304662 tANI_S32 global_operating_class = 0;
4663 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304664 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304665 int retVal;
4666
4667 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304668
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
Atul Mittal115287b2014-07-08 13:26:33 +05304674 ret = wlan_hdd_validate_context(pHddCtx);
4675 if (0 != ret) {
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 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304680 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304681 return -ENOTSUPP;
4682 }
4683 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4684 data, data_len,
4685 wlan_hdd_tdls_config_get_status_policy)) {
4686 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4687 return -EINVAL;
4688 }
4689
4690 /* Parse and fetch mac address */
4691 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4692 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4693 return -EINVAL;
4694 }
4695
4696 memcpy(peer, nla_data(
4697 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4698 sizeof(peer));
4699 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4700
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05304701 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05304702
Atul Mittal115287b2014-07-08 13:26:33 +05304703 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304704 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304705 NLMSG_HDRLEN);
4706
4707 if (!skb) {
4708 hddLog(VOS_TRACE_LEVEL_ERROR,
4709 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4710 return -EINVAL;
4711 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304712 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 +05304713 reason,
4714 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304715 global_operating_class,
4716 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304717 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304718 if (nla_put_s32(skb,
4719 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4720 state) ||
4721 nla_put_s32(skb,
4722 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4723 reason) ||
4724 nla_put_s32(skb,
4725 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4726 global_operating_class) ||
4727 nla_put_s32(skb,
4728 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4729 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304730
4731 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4732 goto nla_put_failure;
4733 }
4734
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304735 retVal = cfg80211_vendor_cmd_reply(skb);
4736 EXIT();
4737 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05304738
4739nla_put_failure:
4740 kfree_skb(skb);
4741 return -EINVAL;
4742}
4743
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304744static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4745 struct wireless_dev *wdev,
4746 const void *data,
4747 int data_len)
4748{
4749 int ret = 0;
4750
4751 vos_ssr_protect(__func__);
4752 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
4753 vos_ssr_unprotect(__func__);
4754
4755 return ret;
4756}
4757
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05304758static int wlan_hdd_cfg80211_exttdls_callback(
4759#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
4760 const tANI_U8* mac,
4761#else
4762 tANI_U8* mac,
4763#endif
Atul Mittal115287b2014-07-08 13:26:33 +05304764 tANI_S32 state,
4765 tANI_S32 reason,
4766 void *ctx)
4767{
4768 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05304769 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304770 tANI_S32 global_operating_class = 0;
4771 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304772 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05304773
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304774 ENTER();
4775
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304776 if (!pAdapter) {
4777 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4778 return -EINVAL;
4779 }
4780
4781 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05304782 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304783 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304784 return -EINVAL;
4785 }
4786
4787 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304788 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304789 return -ENOTSUPP;
4790 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05304791 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
4792#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
4793 NULL,
4794#endif
Atul Mittal115287b2014-07-08 13:26:33 +05304795 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4796 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4797 GFP_KERNEL);
4798
4799 if (!skb) {
4800 hddLog(VOS_TRACE_LEVEL_ERROR,
4801 FL("cfg80211_vendor_event_alloc failed"));
4802 return -EINVAL;
4803 }
4804 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304805 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4806 reason,
4807 state,
4808 global_operating_class,
4809 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304810 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4811 MAC_ADDR_ARRAY(mac));
4812
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304813 if (nla_put(skb,
4814 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4815 VOS_MAC_ADDR_SIZE, mac) ||
4816 nla_put_s32(skb,
4817 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4818 state) ||
4819 nla_put_s32(skb,
4820 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4821 reason) ||
4822 nla_put_s32(skb,
4823 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4824 channel) ||
4825 nla_put_s32(skb,
4826 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4827 global_operating_class)
4828 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304829 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4830 goto nla_put_failure;
4831 }
4832
4833 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304834 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05304835 return (0);
4836
4837nla_put_failure:
4838 kfree_skb(skb);
4839 return -EINVAL;
4840}
4841
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304842static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304843 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304844 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304845 int data_len)
4846{
4847 u8 peer[6] = {0};
4848 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304849 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4850 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4851 eHalStatus status;
4852 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304853 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304854 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304855
4856 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304857
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304858 if (!dev) {
4859 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4860 return -EINVAL;
4861 }
4862
4863 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4864 if (!pAdapter) {
4865 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4866 return -EINVAL;
4867 }
4868
Atul Mittal115287b2014-07-08 13:26:33 +05304869 status = wlan_hdd_validate_context(pHddCtx);
4870 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304871 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304872 return -EINVAL;
4873 }
4874 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304875 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304876 return -ENOTSUPP;
4877 }
4878 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4879 data, data_len,
4880 wlan_hdd_tdls_config_enable_policy)) {
4881 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4882 return -EINVAL;
4883 }
4884
4885 /* Parse and fetch mac address */
4886 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4887 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4888 return -EINVAL;
4889 }
4890
4891 memcpy(peer, nla_data(
4892 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4893 sizeof(peer));
4894 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4895
4896 /* Parse and fetch channel */
4897 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4898 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4899 return -EINVAL;
4900 }
4901 pReqMsg.channel = nla_get_s32(
4902 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4903 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4904
4905 /* Parse and fetch global operating class */
4906 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4907 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4908 return -EINVAL;
4909 }
4910 pReqMsg.global_operating_class = nla_get_s32(
4911 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4912 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4913 pReqMsg.global_operating_class);
4914
4915 /* Parse and fetch latency ms */
4916 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4917 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4918 return -EINVAL;
4919 }
4920 pReqMsg.max_latency_ms = nla_get_s32(
4921 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4922 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4923 pReqMsg.max_latency_ms);
4924
4925 /* Parse and fetch required bandwidth kbps */
4926 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4927 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4928 return -EINVAL;
4929 }
4930
4931 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4932 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4933 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4934 pReqMsg.min_bandwidth_kbps);
4935
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304936 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05304937 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05304938 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304939 wlan_hdd_cfg80211_exttdls_callback);
4940
4941 EXIT();
4942 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304943}
4944
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304945static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4946 struct wireless_dev *wdev,
4947 const void *data,
4948 int data_len)
4949{
4950 int ret = 0;
4951
4952 vos_ssr_protect(__func__);
4953 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
4954 vos_ssr_unprotect(__func__);
4955
4956 return ret;
4957}
4958
4959static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304960 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304961 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304962 int data_len)
4963{
4964 u8 peer[6] = {0};
4965 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304966 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4967 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4968 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304969 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304970 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304971
4972 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304973
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304974 if (!dev) {
4975 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4976 return -EINVAL;
4977 }
4978
4979 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4980 if (!pAdapter) {
4981 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
4982 return -EINVAL;
4983 }
4984
Atul Mittal115287b2014-07-08 13:26:33 +05304985 status = wlan_hdd_validate_context(pHddCtx);
4986 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304987 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304988 return -EINVAL;
4989 }
4990 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304991 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304992 return -ENOTSUPP;
4993 }
4994 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4995 data, data_len,
4996 wlan_hdd_tdls_config_disable_policy)) {
4997 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4998 return -EINVAL;
4999 }
5000 /* Parse and fetch mac address */
5001 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
5002 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5003 return -EINVAL;
5004 }
5005
5006 memcpy(peer, nla_data(
5007 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
5008 sizeof(peer));
5009 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5010
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305011 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
5012
5013 EXIT();
5014 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305015}
5016
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305017static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
5018 struct wireless_dev *wdev,
5019 const void *data,
5020 int data_len)
5021{
5022 int ret = 0;
5023
5024 vos_ssr_protect(__func__);
5025 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
5026 vos_ssr_unprotect(__func__);
5027
5028 return ret;
5029}
5030
Dasari Srinivas7875a302014-09-26 17:50:57 +05305031static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305032__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05305033 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305034 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05305035{
5036 struct net_device *dev = wdev->netdev;
5037 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5038 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5039 struct sk_buff *skb = NULL;
5040 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305041 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305042
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305043 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305044
5045 ret = wlan_hdd_validate_context(pHddCtx);
5046 if (0 != ret)
5047 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305048 return ret;
5049 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305050 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
5051 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
5052 fset |= WIFI_FEATURE_INFRA;
5053 }
5054
5055 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
5056 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
5057 fset |= WIFI_FEATURE_INFRA_5G;
5058 }
5059
5060#ifdef WLAN_FEATURE_P2P
5061 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
5062 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
5063 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
5064 fset |= WIFI_FEATURE_P2P;
5065 }
5066#endif
5067
5068 /* Soft-AP is supported currently by default */
5069 fset |= WIFI_FEATURE_SOFT_AP;
5070
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05305071 /* HOTSPOT is a supplicant feature, enable it by default */
5072 fset |= WIFI_FEATURE_HOTSPOT;
5073
Dasari Srinivas7875a302014-09-26 17:50:57 +05305074#ifdef WLAN_FEATURE_EXTSCAN
5075 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
5076 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
5077 hddLog(LOG1, FL("EXTScan is supported by firmware"));
5078 fset |= WIFI_FEATURE_EXTSCAN;
5079 }
5080#endif
5081
Dasari Srinivas7875a302014-09-26 17:50:57 +05305082 if (sme_IsFeatureSupportedByFW(NAN)) {
5083 hddLog(LOG1, FL("NAN is supported by firmware"));
5084 fset |= WIFI_FEATURE_NAN;
5085 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305086
5087 /* D2D RTT is not supported currently by default */
5088 if (sme_IsFeatureSupportedByFW(RTT)) {
5089 hddLog(LOG1, FL("RTT is supported by firmware"));
5090 fset |= WIFI_FEATURE_D2AP_RTT;
5091 }
5092
5093#ifdef FEATURE_WLAN_BATCH_SCAN
5094 if (fset & WIFI_FEATURE_EXTSCAN) {
5095 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5096 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5097 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5098 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5099 fset |= WIFI_FEATURE_BATCH_SCAN;
5100 }
5101#endif
5102
5103#ifdef FEATURE_WLAN_SCAN_PNO
5104 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5105 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5106 hddLog(LOG1, FL("PNO is supported by firmware"));
5107 fset |= WIFI_FEATURE_PNO;
5108 }
5109#endif
5110
5111 /* STA+STA is supported currently by default */
5112 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5113
5114#ifdef FEATURE_WLAN_TDLS
5115 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5116 sme_IsFeatureSupportedByFW(TDLS)) {
5117 hddLog(LOG1, FL("TDLS is supported by firmware"));
5118 fset |= WIFI_FEATURE_TDLS;
5119 }
5120
5121 /* TDLS_OFFCHANNEL is not supported currently by default */
5122#endif
5123
5124#ifdef WLAN_AP_STA_CONCURRENCY
5125 /* AP+STA concurrency is supported currently by default */
5126 fset |= WIFI_FEATURE_AP_STA;
5127#endif
5128
Mukul Sharma5add0532015-08-17 15:57:47 +05305129#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5130 fset |= WIFI_FEATURE_LINK_LAYER_STATS;
5131 hddLog(LOG1, FL("Link layer stats is supported by driver"));
5132#endif
5133
Dasari Srinivas7875a302014-09-26 17:50:57 +05305134 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5135 NLMSG_HDRLEN);
5136
5137 if (!skb) {
5138 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5139 return -EINVAL;
5140 }
5141 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5142
5143 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5144 hddLog(LOGE, FL("nla put fail"));
5145 goto nla_put_failure;
5146 }
5147
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305148 ret = cfg80211_vendor_cmd_reply(skb);
5149 EXIT();
5150 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305151
5152nla_put_failure:
5153 kfree_skb(skb);
5154 return -EINVAL;
5155}
5156
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305157static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305158wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5159 struct wireless_dev *wdev,
5160 const void *data, int data_len)
5161{
5162 int ret = 0;
5163
5164 vos_ssr_protect(__func__);
5165 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5166 vos_ssr_unprotect(__func__);
5167
5168 return ret;
5169}
5170
5171static int
5172__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305173 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305174 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305175{
5176 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5177 uint8_t i, feature_sets, max_feature_sets;
5178 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5179 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305180 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5181 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305182
5183 ENTER();
5184
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305185 ret = wlan_hdd_validate_context(pHddCtx);
5186 if (0 != ret)
5187 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305188 return ret;
5189 }
5190
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305191 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5192 data, data_len, NULL)) {
5193 hddLog(LOGE, FL("Invalid ATTR"));
5194 return -EINVAL;
5195 }
5196
5197 /* Parse and fetch max feature set */
5198 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5199 hddLog(LOGE, FL("Attr max feature set size failed"));
5200 return -EINVAL;
5201 }
5202 max_feature_sets = nla_get_u32(
5203 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5204 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5205
5206 /* Fill feature combination matrix */
5207 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305208 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5209 WIFI_FEATURE_P2P;
5210
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305211 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5212 WIFI_FEATURE_SOFT_AP;
5213
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305214 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5215 WIFI_FEATURE_SOFT_AP;
5216
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305217 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5218 WIFI_FEATURE_SOFT_AP |
5219 WIFI_FEATURE_P2P;
5220
5221 /* Add more feature combinations here */
5222
5223 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5224 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5225 hddLog(LOG1, "Feature set matrix");
5226 for (i = 0; i < feature_sets; i++)
5227 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5228
5229 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5230 sizeof(u32) * feature_sets +
5231 NLMSG_HDRLEN);
5232
5233 if (reply_skb) {
5234 if (nla_put_u32(reply_skb,
5235 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5236 feature_sets) ||
5237 nla_put(reply_skb,
5238 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5239 sizeof(u32) * feature_sets, feature_set_matrix)) {
5240 hddLog(LOGE, FL("nla put fail"));
5241 kfree_skb(reply_skb);
5242 return -EINVAL;
5243 }
5244
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305245 ret = cfg80211_vendor_cmd_reply(reply_skb);
5246 EXIT();
5247 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305248 }
5249 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5250 return -ENOMEM;
5251
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305252}
5253
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305254static int
5255wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5256 struct wireless_dev *wdev,
5257 const void *data, int data_len)
5258{
5259 int ret = 0;
5260
5261 vos_ssr_protect(__func__);
5262 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5263 data_len);
5264 vos_ssr_unprotect(__func__);
5265
5266 return ret;
5267}
5268
Agarwal Ashish738843c2014-09-25 12:27:56 +05305269static const struct nla_policy
5270wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5271 +1] =
5272{
5273 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5274};
5275
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305276static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305277 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305278 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305279 int data_len)
5280{
5281 struct net_device *dev = wdev->netdev;
5282 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5283 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5284 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5285 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5286 eHalStatus status;
5287 u32 dfsFlag = 0;
5288
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305289 ENTER();
5290
Agarwal Ashish738843c2014-09-25 12:27:56 +05305291 status = wlan_hdd_validate_context(pHddCtx);
5292 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305293 return -EINVAL;
5294 }
5295 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5296 data, data_len,
5297 wlan_hdd_set_no_dfs_flag_config_policy)) {
5298 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5299 return -EINVAL;
5300 }
5301
5302 /* Parse and fetch required bandwidth kbps */
5303 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5304 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5305 return -EINVAL;
5306 }
5307
5308 dfsFlag = nla_get_u32(
5309 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5310 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
5311 dfsFlag);
5312
5313 pHddCtx->disable_dfs_flag = dfsFlag;
5314
5315 sme_disable_dfs_channel(hHal, dfsFlag);
5316 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305317
5318 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05305319 return 0;
5320}
Atul Mittal115287b2014-07-08 13:26:33 +05305321
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305322static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
5323 struct wireless_dev *wdev,
5324 const void *data,
5325 int data_len)
5326{
5327 int ret = 0;
5328
5329 vos_ssr_protect(__func__);
5330 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
5331 vos_ssr_unprotect(__func__);
5332
5333 return ret;
5334
5335}
5336
Mukul Sharma2a271632014-10-13 14:59:01 +05305337const struct
5338nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
5339{
5340 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
5341 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
5342};
5343
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305344static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05305345 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05305346{
5347
5348 u8 bssid[6] = {0};
5349 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5350 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5351 eHalStatus status = eHAL_STATUS_SUCCESS;
5352 v_U32_t isFwrRoamEnabled = FALSE;
5353 int ret;
5354
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305355 ENTER();
5356
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305357 ret = wlan_hdd_validate_context(pHddCtx);
5358 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305359 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05305360 }
5361
5362 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
5363 data, data_len,
5364 qca_wlan_vendor_attr);
5365 if (ret){
5366 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5367 return -EINVAL;
5368 }
5369
5370 /* Parse and fetch Enable flag */
5371 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
5372 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
5373 return -EINVAL;
5374 }
5375
5376 isFwrRoamEnabled = nla_get_u32(
5377 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
5378
5379 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
5380
5381 /* Parse and fetch bssid */
5382 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
5383 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
5384 return -EINVAL;
5385 }
5386
5387 memcpy(bssid, nla_data(
5388 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
5389 sizeof(bssid));
5390 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
5391
5392 //Update roaming
5393 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305394 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05305395 return status;
5396}
5397
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305398static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
5399 struct wireless_dev *wdev, const void *data, int data_len)
5400{
5401 int ret = 0;
5402
5403 vos_ssr_protect(__func__);
5404 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
5405 vos_ssr_unprotect(__func__);
5406
5407 return ret;
5408}
5409
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305410/**
5411 * __wlan_hdd_cfg80211_setband() - set band
5412 * @wiphy: Pointer to wireless phy
5413 * @wdev: Pointer to wireless device
5414 * @data: Pointer to data
5415 * @data_len: Data length
5416 *
5417 * Return: 0 on success, negative errno on failure
5418 */
5419static int
5420__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5421 struct wireless_dev *wdev,
5422 const void *data,
5423 int data_len)
5424{
5425 struct net_device *dev = wdev->netdev;
5426 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5427 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5428 int ret;
5429 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
5430 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
5431
5432 ENTER();
5433
5434 ret = wlan_hdd_validate_context(hdd_ctx);
5435 if (0 != ret) {
5436 hddLog(LOGE, FL("HDD context is not valid"));
5437 return ret;
5438 }
5439
5440 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
5441 policy)) {
5442 hddLog(LOGE, FL("Invalid ATTR"));
5443 return -EINVAL;
5444 }
5445
5446 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
5447 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
5448 return -EINVAL;
5449 }
5450
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05305451 hdd_ctx->isSetBandByNL = TRUE;
5452 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305453 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05305454 hdd_ctx->isSetBandByNL = FALSE;
5455
5456 EXIT();
5457 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305458}
5459
5460/**
5461 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
5462 * @wiphy: wiphy structure pointer
5463 * @wdev: Wireless device structure pointer
5464 * @data: Pointer to the data received
5465 * @data_len: Length of @data
5466 *
5467 * Return: 0 on success; errno on failure
5468 */
5469static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5470 struct wireless_dev *wdev,
5471 const void *data,
5472 int data_len)
5473{
5474 int ret = 0;
5475
5476 vos_ssr_protect(__func__);
5477 ret = __wlan_hdd_cfg80211_setband(wiphy,
5478 wdev, data, data_len);
5479 vos_ssr_unprotect(__func__);
5480
5481 return ret;
5482}
5483
Sunil Duttc69bccb2014-05-26 21:30:20 +05305484const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
5485{
Mukul Sharma2a271632014-10-13 14:59:01 +05305486 {
5487 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5488 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
5489 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5490 WIPHY_VENDOR_CMD_NEED_NETDEV |
5491 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305492 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05305493 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305494
5495 {
5496 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5497 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
5498 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5499 WIPHY_VENDOR_CMD_NEED_NETDEV |
5500 WIPHY_VENDOR_CMD_NEED_RUNNING,
5501 .doit = wlan_hdd_cfg80211_nan_request
5502 },
5503
Sunil Duttc69bccb2014-05-26 21:30:20 +05305504#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5505 {
5506 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5507 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
5508 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5509 WIPHY_VENDOR_CMD_NEED_NETDEV |
5510 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305511 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05305512 },
5513
5514 {
5515 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5516 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
5517 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5518 WIPHY_VENDOR_CMD_NEED_NETDEV |
5519 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305520 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05305521 },
5522
5523 {
5524 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5525 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
5526 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5527 WIPHY_VENDOR_CMD_NEED_NETDEV |
5528 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305529 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05305530 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305531#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305532#ifdef WLAN_FEATURE_EXTSCAN
5533 {
5534 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5535 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
5536 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5537 WIPHY_VENDOR_CMD_NEED_NETDEV |
5538 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305539 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05305540 },
5541 {
5542 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5543 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
5544 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5545 WIPHY_VENDOR_CMD_NEED_NETDEV |
5546 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305547 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05305548 },
5549 {
5550 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5551 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
5552 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5553 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305554 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05305555 },
5556 {
5557 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5558 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
5559 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5560 WIPHY_VENDOR_CMD_NEED_NETDEV |
5561 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305562 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05305563 },
5564 {
5565 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5566 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
5567 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5568 WIPHY_VENDOR_CMD_NEED_NETDEV |
5569 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305570 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05305571 },
5572 {
5573 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5574 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
5575 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5576 WIPHY_VENDOR_CMD_NEED_NETDEV |
5577 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305578 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305579 },
5580 {
5581 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5582 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
5583 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5584 WIPHY_VENDOR_CMD_NEED_NETDEV |
5585 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305586 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305587 },
5588 {
5589 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5590 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
5591 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5592 WIPHY_VENDOR_CMD_NEED_NETDEV |
5593 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305594 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305595 },
5596 {
5597 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5598 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
5599 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5600 WIPHY_VENDOR_CMD_NEED_NETDEV |
5601 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305602 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305603 },
5604#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305605/*EXT TDLS*/
5606 {
5607 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5608 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
5609 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5610 WIPHY_VENDOR_CMD_NEED_NETDEV |
5611 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305612 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05305613 },
5614 {
5615 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5616 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
5617 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5618 WIPHY_VENDOR_CMD_NEED_NETDEV |
5619 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305620 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05305621 },
5622 {
5623 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5624 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
5625 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5626 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305627 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05305628 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05305629 {
5630 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5631 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
5632 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5633 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305634 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05305635 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05305636 {
5637 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5638 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
5639 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5640 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305641 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05305642 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305643 {
5644 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5645 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
5646 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5647 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305648 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305649 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305650 {
5651 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5652 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
5653 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5654 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305655 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305656 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305657 {
5658 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5659 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
5660 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5661 WIPHY_VENDOR_CMD_NEED_NETDEV |
5662 WIPHY_VENDOR_CMD_NEED_RUNNING,
5663 .doit = wlan_hdd_cfg80211_setband
5664 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05305665};
5666
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005667/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05305668static const
5669struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005670{
5671#ifdef FEATURE_WLAN_CH_AVOID
5672 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05305673 .vendor_id = QCA_NL80211_VENDOR_ID,
5674 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005675 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305676#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
5677#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5678 {
5679 /* Index = 1*/
5680 .vendor_id = QCA_NL80211_VENDOR_ID,
5681 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
5682 },
5683 {
5684 /* Index = 2*/
5685 .vendor_id = QCA_NL80211_VENDOR_ID,
5686 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
5687 },
5688 {
5689 /* Index = 3*/
5690 .vendor_id = QCA_NL80211_VENDOR_ID,
5691 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
5692 },
5693 {
5694 /* Index = 4*/
5695 .vendor_id = QCA_NL80211_VENDOR_ID,
5696 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
5697 },
5698 {
5699 /* Index = 5*/
5700 .vendor_id = QCA_NL80211_VENDOR_ID,
5701 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
5702 },
5703 {
5704 /* Index = 6*/
5705 .vendor_id = QCA_NL80211_VENDOR_ID,
5706 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
5707 },
5708#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305709#ifdef WLAN_FEATURE_EXTSCAN
5710 {
5711 .vendor_id = QCA_NL80211_VENDOR_ID,
5712 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
5713 },
5714 {
5715 .vendor_id = QCA_NL80211_VENDOR_ID,
5716 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
5717 },
5718 {
5719 .vendor_id = QCA_NL80211_VENDOR_ID,
5720 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
5721 },
5722 {
5723 .vendor_id = QCA_NL80211_VENDOR_ID,
5724 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
5725 },
5726 {
5727 .vendor_id = QCA_NL80211_VENDOR_ID,
5728 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
5729 },
5730 {
5731 .vendor_id = QCA_NL80211_VENDOR_ID,
5732 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
5733 },
5734 {
5735 .vendor_id = QCA_NL80211_VENDOR_ID,
5736 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
5737 },
5738 {
5739 .vendor_id = QCA_NL80211_VENDOR_ID,
5740 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
5741 },
5742 {
5743 .vendor_id = QCA_NL80211_VENDOR_ID,
5744 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
5745 },
5746 {
5747 .vendor_id = QCA_NL80211_VENDOR_ID,
5748 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
5749 },
5750 {
5751 .vendor_id = QCA_NL80211_VENDOR_ID,
5752 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
5753 },
5754 {
5755 .vendor_id = QCA_NL80211_VENDOR_ID,
5756 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
5757 },
5758 {
5759 .vendor_id = QCA_NL80211_VENDOR_ID,
5760 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
5761 },
5762#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305763/*EXT TDLS*/
5764 {
5765 .vendor_id = QCA_NL80211_VENDOR_ID,
5766 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
5767 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305768
5769 {
5770 .vendor_id = QCA_NL80211_VENDOR_ID,
5771 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
5772 },
5773
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005774};
5775
Jeff Johnson295189b2012-06-20 16:38:30 -07005776/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305777 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305778 * This function is called by hdd_wlan_startup()
5779 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305780 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07005781 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305782struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07005783{
5784 struct wiphy *wiphy;
5785 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305786 /*
5787 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 */
5789 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
5790
5791 if (!wiphy)
5792 {
5793 /* Print error and jump into err label and free the memory */
5794 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
5795 return NULL;
5796 }
5797
Sunil Duttc69bccb2014-05-26 21:30:20 +05305798
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 return wiphy;
5800}
5801
5802/*
5803 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305804 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 * private ioctl to change the band value
5806 */
5807int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
5808{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305809 int i, j;
5810 eNVChannelEnabledType channelEnabledState;
5811
Jeff Johnsone7245742012-09-05 17:12:55 -07005812 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305813
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305814 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005815 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305816
5817 if (NULL == wiphy->bands[i])
5818 {
5819 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5820 __func__, i);
5821 continue;
5822 }
5823
5824 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5825 {
5826 struct ieee80211_supported_band *band = wiphy->bands[i];
5827
5828 channelEnabledState = vos_nv_getChannelEnabledState(
5829 band->channels[j].hw_value);
5830
5831 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
5832 {
Abhishek Singh678227a2014-11-04 10:52:38 +05305833 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305834 continue;
5835 }
5836 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
5837 {
5838 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5839 continue;
5840 }
5841
5842 if (NV_CHANNEL_DISABLE == channelEnabledState ||
5843 NV_CHANNEL_INVALID == channelEnabledState)
5844 {
5845 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5846 }
5847 else if (NV_CHANNEL_DFS == channelEnabledState)
5848 {
5849 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5850 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
5851 }
5852 else
5853 {
5854 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
5855 |IEEE80211_CHAN_RADAR);
5856 }
5857 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005858 }
5859 return 0;
5860}
5861/*
5862 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305863 * This function is called by hdd_wlan_startup()
5864 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 * This function is used to initialize and register wiphy structure.
5866 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305867int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005868 struct wiphy *wiphy,
5869 hdd_config_t *pCfg
5870 )
5871{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305872 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305873 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5874
Jeff Johnsone7245742012-09-05 17:12:55 -07005875 ENTER();
5876
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 /* Now bind the underlying wlan device with wiphy */
5878 set_wiphy_dev(wiphy, dev);
5879
5880 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005881
Kiet Lam6c583332013-10-14 05:37:09 +05305882#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07005883 /* the flag for the other case would be initialzed in
5884 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07005885 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05305886#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005887
Amar Singhalfddc28c2013-09-05 13:03:40 -07005888 /* This will disable updating of NL channels from passive to
5889 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305890#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
5891 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
5892#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07005893 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305894#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07005895
Amar Singhala49cbc52013-10-08 18:37:44 -07005896
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005897#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07005898 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
5899 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
5900 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07005901 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305902#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
5903 wiphy->regulatory_flags = REGULATORY_COUNTRY_IE_IGNORE;
5904#else
5905 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
5906#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005907#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005908
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005909#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005910 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08005911#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005912 || pCfg->isFastRoamIniFeatureEnabled
5913#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005914#ifdef FEATURE_WLAN_ESE
5915 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005916#endif
5917 )
5918 {
5919 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
5920 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08005921#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005922#ifdef FEATURE_WLAN_TDLS
5923 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
5924 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
5925#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305926#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05305927 if (pCfg->configPNOScanSupport)
5928 {
5929 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
5930 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
5931 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
5932 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
5933 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305934#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005935
Abhishek Singh10d85972015-04-17 10:27:23 +05305936#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5937 wiphy->features |= NL80211_FEATURE_HT_IBSS;
5938#endif
5939
Amar Singhalfddc28c2013-09-05 13:03:40 -07005940#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005941 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
5942 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07005943 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005944 driver need to determine what to do with both
5945 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07005946
5947 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07005948#else
5949 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005950#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005951
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305952 wiphy->max_scan_ssids = MAX_SCAN_SSID;
5953
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05305954 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07005955
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305956 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
5957
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05305959 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
5960 | BIT(NL80211_IFTYPE_ADHOC)
5961 | BIT(NL80211_IFTYPE_P2P_CLIENT)
5962 | BIT(NL80211_IFTYPE_P2P_GO)
5963 | BIT(NL80211_IFTYPE_AP);
5964
5965 if (VOS_MONITOR_MODE == hdd_get_conparam())
5966 {
5967 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
5968 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005969
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305970 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005971 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305972#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5973 if( pCfg->enableMCC )
5974 {
5975 /* Currently, supports up to two channels */
5976 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005977
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305978 if( !pCfg->allowMCCGODiffBI )
5979 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005980
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305981 }
5982 wiphy->iface_combinations = &wlan_hdd_iface_combination;
5983 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005984#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305985 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005986
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 /* Before registering we need to update the ht capabilitied based
5988 * on ini values*/
5989 if( !pCfg->ShortGI20MhzEnable )
5990 {
5991 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5992 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5993 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5994 }
5995
5996 if( !pCfg->ShortGI40MhzEnable )
5997 {
5998 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
5999 }
6000
6001 if( !pCfg->nChannelBondingMode5GHz )
6002 {
6003 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
6004 }
6005
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306006 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05306007 if (true == hdd_is_5g_supported(pHddCtx))
6008 {
6009 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
6010 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306011
6012 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
6013 {
6014
6015 if (NULL == wiphy->bands[i])
6016 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05306017 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306018 __func__, i);
6019 continue;
6020 }
6021
6022 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
6023 {
6024 struct ieee80211_supported_band *band = wiphy->bands[i];
6025
6026 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
6027 {
6028 // Enable social channels for P2P
6029 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
6030 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
6031 else
6032 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
6033 continue;
6034 }
6035 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
6036 {
6037 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
6038 continue;
6039 }
6040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 }
6042 /*Initialise the supported cipher suite details*/
6043 wiphy->cipher_suites = hdd_cipher_suites;
6044 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
6045
6046 /*signal strength in mBm (100*dBm) */
6047 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
6048
6049#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05306050 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07006051#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006052
Sunil Duttc69bccb2014-05-26 21:30:20 +05306053 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
6054 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08006055 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
6056 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
6057
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306058 EXIT();
6059 return 0;
6060}
6061
6062/* In this function we are registering wiphy. */
6063int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
6064{
6065 ENTER();
6066 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006067 if (0 > wiphy_register(wiphy))
6068 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306069 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07006070 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
6071 return -EIO;
6072 }
6073
6074 EXIT();
6075 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306076}
Jeff Johnson295189b2012-06-20 16:38:30 -07006077
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306078/* In this function we are updating channel list when,
6079 regulatory domain is FCC and country code is US.
6080 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
6081 As per FCC smart phone is not a indoor device.
6082 GO should not opeate on indoor channels */
6083void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
6084{
6085 int j;
6086 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6087 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
6088 //Default counrtycode from NV at the time of wiphy initialization.
6089 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
6090 &defaultCountryCode[0]))
6091 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006092 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306093 }
6094 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
6095 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306096 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
6097 {
6098 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
6099 return;
6100 }
6101 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
6102 {
6103 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
6104 // Mark UNII -1 band channel as passive
6105 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
6106 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
6107 }
6108 }
6109}
6110
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05306111/* This function registers for all frame which supplicant is interested in */
6112void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07006113{
Jeff Johnson295189b2012-06-20 16:38:30 -07006114 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6115 /* Register for all P2P action, public action etc frames */
6116 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
6117
Jeff Johnsone7245742012-09-05 17:12:55 -07006118 ENTER();
6119
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 /* Right now we are registering these frame when driver is getting
6121 initialized. Once we will move to 2.6.37 kernel, in which we have
6122 frame register ops, we will move this code as a part of that */
6123 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306124 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006125 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6126
6127 /* GAS Initial Response */
6128 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6129 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306130
Jeff Johnson295189b2012-06-20 16:38:30 -07006131 /* GAS Comeback Request */
6132 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6133 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6134
6135 /* GAS Comeback Response */
6136 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6137 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6138
6139 /* P2P Public Action */
6140 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306141 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 P2P_PUBLIC_ACTION_FRAME_SIZE );
6143
6144 /* P2P Action */
6145 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6146 (v_U8_t*)P2P_ACTION_FRAME,
6147 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07006148
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05306149 /* WNM BSS Transition Request frame */
6150 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6151 (v_U8_t*)WNM_BSS_ACTION_FRAME,
6152 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006153
6154 /* WNM-Notification */
6155 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6156 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6157 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006158}
6159
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05306160void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07006161{
Jeff Johnson295189b2012-06-20 16:38:30 -07006162 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6163 /* Register for all P2P action, public action etc frames */
6164 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
6165
Jeff Johnsone7245742012-09-05 17:12:55 -07006166 ENTER();
6167
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 /* Right now we are registering these frame when driver is getting
6169 initialized. Once we will move to 2.6.37 kernel, in which we have
6170 frame register ops, we will move this code as a part of that */
6171 /* GAS Initial Request */
6172
6173 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6174 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6175
6176 /* GAS Initial Response */
6177 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6178 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306179
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 /* GAS Comeback Request */
6181 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6182 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6183
6184 /* GAS Comeback Response */
6185 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6186 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6187
6188 /* P2P Public Action */
6189 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306190 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006191 P2P_PUBLIC_ACTION_FRAME_SIZE );
6192
6193 /* P2P Action */
6194 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6195 (v_U8_t*)P2P_ACTION_FRAME,
6196 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006197 /* WNM-Notification */
6198 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6199 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6200 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006201}
6202
6203#ifdef FEATURE_WLAN_WAPI
6204void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05306205 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006206{
6207 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6208 tCsrRoamSetKey setKey;
6209 v_BOOL_t isConnected = TRUE;
6210 int status = 0;
6211 v_U32_t roamId= 0xFF;
6212 tANI_U8 *pKeyPtr = NULL;
6213 int n = 0;
6214
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306215 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
6216 __func__, hdd_device_modetoString(pAdapter->device_mode),
6217 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006218
Gopichand Nakkalae7480202013-02-11 15:24:22 +05306219 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 setKey.keyId = key_index; // Store Key ID
6221 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
6222 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
6223 setKey.paeRole = 0 ; // the PAE role
6224 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
6225 {
6226 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
6227 }
6228 else
6229 {
6230 isConnected = hdd_connIsConnected(pHddStaCtx);
6231 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
6232 }
6233 setKey.keyLength = key_Len;
6234 pKeyPtr = setKey.Key;
6235 memcpy( pKeyPtr, key, key_Len);
6236
Arif Hussain6d2a3322013-11-17 19:50:10 -08006237 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 __func__, key_Len);
6239 for (n = 0 ; n < key_Len; n++)
6240 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
6241 __func__,n,setKey.Key[n]);
6242
6243 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6244 if ( isConnected )
6245 {
6246 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
6247 pAdapter->sessionId, &setKey, &roamId );
6248 }
6249 if ( status != 0 )
6250 {
6251 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6252 "[%4d] sme_RoamSetKey returned ERROR status= %d",
6253 __LINE__, status );
6254 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6255 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05306256 /* Need to clear any trace of key value in the memory.
6257 * Thus zero out the memory even though it is local
6258 * variable.
6259 */
6260 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006261}
6262#endif /* FEATURE_WLAN_WAPI*/
6263
6264#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306265int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 beacon_data_t **ppBeacon,
6267 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006268#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306269int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006270 beacon_data_t **ppBeacon,
6271 struct cfg80211_beacon_data *params,
6272 int dtim_period)
6273#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306274{
Jeff Johnson295189b2012-06-20 16:38:30 -07006275 int size;
6276 beacon_data_t *beacon = NULL;
6277 beacon_data_t *old = NULL;
6278 int head_len,tail_len;
6279
Jeff Johnsone7245742012-09-05 17:12:55 -07006280 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006281 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306282 {
6283 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6284 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306286 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006287
6288 old = pAdapter->sessionCtx.ap.beacon;
6289
6290 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306291 {
6292 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6293 FL("session(%d) old and new heads points to NULL"),
6294 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306296 }
6297
6298 if (params->tail && !params->tail_len)
6299 {
6300 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6301 FL("tail_len is zero but tail is not NULL"));
6302 return -EINVAL;
6303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006304
Jeff Johnson295189b2012-06-20 16:38:30 -07006305#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
6306 /* Kernel 3.0 is not updating dtim_period for set beacon */
6307 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306308 {
6309 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6310 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006311 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306312 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006313#endif
6314
6315 if(params->head)
6316 head_len = params->head_len;
6317 else
6318 head_len = old->head_len;
6319
6320 if(params->tail || !old)
6321 tail_len = params->tail_len;
6322 else
6323 tail_len = old->tail_len;
6324
6325 size = sizeof(beacon_data_t) + head_len + tail_len;
6326
6327 beacon = kzalloc(size, GFP_KERNEL);
6328
6329 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306330 {
6331 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6332 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306334 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006335
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006336#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006337 if(params->dtim_period || !old )
6338 beacon->dtim_period = params->dtim_period;
6339 else
6340 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006341#else
6342 if(dtim_period || !old )
6343 beacon->dtim_period = dtim_period;
6344 else
6345 beacon->dtim_period = old->dtim_period;
6346#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306347
Jeff Johnson295189b2012-06-20 16:38:30 -07006348 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
6349 beacon->tail = beacon->head + head_len;
6350 beacon->head_len = head_len;
6351 beacon->tail_len = tail_len;
6352
6353 if(params->head) {
6354 memcpy (beacon->head,params->head,beacon->head_len);
6355 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306356 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07006357 if(old)
6358 memcpy (beacon->head,old->head,beacon->head_len);
6359 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306360
Jeff Johnson295189b2012-06-20 16:38:30 -07006361 if(params->tail) {
6362 memcpy (beacon->tail,params->tail,beacon->tail_len);
6363 }
6364 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306365 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07006366 memcpy (beacon->tail,old->tail,beacon->tail_len);
6367 }
6368
6369 *ppBeacon = beacon;
6370
6371 kfree(old);
6372
6373 return 0;
6374
6375}
Jeff Johnson295189b2012-06-20 16:38:30 -07006376
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05306377v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
6378#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
6379 const v_U8_t *pIes,
6380#else
6381 v_U8_t *pIes,
6382#endif
6383 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006384{
6385 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05306386 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07006387 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306388
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306390 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006391 elem_id = ptr[0];
6392 elem_len = ptr[1];
6393 left -= 2;
6394 if(elem_len > left)
6395 {
6396 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006397 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 eid,elem_len,left);
6399 return NULL;
6400 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306401 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006402 {
6403 return ptr;
6404 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306405
Jeff Johnson295189b2012-06-20 16:38:30 -07006406 left -= elem_len;
6407 ptr += (elem_len + 2);
6408 }
6409 return NULL;
6410}
6411
Jeff Johnson295189b2012-06-20 16:38:30 -07006412/* Check if rate is 11g rate or not */
6413static int wlan_hdd_rate_is_11g(u8 rate)
6414{
Sanjay Devnani28322e22013-06-21 16:13:40 -07006415 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006416 u8 i;
6417 for (i = 0; i < 8; i++)
6418 {
6419 if(rate == gRateArray[i])
6420 return TRUE;
6421 }
6422 return FALSE;
6423}
6424
6425/* Check for 11g rate and set proper 11g only mode */
6426static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
6427 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
6428{
6429 u8 i, num_rates = pIe[0];
6430
6431 pIe += 1;
6432 for ( i = 0; i < num_rates; i++)
6433 {
6434 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
6435 {
6436 /* If rate set have 11g rate than change the mode to 11G */
6437 *pSapHw_mode = eSAP_DOT11_MODE_11g;
6438 if (pIe[i] & BASIC_RATE_MASK)
6439 {
6440 /* If we have 11g rate as basic rate, it means mode
6441 is 11g only mode.
6442 */
6443 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
6444 *pCheckRatesfor11g = FALSE;
6445 }
6446 }
6447 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
6448 {
6449 *require_ht = TRUE;
6450 }
6451 }
6452 return;
6453}
6454
6455static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
6456{
6457 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6458 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6459 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6460 u8 checkRatesfor11g = TRUE;
6461 u8 require_ht = FALSE;
6462 u8 *pIe=NULL;
6463
6464 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
6465
6466 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
6467 pBeacon->head_len, WLAN_EID_SUPP_RATES);
6468 if (pIe != NULL)
6469 {
6470 pIe += 1;
6471 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6472 &pConfig->SapHw_mode);
6473 }
6474
6475 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6476 WLAN_EID_EXT_SUPP_RATES);
6477 if (pIe != NULL)
6478 {
6479
6480 pIe += 1;
6481 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6482 &pConfig->SapHw_mode);
6483 }
6484
6485 if( pConfig->channel > 14 )
6486 {
6487 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
6488 }
6489
6490 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6491 WLAN_EID_HT_CAPABILITY);
6492
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306493 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006494 {
6495 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
6496 if(require_ht)
6497 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
6498 }
6499}
6500
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306501static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
6502 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
6503{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006504 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306505 v_U8_t *pIe = NULL;
6506 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6507
6508 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
6509 pBeacon->tail, pBeacon->tail_len);
6510
6511 if (pIe)
6512 {
6513 ielen = pIe[1] + 2;
6514 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6515 {
6516 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
6517 }
6518 else
6519 {
6520 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
6521 return -EINVAL;
6522 }
6523 *total_ielen += ielen;
6524 }
6525 return 0;
6526}
6527
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006528static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
6529 v_U8_t *genie, v_U8_t *total_ielen)
6530{
6531 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6532 int left = pBeacon->tail_len;
6533 v_U8_t *ptr = pBeacon->tail;
6534 v_U8_t elem_id, elem_len;
6535 v_U16_t ielen = 0;
6536
6537 if ( NULL == ptr || 0 == left )
6538 return;
6539
6540 while (left >= 2)
6541 {
6542 elem_id = ptr[0];
6543 elem_len = ptr[1];
6544 left -= 2;
6545 if (elem_len > left)
6546 {
6547 hddLog( VOS_TRACE_LEVEL_ERROR,
6548 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
6549 elem_id, elem_len, left);
6550 return;
6551 }
6552 if (IE_EID_VENDOR == elem_id)
6553 {
6554 /* skipping the VSIE's which we don't want to include or
6555 * it will be included by existing code
6556 */
6557 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
6558#ifdef WLAN_FEATURE_WFD
6559 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
6560#endif
6561 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6562 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6563 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
6564 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6565 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
6566 {
6567 ielen = ptr[1] + 2;
6568 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6569 {
6570 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
6571 *total_ielen += ielen;
6572 }
6573 else
6574 {
6575 hddLog( VOS_TRACE_LEVEL_ERROR,
6576 "IE Length is too big "
6577 "IEs eid=%d elem_len=%d total_ie_lent=%d",
6578 elem_id, elem_len, *total_ielen);
6579 }
6580 }
6581 }
6582
6583 left -= elem_len;
6584 ptr += (elem_len + 2);
6585 }
6586 return;
6587}
6588
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006589#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006590static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6591 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006592#else
6593static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6594 struct cfg80211_beacon_data *params)
6595#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006596{
6597 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306598 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07006600 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006601
6602 genie = vos_mem_malloc(MAX_GENIE_LEN);
6603
6604 if(genie == NULL) {
6605
6606 return -ENOMEM;
6607 }
6608
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306609 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6610 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306612 hddLog(LOGE,
6613 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306614 ret = -EINVAL;
6615 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006616 }
6617
6618#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306619 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6620 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
6621 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306622 hddLog(LOGE,
6623 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306624 ret = -EINVAL;
6625 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006626 }
6627#endif
6628
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306629 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6630 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306632 hddLog(LOGE,
6633 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306634 ret = -EINVAL;
6635 goto done;
6636 }
6637
6638 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
6639 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006640 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006641 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006642
6643 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6644 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
6645 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6646 {
6647 hddLog(LOGE,
6648 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006649 ret = -EINVAL;
6650 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006651 }
6652
6653 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6654 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6655 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6656 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6657 ==eHAL_STATUS_FAILURE)
6658 {
6659 hddLog(LOGE,
6660 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006661 ret = -EINVAL;
6662 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 }
6664
6665 // Added for ProResp IE
6666 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
6667 {
6668 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
6669 u8 probe_rsp_ie_len[3] = {0};
6670 u8 counter = 0;
6671 /* Check Probe Resp Length if it is greater then 255 then Store
6672 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
6673 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
6674 Store More then 255 bytes into One Variable.
6675 */
6676 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6677 {
6678 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6679 {
6680 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6681 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6682 }
6683 else
6684 {
6685 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6686 rem_probe_resp_ie_len = 0;
6687 }
6688 }
6689
6690 rem_probe_resp_ie_len = 0;
6691
6692 if (probe_rsp_ie_len[0] > 0)
6693 {
6694 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6695 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6696 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6697 probe_rsp_ie_len[0], NULL,
6698 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6699 {
6700 hddLog(LOGE,
6701 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006702 ret = -EINVAL;
6703 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 }
6705 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6706 }
6707
6708 if (probe_rsp_ie_len[1] > 0)
6709 {
6710 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6711 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6712 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6713 probe_rsp_ie_len[1], NULL,
6714 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6715 {
6716 hddLog(LOGE,
6717 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006718 ret = -EINVAL;
6719 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006720 }
6721 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6722 }
6723
6724 if (probe_rsp_ie_len[2] > 0)
6725 {
6726 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6727 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6728 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6729 probe_rsp_ie_len[2], NULL,
6730 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6731 {
6732 hddLog(LOGE,
6733 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006734 ret = -EINVAL;
6735 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006736 }
6737 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6738 }
6739
6740 if (probe_rsp_ie_len[1] == 0 )
6741 {
6742 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6743 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
6744 eANI_BOOLEAN_FALSE) )
6745 {
6746 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006747 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 }
6749 }
6750
6751 if (probe_rsp_ie_len[2] == 0 )
6752 {
6753 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6754 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
6755 eANI_BOOLEAN_FALSE) )
6756 {
6757 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006758 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006759 }
6760 }
6761
6762 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6763 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6764 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6765 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6766 == eHAL_STATUS_FAILURE)
6767 {
6768 hddLog(LOGE,
6769 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006770 ret = -EINVAL;
6771 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 }
6773 }
6774 else
6775 {
6776 // Reset WNI_CFG_PROBE_RSP Flags
6777 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
6778
6779 hddLog(VOS_TRACE_LEVEL_INFO,
6780 "%s: No Probe Response IE received in set beacon",
6781 __func__);
6782 }
6783
6784 // Added for AssocResp IE
6785 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
6786 {
6787 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6788 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
6789 params->assocresp_ies_len, NULL,
6790 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6791 {
6792 hddLog(LOGE,
6793 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006794 ret = -EINVAL;
6795 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006796 }
6797
6798 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6799 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
6800 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6801 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6802 == eHAL_STATUS_FAILURE)
6803 {
6804 hddLog(LOGE,
6805 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006806 ret = -EINVAL;
6807 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006808 }
6809 }
6810 else
6811 {
6812 hddLog(VOS_TRACE_LEVEL_INFO,
6813 "%s: No Assoc Response IE received in set beacon",
6814 __func__);
6815
6816 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6817 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6818 eANI_BOOLEAN_FALSE) )
6819 {
6820 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006821 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 }
6823 }
6824
Jeff Johnsone7245742012-09-05 17:12:55 -07006825done:
Jeff Johnson295189b2012-06-20 16:38:30 -07006826 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306827 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006828}
Jeff Johnson295189b2012-06-20 16:38:30 -07006829
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306830/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006831 * FUNCTION: wlan_hdd_validate_operation_channel
6832 * called by wlan_hdd_cfg80211_start_bss() and
6833 * wlan_hdd_cfg80211_set_channel()
6834 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306835 * channel list.
6836 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07006837VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006838{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306839
Jeff Johnson295189b2012-06-20 16:38:30 -07006840 v_U32_t num_ch = 0;
6841 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6842 u32 indx = 0;
6843 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306844 v_U8_t fValidChannel = FALSE, count = 0;
6845 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306846
Jeff Johnson295189b2012-06-20 16:38:30 -07006847 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6848
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306849 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306851 /* Validate the channel */
6852 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006853 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306854 if ( channel == rfChannels[count].channelNum )
6855 {
6856 fValidChannel = TRUE;
6857 break;
6858 }
6859 }
6860 if (fValidChannel != TRUE)
6861 {
6862 hddLog(VOS_TRACE_LEVEL_ERROR,
6863 "%s: Invalid Channel [%d]", __func__, channel);
6864 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006865 }
6866 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306867 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006868 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306869 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6870 valid_ch, &num_ch))
6871 {
6872 hddLog(VOS_TRACE_LEVEL_ERROR,
6873 "%s: failed to get valid channel list", __func__);
6874 return VOS_STATUS_E_FAILURE;
6875 }
6876 for (indx = 0; indx < num_ch; indx++)
6877 {
6878 if (channel == valid_ch[indx])
6879 {
6880 break;
6881 }
6882 }
6883
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306884 if (indx >= num_ch)
6885 {
6886 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6887 {
6888 eCsrBand band;
6889 unsigned int freq;
6890
6891 sme_GetFreqBand(hHal, &band);
6892
6893 if (eCSR_BAND_5G == band)
6894 {
6895#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
6896 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
6897 {
6898 freq = ieee80211_channel_to_frequency(channel,
6899 IEEE80211_BAND_2GHZ);
6900 }
6901 else
6902 {
6903 freq = ieee80211_channel_to_frequency(channel,
6904 IEEE80211_BAND_5GHZ);
6905 }
6906#else
6907 freq = ieee80211_channel_to_frequency(channel);
6908#endif
6909 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
6910 return VOS_STATUS_SUCCESS;
6911 }
6912 }
6913
6914 hddLog(VOS_TRACE_LEVEL_ERROR,
6915 "%s: Invalid Channel [%d]", __func__, channel);
6916 return VOS_STATUS_E_FAILURE;
6917 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006918 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306919
Jeff Johnson295189b2012-06-20 16:38:30 -07006920 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306921
Jeff Johnson295189b2012-06-20 16:38:30 -07006922}
6923
Viral Modi3a32cc52013-02-08 11:14:52 -08006924/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306925 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08006926 * This function is used to set the channel number
6927 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306928static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08006929 struct ieee80211_channel *chan,
6930 enum nl80211_channel_type channel_type
6931 )
6932{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306933 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08006934 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07006935 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08006936 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306937 hdd_context_t *pHddCtx;
6938 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006939
6940 ENTER();
6941
6942 if( NULL == dev )
6943 {
6944 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006945 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006946 return -ENODEV;
6947 }
6948 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306949
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306950 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6951 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
6952 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08006953 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306954 "%s: device_mode = %s (%d) freq = %d", __func__,
6955 hdd_device_modetoString(pAdapter->device_mode),
6956 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306957
6958 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6959 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306960 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08006961 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306962 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006963 }
6964
6965 /*
6966 * Do freq to chan conversion
6967 * TODO: for 11a
6968 */
6969
6970 channel = ieee80211_frequency_to_channel(freq);
6971
6972 /* Check freq range */
6973 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
6974 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
6975 {
6976 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006977 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08006978 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
6979 WNI_CFG_CURRENT_CHANNEL_STAMAX);
6980 return -EINVAL;
6981 }
6982
6983 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6984
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05306985 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
6986 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08006987 {
6988 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
6989 {
6990 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006991 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08006992 return -EINVAL;
6993 }
6994 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6995 "%s: set channel to [%d] for device mode =%d",
6996 __func__, channel,pAdapter->device_mode);
6997 }
6998 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08006999 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08007000 )
7001 {
7002 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7003 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
7004 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7005
7006 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
7007 {
7008 /* Link is up then return cant set channel*/
7009 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007010 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08007011 return -EINVAL;
7012 }
7013
7014 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
7015 pHddStaCtx->conn_info.operationChannel = channel;
7016 pRoamProfile->ChannelInfo.ChannelList =
7017 &pHddStaCtx->conn_info.operationChannel;
7018 }
7019 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08007020 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08007021 )
7022 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307023 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
7024 {
7025 if(VOS_STATUS_SUCCESS !=
7026 wlan_hdd_validate_operation_channel(pAdapter,channel))
7027 {
7028 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007029 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307030 return -EINVAL;
7031 }
7032 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
7033 }
7034 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08007035 {
7036 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
7037
7038 /* If auto channel selection is configured as enable/ 1 then ignore
7039 channel set by supplicant
7040 */
7041 if ( cfg_param->apAutoChannelSelection )
7042 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307043 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
7044 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08007045 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307046 "%s: set channel to auto channel (0) for device mode =%s (%d)",
7047 __func__, hdd_device_modetoString(pAdapter->device_mode),
7048 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08007049 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307050 else
7051 {
7052 if(VOS_STATUS_SUCCESS !=
7053 wlan_hdd_validate_operation_channel(pAdapter,channel))
7054 {
7055 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007056 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307057 return -EINVAL;
7058 }
7059 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
7060 }
Viral Modi3a32cc52013-02-08 11:14:52 -08007061 }
7062 }
7063 else
7064 {
7065 hddLog(VOS_TRACE_LEVEL_FATAL,
7066 "%s: Invalid device mode failed to set valid channel", __func__);
7067 return -EINVAL;
7068 }
7069 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307070 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08007071}
7072
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05307073static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
7074 struct net_device *dev,
7075 struct ieee80211_channel *chan,
7076 enum nl80211_channel_type channel_type
7077 )
7078{
7079 int ret;
7080
7081 vos_ssr_protect(__func__);
7082 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
7083 vos_ssr_unprotect(__func__);
7084
7085 return ret;
7086}
7087
Jeff Johnson295189b2012-06-20 16:38:30 -07007088#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7089static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
7090 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007091#else
7092static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
7093 struct cfg80211_beacon_data *params,
7094 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307095 enum nl80211_hidden_ssid hidden_ssid,
7096 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007097#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007098{
7099 tsap_Config_t *pConfig;
7100 beacon_data_t *pBeacon = NULL;
7101 struct ieee80211_mgmt *pMgmt_frame;
7102 v_U8_t *pIe=NULL;
7103 v_U16_t capab_info;
7104 eCsrAuthType RSNAuthType;
7105 eCsrEncryptionType RSNEncryptType;
7106 eCsrEncryptionType mcRSNEncryptType;
7107 int status = VOS_STATUS_SUCCESS;
7108 tpWLAN_SAPEventCB pSapEventCallback;
7109 hdd_hostapd_state_t *pHostapdState;
7110 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
7111 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307112 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007113 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307114 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07007115 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08007116 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05307117 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07007118 v_BOOL_t MFPCapable = VOS_FALSE;
7119 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307120 v_BOOL_t sapEnable11AC =
7121 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07007122 ENTER();
7123
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307124 iniConfig = pHddCtx->cfg_ini;
7125
Jeff Johnson295189b2012-06-20 16:38:30 -07007126 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
7127
7128 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
7129
7130 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
7131
7132 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
7133
7134 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
7135
7136 //channel is already set in the set_channel Call back
7137 //pConfig->channel = pCommitConfig->channel;
7138
7139 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307140 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07007141 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
7142
7143 pConfig->dtim_period = pBeacon->dtim_period;
7144
Arif Hussain6d2a3322013-11-17 19:50:10 -08007145 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07007146 pConfig->dtim_period);
7147
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08007148 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07007149 {
7150 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007151 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05307152 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
7153 {
7154 tANI_BOOLEAN restartNeeded;
7155 pConfig->ieee80211d = 1;
7156 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
7157 sme_setRegInfo(hHal, pConfig->countryCode);
7158 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
7159 }
7160 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07007161 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07007162 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007163 pConfig->ieee80211d = 1;
7164 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
7165 sme_setRegInfo(hHal, pConfig->countryCode);
7166 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07007167 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007168 else
7169 {
7170 pConfig->ieee80211d = 0;
7171 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307172 /*
7173 * If auto channel is configured i.e. channel is 0,
7174 * so skip channel validation.
7175 */
7176 if( AUTO_CHANNEL_SELECT != pConfig->channel )
7177 {
7178 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
7179 {
7180 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007181 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307182 return -EINVAL;
7183 }
7184 }
7185 else
7186 {
7187 if(1 != pHddCtx->is_dynamic_channel_range_set)
7188 {
7189 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
7190 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
7191 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
7192 }
7193 pHddCtx->is_dynamic_channel_range_set = 0;
7194 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007195 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007196 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007197 {
7198 pConfig->ieee80211d = 0;
7199 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307200
7201#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7202 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7203 pConfig->authType = eSAP_OPEN_SYSTEM;
7204 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7205 pConfig->authType = eSAP_SHARED_KEY;
7206 else
7207 pConfig->authType = eSAP_AUTO_SWITCH;
7208#else
7209 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7210 pConfig->authType = eSAP_OPEN_SYSTEM;
7211 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7212 pConfig->authType = eSAP_SHARED_KEY;
7213 else
7214 pConfig->authType = eSAP_AUTO_SWITCH;
7215#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007216
7217 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307218
7219 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07007220 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
7221
7222 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
7223
7224 /*Set wps station to configured*/
7225 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
7226
7227 if(pIe)
7228 {
7229 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
7230 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007231 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07007232 return -EINVAL;
7233 }
7234 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
7235 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007236 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07007237 /* Check 15 bit of WPS IE as it contain information for wps state
7238 * WPS state
7239 */
7240 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
7241 {
7242 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
7243 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
7244 {
7245 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
7246 }
7247 }
7248 }
7249 else
7250 {
7251 pConfig->wps_state = SAP_WPS_DISABLED;
7252 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307253 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07007254
c_hpothufe599e92014-06-16 11:38:55 +05307255 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7256 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7257 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
7258 eCSR_ENCRYPT_TYPE_NONE;
7259
Jeff Johnson295189b2012-06-20 16:38:30 -07007260 pConfig->RSNWPAReqIELength = 0;
7261 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307262 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007263 WLAN_EID_RSN);
7264 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307265 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7267 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7268 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307269 /* The actual processing may eventually be more extensive than
7270 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07007271 * by the app.
7272 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307273 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007274 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7275 &RSNEncryptType,
7276 &mcRSNEncryptType,
7277 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007278 &MFPCapable,
7279 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007280 pConfig->pRSNWPAReqIE[1]+2,
7281 pConfig->pRSNWPAReqIE );
7282
7283 if( VOS_STATUS_SUCCESS == status )
7284 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307285 /* Now copy over all the security attributes you have
7286 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007287 * */
7288 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7289 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7290 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7291 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307292 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007293 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007294 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7295 }
7296 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307297
Jeff Johnson295189b2012-06-20 16:38:30 -07007298 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7299 pBeacon->tail, pBeacon->tail_len);
7300
7301 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
7302 {
7303 if (pConfig->pRSNWPAReqIE)
7304 {
7305 /*Mixed mode WPA/WPA2*/
7306 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
7307 pConfig->RSNWPAReqIELength += pIe[1] + 2;
7308 }
7309 else
7310 {
7311 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7312 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7313 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307314 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007315 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7316 &RSNEncryptType,
7317 &mcRSNEncryptType,
7318 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007319 &MFPCapable,
7320 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007321 pConfig->pRSNWPAReqIE[1]+2,
7322 pConfig->pRSNWPAReqIE );
7323
7324 if( VOS_STATUS_SUCCESS == status )
7325 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307326 /* Now copy over all the security attributes you have
7327 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007328 * */
7329 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7330 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7331 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7332 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307333 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007334 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007335 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7336 }
7337 }
7338 }
7339
Jeff Johnson4416a782013-03-25 14:17:50 -07007340 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
7341 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
7342 return -EINVAL;
7343 }
7344
Jeff Johnson295189b2012-06-20 16:38:30 -07007345 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
7346
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007347#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007348 if (params->ssid != NULL)
7349 {
7350 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
7351 pConfig->SSIDinfo.ssid.length = params->ssid_len;
7352 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7353 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7354 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007355#else
7356 if (ssid != NULL)
7357 {
7358 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
7359 pConfig->SSIDinfo.ssid.length = ssid_len;
7360 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7361 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7362 }
7363#endif
7364
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307365 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07007366 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307367
Jeff Johnson295189b2012-06-20 16:38:30 -07007368 /* default value */
7369 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
7370 pConfig->num_accept_mac = 0;
7371 pConfig->num_deny_mac = 0;
7372
7373 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7374 pBeacon->tail, pBeacon->tail_len);
7375
7376 /* pIe for black list is following form:
7377 type : 1 byte
7378 length : 1 byte
7379 OUI : 4 bytes
7380 acl type : 1 byte
7381 no of mac addr in black list: 1 byte
7382 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307383 */
7384 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007385 {
7386 pConfig->SapMacaddr_acl = pIe[6];
7387 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007388 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007389 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307390 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
7391 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007392 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7393 for (i = 0; i < pConfig->num_deny_mac; i++)
7394 {
7395 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7396 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007398 }
7399 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7400 pBeacon->tail, pBeacon->tail_len);
7401
7402 /* pIe for white list is following form:
7403 type : 1 byte
7404 length : 1 byte
7405 OUI : 4 bytes
7406 acl type : 1 byte
7407 no of mac addr in white list: 1 byte
7408 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307409 */
7410 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007411 {
7412 pConfig->SapMacaddr_acl = pIe[6];
7413 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007414 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007415 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307416 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
7417 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007418 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7419 for (i = 0; i < pConfig->num_accept_mac; i++)
7420 {
7421 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7422 acl_entry++;
7423 }
7424 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307425
Jeff Johnson295189b2012-06-20 16:38:30 -07007426 wlan_hdd_set_sapHwmode(pHostapdAdapter);
7427
Jeff Johnsone7245742012-09-05 17:12:55 -07007428#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007429 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307430 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
7431 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05307432 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
7433 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007434 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
7435 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307436 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
7437 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07007438 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307439 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007440 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307441 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007442
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307443 /* If ACS disable and selected channel <= 14
7444 * OR
7445 * ACS enabled and ACS operating band is choosen as 2.4
7446 * AND
7447 * VHT in 2.4G Disabled
7448 * THEN
7449 * Fallback to 11N mode
7450 */
7451 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
7452 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05307453 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307454 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007455 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307456 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
7457 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007458 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
7459 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007460 }
7461#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307462
Jeff Johnson295189b2012-06-20 16:38:30 -07007463 // ht_capab is not what the name conveys,this is used for protection bitmap
7464 pConfig->ht_capab =
7465 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
7466
7467 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
7468 {
7469 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
7470 return -EINVAL;
7471 }
7472
7473 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307474 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07007475 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
7476 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307477 pConfig->obssProtEnabled =
7478 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07007479
Chet Lanctot8cecea22014-02-11 19:09:36 -08007480#ifdef WLAN_FEATURE_11W
7481 pConfig->mfpCapable = MFPCapable;
7482 pConfig->mfpRequired = MFPRequired;
7483 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
7484 pConfig->mfpCapable, pConfig->mfpRequired);
7485#endif
7486
Arif Hussain6d2a3322013-11-17 19:50:10 -08007487 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07007488 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007489 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
7490 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
7491 (int)pConfig->channel);
7492 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
7493 pConfig->SapHw_mode, pConfig->privacy,
7494 pConfig->authType);
7495 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
7496 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
7497 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
7498 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07007499
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307500 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 {
7502 //Bss already started. just return.
7503 //TODO Probably it should update some beacon params.
7504 hddLog( LOGE, "Bss Already started...Ignore the request");
7505 EXIT();
7506 return 0;
7507 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307508
Agarwal Ashish51325b52014-06-16 16:50:49 +05307509 if (vos_max_concurrent_connections_reached()) {
7510 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7511 return -EINVAL;
7512 }
7513
Jeff Johnson295189b2012-06-20 16:38:30 -07007514 pConfig->persona = pHostapdAdapter->device_mode;
7515
Peng Xu2446a892014-09-05 17:21:18 +05307516 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
7517 if ( NULL != psmeConfig)
7518 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307519 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05307520 sme_GetConfigParam(hHal, psmeConfig);
7521 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307522#ifdef WLAN_FEATURE_AP_HT40_24G
7523 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
7524 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
7525 && pHddCtx->cfg_ini->apHT40_24GEnabled)
7526 {
7527 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
7528 sme_UpdateConfig (hHal, psmeConfig);
7529 }
7530#endif
Peng Xu2446a892014-09-05 17:21:18 +05307531 vos_mem_free(psmeConfig);
7532 }
Peng Xuafc34e32014-09-25 13:23:55 +05307533 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05307534
Jeff Johnson295189b2012-06-20 16:38:30 -07007535 pSapEventCallback = hdd_hostapd_SAPEventCB;
7536 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
7537 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
7538 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007539 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 return -EINVAL;
7541 }
7542
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307543 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07007544 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
7545
7546 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307547
Jeff Johnson295189b2012-06-20 16:38:30 -07007548 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307549 {
7550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007551 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07007552 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007553 VOS_ASSERT(0);
7554 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307555
Jeff Johnson295189b2012-06-20 16:38:30 -07007556 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05307557 /* Initialize WMM configuation */
7558 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307559 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007560
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007561#ifdef WLAN_FEATURE_P2P_DEBUG
7562 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
7563 {
7564 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
7565 {
7566 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7567 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007568 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007569 }
7570 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
7571 {
7572 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7573 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007574 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007575 }
7576 }
7577#endif
7578
Jeff Johnson295189b2012-06-20 16:38:30 -07007579 pHostapdState->bCommit = TRUE;
7580 EXIT();
7581
7582 return 0;
7583}
7584
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007585#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307586static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307587 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007588 struct beacon_parameters *params)
7589{
7590 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307591 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307592 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007593
7594 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307595
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307596 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7597 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
7598 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307599 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
7600 hdd_device_modetoString(pAdapter->device_mode),
7601 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007602
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307603 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7604 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307605 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007606 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307607 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007608 }
7609
Agarwal Ashish51325b52014-06-16 16:50:49 +05307610 if (vos_max_concurrent_connections_reached()) {
7611 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7612 return -EINVAL;
7613 }
7614
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307615 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007616 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007617 )
7618 {
7619 beacon_data_t *old,*new;
7620
7621 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307622
Jeff Johnson295189b2012-06-20 16:38:30 -07007623 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307624 {
7625 hddLog(VOS_TRACE_LEVEL_WARN,
7626 FL("already beacon info added to session(%d)"),
7627 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007628 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007630
7631 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7632
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307633 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07007634 {
7635 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007636 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007637 return -EINVAL;
7638 }
7639
7640 pAdapter->sessionCtx.ap.beacon = new;
7641
7642 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7643 }
7644
7645 EXIT();
7646 return status;
7647}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307648
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307649static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
7650 struct net_device *dev,
7651 struct beacon_parameters *params)
7652{
7653 int ret;
7654
7655 vos_ssr_protect(__func__);
7656 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
7657 vos_ssr_unprotect(__func__);
7658
7659 return ret;
7660}
7661
7662static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007663 struct net_device *dev,
7664 struct beacon_parameters *params)
7665{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307666 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307667 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7668 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307669 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007670
7671 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307672
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307673 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7674 TRACE_CODE_HDD_CFG80211_SET_BEACON,
7675 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
7676 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7677 __func__, hdd_device_modetoString(pAdapter->device_mode),
7678 pAdapter->device_mode);
7679
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307680 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7681 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307682 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007683 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307684 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007685 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307686
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307687 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007688 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307689 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007690 {
7691 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307692
Jeff Johnson295189b2012-06-20 16:38:30 -07007693 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307694
Jeff Johnson295189b2012-06-20 16:38:30 -07007695 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307696 {
7697 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7698 FL("session(%d) old and new heads points to NULL"),
7699 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007700 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007702
7703 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7704
7705 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307706 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007707 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007708 return -EINVAL;
7709 }
7710
7711 pAdapter->sessionCtx.ap.beacon = new;
7712
7713 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7714 }
7715
7716 EXIT();
7717 return status;
7718}
7719
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307720static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
7721 struct net_device *dev,
7722 struct beacon_parameters *params)
7723{
7724 int ret;
7725
7726 vos_ssr_protect(__func__);
7727 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
7728 vos_ssr_unprotect(__func__);
7729
7730 return ret;
7731}
7732
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007733#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7734
7735#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307736static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007737 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007738#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307739static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007740 struct net_device *dev)
7741#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007742{
7743 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07007744 hdd_context_t *pHddCtx = NULL;
7745 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307746 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307747 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007748
7749 ENTER();
7750
7751 if (NULL == pAdapter)
7752 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307753 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007754 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007755 return -ENODEV;
7756 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007757
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307758 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7759 TRACE_CODE_HDD_CFG80211_STOP_AP,
7760 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307761 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7762 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307763 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007764 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307765 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07007766 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007767
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007768 pScanInfo = &pHddCtx->scan_info;
7769
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307770 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7771 __func__, hdd_device_modetoString(pAdapter->device_mode),
7772 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007773
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307774 ret = wlan_hdd_scan_abort(pAdapter);
7775
Girish Gowli4bf7a632014-06-12 13:42:11 +05307776 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07007777 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307778 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7779 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307780
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307781 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07007782 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7784 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08007785
Jeff Johnsone7245742012-09-05 17:12:55 -07007786 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307787 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07007788 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307789 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07007790 }
7791
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05307792 /* Delete all associated STAs before stopping AP/P2P GO */
7793 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05307794 hdd_hostapd_stop(dev);
7795
Jeff Johnson295189b2012-06-20 16:38:30 -07007796 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007797 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007798 )
7799 {
7800 beacon_data_t *old;
7801
7802 old = pAdapter->sessionCtx.ap.beacon;
7803
7804 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307805 {
7806 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7807 FL("session(%d) beacon data points to NULL"),
7808 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007809 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307810 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007811
Jeff Johnson295189b2012-06-20 16:38:30 -07007812 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007813
7814 mutex_lock(&pHddCtx->sap_lock);
7815 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7816 {
Jeff Johnson4416a782013-03-25 14:17:50 -07007817 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007818 {
7819 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7820
7821 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
7822
7823 if (!VOS_IS_STATUS_SUCCESS(status))
7824 {
7825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007826 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007827 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307828 }
7829 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007830 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307831 /* BSS stopped, clear the active sessions for this device mode */
7832 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 }
7834 mutex_unlock(&pHddCtx->sap_lock);
7835
7836 if(status != VOS_STATUS_SUCCESS)
7837 {
7838 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007839 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007840 return -EINVAL;
7841 }
7842
Jeff Johnson4416a782013-03-25 14:17:50 -07007843 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007844 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
7845 ==eHAL_STATUS_FAILURE)
7846 {
7847 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007848 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007849 }
7850
Jeff Johnson4416a782013-03-25 14:17:50 -07007851 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007852 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7853 eANI_BOOLEAN_FALSE) )
7854 {
7855 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007856 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007857 }
7858
7859 // Reset WNI_CFG_PROBE_RSP Flags
7860 wlan_hdd_reset_prob_rspies(pAdapter);
7861
7862 pAdapter->sessionCtx.ap.beacon = NULL;
7863 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007864#ifdef WLAN_FEATURE_P2P_DEBUG
7865 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
7866 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
7867 {
7868 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
7869 "GO got removed");
7870 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
7871 }
7872#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 }
7874 EXIT();
7875 return status;
7876}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007877
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307878#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7879static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
7880 struct net_device *dev)
7881{
7882 int ret;
7883
7884 vos_ssr_protect(__func__);
7885 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
7886 vos_ssr_unprotect(__func__);
7887
7888 return ret;
7889}
7890#else
7891static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
7892 struct net_device *dev)
7893{
7894 int ret;
7895
7896 vos_ssr_protect(__func__);
7897 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
7898 vos_ssr_unprotect(__func__);
7899
7900 return ret;
7901}
7902#endif
7903
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007904#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
7905
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307906static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307907 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007908 struct cfg80211_ap_settings *params)
7909{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307910 hdd_adapter_t *pAdapter;
7911 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307912 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007913
7914 ENTER();
7915
Girish Gowlib143d7a2015-02-18 19:39:55 +05307916 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007917 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307918 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05307919 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307920 return -ENODEV;
7921 }
7922
7923 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7924 if (NULL == pAdapter)
7925 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307926 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307927 "%s: HDD adapter is Null", __func__);
7928 return -ENODEV;
7929 }
7930
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307931 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7932 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
7933 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307934 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
7935 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307936 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307937 "%s: HDD adapter magic is invalid", __func__);
7938 return -ENODEV;
7939 }
7940
7941 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307942 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307943 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307944 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307945 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307946 }
7947
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307948 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
7949 __func__, hdd_device_modetoString(pAdapter->device_mode),
7950 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307951
7952 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007953 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007954 )
7955 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307956 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007957
7958 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307959
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007960 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307961 {
7962 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7963 FL("already beacon info added to session(%d)"),
7964 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007965 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307966 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007967
Girish Gowlib143d7a2015-02-18 19:39:55 +05307968#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7969 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7970 &new,
7971 &params->beacon);
7972#else
7973 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7974 &new,
7975 &params->beacon,
7976 params->dtim_period);
7977#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007978
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307979 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007980 {
7981 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307982 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007983 return -EINVAL;
7984 }
7985 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08007986#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07007987 wlan_hdd_cfg80211_set_channel(wiphy, dev,
7988#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
7989 params->channel, params->channel_type);
7990#else
7991 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
7992#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08007993#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007994 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307995 params->ssid_len, params->hidden_ssid,
7996 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007997 }
7998
7999 EXIT();
8000 return status;
8001}
8002
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308003static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
8004 struct net_device *dev,
8005 struct cfg80211_ap_settings *params)
8006{
8007 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008008
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308009 vos_ssr_protect(__func__);
8010 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
8011 vos_ssr_unprotect(__func__);
8012
8013 return ret;
8014}
8015
8016static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008017 struct net_device *dev,
8018 struct cfg80211_beacon_data *params)
8019{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308020 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308021 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308022 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008023
8024 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308025
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308026 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8027 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
8028 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08008029 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008030 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308031
8032 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8033 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308034 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07008035 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308036 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07008037 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008038
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308039 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008040 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308041 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008042 {
8043 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308044
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008045 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308046
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008047 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308048 {
8049 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8050 FL("session(%d) beacon data points to NULL"),
8051 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008052 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308053 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008054
8055 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
8056
8057 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308058 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008059 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008060 return -EINVAL;
8061 }
8062
8063 pAdapter->sessionCtx.ap.beacon = new;
8064
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05308065 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
8066 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008067 }
8068
8069 EXIT();
8070 return status;
8071}
8072
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308073static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
8074 struct net_device *dev,
8075 struct cfg80211_beacon_data *params)
8076{
8077 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008078
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308079 vos_ssr_protect(__func__);
8080 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
8081 vos_ssr_unprotect(__func__);
8082
8083 return ret;
8084}
8085
8086#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008087
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308088static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008089 struct net_device *dev,
8090 struct bss_parameters *params)
8091{
8092 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308093 hdd_context_t *pHddCtx;
8094 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008095
8096 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308097
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308098 if (NULL == pAdapter)
8099 {
8100 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8101 "%s: HDD adapter is Null", __func__);
8102 return -ENODEV;
8103 }
8104 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308105 ret = wlan_hdd_validate_context(pHddCtx);
8106 if (0 != ret)
8107 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308108 return ret;
8109 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308110 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8111 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
8112 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308113 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8114 __func__, hdd_device_modetoString(pAdapter->device_mode),
8115 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008116
8117 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008118 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308119 )
Jeff Johnson295189b2012-06-20 16:38:30 -07008120 {
8121 /* ap_isolate == -1 means that in change bss, upper layer doesn't
8122 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308123 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07008124 {
8125 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308126 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008127 }
8128
8129 EXIT();
8130 return 0;
8131}
8132
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308133static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
8134 struct net_device *dev,
8135 struct bss_parameters *params)
8136{
8137 int ret;
8138
8139 vos_ssr_protect(__func__);
8140 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
8141 vos_ssr_unprotect(__func__);
8142
8143 return ret;
8144}
Kiet Lam10841362013-11-01 11:36:50 +05308145/* FUNCTION: wlan_hdd_change_country_code_cd
8146* to wait for contry code completion
8147*/
8148void* wlan_hdd_change_country_code_cb(void *pAdapter)
8149{
8150 hdd_adapter_t *call_back_pAdapter = pAdapter;
8151 complete(&call_back_pAdapter->change_country_code);
8152 return NULL;
8153}
8154
Jeff Johnson295189b2012-06-20 16:38:30 -07008155/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308156 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07008157 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
8158 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308159int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008160 struct net_device *ndev,
8161 enum nl80211_iftype type,
8162 u32 *flags,
8163 struct vif_params *params
8164 )
8165{
8166 struct wireless_dev *wdev;
8167 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008168 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07008169 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008170 tCsrRoamProfile *pRoamProfile = NULL;
8171 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308172 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008173 eMib_dot11DesiredBssType connectedBssType;
8174 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308175 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008176
8177 ENTER();
8178
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308179 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008180 {
8181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8182 "%s: Adapter context is null", __func__);
8183 return VOS_STATUS_E_FAILURE;
8184 }
8185
8186 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8187 if (!pHddCtx)
8188 {
8189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8190 "%s: HDD context is null", __func__);
8191 return VOS_STATUS_E_FAILURE;
8192 }
8193
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308194 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8195 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
8196 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308197 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308198 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07008199 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308200 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 }
8202
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308203 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8204 __func__, hdd_device_modetoString(pAdapter->device_mode),
8205 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008206
Agarwal Ashish51325b52014-06-16 16:50:49 +05308207 if (vos_max_concurrent_connections_reached()) {
8208 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
8209 return -EINVAL;
8210 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308211 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07008212 wdev = ndev->ieee80211_ptr;
8213
8214#ifdef WLAN_BTAMP_FEATURE
8215 if((NL80211_IFTYPE_P2P_CLIENT == type)||
8216 (NL80211_IFTYPE_ADHOC == type)||
8217 (NL80211_IFTYPE_AP == type)||
8218 (NL80211_IFTYPE_P2P_GO == type))
8219 {
8220 pHddCtx->isAmpAllowed = VOS_FALSE;
8221 // stop AMP traffic
8222 status = WLANBAP_StopAmp();
8223 if(VOS_STATUS_SUCCESS != status )
8224 {
8225 pHddCtx->isAmpAllowed = VOS_TRUE;
8226 hddLog(VOS_TRACE_LEVEL_FATAL,
8227 "%s: Failed to stop AMP", __func__);
8228 return -EINVAL;
8229 }
8230 }
8231#endif //WLAN_BTAMP_FEATURE
8232 /* Reset the current device mode bit mask*/
8233 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
8234
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05308235 if ((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
8236 ((type == NL80211_IFTYPE_P2P_CLIENT) ||
8237 (type == NL80211_IFTYPE_P2P_GO)))
8238 {
8239 /* Notify Mode change in case of concurrency.
8240 * Below function invokes TDLS teardown Functionality Since TDLS is
8241 * not Supported in case of concurrency i.e Once P2P session
8242 * is detected disable offchannel and teardown TDLS links
8243 */
8244 hddLog(LOG1,
8245 FL("Device mode = %d Interface type = %d"),
8246 pAdapter->device_mode, type);
8247 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
8248 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05308249
Jeff Johnson295189b2012-06-20 16:38:30 -07008250 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008251 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07008252 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07008253 )
8254 {
8255 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008256 if (!pWextState)
8257 {
8258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8259 "%s: pWextState is null", __func__);
8260 return VOS_STATUS_E_FAILURE;
8261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008262 pRoamProfile = &pWextState->roamProfile;
8263 LastBSSType = pRoamProfile->BSSType;
8264
8265 switch (type)
8266 {
8267 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008268 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008269 hddLog(VOS_TRACE_LEVEL_INFO,
8270 "%s: setting interface Type to INFRASTRUCTURE", __func__);
8271 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07008272#ifdef WLAN_FEATURE_11AC
8273 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
8274 {
8275 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
8276 }
8277#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308278 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07008279 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008280 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008281 //Check for sub-string p2p to confirm its a p2p interface
8282 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308283 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +05308284#ifdef FEATURE_WLAN_TDLS
8285 mutex_lock(&pHddCtx->tdls_lock);
8286 wlan_hdd_tdls_exit(pAdapter, TRUE);
8287 mutex_unlock(&pHddCtx->tdls_lock);
8288#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008289 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8290 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8291 }
8292 else
8293 {
8294 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008295 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008297 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05308298
Jeff Johnson295189b2012-06-20 16:38:30 -07008299 case NL80211_IFTYPE_ADHOC:
8300 hddLog(VOS_TRACE_LEVEL_INFO,
8301 "%s: setting interface Type to ADHOC", __func__);
8302 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
8303 pRoamProfile->phyMode =
8304 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07008305 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008306 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +05308307 hdd_set_ibss_ops( pAdapter );
8308 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +05308309
8310 status = hdd_sta_id_hash_attach(pAdapter);
8311 if (VOS_STATUS_SUCCESS != status) {
8312 hddLog(VOS_TRACE_LEVEL_ERROR,
8313 FL("Failed to initialize hash for IBSS"));
8314 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008315 break;
8316
8317 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008318 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008319 {
8320 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8321 "%s: setting interface Type to %s", __func__,
8322 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
8323
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008324 //Cancel any remain on channel for GO mode
8325 if (NL80211_IFTYPE_P2P_GO == type)
8326 {
8327 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
8328 }
Mohit Khanna0f232092012-09-11 14:46:08 -07008329 if (NL80211_IFTYPE_AP == type)
8330 {
8331 /* As Loading WLAN Driver one interface being created for p2p device
8332 * address. This will take one HW STA and the max number of clients
8333 * that can connect to softAP will be reduced by one. so while changing
8334 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
8335 * interface as it is not required in SoftAP mode.
8336 */
8337
8338 // Get P2P Adapter
8339 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
8340
8341 if (pP2pAdapter)
8342 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05308343 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +05308344 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07008345 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
8346 }
8347 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05308348 //Disable IMPS & BMPS for SAP/GO
8349 if(VOS_STATUS_E_FAILURE ==
8350 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
8351 {
8352 //Fail to Exit BMPS
8353 VOS_ASSERT(0);
8354 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05308355
8356 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
8357
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308358#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07008359
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308360 /* A Mutex Lock is introduced while changing the mode to
8361 * protect the concurrent access for the Adapters by TDLS
8362 * module.
8363 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308364 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308365#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008366 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +05308367 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008368 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8370 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308371#ifdef FEATURE_WLAN_TDLS
8372 mutex_unlock(&pHddCtx->tdls_lock);
8373#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008374 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
8375 (pConfig->apRandomBssidEnabled))
8376 {
8377 /* To meet Android requirements create a randomized
8378 MAC address of the form 02:1A:11:Fx:xx:xx */
8379 get_random_bytes(&ndev->dev_addr[3], 3);
8380 ndev->dev_addr[0] = 0x02;
8381 ndev->dev_addr[1] = 0x1A;
8382 ndev->dev_addr[2] = 0x11;
8383 ndev->dev_addr[3] |= 0xF0;
8384 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
8385 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08008386 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
8387 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008388 }
8389
Jeff Johnson295189b2012-06-20 16:38:30 -07008390 hdd_set_ap_ops( pAdapter->dev );
8391
Kiet Lam10841362013-11-01 11:36:50 +05308392 /* This is for only SAP mode where users can
8393 * control country through ini.
8394 * P2P GO follows station country code
8395 * acquired during the STA scanning. */
8396 if((NL80211_IFTYPE_AP == type) &&
8397 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
8398 {
8399 int status = 0;
8400 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
8401 "%s: setting country code from INI ", __func__);
8402 init_completion(&pAdapter->change_country_code);
8403 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
8404 (void *)(tSmeChangeCountryCallback)
8405 wlan_hdd_change_country_code_cb,
8406 pConfig->apCntryCode, pAdapter,
8407 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05308408 eSIR_FALSE,
8409 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05308410 if (eHAL_STATUS_SUCCESS == status)
8411 {
8412 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308413 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05308414 &pAdapter->change_country_code,
8415 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308416 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05308417 {
8418 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308419 FL("SME Timed out while setting country code %ld"),
8420 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08008421
8422 if (pHddCtx->isLogpInProgress)
8423 {
8424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8425 "%s: LOGP in Progress. Ignore!!!", __func__);
8426 return -EAGAIN;
8427 }
Kiet Lam10841362013-11-01 11:36:50 +05308428 }
8429 }
8430 else
8431 {
8432 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008433 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05308434 return -EINVAL;
8435 }
8436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008437 status = hdd_init_ap_mode(pAdapter);
8438 if(status != VOS_STATUS_SUCCESS)
8439 {
8440 hddLog(VOS_TRACE_LEVEL_FATAL,
8441 "%s: Error initializing the ap mode", __func__);
8442 return -EINVAL;
8443 }
8444 hdd_set_conparam(1);
8445
Nirav Shah7e3c8132015-06-22 23:51:42 +05308446 status = hdd_sta_id_hash_attach(pAdapter);
8447 if (VOS_STATUS_SUCCESS != status)
8448 {
8449 hddLog(VOS_TRACE_LEVEL_ERROR,
8450 FL("Failed to initialize hash for AP"));
8451 return -EINVAL;
8452 }
8453
Jeff Johnson295189b2012-06-20 16:38:30 -07008454 /*interface type changed update in wiphy structure*/
8455 if(wdev)
8456 {
8457 wdev->iftype = type;
8458 pHddCtx->change_iface = type;
8459 }
8460 else
8461 {
8462 hddLog(VOS_TRACE_LEVEL_ERROR,
8463 "%s: ERROR !!!! Wireless dev is NULL", __func__);
8464 return -EINVAL;
8465 }
8466 goto done;
8467 }
8468
8469 default:
8470 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8471 __func__);
8472 return -EOPNOTSUPP;
8473 }
8474 }
8475 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008476 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07008477 )
8478 {
8479 switch(type)
8480 {
8481 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008482 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008483 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05308484
8485 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308486#ifdef FEATURE_WLAN_TDLS
8487
8488 /* A Mutex Lock is introduced while changing the mode to
8489 * protect the concurrent access for the Adapters by TDLS
8490 * module.
8491 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308492 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308493#endif
c_hpothu002231a2015-02-05 14:58:51 +05308494 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008495 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008496 //Check for sub-string p2p to confirm its a p2p interface
8497 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008498 {
8499 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8500 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8501 }
8502 else
8503 {
8504 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008505 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008506 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008507 hdd_set_conparam(0);
8508 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008509 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
8510 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308511#ifdef FEATURE_WLAN_TDLS
8512 mutex_unlock(&pHddCtx->tdls_lock);
8513#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05308514 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008515 if( VOS_STATUS_SUCCESS != status )
8516 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07008517 /* In case of JB, for P2P-GO, only change interface will be called,
8518 * This is the right place to enable back bmps_imps()
8519 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308520 if (pHddCtx->hdd_wlan_suspended)
8521 {
8522 hdd_set_pwrparams(pHddCtx);
8523 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008524 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008525 goto done;
8526 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008527 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008528 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008529 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8530 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008531 goto done;
8532 default:
8533 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8534 __func__);
8535 return -EOPNOTSUPP;
8536
8537 }
8538
8539 }
8540 else
8541 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308542 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
8543 __func__, hdd_device_modetoString(pAdapter->device_mode),
8544 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008545 return -EOPNOTSUPP;
8546 }
8547
8548
8549 if(pRoamProfile)
8550 {
8551 if ( LastBSSType != pRoamProfile->BSSType )
8552 {
8553 /*interface type changed update in wiphy structure*/
8554 wdev->iftype = type;
8555
8556 /*the BSS mode changed, We need to issue disconnect
8557 if connected or in IBSS disconnect state*/
8558 if ( hdd_connGetConnectedBssType(
8559 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
8560 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
8561 {
8562 /*need to issue a disconnect to CSR.*/
8563 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8564 if( eHAL_STATUS_SUCCESS ==
8565 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8566 pAdapter->sessionId,
8567 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
8568 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308569 ret = wait_for_completion_interruptible_timeout(
8570 &pAdapter->disconnect_comp_var,
8571 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8572 if (ret <= 0)
8573 {
8574 hddLog(VOS_TRACE_LEVEL_ERROR,
8575 FL("wait on disconnect_comp_var failed %ld"), ret);
8576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008577 }
8578 }
8579 }
8580 }
8581
8582done:
8583 /*set bitmask based on updated value*/
8584 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07008585
8586 /* Only STA mode support TM now
8587 * all other mode, TM feature should be disabled */
8588 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
8589 (~VOS_STA & pHddCtx->concurrency_mode) )
8590 {
8591 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
8592 }
8593
Jeff Johnson295189b2012-06-20 16:38:30 -07008594#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308595 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05308596 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07008597 {
8598 //we are ok to do AMP
8599 pHddCtx->isAmpAllowed = VOS_TRUE;
8600 }
8601#endif //WLAN_BTAMP_FEATURE
8602 EXIT();
8603 return 0;
8604}
8605
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308606/*
8607 * FUNCTION: wlan_hdd_cfg80211_change_iface
8608 * wrapper function to protect the actual implementation from SSR.
8609 */
8610int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
8611 struct net_device *ndev,
8612 enum nl80211_iftype type,
8613 u32 *flags,
8614 struct vif_params *params
8615 )
8616{
8617 int ret;
8618
8619 vos_ssr_protect(__func__);
8620 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
8621 vos_ssr_unprotect(__func__);
8622
8623 return ret;
8624}
8625
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008626#ifdef FEATURE_WLAN_TDLS
8627static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308628 struct net_device *dev,
8629#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
8630 const u8 *mac,
8631#else
8632 u8 *mac,
8633#endif
8634 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008635{
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008636 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008637 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308638 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308639 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308640 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308641 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008642
8643 ENTER();
8644
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308645 if (!dev) {
8646 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
8647 return -EINVAL;
8648 }
8649
8650 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8651 if (!pAdapter) {
8652 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
8653 return -EINVAL;
8654 }
8655
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308656 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008657 {
8658 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8659 "Invalid arguments");
8660 return -EINVAL;
8661 }
Hoonki Lee27511902013-03-14 18:19:06 -07008662
8663 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
8664 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
8665 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308666 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -07008667 "%s: TDLS mode is disabled OR not enabled in FW."
8668 MAC_ADDRESS_STR " Request declined.",
8669 __func__, MAC_ADDR_ARRAY(mac));
8670 return -ENOTSUPP;
8671 }
8672
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008673 if (pHddCtx->isLogpInProgress)
8674 {
8675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8676 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05308677 wlan_hdd_tdls_set_link_status(pAdapter,
8678 mac,
8679 eTDLS_LINK_IDLE,
8680 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008681 return -EBUSY;
8682 }
8683
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308684 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05308685 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008686
8687 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308688 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008689 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
8690 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308691 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008692 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008693 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308694 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008695
8696 /* in add station, we accept existing valid staId if there is */
8697 if ((0 == update) &&
8698 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
8699 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008700 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308701 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008702 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008703 " link_status %d. staId %d. add station ignored.",
8704 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
8705 return 0;
8706 }
8707 /* in change station, we accept only when staId is valid */
8708 if ((1 == update) &&
8709 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
8710 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
8711 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308712 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008713 "%s: " MAC_ADDRESS_STR
8714 " link status %d. staId %d. change station %s.",
8715 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
8716 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
8717 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008718 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008719
8720 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05308721 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008722 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008723 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8724 "%s: " MAC_ADDRESS_STR
8725 " TDLS setup is ongoing. Request declined.",
8726 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07008727 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008728 }
8729
8730 /* first to check if we reached to maximum supported TDLS peer.
8731 TODO: for now, return -EPERM looks working fine,
8732 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308733 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
8734 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008735 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008736 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8737 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308738 " TDLS Max peer already connected. Request declined."
8739 " Num of peers (%d), Max allowed (%d).",
8740 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
8741 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008742 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008743 }
8744 else
8745 {
8746 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308747 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008748 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008749 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008750 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8751 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
8752 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008753 return -EPERM;
8754 }
8755 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008756 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05308757 wlan_hdd_tdls_set_link_status(pAdapter,
8758 mac,
8759 eTDLS_LINK_CONNECTING,
8760 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008761
Jeff Johnsond75fe012013-04-06 10:53:06 -07008762 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308763 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008764 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008766 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008767 if(StaParams->htcap_present)
8768 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008770 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008772 "ht_capa->extended_capabilities: %0x",
8773 StaParams->HTCap.extendedHtCapInfo);
8774 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008776 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008778 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008779 if(StaParams->vhtcap_present)
8780 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008782 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
8783 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
8784 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
8785 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008786 {
8787 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008788 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008789 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008791 "[%d]: %x ", i, StaParams->supported_rates[i]);
8792 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07008793 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308794 else if ((1 == update) && (NULL == StaParams))
8795 {
8796 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8797 "%s : update is true, but staParams is NULL. Error!", __func__);
8798 return -EPERM;
8799 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008800
8801 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
8802
8803 if (!update)
8804 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308805 /*Before adding sta make sure that device exited from BMPS*/
8806 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8807 {
8808 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8809 "%s: Adding tdls peer sta. Disable BMPS", __func__);
8810 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8811 if (status != VOS_STATUS_SUCCESS) {
8812 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
8813 }
8814 }
8815
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308816 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008817 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308818 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308819 hddLog(VOS_TRACE_LEVEL_ERROR,
8820 FL("Failed to add TDLS peer STA. Enable Bmps"));
8821 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308822 return -EPERM;
8823 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008824 }
8825 else
8826 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308827 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008828 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308829 if (ret != eHAL_STATUS_SUCCESS) {
8830 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
8831 return -EPERM;
8832 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008833 }
8834
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308835 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008836 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
8837
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308838 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008839 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308841 "%s: timeout waiting for tdls add station indication %ld",
8842 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008843 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008844 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308845
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008846 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
8847 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008849 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008850 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008851 }
8852
8853 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008854
8855error:
Atul Mittal115287b2014-07-08 13:26:33 +05308856 wlan_hdd_tdls_set_link_status(pAdapter,
8857 mac,
8858 eTDLS_LINK_IDLE,
8859 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008860 return -EPERM;
8861
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008862}
8863#endif
8864
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308865static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008866 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308867#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
8868 const u8 *mac,
8869#else
Jeff Johnson295189b2012-06-20 16:38:30 -07008870 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308871#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008872 struct station_parameters *params)
8873{
8874 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308875 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308876 hdd_context_t *pHddCtx;
8877 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008878 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308879 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008880#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008881 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008882 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308883 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008884#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008885
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308886 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308887
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308888 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308889 if ((NULL == pAdapter))
8890 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308892 "invalid adapter ");
8893 return -EINVAL;
8894 }
8895
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308896 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8897 TRACE_CODE_HDD_CHANGE_STATION,
8898 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05308899 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308900
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308901 ret = wlan_hdd_validate_context(pHddCtx);
8902 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +05308903 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308904 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308905 }
8906
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308907 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8908
8909 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008910 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308911 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8912 "invalid HDD station context");
8913 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008914 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008915 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
8916
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008917 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
8918 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07008919 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008920 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07008921 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308922 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008923 WLANTL_STA_AUTHENTICATED);
8924
Gopichand Nakkala29149562013-05-10 21:43:41 +05308925 if (status != VOS_STATUS_SUCCESS)
8926 {
8927 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8928 "%s: Not able to change TL state to AUTHENTICATED", __func__);
8929 return -EINVAL;
8930 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008931 }
8932 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07008933 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
8934 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308935#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008936 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
8937 StaParams.capability = params->capability;
8938 StaParams.uapsd_queues = params->uapsd_queues;
8939 StaParams.max_sp = params->max_sp;
8940
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308941 /* Convert (first channel , number of channels) tuple to
8942 * the total list of channels. This goes with the assumption
8943 * that if the first channel is < 14, then the next channels
8944 * are an incremental of 1 else an incremental of 4 till the number
8945 * of channels.
8946 */
8947 if (0 != params->supported_channels_len) {
8948 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
8949 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
8950 {
8951 int wifi_chan_index;
8952 StaParams.supported_channels[j] = params->supported_channels[i];
8953 wifi_chan_index =
8954 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
8955 no_of_channels = params->supported_channels[i+1];
8956 for(k=1; k <= no_of_channels; k++)
8957 {
8958 StaParams.supported_channels[j+1] =
8959 StaParams.supported_channels[j] + wifi_chan_index;
8960 j+=1;
8961 }
8962 }
8963 StaParams.supported_channels_len = j;
8964 }
8965 vos_mem_copy(StaParams.supported_oper_classes,
8966 params->supported_oper_classes,
8967 params->supported_oper_classes_len);
8968 StaParams.supported_oper_classes_len =
8969 params->supported_oper_classes_len;
8970
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008971 if (0 != params->ext_capab_len)
8972 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
8973 sizeof(StaParams.extn_capability));
8974
8975 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008976 {
8977 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008978 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008979 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008980
8981 StaParams.supported_rates_len = params->supported_rates_len;
8982
8983 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
8984 * The supported_rates array , for all the structures propogating till Add Sta
8985 * to the firmware has to be modified , if the supplicant (ieee80211) is
8986 * modified to send more rates.
8987 */
8988
8989 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
8990 */
8991 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
8992 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
8993
8994 if (0 != StaParams.supported_rates_len) {
8995 int i = 0;
8996 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
8997 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008998 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008999 "Supported Rates with Length %d", StaParams.supported_rates_len);
9000 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009001 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009002 "[%d]: %0x", i, StaParams.supported_rates[i]);
9003 }
9004
9005 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07009006 {
9007 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009008 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07009009 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009010
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009011 if (0 != params->ext_capab_len ) {
9012 /*Define A Macro : TODO Sunil*/
9013 if ((1<<4) & StaParams.extn_capability[3]) {
9014 isBufSta = 1;
9015 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05309016 /* TDLS Channel Switching Support */
9017 if ((1<<6) & StaParams.extn_capability[3]) {
9018 isOffChannelSupported = 1;
9019 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009020 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05309021 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
9022 &StaParams, isBufSta,
9023 isOffChannelSupported);
9024
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309025 if (VOS_STATUS_SUCCESS != status) {
9026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9027 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
9028 return -EINVAL;
9029 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009030 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
9031
9032 if (VOS_STATUS_SUCCESS != status) {
9033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9034 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
9035 return -EINVAL;
9036 }
9037 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07009038#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05309039 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009040 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009041 return status;
9042}
9043
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309044#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
9045static int wlan_hdd_change_station(struct wiphy *wiphy,
9046 struct net_device *dev,
9047 const u8 *mac,
9048 struct station_parameters *params)
9049#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309050static int wlan_hdd_change_station(struct wiphy *wiphy,
9051 struct net_device *dev,
9052 u8 *mac,
9053 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309054#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309055{
9056 int ret;
9057
9058 vos_ssr_protect(__func__);
9059 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
9060 vos_ssr_unprotect(__func__);
9061
9062 return ret;
9063}
9064
Jeff Johnson295189b2012-06-20 16:38:30 -07009065/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309066 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009067 * This function is used to initialize the key information
9068 */
9069#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309070static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009071 struct net_device *ndev,
9072 u8 key_index, bool pairwise,
9073 const u8 *mac_addr,
9074 struct key_params *params
9075 )
9076#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309077static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009078 struct net_device *ndev,
9079 u8 key_index, const u8 *mac_addr,
9080 struct key_params *params
9081 )
9082#endif
9083{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009084 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07009085 tCsrRoamSetKey setKey;
9086 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309087 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009088 v_U32_t roamId= 0xFF;
9089 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009090 hdd_hostapd_state_t *pHostapdState;
9091 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009092 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309093 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009094
9095 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309096
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309097 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9098 TRACE_CODE_HDD_CFG80211_ADD_KEY,
9099 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309100 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9101 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309102 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009103 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309104 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009105 }
9106
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309107 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9108 __func__, hdd_device_modetoString(pAdapter->device_mode),
9109 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009110
9111 if (CSR_MAX_NUM_KEY <= key_index)
9112 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009113 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009114 key_index);
9115
9116 return -EINVAL;
9117 }
9118
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009119 if (CSR_MAX_KEY_LEN < params->key_len)
9120 {
9121 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
9122 params->key_len);
9123
9124 return -EINVAL;
9125 }
9126
9127 hddLog(VOS_TRACE_LEVEL_INFO,
9128 "%s: called with key index = %d & key length %d",
9129 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07009130
9131 /*extract key idx, key len and key*/
9132 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9133 setKey.keyId = key_index;
9134 setKey.keyLength = params->key_len;
9135 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
9136
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009137 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07009138 {
9139 case WLAN_CIPHER_SUITE_WEP40:
9140 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
9141 break;
9142
9143 case WLAN_CIPHER_SUITE_WEP104:
9144 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
9145 break;
9146
9147 case WLAN_CIPHER_SUITE_TKIP:
9148 {
9149 u8 *pKey = &setKey.Key[0];
9150 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
9151
9152 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
9153
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009154 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07009155
9156 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009157 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07009158 |--------------|----------|----------|
9159 <---16bytes---><--8bytes--><--8bytes-->
9160
9161 */
9162 /*Sme expects the 32 bytes key to be in the below order
9163
9164 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009165 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07009166 |--------------|----------|----------|
9167 <---16bytes---><--8bytes--><--8bytes-->
9168 */
9169 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009170 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07009171
9172 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009173 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009174
9175 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009176 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009177
9178
9179 break;
9180 }
9181
9182 case WLAN_CIPHER_SUITE_CCMP:
9183 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
9184 break;
9185
9186#ifdef FEATURE_WLAN_WAPI
9187 case WLAN_CIPHER_SUITE_SMS4:
9188 {
9189 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9190 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
9191 params->key, params->key_len);
9192 return 0;
9193 }
9194#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009195
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009196#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009197 case WLAN_CIPHER_SUITE_KRK:
9198 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
9199 break;
9200#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009201
9202#ifdef WLAN_FEATURE_11W
9203 case WLAN_CIPHER_SUITE_AES_CMAC:
9204 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07009205 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07009206#endif
9207
Jeff Johnson295189b2012-06-20 16:38:30 -07009208 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009209 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07009210 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309211 status = -EOPNOTSUPP;
9212 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009213 }
9214
9215 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
9216 __func__, setKey.encType);
9217
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009218 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07009219#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9220 (!pairwise)
9221#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009222 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07009223#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009224 )
9225 {
9226 /* set group key*/
9227 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9228 "%s- %d: setting Broadcast key",
9229 __func__, __LINE__);
9230 setKey.keyDirection = eSIR_RX_ONLY;
9231 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9232 }
9233 else
9234 {
9235 /* set pairwise key*/
9236 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9237 "%s- %d: setting pairwise key",
9238 __func__, __LINE__);
9239 setKey.keyDirection = eSIR_TX_RX;
9240 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9241 }
9242 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
9243 {
9244 setKey.keyDirection = eSIR_TX_RX;
9245 /*Set the group key*/
9246 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9247 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009248
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009249 if ( 0 != status )
9250 {
9251 hddLog(VOS_TRACE_LEVEL_ERROR,
9252 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309253 status = -EINVAL;
9254 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009255 }
9256 /*Save the keys here and call sme_RoamSetKey for setting
9257 the PTK after peer joins the IBSS network*/
9258 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
9259 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309260 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009261 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05309262 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
9263 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
9264 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009265 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009266 if( pHostapdState->bssState == BSS_START )
9267 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009268 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9269 vos_status = wlan_hdd_check_ula_done(pAdapter);
9270
9271 if ( vos_status != VOS_STATUS_SUCCESS )
9272 {
9273 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9274 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9275 __LINE__, vos_status );
9276
9277 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9278
9279 status = -EINVAL;
9280 goto end;
9281 }
9282
Jeff Johnson295189b2012-06-20 16:38:30 -07009283 status = WLANSAP_SetKeySta( pVosContext, &setKey);
9284
9285 if ( status != eHAL_STATUS_SUCCESS )
9286 {
9287 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9288 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9289 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309290 status = -EINVAL;
9291 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009292 }
9293 }
9294
9295 /* Saving WEP keys */
9296 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
9297 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
9298 {
9299 //Save the wep key in ap context. Issue setkey after the BSS is started.
9300 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9301 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
9302 }
9303 else
9304 {
9305 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009306 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009307 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
9308 }
9309 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009310 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9311 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009312 {
9313 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9314 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9315
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309316#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9317 if (!pairwise)
9318#else
9319 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9320#endif
9321 {
9322 /* set group key*/
9323 if (pHddStaCtx->roam_info.deferKeyComplete)
9324 {
9325 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9326 "%s- %d: Perform Set key Complete",
9327 __func__, __LINE__);
9328 hdd_PerformRoamSetKeyComplete(pAdapter);
9329 }
9330 }
9331
Jeff Johnson295189b2012-06-20 16:38:30 -07009332 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
9333
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08009334 pWextState->roamProfile.Keys.defaultIndex = key_index;
9335
9336
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009337 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009338 params->key, params->key_len);
9339
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309340
Jeff Johnson295189b2012-06-20 16:38:30 -07009341 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9342
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309343 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009344 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309345 __func__, setKey.peerMac[0], setKey.peerMac[1],
9346 setKey.peerMac[2], setKey.peerMac[3],
9347 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009348 setKey.keyDirection);
9349
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009350 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +05309351
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009352 if ( vos_status != VOS_STATUS_SUCCESS )
9353 {
9354 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009355 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9356 __LINE__, vos_status );
9357
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009358 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009359
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009360 status = -EINVAL;
9361 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009362
9363 }
9364
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009365#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309366 /* The supplicant may attempt to set the PTK once pre-authentication
9367 is done. Save the key in the UMAC and include it in the ADD BSS
9368 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009369 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309370 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009371 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309372 hddLog(VOS_TRACE_LEVEL_INFO_MED,
9373 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309374 status = 0;
9375 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309376 }
9377 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
9378 {
9379 hddLog(VOS_TRACE_LEVEL_ERROR,
9380 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309381 status = -EINVAL;
9382 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009383 }
9384#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07009385
9386 /* issue set key request to SME*/
9387 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9388 pAdapter->sessionId, &setKey, &roamId );
9389
9390 if ( 0 != status )
9391 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309392 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009393 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
9394 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309395 status = -EINVAL;
9396 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009397 }
9398
9399
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309400 /* in case of IBSS as there was no information available about WEP keys during
9401 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07009402 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309403 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
9404 !( ( IW_AUTH_KEY_MGMT_802_1X
9405 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07009406 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
9407 )
9408 &&
9409 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
9410 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
9411 )
9412 )
9413 {
9414 setKey.keyDirection = eSIR_RX_ONLY;
9415 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9416
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309417 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009418 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309419 __func__, setKey.peerMac[0], setKey.peerMac[1],
9420 setKey.peerMac[2], setKey.peerMac[3],
9421 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009422 setKey.keyDirection);
9423
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309424 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009425 pAdapter->sessionId, &setKey, &roamId );
9426
9427 if ( 0 != status )
9428 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309429 hddLog(VOS_TRACE_LEVEL_ERROR,
9430 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009431 __func__, status);
9432 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309433 status = -EINVAL;
9434 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009435 }
9436 }
9437 }
9438
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309439end:
9440 /* Need to clear any trace of key value in the memory.
9441 * Thus zero out the memory even though it is local
9442 * variable.
9443 */
9444 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309445 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309446 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009447}
9448
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309449#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9450static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9451 struct net_device *ndev,
9452 u8 key_index, bool pairwise,
9453 const u8 *mac_addr,
9454 struct key_params *params
9455 )
9456#else
9457static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9458 struct net_device *ndev,
9459 u8 key_index, const u8 *mac_addr,
9460 struct key_params *params
9461 )
9462#endif
9463{
9464 int ret;
9465 vos_ssr_protect(__func__);
9466#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9467 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
9468 mac_addr, params);
9469#else
9470 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
9471 params);
9472#endif
9473 vos_ssr_unprotect(__func__);
9474
9475 return ret;
9476}
9477
Jeff Johnson295189b2012-06-20 16:38:30 -07009478/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309479 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009480 * This function is used to get the key information
9481 */
9482#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309483static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309484 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309486 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009487 const u8 *mac_addr, void *cookie,
9488 void (*callback)(void *cookie, struct key_params*)
9489 )
9490#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309491static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309492 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009493 struct net_device *ndev,
9494 u8 key_index, const u8 *mac_addr, void *cookie,
9495 void (*callback)(void *cookie, struct key_params*)
9496 )
9497#endif
9498{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309499 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309500 hdd_wext_state_t *pWextState = NULL;
9501 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009502 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309503 hdd_context_t *pHddCtx;
9504 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009505
9506 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309507
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309508 if (NULL == pAdapter)
9509 {
9510 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9511 "%s: HDD adapter is Null", __func__);
9512 return -ENODEV;
9513 }
9514
9515 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9516 ret = wlan_hdd_validate_context(pHddCtx);
9517 if (0 != ret)
9518 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309519 return ret;
9520 }
9521
9522 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9523 pRoamProfile = &(pWextState->roamProfile);
9524
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309525 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9526 __func__, hdd_device_modetoString(pAdapter->device_mode),
9527 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309528
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 memset(&params, 0, sizeof(params));
9530
9531 if (CSR_MAX_NUM_KEY <= key_index)
9532 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309533 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07009534 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309535 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009536
9537 switch(pRoamProfile->EncryptionType.encryptionType[0])
9538 {
9539 case eCSR_ENCRYPT_TYPE_NONE:
9540 params.cipher = IW_AUTH_CIPHER_NONE;
9541 break;
9542
9543 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
9544 case eCSR_ENCRYPT_TYPE_WEP40:
9545 params.cipher = WLAN_CIPHER_SUITE_WEP40;
9546 break;
9547
9548 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
9549 case eCSR_ENCRYPT_TYPE_WEP104:
9550 params.cipher = WLAN_CIPHER_SUITE_WEP104;
9551 break;
9552
9553 case eCSR_ENCRYPT_TYPE_TKIP:
9554 params.cipher = WLAN_CIPHER_SUITE_TKIP;
9555 break;
9556
9557 case eCSR_ENCRYPT_TYPE_AES:
9558 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
9559 break;
9560
9561 default:
9562 params.cipher = IW_AUTH_CIPHER_NONE;
9563 break;
9564 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309565
c_hpothuaaf19692014-05-17 17:01:48 +05309566 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9567 TRACE_CODE_HDD_CFG80211_GET_KEY,
9568 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309569
Jeff Johnson295189b2012-06-20 16:38:30 -07009570 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
9571 params.seq_len = 0;
9572 params.seq = NULL;
9573 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
9574 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309575 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009576 return 0;
9577}
9578
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309579#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9580static int wlan_hdd_cfg80211_get_key(
9581 struct wiphy *wiphy,
9582 struct net_device *ndev,
9583 u8 key_index, bool pairwise,
9584 const u8 *mac_addr, void *cookie,
9585 void (*callback)(void *cookie, struct key_params*)
9586 )
9587#else
9588static int wlan_hdd_cfg80211_get_key(
9589 struct wiphy *wiphy,
9590 struct net_device *ndev,
9591 u8 key_index, const u8 *mac_addr, void *cookie,
9592 void (*callback)(void *cookie, struct key_params*)
9593 )
9594#endif
9595{
9596 int ret;
9597
9598 vos_ssr_protect(__func__);
9599#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9600 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
9601 mac_addr, cookie, callback);
9602#else
9603 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
9604 callback);
9605#endif
9606 vos_ssr_unprotect(__func__);
9607
9608 return ret;
9609}
9610
Jeff Johnson295189b2012-06-20 16:38:30 -07009611/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309612 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009613 * This function is used to delete the key information
9614 */
9615#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309616static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009617 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309618 u8 key_index,
9619 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009620 const u8 *mac_addr
9621 )
9622#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309623static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009624 struct net_device *ndev,
9625 u8 key_index,
9626 const u8 *mac_addr
9627 )
9628#endif
9629{
9630 int status = 0;
9631
9632 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309633 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009634 //it is observed that this is invalidating peer
9635 //key index whenever re-key is done. This is affecting data link.
9636 //It should be ok to ignore del_key.
9637#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309638 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
9639 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009640 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
9641 tCsrRoamSetKey setKey;
9642 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309643
Jeff Johnson295189b2012-06-20 16:38:30 -07009644 ENTER();
9645
9646 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
9647 __func__,pAdapter->device_mode);
9648
9649 if (CSR_MAX_NUM_KEY <= key_index)
9650 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309651 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009652 key_index);
9653
9654 return -EINVAL;
9655 }
9656
9657 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9658 setKey.keyId = key_index;
9659
9660 if (mac_addr)
9661 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9662 else
9663 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
9664
9665 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
9666
9667 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009668 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309669 )
9670 {
9671
9672 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07009673 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9674 if( pHostapdState->bssState == BSS_START)
9675 {
9676 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309677
Jeff Johnson295189b2012-06-20 16:38:30 -07009678 if ( status != eHAL_STATUS_SUCCESS )
9679 {
9680 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9681 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9682 __LINE__, status );
9683 }
9684 }
9685 }
9686 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309687 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07009688 )
9689 {
9690 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9691
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309692 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9693
9694 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009695 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309696 __func__, setKey.peerMac[0], setKey.peerMac[1],
9697 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07009698 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309699 if(pAdapter->sessionCtx.station.conn_info.connState ==
9700 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07009701 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309702 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009703 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309704
Jeff Johnson295189b2012-06-20 16:38:30 -07009705 if ( 0 != status )
9706 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309707 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009708 "%s: sme_RoamSetKey failure, returned %d",
9709 __func__, status);
9710 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9711 return -EINVAL;
9712 }
9713 }
9714 }
9715#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07009716 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009717 return status;
9718}
9719
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309720#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9721static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9722 struct net_device *ndev,
9723 u8 key_index,
9724 bool pairwise,
9725 const u8 *mac_addr
9726 )
9727#else
9728static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9729 struct net_device *ndev,
9730 u8 key_index,
9731 const u8 *mac_addr
9732 )
9733#endif
9734{
9735 int ret;
9736
9737 vos_ssr_protect(__func__);
9738#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9739 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
9740 mac_addr);
9741#else
9742 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
9743#endif
9744 vos_ssr_unprotect(__func__);
9745
9746 return ret;
9747}
9748
Jeff Johnson295189b2012-06-20 16:38:30 -07009749/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309750 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009751 * This function is used to set the default tx key index
9752 */
9753#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309754static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009755 struct net_device *ndev,
9756 u8 key_index,
9757 bool unicast, bool multicast)
9758#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309759static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009760 struct net_device *ndev,
9761 u8 key_index)
9762#endif
9763{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309764 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309765 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05309766 hdd_wext_state_t *pWextState;
9767 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309768 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009769
9770 ENTER();
9771
Gopichand Nakkala29149562013-05-10 21:43:41 +05309772 if ((NULL == pAdapter))
9773 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05309775 "invalid adapter");
9776 return -EINVAL;
9777 }
9778
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309779 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9780 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
9781 pAdapter->sessionId, key_index));
9782
Gopichand Nakkala29149562013-05-10 21:43:41 +05309783 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9784 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9785
9786 if ((NULL == pWextState) || (NULL == pHddStaCtx))
9787 {
9788 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9789 "invalid Wext state or HDD context");
9790 return -EINVAL;
9791 }
9792
Arif Hussain6d2a3322013-11-17 19:50:10 -08009793 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009794 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309795
Jeff Johnson295189b2012-06-20 16:38:30 -07009796 if (CSR_MAX_NUM_KEY <= key_index)
9797 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309798 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009799 key_index);
9800
9801 return -EINVAL;
9802 }
9803
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309804 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9805 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309806 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009807 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309808 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009809 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309810
Jeff Johnson295189b2012-06-20 16:38:30 -07009811 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07009812 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309813 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009814 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05309815 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08009816 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309817 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08009818 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009819 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309820 {
9821 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07009822 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309823
Jeff Johnson295189b2012-06-20 16:38:30 -07009824 tCsrRoamSetKey setKey;
9825 v_U32_t roamId= 0xFF;
9826 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309827
9828 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009829 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309830
Jeff Johnson295189b2012-06-20 16:38:30 -07009831 Keys->defaultIndex = (u8)key_index;
9832 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9833 setKey.keyId = key_index;
9834 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309835
9836 vos_mem_copy(&setKey.Key[0],
9837 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009838 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309839
Gopichand Nakkala29149562013-05-10 21:43:41 +05309840 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309841
9842 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07009843 &pHddStaCtx->conn_info.bssId[0],
9844 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309845
Gopichand Nakkala29149562013-05-10 21:43:41 +05309846 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
9847 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
9848 eCSR_ENCRYPT_TYPE_WEP104)
9849 {
9850 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
9851 even though ap is configured for WEP-40 encryption. In this canse the key length
9852 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
9853 type(104) and switching encryption type to 40*/
9854 pWextState->roamProfile.EncryptionType.encryptionType[0] =
9855 eCSR_ENCRYPT_TYPE_WEP40;
9856 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
9857 eCSR_ENCRYPT_TYPE_WEP40;
9858 }
9859
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309860 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07009861 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309862
Jeff Johnson295189b2012-06-20 16:38:30 -07009863 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309864 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009865 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309866
Jeff Johnson295189b2012-06-20 16:38:30 -07009867 if ( 0 != status )
9868 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309869 hddLog(VOS_TRACE_LEVEL_ERROR,
9870 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009871 status);
9872 return -EINVAL;
9873 }
9874 }
9875 }
9876
9877 /* In SoftAp mode setting key direction for default mode */
9878 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
9879 {
9880 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
9881 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
9882 (eCSR_ENCRYPT_TYPE_AES !=
9883 pWextState->roamProfile.EncryptionType.encryptionType[0])
9884 )
9885 {
9886 /* Saving key direction for default key index to TX default */
9887 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9888 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
9889 }
9890 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309891 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009892 return status;
9893}
9894
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309895#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9896static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9897 struct net_device *ndev,
9898 u8 key_index,
9899 bool unicast, bool multicast)
9900#else
9901static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9902 struct net_device *ndev,
9903 u8 key_index)
9904#endif
9905{
9906 int ret;
9907 vos_ssr_protect(__func__);
9908#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9909 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
9910 multicast);
9911#else
9912 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
9913#endif
9914 vos_ssr_unprotect(__func__);
9915
9916 return ret;
9917}
9918
Jeff Johnson295189b2012-06-20 16:38:30 -07009919/*
9920 * FUNCTION: wlan_hdd_cfg80211_inform_bss
9921 * This function is used to inform the BSS details to nl80211 interface.
9922 */
9923static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
9924 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
9925{
9926 struct net_device *dev = pAdapter->dev;
9927 struct wireless_dev *wdev = dev->ieee80211_ptr;
9928 struct wiphy *wiphy = wdev->wiphy;
9929 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
9930 int chan_no;
9931 int ie_length;
9932 const char *ie;
9933 unsigned int freq;
9934 struct ieee80211_channel *chan;
9935 int rssi = 0;
9936 struct cfg80211_bss *bss = NULL;
9937
Jeff Johnson295189b2012-06-20 16:38:30 -07009938 if( NULL == pBssDesc )
9939 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009940 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009941 return bss;
9942 }
9943
9944 chan_no = pBssDesc->channelId;
9945 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
9946 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
9947
9948 if( NULL == ie )
9949 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009950 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009951 return bss;
9952 }
9953
9954#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
9955 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
9956 {
9957 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9958 }
9959 else
9960 {
9961 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9962 }
9963#else
9964 freq = ieee80211_channel_to_frequency(chan_no);
9965#endif
9966
9967 chan = __ieee80211_get_channel(wiphy, freq);
9968
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05309969 if (!chan) {
9970 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
9971 return NULL;
9972 }
9973
Abhishek Singhaee43942014-06-16 18:55:47 +05309974 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07009975
Anand N Sunkad9f80b742015-07-30 20:05:51 +05309976 return cfg80211_inform_bss(wiphy, chan,
9977#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
9978 CFG80211_BSS_FTYPE_UNKNOWN,
9979#endif
9980 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309981 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07009982 pBssDesc->capabilityInfo,
9983 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05309984 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07009985}
9986
9987
9988
9989/*
9990 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
9991 * This function is used to inform the BSS details to nl80211 interface.
9992 */
9993struct cfg80211_bss*
9994wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
9995 tSirBssDescription *bss_desc
9996 )
9997{
9998 /*
9999 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
10000 already exists in bss data base of cfg80211 for that particular BSS ID.
10001 Using cfg80211_inform_bss_frame to update the bss entry instead of
10002 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
10003 now there is no possibility to get the mgmt(probe response) frame from PE,
10004 converting bss_desc to ieee80211_mgmt(probe response) and passing to
10005 cfg80211_inform_bss_frame.
10006 */
10007 struct net_device *dev = pAdapter->dev;
10008 struct wireless_dev *wdev = dev->ieee80211_ptr;
10009 struct wiphy *wiphy = wdev->wiphy;
10010 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080010011#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
10012 qcom_ie_age *qie_age = NULL;
10013 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
10014#else
Jeff Johnson295189b2012-06-20 16:38:30 -070010015 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080010016#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010017 const char *ie =
10018 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
10019 unsigned int freq;
10020 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053010021 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010022 struct cfg80211_bss *bss_status = NULL;
10023 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
10024 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070010025 hdd_context_t *pHddCtx;
10026 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070010027#ifdef WLAN_OPEN_SOURCE
10028 struct timespec ts;
10029#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010030
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010031
Wilson Yangf80a0542013-10-07 13:02:37 -070010032 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10033 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070010034 if (0 != status)
10035 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070010036 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070010037 }
10038
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053010039 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070010040 if (!mgmt)
10041 {
10042 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10043 "%s: memory allocation failed ", __func__);
10044 return NULL;
10045 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070010046
Jeff Johnson295189b2012-06-20 16:38:30 -070010047 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070010048
10049#ifdef WLAN_OPEN_SOURCE
10050 /* Android does not want the timestamp from the frame.
10051 Instead it wants a monotonic increasing value */
10052 get_monotonic_boottime(&ts);
10053 mgmt->u.probe_resp.timestamp =
10054 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
10055#else
10056 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070010057 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
10058 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070010059
10060#endif
10061
Jeff Johnson295189b2012-06-20 16:38:30 -070010062 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
10063 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080010064
10065#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
10066 /* GPS Requirement: need age ie per entry. Using vendor specific. */
10067 /* Assuming this is the last IE, copy at the end */
10068 ie_length -=sizeof(qcom_ie_age);
10069 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
10070 qie_age->element_id = QCOM_VENDOR_IE_ID;
10071 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
10072 qie_age->oui_1 = QCOM_OUI1;
10073 qie_age->oui_2 = QCOM_OUI2;
10074 qie_age->oui_3 = QCOM_OUI3;
10075 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
10076 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
10077#endif
10078
Jeff Johnson295189b2012-06-20 16:38:30 -070010079 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053010080 if (bss_desc->fProbeRsp)
10081 {
10082 mgmt->frame_control |=
10083 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
10084 }
10085 else
10086 {
10087 mgmt->frame_control |=
10088 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
10089 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010090
10091#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010092 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070010093 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
10094 {
10095 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
10096 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010097 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
10099
10100 {
10101 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
10102 }
10103 else
10104 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010105 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
10106 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070010107 kfree(mgmt);
10108 return NULL;
10109 }
10110#else
10111 freq = ieee80211_channel_to_frequency(chan_no);
10112#endif
10113 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080010114 /*when the band is changed on the fly using the GUI, three things are done
10115 * 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)
10116 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
10117 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
10118 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
10119 * and discards the channels correponding to previous band and calls back with zero bss results.
10120 * 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
10121 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
10122 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
10123 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
10124 * So drop the bss and continue to next bss.
10125 */
10126 if(chan == NULL)
10127 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010128 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -070010129 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080010130 return NULL;
10131 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053010132 /*To keep the rssi icon of the connected AP in the scan window
10133 *and the rssi icon of the wireless networks in sync
10134 * */
10135 if (( eConnectionState_Associated ==
10136 pAdapter->sessionCtx.station.conn_info.connState ) &&
10137 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
10138 pAdapter->sessionCtx.station.conn_info.bssId,
10139 WNI_CFG_BSSID_LEN)) &&
10140 (pHddCtx->hdd_wlan_suspended == FALSE))
10141 {
10142 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
10143 rssi = (pAdapter->rssi * 100);
10144 }
10145 else
10146 {
10147 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
10148 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010149
Nirav Shah20ac06f2013-12-12 18:14:06 +053010150 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053010151 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
10152 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053010153
Jeff Johnson295189b2012-06-20 16:38:30 -070010154 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
10155 frame_len, rssi, GFP_KERNEL);
10156 kfree(mgmt);
10157 return bss_status;
10158}
10159
10160/*
10161 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
10162 * This function is used to update the BSS data base of CFG8011
10163 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010164struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070010165 tCsrRoamInfo *pRoamInfo
10166 )
10167{
10168 tCsrRoamConnectedProfile roamProfile;
10169 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10170 struct cfg80211_bss *bss = NULL;
10171
10172 ENTER();
10173
10174 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
10175 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
10176
10177 if (NULL != roamProfile.pBssDesc)
10178 {
Girish Gowlif4b68022014-08-28 23:18:57 +053010179 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10180 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010181
10182 if (NULL == bss)
10183 {
10184 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
10185 __func__);
10186 }
10187
10188 sme_RoamFreeConnectProfile(hHal, &roamProfile);
10189 }
10190 else
10191 {
10192 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
10193 __func__);
10194 }
10195 return bss;
10196}
10197
10198/*
10199 * FUNCTION: wlan_hdd_cfg80211_update_bss
10200 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010201static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
10202 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070010203 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010204{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010205 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010206 tCsrScanResultInfo *pScanResult;
10207 eHalStatus status = 0;
10208 tScanResultHandle pResult;
10209 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070010210 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010211 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070010212 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010213
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010214 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10215 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
10216 NO_SESSION, pAdapter->sessionId));
10217
Wilson Yangf80a0542013-10-07 13:02:37 -070010218 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10219
10220 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -070010221 {
Wilson Yangf80a0542013-10-07 13:02:37 -070010222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10223 "%s:LOGP in Progress. Ignore!!!",__func__);
10224 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010225 }
10226
Wilson Yangf80a0542013-10-07 13:02:37 -070010227
10228 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +053010229 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -070010230 {
10231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10232 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
10233 return VOS_STATUS_E_PERM;
10234 }
10235
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010236 if (pAdapter->request != NULL)
10237 {
10238 if ((pAdapter->request->n_ssids == 1)
10239 && (pAdapter->request->ssids != NULL)
10240 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
10241 is_p2p_scan = true;
10242 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010243 /*
10244 * start getting scan results and populate cgf80211 BSS database
10245 */
10246 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
10247
10248 /* no scan results */
10249 if (NULL == pResult)
10250 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010251 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
10252 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053010253 wlan_hdd_get_frame_logs(pAdapter,
10254 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070010255 return status;
10256 }
10257
10258 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
10259
10260 while (pScanResult)
10261 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010262 /*
10263 * cfg80211_inform_bss() is not updating ie field of bss entry, if
10264 * entry already exists in bss data base of cfg80211 for that
10265 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
10266 * bss entry instead of cfg80211_inform_bss, But this call expects
10267 * mgmt packet as input. As of now there is no possibility to get
10268 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070010269 * ieee80211_mgmt(probe response) and passing to c
10270 * fg80211_inform_bss_frame.
10271 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010272 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
10273 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
10274 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010275 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10276 continue; //Skip the non p2p bss entries
10277 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010278 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10279 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010280
Jeff Johnson295189b2012-06-20 16:38:30 -070010281
10282 if (NULL == bss_status)
10283 {
10284 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010285 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010286 }
10287 else
10288 {
Yue Maf49ba872013-08-19 12:04:25 -070010289 cfg80211_put_bss(
10290#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10291 wiphy,
10292#endif
10293 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010294 }
10295
10296 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10297 }
10298
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010299 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010300 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010301 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010302}
10303
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010304void
10305hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
10306{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010307 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080010308 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010309} /****** end hddPrintMacAddr() ******/
10310
10311void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010312hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010313{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010314 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010315 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010316 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
10317 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
10318 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010319} /****** end hddPrintPmkId() ******/
10320
10321//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
10322//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
10323
10324//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
10325//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
10326
10327#define dump_bssid(bssid) \
10328 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010329 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
10330 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010331 }
10332
10333#define dump_pmkid(pMac, pmkid) \
10334 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010335 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
10336 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010337 }
10338
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070010339#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010340/*
10341 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
10342 * This function is used to notify the supplicant of a new PMKSA candidate.
10343 */
10344int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010345 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010346 int index, bool preauth )
10347{
Jeff Johnsone7245742012-09-05 17:12:55 -070010348#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010349 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010350 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010351
10352 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070010353 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010354
10355 if( NULL == pRoamInfo )
10356 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010357 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010358 return -EINVAL;
10359 }
10360
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010361 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
10362 {
10363 dump_bssid(pRoamInfo->bssid);
10364 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010365 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010366 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010367#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010368 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010369}
10370#endif //FEATURE_WLAN_LFR
10371
Yue Maef608272013-04-08 23:09:17 -070010372#ifdef FEATURE_WLAN_LFR_METRICS
10373/*
10374 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
10375 * 802.11r/LFR metrics reporting function to report preauth initiation
10376 *
10377 */
10378#define MAX_LFR_METRICS_EVENT_LENGTH 100
10379VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
10380 tCsrRoamInfo *pRoamInfo)
10381{
10382 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10383 union iwreq_data wrqu;
10384
10385 ENTER();
10386
10387 if (NULL == pAdapter)
10388 {
10389 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10390 return VOS_STATUS_E_FAILURE;
10391 }
10392
10393 /* create the event */
10394 memset(&wrqu, 0, sizeof(wrqu));
10395 memset(metrics_notification, 0, sizeof(metrics_notification));
10396
10397 wrqu.data.pointer = metrics_notification;
10398 wrqu.data.length = scnprintf(metrics_notification,
10399 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
10400 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10401
10402 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10403
10404 EXIT();
10405
10406 return VOS_STATUS_SUCCESS;
10407}
10408
10409/*
10410 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
10411 * 802.11r/LFR metrics reporting function to report preauth completion
10412 * or failure
10413 */
10414VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
10415 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
10416{
10417 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10418 union iwreq_data wrqu;
10419
10420 ENTER();
10421
10422 if (NULL == pAdapter)
10423 {
10424 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10425 return VOS_STATUS_E_FAILURE;
10426 }
10427
10428 /* create the event */
10429 memset(&wrqu, 0, sizeof(wrqu));
10430 memset(metrics_notification, 0, sizeof(metrics_notification));
10431
10432 scnprintf(metrics_notification, sizeof(metrics_notification),
10433 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
10434 MAC_ADDR_ARRAY(pRoamInfo->bssid));
10435
10436 if (1 == preauth_status)
10437 strncat(metrics_notification, " TRUE", 5);
10438 else
10439 strncat(metrics_notification, " FALSE", 6);
10440
10441 wrqu.data.pointer = metrics_notification;
10442 wrqu.data.length = strlen(metrics_notification);
10443
10444 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10445
10446 EXIT();
10447
10448 return VOS_STATUS_SUCCESS;
10449}
10450
10451/*
10452 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
10453 * 802.11r/LFR metrics reporting function to report handover initiation
10454 *
10455 */
10456VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
10457 tCsrRoamInfo *pRoamInfo)
10458{
10459 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10460 union iwreq_data wrqu;
10461
10462 ENTER();
10463
10464 if (NULL == pAdapter)
10465 {
10466 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10467 return VOS_STATUS_E_FAILURE;
10468 }
10469
10470 /* create the event */
10471 memset(&wrqu, 0, sizeof(wrqu));
10472 memset(metrics_notification, 0, sizeof(metrics_notification));
10473
10474 wrqu.data.pointer = metrics_notification;
10475 wrqu.data.length = scnprintf(metrics_notification,
10476 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
10477 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10478
10479 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10480
10481 EXIT();
10482
10483 return VOS_STATUS_SUCCESS;
10484}
10485#endif
10486
Jeff Johnson295189b2012-06-20 16:38:30 -070010487/*
10488 * FUNCTION: hdd_cfg80211_scan_done_callback
10489 * scanning callback function, called after finishing scan
10490 *
10491 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010492static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070010493 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
10494{
10495 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010496 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070010497 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010498 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010499 struct cfg80211_scan_request *req = NULL;
10500 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010501 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010502 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010503 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010504 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010505
10506 ENTER();
10507
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010508 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053010509 if (NULL == pHddCtx) {
10510 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010511 goto allow_suspend;
10512 }
10513
10514 pScanInfo = &pHddCtx->scan_info;
10515
Jeff Johnson295189b2012-06-20 16:38:30 -070010516 hddLog(VOS_TRACE_LEVEL_INFO,
10517 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080010518 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010519 __func__, halHandle, pContext, (int) scanId, (int) status);
10520
Kiet Lamac06e2c2013-10-23 16:25:07 +053010521 pScanInfo->mScanPendingCounter = 0;
10522
Jeff Johnson295189b2012-06-20 16:38:30 -070010523 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010524 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070010525 &pScanInfo->scan_req_completion_event,
10526 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010527 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070010528 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010529 hddLog(VOS_TRACE_LEVEL_ERROR,
10530 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070010531 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010532 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010533 }
10534
Yue Maef608272013-04-08 23:09:17 -070010535 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010536 {
10537 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010538 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010539 }
10540
10541 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010542 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070010543 {
10544 hddLog(VOS_TRACE_LEVEL_INFO,
10545 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010546 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070010547 (int) scanId);
10548 }
10549
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010550 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010551 pAdapter);
10552
10553 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010554 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010555
10556
10557 /* If any client wait scan result through WEXT
10558 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010559 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070010560 {
10561 /* The other scan request waiting for current scan finish
10562 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010563 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010564 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010565 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070010566 }
10567 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010568 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010569 {
10570 struct net_device *dev = pAdapter->dev;
10571 union iwreq_data wrqu;
10572 int we_event;
10573 char *msg;
10574
10575 memset(&wrqu, '\0', sizeof(wrqu));
10576 we_event = SIOCGIWSCAN;
10577 msg = NULL;
10578 wireless_send_event(dev, we_event, &wrqu, msg);
10579 }
10580 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010581 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010582
10583 /* Get the Scan Req */
10584 req = pAdapter->request;
10585
10586 if (!req)
10587 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010588 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010589 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010590 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010591 }
10592
Jeff Johnson295189b2012-06-20 16:38:30 -070010593 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070010594 /* Scan is no longer pending */
10595 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010596
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010597 /* last_scan_timestamp is used to decide if new scan
10598 * is needed or not on station interface. If last station
10599 * scan time and new station scan time is less then
10600 * last_scan_timestamp ; driver will return cached scan.
10601 */
10602 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
10603 {
10604 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
10605
10606 if ( req->n_channels )
10607 {
10608 for (i = 0; i < req->n_channels ; i++ )
10609 {
10610 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
10611 }
10612 /* store no of channel scanned */
10613 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
10614 }
10615
10616 }
10617
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070010618 /*
10619 * cfg80211_scan_done informing NL80211 about completion
10620 * of scanning
10621 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010622 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
10623 {
10624 aborted = true;
10625 }
10626 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080010627 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070010628
Siddharth Bhal76972212014-10-15 16:22:51 +053010629 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
10630 /* Generate new random mac addr for next scan */
10631 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
10632 hdd_processSpoofMacAddrRequest(pHddCtx);
10633 }
10634
Jeff Johnsone7245742012-09-05 17:12:55 -070010635allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010636 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010637 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070010638
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010639 /* Acquire wakelock to handle the case where APP's tries to suspend
10640 * immediatly after the driver gets connect request(i.e after scan)
10641 * from supplicant, this result in app's is suspending and not able
10642 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010643 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010644
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010645#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010646 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010647#endif
10648
Jeff Johnson295189b2012-06-20 16:38:30 -070010649 EXIT();
10650 return 0;
10651}
10652
10653/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053010654 * FUNCTION: hdd_isConnectionInProgress
10655 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010656 *
10657 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010658v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010659{
10660 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10661 hdd_station_ctx_t *pHddStaCtx = NULL;
10662 hdd_adapter_t *pAdapter = NULL;
10663 VOS_STATUS status = 0;
10664 v_U8_t staId = 0;
10665 v_U8_t *staMac = NULL;
10666
c_hpothu9b781ba2013-12-30 20:57:45 +053010667 if (TRUE == pHddCtx->btCoexModeSet)
10668 {
10669 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053010670 FL("BTCoex Mode operation in progress"));
10671 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053010672 }
10673
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010674 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10675
10676 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10677 {
10678 pAdapter = pAdapterNode->pAdapter;
10679
10680 if( pAdapter )
10681 {
10682 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010683 "%s: Adapter with device mode %s (%d) exists",
10684 __func__, hdd_device_modetoString(pAdapter->device_mode),
10685 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010686 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053010687 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10688 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
10689 (eConnectionState_Connecting ==
10690 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
10691 {
10692 hddLog(VOS_TRACE_LEVEL_ERROR,
10693 "%s: %p(%d) Connection is in progress", __func__,
10694 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10695 return VOS_TRUE;
10696 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010697 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053010698 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010699 {
10700 hddLog(VOS_TRACE_LEVEL_ERROR,
10701 "%s: %p(%d) Reassociation is in progress", __func__,
10702 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10703 return VOS_TRUE;
10704 }
10705 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010706 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10707 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010708 {
10709 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10710 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010711 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010712 {
10713 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
10714 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010715 "%s: client " MAC_ADDRESS_STR
10716 " is in the middle of WPS/EAPOL exchange.", __func__,
10717 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010718 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010719 }
10720 }
10721 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
10722 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
10723 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010724 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10725 ptSapContext pSapCtx = NULL;
10726 pSapCtx = VOS_GET_SAP_CB(pVosContext);
10727 if(pSapCtx == NULL){
10728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10729 FL("psapCtx is NULL"));
10730 return VOS_FALSE;
10731 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010732 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
10733 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010734 if ((pSapCtx->aStaInfo[staId].isUsed) &&
10735 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010736 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010737 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010738
10739 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010740 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
10741 "middle of WPS/EAPOL exchange.", __func__,
10742 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010743 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010744 }
10745 }
10746 }
10747 }
10748 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10749 pAdapterNode = pNext;
10750 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053010751 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010752}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010753
10754/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010755 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070010756 * this scan respond to scan trigger and update cfg80211 scan database
10757 * later, scan dump command can be used to recieve scan results
10758 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010759int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010760#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10761 struct net_device *dev,
10762#endif
10763 struct cfg80211_scan_request *request)
10764{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010765 hdd_adapter_t *pAdapter = NULL;
10766 hdd_context_t *pHddCtx = NULL;
10767 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010768 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010769 tCsrScanRequest scanRequest;
10770 tANI_U8 *channelList = NULL, i;
10771 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010772 int status;
10773 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010774 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010775 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053010776 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010777 bool is_p2p_scan = false;
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010778 v_S7_t rssi=0;
10779 hdd_station_ctx_t *pHddStaCtx=NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010780
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010781#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
10782 struct net_device *dev = NULL;
10783 if (NULL == request)
10784 {
10785 hddLog(VOS_TRACE_LEVEL_ERROR,
10786 "%s: scan req param null", __func__);
10787 return -EINVAL;
10788 }
10789 dev = request->wdev->netdev;
10790#endif
10791
10792 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
10793 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
10794 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10795
Jeff Johnson295189b2012-06-20 16:38:30 -070010796 ENTER();
10797
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010798 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10799 __func__, hdd_device_modetoString(pAdapter->device_mode),
10800 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010801
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010802 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010803 if (0 != status)
10804 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010805 return status;
10806 }
10807
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010808 if (NULL == pwextBuf)
10809 {
10810 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
10811 __func__);
10812 return -EIO;
10813 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010814 cfg_param = pHddCtx->cfg_ini;
10815 pScanInfo = &pHddCtx->scan_info;
10816
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010817 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10818 if ( (pHddStaCtx != NULL) && (TRUE == hdd_connIsConnected(pHddStaCtx)))
10819 {
10820 wlan_hdd_get_roam_rssi(pAdapter, &rssi);
10821 hddLog(VOS_TRACE_LEVEL_INFO, FL("rssi: %d"), rssi);
10822 }
10823
Jeff Johnson295189b2012-06-20 16:38:30 -070010824#ifdef WLAN_BTAMP_FEATURE
10825 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010826 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070010827 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010828 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010829 "%s: No scanning when AMP is on", __func__);
10830 return -EOPNOTSUPP;
10831 }
10832#endif
10833 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010834 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010835 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010836 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010837 "%s: Not scanning on device_mode = %s (%d)",
10838 __func__, hdd_device_modetoString(pAdapter->device_mode),
10839 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010840 return -EOPNOTSUPP;
10841 }
10842
10843 if (TRUE == pScanInfo->mScanPending)
10844 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010845 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
10846 {
10847 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
10848 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010849 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010850 }
10851
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053010852 // Don't allow scan if PNO scan is going on.
10853 if (pHddCtx->isPnoEnable)
10854 {
10855 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10856 FL("pno scan in progress"));
10857 return -EBUSY;
10858 }
10859
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010860 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070010861 //Channel and action frame is pending
10862 //Otherwise Cancel Remain On Channel and allow Scan
10863 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010864 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070010865 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010866 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010867 return -EBUSY;
10868 }
10869
Jeff Johnson295189b2012-06-20 16:38:30 -070010870 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
10871 {
10872 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080010873 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010874 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010875 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010876 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
10877 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010878 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010879 "%s: MAX TM Level Scan not allowed", __func__);
10880 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010881 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010882 }
10883 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
10884
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010885 /* Check if scan is allowed at this point of time.
10886 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010887 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010888 {
10889 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
10890 return -EBUSY;
10891 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010892
Jeff Johnson295189b2012-06-20 16:38:30 -070010893 vos_mem_zero( &scanRequest, sizeof(scanRequest));
10894
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010895 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
10896 * Becasue of this, driver is assuming that this is not wildcard scan and so
10897 * is not aging out the scan results.
10898 */
10899 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070010900 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010901 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010902 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010903
10904 if ((request->ssids) && (0 < request->n_ssids))
10905 {
10906 tCsrSSIDInfo *SsidInfo;
10907 int j;
10908 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
10909 /* Allocate num_ssid tCsrSSIDInfo structure */
10910 SsidInfo = scanRequest.SSIDs.SSIDList =
10911 ( tCsrSSIDInfo *)vos_mem_malloc(
10912 request->n_ssids*sizeof(tCsrSSIDInfo));
10913
10914 if(NULL == scanRequest.SSIDs.SSIDList)
10915 {
10916 hddLog(VOS_TRACE_LEVEL_ERROR,
10917 "%s: memory alloc failed SSIDInfo buffer", __func__);
10918 return -ENOMEM;
10919 }
10920
10921 /* copy all the ssid's and their length */
10922 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
10923 {
10924 /* get the ssid length */
10925 SsidInfo->SSID.length = request->ssids[j].ssid_len;
10926 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
10927 SsidInfo->SSID.length);
10928 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
10929 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
10930 j, SsidInfo->SSID.ssId);
10931 }
10932 /* set the scan type to active */
10933 scanRequest.scanType = eSIR_ACTIVE_SCAN;
10934 }
10935 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070010936 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010937 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10938 TRACE_CODE_HDD_CFG80211_SCAN,
10939 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070010940 /* set the scan type to active */
10941 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010942 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010943 else
10944 {
10945 /*Set the scan type to default type, in this case it is ACTIVE*/
10946 scanRequest.scanType = pScanInfo->scan_mode;
10947 }
10948 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
10949 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070010950
10951 /* set BSSType to default type */
10952 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
10953
10954 /*TODO: scan the requested channels only*/
10955
10956 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010957 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070010958 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010959 hddLog(VOS_TRACE_LEVEL_WARN,
10960 "No of Scan Channels exceeded limit: %d", request->n_channels);
10961 request->n_channels = MAX_CHANNEL;
10962 }
10963
10964 hddLog(VOS_TRACE_LEVEL_INFO,
10965 "No of Scan Channels: %d", request->n_channels);
10966
10967
10968 if( request->n_channels )
10969 {
10970 char chList [(request->n_channels*5)+1];
10971 int len;
10972 channelList = vos_mem_malloc( request->n_channels );
10973 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053010974 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010975 hddLog(VOS_TRACE_LEVEL_ERROR,
10976 "%s: memory alloc failed channelList", __func__);
10977 status = -ENOMEM;
10978 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053010979 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010980
10981 for( i = 0, len = 0; i < request->n_channels ; i++ )
10982 {
10983 channelList[i] = request->channels[i]->hw_value;
10984 len += snprintf(chList+len, 5, "%d ", channelList[i]);
10985 }
10986
Nirav Shah20ac06f2013-12-12 18:14:06 +053010987 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010988 "Channel-List: %s ", chList);
10989 }
c_hpothu53512302014-04-15 18:49:53 +053010990
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010991 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
10992 scanRequest.ChannelInfo.ChannelList = channelList;
10993
10994 /* set requestType to full scan */
10995 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
10996
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010997 /* if there is back to back scan happening in driver with in
10998 * nDeferScanTimeInterval interval driver should defer new scan request
10999 * and should provide last cached scan results instead of new channel list.
11000 * This rule is not applicable if scan is p2p scan.
11001 * This condition will work only in case when last request no of channels
11002 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053011003 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053011004 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011005 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011006
Sushant Kaushik86592172015-04-27 16:35:03 +053011007 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
11008 /* if wps ie is NULL , then only defer scan */
11009 if ( pWpsIe == NULL &&
11010 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053011011 {
11012 if ( pScanInfo->last_scan_timestamp !=0 &&
11013 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
11014 {
11015 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
11016 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
11017 vos_mem_compare(pScanInfo->last_scan_channelList,
11018 channelList, pScanInfo->last_scan_numChannels))
11019 {
11020 hddLog(VOS_TRACE_LEVEL_WARN,
11021 " New and old station scan time differ is less then %u",
11022 pHddCtx->cfg_ini->nDeferScanTimeInterval);
11023
11024 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011025 pAdapter);
11026
Agarwal Ashish57e84372014-12-05 18:26:53 +053011027 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053011028 "Return old cached scan as all channels and no of channels are same");
11029
Agarwal Ashish57e84372014-12-05 18:26:53 +053011030 if (0 > ret)
11031 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011032
Agarwal Ashish57e84372014-12-05 18:26:53 +053011033 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053011034
11035 status = eHAL_STATUS_SUCCESS;
11036 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053011037 }
11038 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011039 }
11040
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011041 /* Flush the scan results(only p2p beacons) for STA scan and P2P
11042 * search (Flush on both full scan and social scan but not on single
11043 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
11044 */
11045
11046 /* Supplicant does single channel scan after 8-way handshake
11047 * and in that case driver shoudnt flush scan results. If
11048 * driver flushes the scan results here and unfortunately if
11049 * the AP doesnt respond to our probe req then association
11050 * fails which is not desired
11051 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053011052 if ((request->n_ssids == 1)
11053 && (request->ssids != NULL)
11054 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
11055 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011056
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053011057 if( is_p2p_scan ||
11058 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011059 {
11060 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
11061 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
11062 pAdapter->sessionId );
11063 }
11064
11065 if( request->ie_len )
11066 {
11067 /* save this for future association (join requires this) */
11068 /*TODO: Array needs to be converted to dynamic allocation,
11069 * as multiple ie.s can be sent in cfg80211_scan_request structure
11070 * CR 597966
11071 */
11072 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
11073 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
11074 pScanInfo->scanAddIE.length = request->ie_len;
11075
11076 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11077 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
11078 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070011079 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011080 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070011081 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011082 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
11083 memcpy( pwextBuf->roamProfile.addIEScan,
11084 request->ie, request->ie_len);
11085 }
11086 else
11087 {
11088 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
11089 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070011090 }
11091
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011092 }
11093 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
11094 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
11095
11096 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
11097 request->ie_len);
11098 if (pP2pIe != NULL)
11099 {
11100#ifdef WLAN_FEATURE_P2P_DEBUG
11101 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
11102 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
11103 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053011104 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011105 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
11106 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
11107 "Go nego completed to Connection is started");
11108 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
11109 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053011110 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011111 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
11112 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070011113 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011114 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
11115 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
11116 "Disconnected state to Connection is started");
11117 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
11118 "for 4way Handshake");
11119 }
11120#endif
11121
11122 /* no_cck will be set during p2p find to disable 11b rates */
11123 if(TRUE == request->no_cck)
11124 {
11125 hddLog(VOS_TRACE_LEVEL_INFO,
11126 "%s: This is a P2P Search", __func__);
11127 scanRequest.p2pSearch = 1;
11128
11129 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053011130 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011131 /* set requestType to P2P Discovery */
11132 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
11133 }
11134
11135 /*
11136 Skip Dfs Channel in case of P2P Search
11137 if it is set in ini file
11138 */
11139 if(cfg_param->skipDfsChnlInP2pSearch)
11140 {
11141 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053011142 }
11143 else
11144 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011145 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053011146 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011147
Agarwal Ashish4f616132013-12-30 23:32:50 +053011148 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011149 }
11150 }
11151
11152 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
11153
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053011154#ifdef FEATURE_WLAN_TDLS
11155 /* if tdls disagree scan right now, return immediately.
11156 tdls will schedule the scan when scan is allowed. (return SUCCESS)
11157 or will reject the scan if any TDLS is in progress. (return -EBUSY)
11158 */
11159 status = wlan_hdd_tdls_scan_callback (pAdapter,
11160 wiphy,
11161#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11162 dev,
11163#endif
11164 request);
11165 if(status <= 0)
11166 {
11167 if(!status)
11168 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
11169 "scan rejected %d", __func__, status);
11170 else
11171 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
11172 __func__, status);
11173
11174 return status;
11175 }
11176#endif
11177
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070011178 /* acquire the wakelock to avoid the apps suspend during the scan. To
11179 * address the following issues.
11180 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
11181 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
11182 * for long time, this result in apps running at full power for long time.
11183 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
11184 * be stuck in full power because of resume BMPS
11185 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011186 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070011187
Nirav Shah20ac06f2013-12-12 18:14:06 +053011188 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
11189 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011190 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
11191 scanRequest.requestType, scanRequest.scanType,
11192 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053011193 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
11194
Siddharth Bhal76972212014-10-15 16:22:51 +053011195 if (pHddCtx->spoofMacAddr.isEnabled)
11196 {
11197 hddLog(VOS_TRACE_LEVEL_INFO,
11198 "%s: MAC Spoofing enabled for current scan", __func__);
11199 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
11200 * to fill TxBds for probe request during current scan
11201 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011202 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053011203 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011204
11205 if(status != VOS_STATUS_SUCCESS)
11206 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011207 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011208 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053011209#ifdef FEATURE_WLAN_TDLS
11210 wlan_hdd_tdls_scan_done_callback(pAdapter);
11211#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011212 goto free_mem;
11213 }
Siddharth Bhal76972212014-10-15 16:22:51 +053011214 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053011215 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070011216 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011217 pAdapter->sessionId, &scanRequest, &scanId,
11218 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070011219
Jeff Johnson295189b2012-06-20 16:38:30 -070011220 if (eHAL_STATUS_SUCCESS != status)
11221 {
11222 hddLog(VOS_TRACE_LEVEL_ERROR,
11223 "%s: sme_ScanRequest returned error %d", __func__, status);
11224 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011225 if(eHAL_STATUS_RESOURCES == status)
11226 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053011227 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
11228 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011229 status = -EBUSY;
11230 } else {
11231 status = -EIO;
11232 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011233 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053011234
11235#ifdef FEATURE_WLAN_TDLS
11236 wlan_hdd_tdls_scan_done_callback(pAdapter);
11237#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011238 goto free_mem;
11239 }
11240
11241 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053011242 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011243 pAdapter->request = request;
11244 pScanInfo->scanId = scanId;
11245
11246 complete(&pScanInfo->scan_req_completion_event);
11247
11248free_mem:
11249 if( scanRequest.SSIDs.SSIDList )
11250 {
11251 vos_mem_free(scanRequest.SSIDs.SSIDList);
11252 }
11253
11254 if( channelList )
11255 vos_mem_free( channelList );
11256
11257 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011258 return status;
11259}
11260
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011261int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
11262#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11263 struct net_device *dev,
11264#endif
11265 struct cfg80211_scan_request *request)
11266{
11267 int ret;
11268
11269 vos_ssr_protect(__func__);
11270 ret = __wlan_hdd_cfg80211_scan(wiphy,
11271#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11272 dev,
11273#endif
11274 request);
11275 vos_ssr_unprotect(__func__);
11276
11277 return ret;
11278}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011279
11280void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
11281{
11282 v_U8_t iniDot11Mode =
11283 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
11284 eHddDot11Mode hddDot11Mode = iniDot11Mode;
11285
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011286 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
11287 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011288 switch ( iniDot11Mode )
11289 {
11290 case eHDD_DOT11_MODE_AUTO:
11291 case eHDD_DOT11_MODE_11ac:
11292 case eHDD_DOT11_MODE_11ac_ONLY:
11293#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053011294 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
11295 sme_IsFeatureSupportedByFW(DOT11AC) )
11296 hddDot11Mode = eHDD_DOT11_MODE_11ac;
11297 else
11298 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011299#else
11300 hddDot11Mode = eHDD_DOT11_MODE_11n;
11301#endif
11302 break;
11303 case eHDD_DOT11_MODE_11n:
11304 case eHDD_DOT11_MODE_11n_ONLY:
11305 hddDot11Mode = eHDD_DOT11_MODE_11n;
11306 break;
11307 default:
11308 hddDot11Mode = iniDot11Mode;
11309 break;
11310 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011311#ifdef WLAN_FEATURE_AP_HT40_24G
11312 if (operationChannel > SIR_11B_CHANNEL_END)
11313#endif
11314 {
11315 /* This call decides required channel bonding mode */
11316 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011317 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
11318 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011319 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011320}
11321
Jeff Johnson295189b2012-06-20 16:38:30 -070011322/*
11323 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011324 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011325 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011326int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011327 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070011328{
11329 int status = 0;
11330 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080011331 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011332 v_U32_t roamId;
11333 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070011334 eCsrAuthType RSNAuthType;
11335
11336 ENTER();
11337
11338 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080011339 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11340
11341 status = wlan_hdd_validate_context(pHddCtx);
11342 if (status)
11343 {
Yue Mae36e3552014-03-05 17:06:20 -080011344 return status;
11345 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011346
Jeff Johnson295189b2012-06-20 16:38:30 -070011347 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
11348 {
11349 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
11350 return -EINVAL;
11351 }
11352
11353 pRoamProfile = &pWextState->roamProfile;
11354
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011355 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070011356 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011357 hdd_station_ctx_t *pHddStaCtx;
11358 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011359
Siddharth Bhalda0d1622015-04-24 15:47:49 +053011360 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
11361
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011362 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070011363 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
11364 {
11365 /*QoS not enabled in cfg file*/
11366 pRoamProfile->uapsd_mask = 0;
11367 }
11368 else
11369 {
11370 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011371 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070011372 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
11373 }
11374
11375 pRoamProfile->SSIDs.numOfSSIDs = 1;
11376 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
11377 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011378 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070011379 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
11380 ssid, ssid_len);
11381
11382 if (bssid)
11383 {
11384 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
11385 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
11386 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011387 /* Save BSSID in seperate variable as well, as RoamProfile
11388 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070011389 case of join failure we should send valid BSSID to supplicant
11390 */
11391 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
11392 WNI_CFG_BSSID_LEN);
11393 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070011394 else
11395 {
11396 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
11397 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011398
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011399 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
11400 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011401 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
11402 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011403 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011404 /*set gen ie*/
11405 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
11406 /*set auth*/
11407 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
11408 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011409#ifdef FEATURE_WLAN_WAPI
11410 if (pAdapter->wapi_info.nWapiMode)
11411 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011412 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011413 switch (pAdapter->wapi_info.wapiAuthMode)
11414 {
11415 case WAPI_AUTH_MODE_PSK:
11416 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011417 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011418 pAdapter->wapi_info.wapiAuthMode);
11419 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
11420 break;
11421 }
11422 case WAPI_AUTH_MODE_CERT:
11423 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011424 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011425 pAdapter->wapi_info.wapiAuthMode);
11426 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
11427 break;
11428 }
11429 } // End of switch
11430 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
11431 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
11432 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011433 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011434 pRoamProfile->AuthType.numEntries = 1;
11435 pRoamProfile->EncryptionType.numEntries = 1;
11436 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11437 pRoamProfile->mcEncryptionType.numEntries = 1;
11438 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11439 }
11440 }
11441#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011442#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011443 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011444 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11445 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
11446 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011447 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
11448 sizeof (tSirGtkOffloadParams));
11449 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011450 }
11451#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011452 pRoamProfile->csrPersona = pAdapter->device_mode;
11453
Jeff Johnson32d95a32012-09-10 13:15:23 -070011454 if( operatingChannel )
11455 {
11456 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
11457 pRoamProfile->ChannelInfo.numOfChannels = 1;
11458 }
Chet Lanctot186b5732013-03-18 10:26:30 -070011459 else
11460 {
11461 pRoamProfile->ChannelInfo.ChannelList = NULL;
11462 pRoamProfile->ChannelInfo.numOfChannels = 0;
11463 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011464 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
11465 {
11466 hdd_select_cbmode(pAdapter,operatingChannel);
11467 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011468
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011469 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
11470 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011471 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011472 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011473 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
11474 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011475 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11476 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053011477 {
11478 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11479 "%s: Set HDD connState to eConnectionState_Connecting",
11480 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011481 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
11482 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053011483 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011484 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011485 pAdapter->sessionId, pRoamProfile, &roamId);
11486
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011487 if ((eHAL_STATUS_SUCCESS != status) &&
11488 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11489 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011490
11491 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011492 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
11493 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
11494 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011495 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011496 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011497 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011498
11499 pRoamProfile->ChannelInfo.ChannelList = NULL;
11500 pRoamProfile->ChannelInfo.numOfChannels = 0;
11501
Jeff Johnson295189b2012-06-20 16:38:30 -070011502 }
11503 else
11504 {
11505 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
11506 return -EINVAL;
11507 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080011508 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011509 return status;
11510}
11511
11512/*
11513 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
11514 * This function is used to set the authentication type (OPEN/SHARED).
11515 *
11516 */
11517static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
11518 enum nl80211_auth_type auth_type)
11519{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011520 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011521 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11522
11523 ENTER();
11524
11525 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011526 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070011527 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011528 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011529 hddLog(VOS_TRACE_LEVEL_INFO,
11530 "%s: set authentication type to AUTOSWITCH", __func__);
11531 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
11532 break;
11533
11534 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011535#ifdef WLAN_FEATURE_VOWIFI_11R
11536 case NL80211_AUTHTYPE_FT:
11537#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011538 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011539 "%s: set authentication type to OPEN", __func__);
11540 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11541 break;
11542
11543 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011544 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011545 "%s: set authentication type to SHARED", __func__);
11546 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
11547 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011548#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011549 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011550 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011551 "%s: set authentication type to CCKM WPA", __func__);
11552 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
11553 break;
11554#endif
11555
11556
11557 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011558 hddLog(VOS_TRACE_LEVEL_ERROR,
11559 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011560 auth_type);
11561 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
11562 return -EINVAL;
11563 }
11564
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011565 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011566 pHddStaCtx->conn_info.authType;
11567 return 0;
11568}
11569
11570/*
11571 * FUNCTION: wlan_hdd_set_akm_suite
11572 * This function is used to set the key mgmt type(PSK/8021x).
11573 *
11574 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011575static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011576 u32 key_mgmt
11577 )
11578{
11579 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11580 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053011581 /* Should be in ieee802_11_defs.h */
11582#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
11583#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070011584 /*set key mgmt type*/
11585 switch(key_mgmt)
11586 {
11587 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053011588 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011589#ifdef WLAN_FEATURE_VOWIFI_11R
11590 case WLAN_AKM_SUITE_FT_PSK:
11591#endif
11592 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070011593 __func__);
11594 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
11595 break;
11596
11597 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053011598 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011599#ifdef WLAN_FEATURE_VOWIFI_11R
11600 case WLAN_AKM_SUITE_FT_8021X:
11601#endif
11602 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011603 __func__);
11604 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11605 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011606#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011607#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
11608#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
11609 case WLAN_AKM_SUITE_CCKM:
11610 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
11611 __func__);
11612 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
11613 break;
11614#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070011615#ifndef WLAN_AKM_SUITE_OSEN
11616#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
11617 case WLAN_AKM_SUITE_OSEN:
11618 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
11619 __func__);
11620 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11621 break;
11622#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011623
11624 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011625 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011626 __func__, key_mgmt);
11627 return -EINVAL;
11628
11629 }
11630 return 0;
11631}
11632
11633/*
11634 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011635 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070011636 * (NONE/WEP40/WEP104/TKIP/CCMP).
11637 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011638static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
11639 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070011640 bool ucast
11641 )
11642{
11643 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011644 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011645 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11646
11647 ENTER();
11648
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011649 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011650 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053011651 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070011652 __func__, cipher);
11653 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11654 }
11655 else
11656 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011657
Jeff Johnson295189b2012-06-20 16:38:30 -070011658 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011659 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011660 {
11661 case IW_AUTH_CIPHER_NONE:
11662 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11663 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011664
Jeff Johnson295189b2012-06-20 16:38:30 -070011665 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011666 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070011667 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011668
Jeff Johnson295189b2012-06-20 16:38:30 -070011669 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011670 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070011671 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011672
Jeff Johnson295189b2012-06-20 16:38:30 -070011673 case WLAN_CIPHER_SUITE_TKIP:
11674 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
11675 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011676
Jeff Johnson295189b2012-06-20 16:38:30 -070011677 case WLAN_CIPHER_SUITE_CCMP:
11678 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11679 break;
11680#ifdef FEATURE_WLAN_WAPI
11681 case WLAN_CIPHER_SUITE_SMS4:
11682 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
11683 break;
11684#endif
11685
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011686#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011687 case WLAN_CIPHER_SUITE_KRK:
11688 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
11689 break;
11690#endif
11691 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011692 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011693 __func__, cipher);
11694 return -EOPNOTSUPP;
11695 }
11696 }
11697
11698 if (ucast)
11699 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011700 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011701 __func__, encryptionType);
11702 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11703 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011704 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011705 encryptionType;
11706 }
11707 else
11708 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011709 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011710 __func__, encryptionType);
11711 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
11712 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
11713 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
11714 }
11715
11716 return 0;
11717}
11718
11719
11720/*
11721 * FUNCTION: wlan_hdd_cfg80211_set_ie
11722 * This function is used to parse WPA/RSN IE's.
11723 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011724int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011725#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11726 const u8 *ie,
11727#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011728 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011729#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011730 size_t ie_len
11731 )
11732{
11733 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011734#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11735 const u8 *genie = ie;
11736#else
Jeff Johnson295189b2012-06-20 16:38:30 -070011737 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011738#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011739 v_U16_t remLen = ie_len;
11740#ifdef FEATURE_WLAN_WAPI
11741 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
11742 u16 *tmp;
11743 v_U16_t akmsuiteCount;
11744 int *akmlist;
11745#endif
11746 ENTER();
11747
11748 /* clear previous assocAddIE */
11749 pWextState->assocAddIE.length = 0;
11750 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011751 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011752
11753 while (remLen >= 2)
11754 {
11755 v_U16_t eLen = 0;
11756 v_U8_t elementId;
11757 elementId = *genie++;
11758 eLen = *genie++;
11759 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011760
Arif Hussain6d2a3322013-11-17 19:50:10 -080011761 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070011762 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011763
11764 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070011765 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011766 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011767 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 -070011768 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011769 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011770 "%s: Invalid WPA IE", __func__);
11771 return -EINVAL;
11772 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011773 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070011774 {
11775 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011776 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011777 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011778
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011779 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011780 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011781 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
11782 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011783 VOS_ASSERT(0);
11784 return -ENOMEM;
11785 }
11786 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11787 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11788 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011789
Jeff Johnson295189b2012-06-20 16:38:30 -070011790 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
11791 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11792 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11793 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011794 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
11795 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011796 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
11797 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11798 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
11799 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
11800 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
11801 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011802 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053011803 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070011804 {
11805 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011806 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011807 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011808
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011809 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011810 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011811 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11812 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011813 VOS_ASSERT(0);
11814 return -ENOMEM;
11815 }
11816 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11817 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11818 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011819
Jeff Johnson295189b2012-06-20 16:38:30 -070011820 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11821 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11822 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011823#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011824 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
11825 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011826 /*Consider WFD IE, only for P2P Client */
11827 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
11828 {
11829 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011830 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011831 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011832
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011833 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011834 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011835 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11836 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011837 VOS_ASSERT(0);
11838 return -ENOMEM;
11839 }
11840 // WFD IE is saved to Additional IE ; it should be accumulated to handle
11841 // WPS IE + P2P IE + WFD IE
11842 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11843 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011844
Jeff Johnson295189b2012-06-20 16:38:30 -070011845 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11846 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11847 }
11848#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011849 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011850 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011851 HS20_OUI_TYPE_SIZE)) )
11852 {
11853 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011854 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011855 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011856
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011857 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011858 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011859 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11860 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011861 VOS_ASSERT(0);
11862 return -ENOMEM;
11863 }
11864 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11865 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011866
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011867 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11868 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11869 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011870 /* Appending OSEN Information Element in Assiciation Request */
11871 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
11872 OSEN_OUI_TYPE_SIZE)) )
11873 {
11874 v_U16_t curAddIELen = pWextState->assocAddIE.length;
11875 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
11876 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011877
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011878 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011879 {
11880 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11881 "Need bigger buffer space");
11882 VOS_ASSERT(0);
11883 return -ENOMEM;
11884 }
11885 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11886 pWextState->assocAddIE.length += eLen + 2;
11887
11888 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
11889 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11890 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11891 }
11892
Abhishek Singh4322e622015-06-10 15:42:54 +053011893 /* Update only for WPA IE */
11894 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
11895 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011896
11897 /* populating as ADDIE in beacon frames */
11898 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011899 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011900 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
11901 {
11902 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11903 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
11904 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11905 {
11906 hddLog(LOGE,
11907 "Coldn't pass "
11908 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
11909 }
11910 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
11911 else
11912 hddLog(LOGE,
11913 "Could not pass on "
11914 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
11915
11916 /* IBSS mode doesn't contain params->proberesp_ies still
11917 beaconIE's need to be populated in probe response frames */
11918 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
11919 {
11920 u16 rem_probe_resp_ie_len = eLen + 2;
11921 u8 probe_rsp_ie_len[3] = {0};
11922 u8 counter = 0;
11923
11924 /* Check Probe Resp Length if it is greater then 255 then
11925 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
11926 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
11927 not able Store More then 255 bytes into One Variable */
11928
11929 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
11930 {
11931 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
11932 {
11933 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
11934 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
11935 }
11936 else
11937 {
11938 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
11939 rem_probe_resp_ie_len = 0;
11940 }
11941 }
11942
11943 rem_probe_resp_ie_len = 0;
11944
11945 if (probe_rsp_ie_len[0] > 0)
11946 {
11947 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11948 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
11949 (tANI_U8*)(genie - 2),
11950 probe_rsp_ie_len[0], NULL,
11951 eANI_BOOLEAN_FALSE)
11952 == eHAL_STATUS_FAILURE)
11953 {
11954 hddLog(LOGE,
11955 "Could not pass"
11956 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
11957 }
11958 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
11959 }
11960
11961 if (probe_rsp_ie_len[1] > 0)
11962 {
11963 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11964 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
11965 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11966 probe_rsp_ie_len[1], NULL,
11967 eANI_BOOLEAN_FALSE)
11968 == eHAL_STATUS_FAILURE)
11969 {
11970 hddLog(LOGE,
11971 "Could not pass"
11972 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
11973 }
11974 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
11975 }
11976
11977 if (probe_rsp_ie_len[2] > 0)
11978 {
11979 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11980 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
11981 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11982 probe_rsp_ie_len[2], NULL,
11983 eANI_BOOLEAN_FALSE)
11984 == eHAL_STATUS_FAILURE)
11985 {
11986 hddLog(LOGE,
11987 "Could not pass"
11988 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
11989 }
11990 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
11991 }
11992
11993 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11994 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
11995 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11996 {
11997 hddLog(LOGE,
11998 "Could not pass"
11999 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
12000 }
12001 }
12002 else
12003 {
12004 // Reset WNI_CFG_PROBE_RSP Flags
12005 wlan_hdd_reset_prob_rspies(pAdapter);
12006
12007 hddLog(VOS_TRACE_LEVEL_INFO,
12008 "%s: No Probe Response IE received in set beacon",
12009 __func__);
12010 }
12011 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070012012 break;
12013 case DOT11F_EID_RSN:
12014 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
12015 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
12016 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
12017 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
12018 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
12019 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053012020
12021 /* Appending Extended Capabilities with Interworking bit set
12022 * in Assoc Req.
12023 *
12024 * In assoc req this EXT Cap will only be taken into account if
12025 * interworkingService bit is set to 1. Currently
12026 * driver is only interested in interworkingService capability
12027 * from supplicant. If in future any other EXT Cap info is
12028 * required from supplicat, it needs to be handled while
12029 * sending Assoc Req in LIM.
12030 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012031 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012032 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012033 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012034 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012035 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012036
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053012037 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012038 {
Jeff Johnson902c9832012-12-10 14:28:09 -080012039 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
12040 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012041 VOS_ASSERT(0);
12042 return -ENOMEM;
12043 }
12044 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
12045 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012046
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012047 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
12048 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
12049 break;
12050 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012051#ifdef FEATURE_WLAN_WAPI
12052 case WLAN_EID_WAPI:
12053 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070012054 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070012055 pAdapter->wapi_info.nWapiMode);
12056 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012057 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070012058 akmsuiteCount = WPA_GET_LE16(tmp);
12059 tmp = tmp + 1;
12060 akmlist = (int *)(tmp);
12061 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
12062 {
12063 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
12064 }
12065 else
12066 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012067 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070012068 VOS_ASSERT(0);
12069 return -EINVAL;
12070 }
12071
12072 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
12073 {
12074 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012075 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012076 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012077 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012078 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012079 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012080 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012081 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012082 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
12083 }
12084 break;
12085#endif
12086 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012087 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012088 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012089 /* when Unknown IE is received we should break and continue
12090 * to the next IE in the buffer instead we were returning
12091 * so changing this to break */
12092 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012093 }
12094 genie += eLen;
12095 remLen -= eLen;
12096 }
12097 EXIT();
12098 return 0;
12099}
12100
12101/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053012102 * FUNCTION: hdd_isWPAIEPresent
12103 * Parse the received IE to find the WPA IE
12104 *
12105 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012106static bool hdd_isWPAIEPresent(
12107#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
12108 const u8 *ie,
12109#else
12110 u8 *ie,
12111#endif
12112 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053012113{
12114 v_U8_t eLen = 0;
12115 v_U16_t remLen = ie_len;
12116 v_U8_t elementId = 0;
12117
12118 while (remLen >= 2)
12119 {
12120 elementId = *ie++;
12121 eLen = *ie++;
12122 remLen -= 2;
12123 if (eLen > remLen)
12124 {
12125 hddLog(VOS_TRACE_LEVEL_ERROR,
12126 "%s: IE length is wrong %d", __func__, eLen);
12127 return FALSE;
12128 }
12129 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
12130 {
12131 /* OUI - 0x00 0X50 0XF2
12132 WPA Information Element - 0x01
12133 WPA version - 0x01*/
12134 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
12135 return TRUE;
12136 }
12137 ie += eLen;
12138 remLen -= eLen;
12139 }
12140 return FALSE;
12141}
12142
12143/*
Jeff Johnson295189b2012-06-20 16:38:30 -070012144 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012145 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012146 * parameters during connect operation.
12147 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012148int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012149 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012150 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012151{
12152 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012153 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012154 ENTER();
12155
12156 /*set wpa version*/
12157 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
12158
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012159 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070012160 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053012161 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070012162 {
12163 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12164 }
12165 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
12166 {
12167 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12168 }
12169 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012170
12171 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012172 pWextState->wpaVersion);
12173
12174 /*set authentication type*/
12175 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
12176
12177 if (0 > status)
12178 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012179 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012180 "%s: failed to set authentication type ", __func__);
12181 return status;
12182 }
12183
12184 /*set key mgmt type*/
12185 if (req->crypto.n_akm_suites)
12186 {
12187 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
12188 if (0 > status)
12189 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012190 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070012191 __func__);
12192 return status;
12193 }
12194 }
12195
12196 /*set pairwise cipher type*/
12197 if (req->crypto.n_ciphers_pairwise)
12198 {
12199 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
12200 req->crypto.ciphers_pairwise[0], true);
12201 if (0 > status)
12202 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012203 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012204 "%s: failed to set unicast cipher type", __func__);
12205 return status;
12206 }
12207 }
12208 else
12209 {
12210 /*Reset previous cipher suite to none*/
12211 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
12212 if (0 > status)
12213 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012214 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012215 "%s: failed to set unicast cipher type", __func__);
12216 return status;
12217 }
12218 }
12219
12220 /*set group cipher type*/
12221 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
12222 false);
12223
12224 if (0 > status)
12225 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012226 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070012227 __func__);
12228 return status;
12229 }
12230
Chet Lanctot186b5732013-03-18 10:26:30 -070012231#ifdef WLAN_FEATURE_11W
12232 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
12233#endif
12234
Jeff Johnson295189b2012-06-20 16:38:30 -070012235 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
12236 if (req->ie_len)
12237 {
12238 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
12239 if ( 0 > status)
12240 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012241 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012242 __func__);
12243 return status;
12244 }
12245 }
12246
12247 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012248 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012249 {
12250 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
12251 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
12252 )
12253 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012254 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070012255 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
12256 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012257 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012258 __func__);
12259 return -EOPNOTSUPP;
12260 }
12261 else
12262 {
12263 u8 key_len = req->key_len;
12264 u8 key_idx = req->key_idx;
12265
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012266 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012267 && (CSR_MAX_NUM_KEY > key_idx)
12268 )
12269 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012270 hddLog(VOS_TRACE_LEVEL_INFO,
12271 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012272 __func__, key_idx, key_len);
12273 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012274 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012275 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012276 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070012277 (u8)key_len;
12278 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
12279 }
12280 }
12281 }
12282 }
12283
12284 return status;
12285}
12286
12287/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012288 * FUNCTION: wlan_hdd_try_disconnect
12289 * This function is used to disconnect from previous
12290 * connection
12291 */
12292static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
12293{
12294 long ret = 0;
12295 hdd_station_ctx_t *pHddStaCtx;
12296 eMib_dot11DesiredBssType connectedBssType;
12297
12298 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12299
12300 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
12301
12302 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
12303 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
12304 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
12305 {
12306 /* Issue disconnect to CSR */
12307 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12308 if( eHAL_STATUS_SUCCESS ==
12309 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12310 pAdapter->sessionId,
12311 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
12312 {
12313 ret = wait_for_completion_interruptible_timeout(
12314 &pAdapter->disconnect_comp_var,
12315 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12316 if (0 >= ret)
12317 {
12318 hddLog(LOGE, FL("Failed to receive disconnect event"));
12319 return -EALREADY;
12320 }
12321 }
12322 }
12323 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
12324 {
12325 ret = wait_for_completion_interruptible_timeout(
12326 &pAdapter->disconnect_comp_var,
12327 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12328 if (0 >= ret)
12329 {
12330 hddLog(LOGE, FL("Failed to receive disconnect event"));
12331 return -EALREADY;
12332 }
12333 }
12334
12335 return 0;
12336}
12337
12338/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053012339 * FUNCTION: __wlan_hdd_cfg80211_connect
12340 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070012341 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012342static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012343 struct net_device *ndev,
12344 struct cfg80211_connect_params *req
12345 )
12346{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012347 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012348 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012349 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053012350 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012351
12352 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012353
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012354 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12355 TRACE_CODE_HDD_CFG80211_CONNECT,
12356 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012357 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012358 "%s: device_mode = %s (%d)", __func__,
12359 hdd_device_modetoString(pAdapter->device_mode),
12360 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012361
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012362 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012363 if (!pHddCtx)
12364 {
12365 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12366 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053012367 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012368 }
12369
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012370 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012371 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012372 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012373 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012374 }
12375
Agarwal Ashish51325b52014-06-16 16:50:49 +053012376 if (vos_max_concurrent_connections_reached()) {
12377 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12378 return -ECONNREFUSED;
12379 }
12380
Jeff Johnson295189b2012-06-20 16:38:30 -070012381#ifdef WLAN_BTAMP_FEATURE
12382 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012383 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070012384 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012385 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012386 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080012387 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012388 }
12389#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012390
12391 //If Device Mode is Station Concurrent Sessions Exit BMps
12392 //P2P Mode will be taken care in Open/close adapter
12393 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012394 (vos_concurrent_open_sessions_running())) {
12395 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
12396 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012397 }
12398
12399 /*Try disconnecting if already in connected state*/
12400 status = wlan_hdd_try_disconnect(pAdapter);
12401 if ( 0 > status)
12402 {
12403 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12404 " connection"));
12405 return -EALREADY;
12406 }
12407
Jeff Johnson295189b2012-06-20 16:38:30 -070012408 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012409 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070012410
12411 if ( 0 > status)
12412 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012413 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070012414 __func__);
12415 return status;
12416 }
Mohit Khanna765234a2012-09-11 15:08:35 -070012417 if ( req->channel )
12418 {
12419 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
12420 req->ssid_len, req->bssid,
12421 req->channel->hw_value);
12422 }
12423 else
12424 {
12425 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012426 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070012427 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012428
Sushant Kaushikd7083982015-03-18 14:33:24 +053012429 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012430 {
12431 //ReEnable BMPS if disabled
12432 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
12433 (NULL != pHddCtx))
12434 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012435 if (pHddCtx->hdd_wlan_suspended)
12436 {
12437 hdd_set_pwrparams(pHddCtx);
12438 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012439 //ReEnable Bmps and Imps back
12440 hdd_enable_bmps_imps(pHddCtx);
12441 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053012442 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012443 return status;
12444 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012445 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012446 EXIT();
12447 return status;
12448}
12449
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012450static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
12451 struct net_device *ndev,
12452 struct cfg80211_connect_params *req)
12453{
12454 int ret;
12455 vos_ssr_protect(__func__);
12456 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
12457 vos_ssr_unprotect(__func__);
12458
12459 return ret;
12460}
Jeff Johnson295189b2012-06-20 16:38:30 -070012461
12462/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012463 * FUNCTION: wlan_hdd_disconnect
12464 * This function is used to issue a disconnect request to SME
12465 */
12466int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
12467{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012468 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012469 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012470 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012471 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012472
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012473 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012474
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012475 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012476 if (0 != status)
12477 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012478 return status;
12479 }
12480
Sushant Kaushikb4834d22015-07-15 15:29:05 +053012481 if (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)
12482 {
12483 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
12484 pAdapter->sessionId);
12485 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012486 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012487
Agarwal Ashish47d18112014-08-04 19:55:07 +053012488 /* Need to apply spin lock before decreasing active sessions
12489 * as there can be chance for double decrement if context switch
12490 * Calls hdd_DisConnectHandler.
12491 */
12492
12493 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012494 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
12495 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012496 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
12497 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053012498 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
12499 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012500
Abhishek Singhf4669da2014-05-26 15:07:49 +053012501 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053012502 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
12503
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012504 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012505
Mihir Shete182a0b22014-08-18 16:08:48 +053012506 /*
12507 * stop tx queues before deleting STA/BSS context from the firmware.
12508 * tx has to be disabled because the firmware can get busy dropping
12509 * the tx frames after BSS/STA has been deleted and will not send
12510 * back a response resulting in WDI timeout
12511 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053012512 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053012513 netif_tx_disable(pAdapter->dev);
12514 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012515
Mihir Shete182a0b22014-08-18 16:08:48 +053012516 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012517 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12518 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012519 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
12520 {
12521 hddLog(VOS_TRACE_LEVEL_INFO,
12522 FL("status = %d, already disconnected"),
12523 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012524
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012525 }
12526 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012527 {
12528 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012529 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012530 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012531 result = -EINVAL;
12532 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012533 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012534 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012535 &pAdapter->disconnect_comp_var,
12536 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012537 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012538 {
12539 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012540 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012541 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012542 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012543 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012544 {
12545 hddLog(VOS_TRACE_LEVEL_ERROR,
12546 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012547 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012548 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012549disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012550 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12551 FL("Set HDD connState to eConnectionState_NotConnected"));
12552 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
12553
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012554 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012555 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012556}
12557
12558
12559/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012560 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070012561 * This function is used to issue a disconnect request to SME
12562 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012563static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012564 struct net_device *dev,
12565 u16 reason
12566 )
12567{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012568 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012569 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012570 tCsrRoamProfile *pRoamProfile;
12571 hdd_station_ctx_t *pHddStaCtx;
12572 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012573#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012574 tANI_U8 staIdx;
12575#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012576
Jeff Johnson295189b2012-06-20 16:38:30 -070012577 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012578
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012579 if (!pAdapter) {
12580 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
12581 return -EINVAL;
12582 }
12583
12584 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12585 if (!pHddStaCtx) {
12586 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
12587 return -EINVAL;
12588 }
12589
12590 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12591 status = wlan_hdd_validate_context(pHddCtx);
12592 if (0 != status)
12593 {
12594 return status;
12595 }
12596
12597 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
12598
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012599 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12600 TRACE_CODE_HDD_CFG80211_DISCONNECT,
12601 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012602 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
12603 __func__, hdd_device_modetoString(pAdapter->device_mode),
12604 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012605
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012606 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
12607 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070012608
Jeff Johnson295189b2012-06-20 16:38:30 -070012609 if (NULL != pRoamProfile)
12610 {
12611 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012612 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
12613 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070012614 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012615 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070012616 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012617 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012618 switch(reason)
12619 {
12620 case WLAN_REASON_MIC_FAILURE:
12621 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
12622 break;
12623
12624 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
12625 case WLAN_REASON_DISASSOC_AP_BUSY:
12626 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
12627 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
12628 break;
12629
12630 case WLAN_REASON_PREV_AUTH_NOT_VALID:
12631 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053012632 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070012633 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
12634 break;
12635
Jeff Johnson295189b2012-06-20 16:38:30 -070012636 default:
12637 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
12638 break;
12639 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012640 pScanInfo = &pHddCtx->scan_info;
12641 if (pScanInfo->mScanPending)
12642 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012643 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012644 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053012645 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012646 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012647 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053012648 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012649#ifdef FEATURE_WLAN_TDLS
12650 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012651 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012652 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012653 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
12654 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012655 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012656 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012657 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012659 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012660 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012661 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012662 status = sme_DeleteTdlsPeerSta(
12663 WLAN_HDD_GET_HAL_CTX(pAdapter),
12664 pAdapter->sessionId,
12665 mac);
12666 if (status != eHAL_STATUS_SUCCESS) {
12667 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
12668 return -EPERM;
12669 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012670 }
12671 }
12672#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012673 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012674 status = wlan_hdd_disconnect(pAdapter, reasonCode);
12675 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070012676 {
12677 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012678 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012679 __func__, (int)status );
12680 return -EINVAL;
12681 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012682 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012683 else
12684 {
12685 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
12686 "called while in %d state", __func__,
12687 pHddStaCtx->conn_info.connState);
12688 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012689 }
12690 else
12691 {
12692 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
12693 }
12694
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012695 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012696 return status;
12697}
12698
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012699static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
12700 struct net_device *dev,
12701 u16 reason
12702 )
12703{
12704 int ret;
12705 vos_ssr_protect(__func__);
12706 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
12707 vos_ssr_unprotect(__func__);
12708
12709 return ret;
12710}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012711
Jeff Johnson295189b2012-06-20 16:38:30 -070012712/*
12713 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012714 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012715 * settings in IBSS mode.
12716 */
12717static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012718 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012719 struct cfg80211_ibss_params *params
12720 )
12721{
12722 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012723 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012724 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
12725 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012726
Jeff Johnson295189b2012-06-20 16:38:30 -070012727 ENTER();
12728
12729 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070012730 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070012731
12732 if (params->ie_len && ( NULL != params->ie) )
12733 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012734 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12735 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012736 {
12737 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12738 encryptionType = eCSR_ENCRYPT_TYPE_AES;
12739 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012740 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012741 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012742 tDot11fIEWPA dot11WPAIE;
12743 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012744 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012745
Wilson Yang00256342013-10-10 23:13:38 -070012746 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012747 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12748 params->ie_len, DOT11F_EID_WPA);
12749 if ( NULL != ie )
12750 {
12751 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12752 // Unpack the WPA IE
12753 //Skip past the EID byte and length byte - and four byte WiFi OUI
12754 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
12755 &ie[2+4],
12756 ie[1] - 4,
12757 &dot11WPAIE);
12758 /*Extract the multicast cipher, the encType for unicast
12759 cipher for wpa-none is none*/
12760 encryptionType =
12761 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
12762 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012763 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012764
Jeff Johnson295189b2012-06-20 16:38:30 -070012765 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
12766
12767 if (0 > status)
12768 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012769 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012770 __func__);
12771 return status;
12772 }
12773 }
12774
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012775 pWextState->roamProfile.AuthType.authType[0] =
12776 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012777 eCSR_AUTH_TYPE_OPEN_SYSTEM;
12778
12779 if (params->privacy)
12780 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012781 /* Security enabled IBSS, At this time there is no information available
12782 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070012783 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012784 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070012785 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012786 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070012787 *enable privacy bit in beacons */
12788
12789 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
12790 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012791 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
12792 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012793 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
12794 pWextState->roamProfile.EncryptionType.numEntries = 1;
12795 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012796 return status;
12797}
12798
12799/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012800 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012801 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012802 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012803static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012804 struct net_device *dev,
12805 struct cfg80211_ibss_params *params
12806 )
12807{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012808 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012809 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12810 tCsrRoamProfile *pRoamProfile;
12811 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012812 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12813 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012814 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070012815
12816 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012817
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012818 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12819 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
12820 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012821 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012822 "%s: device_mode = %s (%d)", __func__,
12823 hdd_device_modetoString(pAdapter->device_mode),
12824 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012825
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012826 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012827 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012828 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012829 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012830 }
12831
12832 if (NULL == pWextState)
12833 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012834 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012835 __func__);
12836 return -EIO;
12837 }
12838
Agarwal Ashish51325b52014-06-16 16:50:49 +053012839 if (vos_max_concurrent_connections_reached()) {
12840 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12841 return -ECONNREFUSED;
12842 }
12843
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012844 /*Try disconnecting if already in connected state*/
12845 status = wlan_hdd_try_disconnect(pAdapter);
12846 if ( 0 > status)
12847 {
12848 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12849 " IBSS connection"));
12850 return -EALREADY;
12851 }
12852
Jeff Johnson295189b2012-06-20 16:38:30 -070012853 pRoamProfile = &pWextState->roamProfile;
12854
12855 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
12856 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012857 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012858 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012859 return -EINVAL;
12860 }
12861
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012862 /* BSSID is provided by upper layers hence no need to AUTO generate */
12863 if (NULL != params->bssid) {
12864 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12865 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
12866 hddLog (VOS_TRACE_LEVEL_ERROR,
12867 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12868 return -EIO;
12869 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012870 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012871 }
krunal sonie9002db2013-11-25 14:24:17 -080012872 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
12873 {
12874 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12875 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
12876 {
12877 hddLog (VOS_TRACE_LEVEL_ERROR,
12878 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12879 return -EIO;
12880 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012881
12882 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080012883 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012884 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080012885 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012886
Jeff Johnson295189b2012-06-20 16:38:30 -070012887 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070012888 if (NULL !=
12889#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12890 params->chandef.chan)
12891#else
12892 params->channel)
12893#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012894 {
12895 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012896 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12897 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
12898 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12899 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012900
12901 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012902 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070012903 ieee80211_frequency_to_channel(
12904#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12905 params->chandef.chan->center_freq);
12906#else
12907 params->channel->center_freq);
12908#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012909
12910 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
12911 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070012912 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012913 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
12914 __func__);
12915 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070012916 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012917
12918 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012919 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012920 if (channelNum == validChan[indx])
12921 {
12922 break;
12923 }
12924 }
12925 if (indx >= numChans)
12926 {
12927 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012928 __func__, channelNum);
12929 return -EINVAL;
12930 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012931 /* Set the Operational Channel */
12932 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
12933 channelNum);
12934 pRoamProfile->ChannelInfo.numOfChannels = 1;
12935 pHddStaCtx->conn_info.operationChannel = channelNum;
12936 pRoamProfile->ChannelInfo.ChannelList =
12937 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070012938 }
12939
12940 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012941 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070012942 if (status < 0)
12943 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012944 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070012945 __func__);
12946 return status;
12947 }
12948
12949 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012950 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012951 params->ssid_len, params->bssid,
12952 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070012953
12954 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012955 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012956
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012957 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012958 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012959}
12960
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012961static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
12962 struct net_device *dev,
12963 struct cfg80211_ibss_params *params
12964 )
12965{
12966 int ret = 0;
12967
12968 vos_ssr_protect(__func__);
12969 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
12970 vos_ssr_unprotect(__func__);
12971
12972 return ret;
12973}
12974
Jeff Johnson295189b2012-06-20 16:38:30 -070012975/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012976 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012977 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012978 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012979static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012980 struct net_device *dev
12981 )
12982{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012983 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012984 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12985 tCsrRoamProfile *pRoamProfile;
12986 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012987 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012988
12989 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012990
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012991 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12992 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
12993 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012994 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012995 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012996 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012997 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012998 }
12999
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013000 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
13001 hdd_device_modetoString(pAdapter->device_mode),
13002 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070013003 if (NULL == pWextState)
13004 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013005 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070013006 __func__);
13007 return -EIO;
13008 }
13009
13010 pRoamProfile = &pWextState->roamProfile;
13011
13012 /* Issue disconnect only if interface type is set to IBSS */
13013 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
13014 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013015 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070013016 __func__);
13017 return -EINVAL;
13018 }
13019
13020 /* Issue Disconnect request */
13021 INIT_COMPLETION(pAdapter->disconnect_comp_var);
13022 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
13023 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
13024
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013025 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013026 return 0;
13027}
13028
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013029static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
13030 struct net_device *dev
13031 )
13032{
13033 int ret = 0;
13034
13035 vos_ssr_protect(__func__);
13036 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
13037 vos_ssr_unprotect(__func__);
13038
13039 return ret;
13040}
13041
Jeff Johnson295189b2012-06-20 16:38:30 -070013042/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013043 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070013044 * This function is used to set the phy parameters
13045 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
13046 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013047static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013048 u32 changed)
13049{
13050 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
13051 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013052 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013053
13054 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013055
13056 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013057 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
13058 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013059
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013060 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013061 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013062 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013063 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013064 }
13065
Jeff Johnson295189b2012-06-20 16:38:30 -070013066 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
13067 {
13068 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
13069 WNI_CFG_RTS_THRESHOLD_STAMAX :
13070 wiphy->rts_threshold;
13071
13072 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013073 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070013074 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013075 hddLog(VOS_TRACE_LEVEL_ERROR,
13076 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013077 __func__, rts_threshold);
13078 return -EINVAL;
13079 }
13080
13081 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
13082 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013083 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013084 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013085 hddLog(VOS_TRACE_LEVEL_ERROR,
13086 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013087 __func__, rts_threshold);
13088 return -EIO;
13089 }
13090
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013091 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013092 rts_threshold);
13093 }
13094
13095 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
13096 {
13097 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
13098 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
13099 wiphy->frag_threshold;
13100
13101 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013102 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013103 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013104 hddLog(VOS_TRACE_LEVEL_ERROR,
13105 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013106 frag_threshold);
13107 return -EINVAL;
13108 }
13109
13110 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
13111 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013112 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013113 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013114 hddLog(VOS_TRACE_LEVEL_ERROR,
13115 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013116 __func__, frag_threshold);
13117 return -EIO;
13118 }
13119
13120 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
13121 frag_threshold);
13122 }
13123
13124 if ((changed & WIPHY_PARAM_RETRY_SHORT)
13125 || (changed & WIPHY_PARAM_RETRY_LONG))
13126 {
13127 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
13128 wiphy->retry_short :
13129 wiphy->retry_long;
13130
13131 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
13132 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
13133 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013134 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013135 __func__, retry_value);
13136 return -EINVAL;
13137 }
13138
13139 if (changed & WIPHY_PARAM_RETRY_SHORT)
13140 {
13141 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
13142 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013143 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013144 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013145 hddLog(VOS_TRACE_LEVEL_ERROR,
13146 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013147 __func__, retry_value);
13148 return -EIO;
13149 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013150 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013151 __func__, retry_value);
13152 }
13153 else if (changed & WIPHY_PARAM_RETRY_SHORT)
13154 {
13155 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
13156 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013157 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013158 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013159 hddLog(VOS_TRACE_LEVEL_ERROR,
13160 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013161 __func__, retry_value);
13162 return -EIO;
13163 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013164 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013165 __func__, retry_value);
13166 }
13167 }
13168
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013169 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013170 return 0;
13171}
13172
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013173static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
13174 u32 changed)
13175{
13176 int ret;
13177
13178 vos_ssr_protect(__func__);
13179 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
13180 vos_ssr_unprotect(__func__);
13181
13182 return ret;
13183}
13184
Jeff Johnson295189b2012-06-20 16:38:30 -070013185/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013186 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013187 * This function is used to set the txpower
13188 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013189static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013190#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13191 struct wireless_dev *wdev,
13192#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013193#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013194 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013195#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013196 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013197#endif
13198 int dbm)
13199{
13200 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013201 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013202 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
13203 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013204 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013205
13206 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013207
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013208 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13209 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
13210 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013211 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013212 if (0 != status)
13213 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013214 return status;
13215 }
13216
13217 hHal = pHddCtx->hHal;
13218
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013219 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
13220 dbm, ccmCfgSetCallback,
13221 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013222 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013223 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013224 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
13225 return -EIO;
13226 }
13227
13228 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
13229 dbm);
13230
13231 switch(type)
13232 {
13233 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
13234 /* Fall through */
13235 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
13236 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
13237 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013238 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
13239 __func__);
13240 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070013241 }
13242 break;
13243 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013244 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070013245 __func__);
13246 return -EOPNOTSUPP;
13247 break;
13248 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013249 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
13250 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070013251 return -EIO;
13252 }
13253
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013254 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013255 return 0;
13256}
13257
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013258static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
13259#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13260 struct wireless_dev *wdev,
13261#endif
13262#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13263 enum tx_power_setting type,
13264#else
13265 enum nl80211_tx_power_setting type,
13266#endif
13267 int dbm)
13268{
13269 int ret;
13270 vos_ssr_protect(__func__);
13271 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
13272#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13273 wdev,
13274#endif
13275#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13276 type,
13277#else
13278 type,
13279#endif
13280 dbm);
13281 vos_ssr_unprotect(__func__);
13282
13283 return ret;
13284}
13285
Jeff Johnson295189b2012-06-20 16:38:30 -070013286/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013287 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013288 * This function is used to read the txpower
13289 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013290static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013291#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13292 struct wireless_dev *wdev,
13293#endif
13294 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070013295{
13296
13297 hdd_adapter_t *pAdapter;
13298 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013299 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013300
Jeff Johnsone7245742012-09-05 17:12:55 -070013301 ENTER();
13302
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013303 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013304 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013305 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013306 *dbm = 0;
13307 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013308 }
13309
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
13311 if (NULL == pAdapter)
13312 {
13313 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
13314 return -ENOENT;
13315 }
13316
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053013317 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13318 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
13319 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070013320 wlan_hdd_get_classAstats(pAdapter);
13321 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
13322
Jeff Johnsone7245742012-09-05 17:12:55 -070013323 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013324 return 0;
13325}
13326
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013327static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
13328#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13329 struct wireless_dev *wdev,
13330#endif
13331 int *dbm)
13332{
13333 int ret;
13334
13335 vos_ssr_protect(__func__);
13336 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
13337#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13338 wdev,
13339#endif
13340 dbm);
13341 vos_ssr_unprotect(__func__);
13342
13343 return ret;
13344}
13345
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013346static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013347#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13348 const u8* mac,
13349#else
13350 u8* mac,
13351#endif
13352 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070013353{
13354 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13355 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13356 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053013357 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013358
13359 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
13360 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070013361
13362 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
13363 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
13364 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
13365 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
13366 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
13367 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
13368 tANI_U16 maxRate = 0;
13369 tANI_U16 myRate;
13370 tANI_U16 currentRate = 0;
13371 tANI_U8 maxSpeedMCS = 0;
13372 tANI_U8 maxMCSIdx = 0;
13373 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053013374 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013375 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013376 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013377
Leo Chang6f8870f2013-03-26 18:11:36 -070013378#ifdef WLAN_FEATURE_11AC
13379 tANI_U32 vht_mcs_map;
13380 eDataRate11ACMaxMcs vhtMaxMcs;
13381#endif /* WLAN_FEATURE_11AC */
13382
Jeff Johnsone7245742012-09-05 17:12:55 -070013383 ENTER();
13384
Jeff Johnson295189b2012-06-20 16:38:30 -070013385 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
13386 (0 == ssidlen))
13387 {
13388 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
13389 " Invalid ssidlen, %d", __func__, ssidlen);
13390 /*To keep GUI happy*/
13391 return 0;
13392 }
13393
Mukul Sharma811205f2014-07-09 21:07:30 +053013394 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
13395 {
13396 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13397 "%s: Roaming in progress, so unable to proceed this request", __func__);
13398 return 0;
13399 }
13400
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013401 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013402 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013403 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013404 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013405 }
13406
Jeff Johnson295189b2012-06-20 16:38:30 -070013407
Kiet Lam3b17fc82013-09-27 05:24:08 +053013408 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
13409 sinfo->filled |= STATION_INFO_SIGNAL;
13410
c_hpothu09f19542014-05-30 21:53:31 +053013411 wlan_hdd_get_station_stats(pAdapter);
13412 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
13413
13414 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053013415 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
13416 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053013417 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053013418 {
13419 rate_flags = pAdapter->maxRateFlags;
13420 }
c_hpothu44ff4e02014-05-08 00:13:57 +053013421
Jeff Johnson295189b2012-06-20 16:38:30 -070013422 //convert to the UI units of 100kbps
13423 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
13424
13425#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070013426 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 -070013427 sinfo->signal,
13428 pCfg->reportMaxLinkSpeed,
13429 myRate,
13430 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013431 (int) pCfg->linkSpeedRssiMid,
13432 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070013433 (int) rate_flags,
13434 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013435#endif //LINKSPEED_DEBUG_ENABLED
13436
13437 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
13438 {
13439 // we do not want to necessarily report the current speed
13440 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
13441 {
13442 // report the max possible speed
13443 rssidx = 0;
13444 }
13445 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
13446 {
13447 // report the max possible speed with RSSI scaling
13448 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
13449 {
13450 // report the max possible speed
13451 rssidx = 0;
13452 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013453 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070013454 {
13455 // report middle speed
13456 rssidx = 1;
13457 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013458 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
13459 {
13460 // report middle speed
13461 rssidx = 2;
13462 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013463 else
13464 {
13465 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013466 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070013467 }
13468 }
13469 else
13470 {
13471 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
13472 hddLog(VOS_TRACE_LEVEL_ERROR,
13473 "%s: Invalid value for reportMaxLinkSpeed: %u",
13474 __func__, pCfg->reportMaxLinkSpeed);
13475 rssidx = 0;
13476 }
13477
13478 maxRate = 0;
13479
13480 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013481 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
13482 OperationalRates, &ORLeng))
13483 {
13484 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13485 /*To keep GUI happy*/
13486 return 0;
13487 }
13488
Jeff Johnson295189b2012-06-20 16:38:30 -070013489 for (i = 0; i < ORLeng; i++)
13490 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013491 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 {
13493 /* Validate Rate Set */
13494 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
13495 {
13496 currentRate = supported_data_rate[j].supported_rate[rssidx];
13497 break;
13498 }
13499 }
13500 /* Update MAX rate */
13501 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13502 }
13503
13504 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013505 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
13506 ExtendedRates, &ERLeng))
13507 {
13508 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13509 /*To keep GUI happy*/
13510 return 0;
13511 }
13512
Jeff Johnson295189b2012-06-20 16:38:30 -070013513 for (i = 0; i < ERLeng; i++)
13514 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013515 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013516 {
13517 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
13518 {
13519 currentRate = supported_data_rate[j].supported_rate[rssidx];
13520 break;
13521 }
13522 }
13523 /* Update MAX rate */
13524 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13525 }
c_hpothu79aab322014-07-14 21:11:01 +053013526
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013527 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053013528 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013529 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053013530 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070013531 {
c_hpothu79aab322014-07-14 21:11:01 +053013532 if (rate_flags & eHAL_TX_RATE_VHT80)
13533 mode = 2;
13534 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
13535 mode = 1;
13536 else
13537 mode = 0;
13538
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013539 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
13540 MCSRates, &MCSLeng))
13541 {
13542 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13543 /*To keep GUI happy*/
13544 return 0;
13545 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070013547#ifdef WLAN_FEATURE_11AC
13548 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013549 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070013550 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013551 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013552 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070013553 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070013554 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013555 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013556 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013557 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070013558 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013559 maxMCSIdx = 7;
13560 }
13561 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
13562 {
13563 maxMCSIdx = 8;
13564 }
13565 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
13566 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013567 //VHT20 is supporting 0~8
13568 if (rate_flags & eHAL_TX_RATE_VHT20)
13569 maxMCSIdx = 8;
13570 else
13571 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070013572 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013573
c_hpothu79aab322014-07-14 21:11:01 +053013574 if (0 != rssidx)/*check for scaled */
13575 {
13576 //get middle rate MCS index if rssi=1/2
13577 for (i=0; i <= maxMCSIdx; i++)
13578 {
13579 if (sinfo->signal <= rssiMcsTbl[mode][i])
13580 {
13581 maxMCSIdx = i;
13582 break;
13583 }
13584 }
13585 }
13586
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013587 if (rate_flags & eHAL_TX_RATE_VHT80)
13588 {
13589 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
13590 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
13591 }
13592 else if (rate_flags & eHAL_TX_RATE_VHT40)
13593 {
13594 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
13595 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
13596 }
13597 else if (rate_flags & eHAL_TX_RATE_VHT20)
13598 {
13599 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
13600 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
13601 }
13602
Leo Chang6f8870f2013-03-26 18:11:36 -070013603 maxSpeedMCS = 1;
13604 if (currentRate > maxRate)
13605 {
13606 maxRate = currentRate;
13607 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013608
Leo Chang6f8870f2013-03-26 18:11:36 -070013609 }
13610 else
13611#endif /* WLAN_FEATURE_11AC */
13612 {
13613 if (rate_flags & eHAL_TX_RATE_HT40)
13614 {
13615 rateFlag |= 1;
13616 }
13617 if (rate_flags & eHAL_TX_RATE_SGI)
13618 {
13619 rateFlag |= 2;
13620 }
13621
Girish Gowli01abcee2014-07-31 20:18:55 +053013622 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053013623 if (rssidx == 1 || rssidx == 2)
13624 {
13625 //get middle rate MCS index if rssi=1/2
13626 for (i=0; i <= 7; i++)
13627 {
13628 if (sinfo->signal <= rssiMcsTbl[mode][i])
13629 {
13630 temp = i+1;
13631 break;
13632 }
13633 }
13634 }
c_hpothu79aab322014-07-14 21:11:01 +053013635
13636 for (i = 0; i < MCSLeng; i++)
13637 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013638 for (j = 0; j < temp; j++)
13639 {
13640 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
13641 {
13642 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013643 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013644 break;
13645 }
13646 }
13647 if ((j < temp) && (currentRate > maxRate))
13648 {
13649 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070013650 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013651 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013652 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013653 }
13654 }
13655
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013656 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
13657 {
13658 maxRate = myRate;
13659 maxSpeedMCS = 1;
13660 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13661 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013662 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053013663 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070013664 {
13665 maxRate = myRate;
13666 if (rate_flags & eHAL_TX_RATE_LEGACY)
13667 {
13668 maxSpeedMCS = 0;
13669 }
13670 else
13671 {
13672 maxSpeedMCS = 1;
13673 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13674 }
13675 }
13676
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013677 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070013678 {
13679 sinfo->txrate.legacy = maxRate;
13680#ifdef LINKSPEED_DEBUG_ENABLED
13681 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
13682#endif //LINKSPEED_DEBUG_ENABLED
13683 }
13684 else
13685 {
13686 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070013687#ifdef WLAN_FEATURE_11AC
13688 sinfo->txrate.nss = 1;
13689 if (rate_flags & eHAL_TX_RATE_VHT80)
13690 {
13691 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013692 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070013693 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013694 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070013695 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013696 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13697 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13698 }
13699 else if (rate_flags & eHAL_TX_RATE_VHT20)
13700 {
13701 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13702 }
13703#endif /* WLAN_FEATURE_11AC */
13704 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
13705 {
13706 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13707 if (rate_flags & eHAL_TX_RATE_HT40)
13708 {
13709 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13710 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013711 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013712 if (rate_flags & eHAL_TX_RATE_SGI)
13713 {
13714 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13715 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013716
Jeff Johnson295189b2012-06-20 16:38:30 -070013717#ifdef LINKSPEED_DEBUG_ENABLED
13718 pr_info("Reporting MCS rate %d flags %x\n",
13719 sinfo->txrate.mcs,
13720 sinfo->txrate.flags );
13721#endif //LINKSPEED_DEBUG_ENABLED
13722 }
13723 }
13724 else
13725 {
13726 // report current rate instead of max rate
13727
13728 if (rate_flags & eHAL_TX_RATE_LEGACY)
13729 {
13730 //provide to the UI in units of 100kbps
13731 sinfo->txrate.legacy = myRate;
13732#ifdef LINKSPEED_DEBUG_ENABLED
13733 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
13734#endif //LINKSPEED_DEBUG_ENABLED
13735 }
13736 else
13737 {
13738 //must be MCS
13739 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013740#ifdef WLAN_FEATURE_11AC
13741 sinfo->txrate.nss = 1;
13742 if (rate_flags & eHAL_TX_RATE_VHT80)
13743 {
13744 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13745 }
13746 else
13747#endif /* WLAN_FEATURE_11AC */
13748 {
13749 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13750 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 if (rate_flags & eHAL_TX_RATE_SGI)
13752 {
13753 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13754 }
13755 if (rate_flags & eHAL_TX_RATE_HT40)
13756 {
13757 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13758 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013759#ifdef WLAN_FEATURE_11AC
13760 else if (rate_flags & eHAL_TX_RATE_VHT80)
13761 {
13762 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
13763 }
13764#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070013765#ifdef LINKSPEED_DEBUG_ENABLED
13766 pr_info("Reporting actual MCS rate %d flags %x\n",
13767 sinfo->txrate.mcs,
13768 sinfo->txrate.flags );
13769#endif //LINKSPEED_DEBUG_ENABLED
13770 }
13771 }
13772 sinfo->filled |= STATION_INFO_TX_BITRATE;
13773
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013774 sinfo->tx_packets =
13775 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
13776 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
13777 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
13778 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
13779
13780 sinfo->tx_retries =
13781 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
13782 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
13783 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
13784 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
13785
13786 sinfo->tx_failed =
13787 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
13788 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
13789 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
13790 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
13791
13792 sinfo->filled |=
13793 STATION_INFO_TX_PACKETS |
13794 STATION_INFO_TX_RETRIES |
13795 STATION_INFO_TX_FAILED;
13796
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013797 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13798 TRACE_CODE_HDD_CFG80211_GET_STA,
13799 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013800 EXIT();
13801 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013802}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013803#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
13804static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13805 const u8* mac, struct station_info *sinfo)
13806#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013807static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13808 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013809#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013810{
13811 int ret;
13812
13813 vos_ssr_protect(__func__);
13814 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
13815 vos_ssr_unprotect(__func__);
13816
13817 return ret;
13818}
13819
13820static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070013821 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070013822{
13823 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013824 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013825 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013826 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013827
Jeff Johnsone7245742012-09-05 17:12:55 -070013828 ENTER();
13829
Jeff Johnson295189b2012-06-20 16:38:30 -070013830 if (NULL == pAdapter)
13831 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013832 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013833 return -ENODEV;
13834 }
13835
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013836 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13837 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
13838 pAdapter->sessionId, timeout));
13839
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013840 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013841 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013842 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013843 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013844 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013845 }
13846
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013847 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
13848 (TRUE == pHddCtx->hdd_wlan_suspended) &&
13849 (pHddCtx->cfg_ini->fhostArpOffload) &&
13850 (eConnectionState_Associated ==
13851 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13852 {
Amar Singhald53568e2013-09-26 11:03:45 -070013853
13854 hddLog(VOS_TRACE_LEVEL_INFO,
13855 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053013856 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013857 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13858 {
13859 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013860 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013861 __func__, vos_status);
13862 }
13863 }
13864
Jeff Johnson295189b2012-06-20 16:38:30 -070013865 /**The get power cmd from the supplicant gets updated by the nl only
13866 *on successful execution of the function call
13867 *we are oppositely mapped w.r.t mode in the driver
13868 **/
13869 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
13870
13871 if (VOS_STATUS_E_FAILURE == vos_status)
13872 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013873 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13874 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013875 return -EINVAL;
13876 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013877 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013878 return 0;
13879}
13880
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013881static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
13882 struct net_device *dev, bool mode, int timeout)
13883{
13884 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013885
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013886 vos_ssr_protect(__func__);
13887 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
13888 vos_ssr_unprotect(__func__);
13889
13890 return ret;
13891}
Jeff Johnson295189b2012-06-20 16:38:30 -070013892#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013893static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
13894 struct net_device *netdev,
13895 u8 key_index)
13896{
13897 ENTER();
13898 return 0;
13899}
13900
Jeff Johnson295189b2012-06-20 16:38:30 -070013901static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013902 struct net_device *netdev,
13903 u8 key_index)
13904{
13905 int ret;
13906 vos_ssr_protect(__func__);
13907 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
13908 vos_ssr_unprotect(__func__);
13909 return ret;
13910}
13911#endif //LINUX_VERSION_CODE
13912
13913#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13914static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13915 struct net_device *dev,
13916 struct ieee80211_txq_params *params)
13917{
13918 ENTER();
13919 return 0;
13920}
13921#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13922static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13923 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013924{
Jeff Johnsone7245742012-09-05 17:12:55 -070013925 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070013926 return 0;
13927}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013928#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070013929
13930#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13931static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013932 struct net_device *dev,
13933 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013934{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013935 int ret;
13936
13937 vos_ssr_protect(__func__);
13938 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
13939 vos_ssr_unprotect(__func__);
13940 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013941}
13942#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13943static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
13944 struct ieee80211_txq_params *params)
13945{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013946 int ret;
13947
13948 vos_ssr_protect(__func__);
13949 ret = __wlan_hdd_set_txq_params(wiphy, params);
13950 vos_ssr_unprotect(__func__);
13951 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013952}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013953#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013954
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013955static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013956 struct net_device *dev,
13957 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070013958{
13959 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013960 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013961 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013962 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013963 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013964 v_CONTEXT_t pVosContext = NULL;
13965 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013966
Jeff Johnsone7245742012-09-05 17:12:55 -070013967 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013968
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013969 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013971 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013972 return -EINVAL;
13973 }
13974
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013975 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13976 TRACE_CODE_HDD_CFG80211_DEL_STA,
13977 pAdapter->sessionId, pAdapter->device_mode));
13978
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013979 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13980 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013981 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013982 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013983 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013984 }
13985
Jeff Johnson295189b2012-06-20 16:38:30 -070013986 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013987 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 )
13989 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013990 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13991 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13992 if(pSapCtx == NULL){
13993 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13994 FL("psapCtx is NULL"));
13995 return -ENOENT;
13996 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013997 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070013998 {
13999 v_U16_t i;
14000 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
14001 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014002 if ((pSapCtx->aStaInfo[i].isUsed) &&
14003 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070014004 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014005 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014006 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014007 ETHER_ADDR_LEN);
14008
Jeff Johnson295189b2012-06-20 16:38:30 -070014009 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080014010 "%s: Delete STA with MAC::"
14011 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014012 __func__,
14013 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
14014 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070014015 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014016 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014017 }
14018 }
14019 }
14020 else
14021 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014022
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014023 vos_status = hdd_softap_GetStaId(pAdapter,
14024 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014025 if (!VOS_IS_STATUS_SUCCESS(vos_status))
14026 {
14027 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080014028 "%s: Skip this DEL STA as this is not used::"
14029 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014030 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014031 return -ENOENT;
14032 }
14033
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014034 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014035 {
14036 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080014037 "%s: Skip this DEL STA as deauth is in progress::"
14038 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014039 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014040 return -ENOENT;
14041 }
14042
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014043 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014044
Jeff Johnson295189b2012-06-20 16:38:30 -070014045 hddLog(VOS_TRACE_LEVEL_INFO,
14046 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080014047 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014048 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014049 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014050
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014051 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014052 if (!VOS_IS_STATUS_SUCCESS(vos_status))
14053 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014054 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014055 hddLog(VOS_TRACE_LEVEL_INFO,
14056 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080014057 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014058 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014059 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014060 return -ENOENT;
14061 }
14062
Jeff Johnson295189b2012-06-20 16:38:30 -070014063 }
14064 }
14065
14066 EXIT();
14067
14068 return 0;
14069}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014070
14071#ifdef CFG80211_DEL_STA_V2
14072static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14073 struct net_device *dev,
14074 struct station_del_parameters *param)
14075#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014076#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
14077static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14078 struct net_device *dev, const u8 *mac)
14079#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014080static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14081 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014082#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014083#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014084{
14085 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014086 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070014087
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014088 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014089
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014090#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014091 if (NULL == param) {
14092 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014093 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014094 return -EINVAL;
14095 }
14096
14097 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
14098 param->subtype, &delStaParams);
14099
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014100#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053014101 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014102 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014103#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014104 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
14105
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014106 vos_ssr_unprotect(__func__);
14107
14108 return ret;
14109}
14110
14111static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014112 struct net_device *dev,
14113#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14114 const u8 *mac,
14115#else
14116 u8 *mac,
14117#endif
14118 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014119{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014120 hdd_adapter_t *pAdapter;
14121 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014122 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014123#ifdef FEATURE_WLAN_TDLS
14124 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014125
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014126 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014127
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014128 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14129 if (NULL == pAdapter)
14130 {
14131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14132 "%s: Adapter is NULL",__func__);
14133 return -EINVAL;
14134 }
14135 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14136 status = wlan_hdd_validate_context(pHddCtx);
14137 if (0 != status)
14138 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014139 return status;
14140 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014141
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014142 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14143 TRACE_CODE_HDD_CFG80211_ADD_STA,
14144 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014145 mask = params->sta_flags_mask;
14146
14147 set = params->sta_flags_set;
14148
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014149 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014150 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
14151 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014152
14153 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
14154 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080014155 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014156 }
14157 }
14158#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014159 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014160 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014161}
14162
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014163#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
14164static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
14165 struct net_device *dev, const u8 *mac,
14166 struct station_parameters *params)
14167#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014168static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
14169 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014170#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014171{
14172 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014173
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014174 vos_ssr_protect(__func__);
14175 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
14176 vos_ssr_unprotect(__func__);
14177
14178 return ret;
14179}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014180#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070014181
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014182static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070014183 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014184{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014185 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14186 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014187 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014188 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014189 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014190 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070014191
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014192 ENTER();
14193
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014194 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014195 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014196 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014197 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014198 return -EINVAL;
14199 }
14200
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014201 if (!pmksa) {
14202 hddLog(LOGE, FL("pmksa is NULL"));
14203 return -EINVAL;
14204 }
14205
14206 if (!pmksa->bssid || !pmksa->pmkid) {
14207 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
14208 pmksa->bssid, pmksa->pmkid);
14209 return -EINVAL;
14210 }
14211
14212 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
14213 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14214
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014215 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14216 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014217 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014218 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014219 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014220 }
14221
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014222 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014223 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14224
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014225 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
14226 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014227
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014228 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014229 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014230 &pmk_id, 1, FALSE);
14231
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014232 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14233 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
14234 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014235
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014236 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014237 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014238}
14239
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014240static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
14241 struct cfg80211_pmksa *pmksa)
14242{
14243 int ret;
14244
14245 vos_ssr_protect(__func__);
14246 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
14247 vos_ssr_unprotect(__func__);
14248
14249 return ret;
14250}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014251
Wilson Yang6507c4e2013-10-01 20:11:19 -070014252
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014253static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070014254 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014255{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014256 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14257 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014258 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014259 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014260
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014261 ENTER();
14262
Wilson Yang6507c4e2013-10-01 20:11:19 -070014263 /* Validate pAdapter */
14264 if (NULL == pAdapter)
14265 {
14266 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
14267 return -EINVAL;
14268 }
14269
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014270 if (!pmksa) {
14271 hddLog(LOGE, FL("pmksa is NULL"));
14272 return -EINVAL;
14273 }
14274
14275 if (!pmksa->bssid) {
14276 hddLog(LOGE, FL("pmksa->bssid is NULL"));
14277 return -EINVAL;
14278 }
14279
Kiet Lam98c46a12014-10-31 15:34:57 -070014280 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
14281 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14282
Wilson Yang6507c4e2013-10-01 20:11:19 -070014283 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14284 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014285 if (0 != status)
14286 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014287 return status;
14288 }
14289
14290 /*Retrieve halHandle*/
14291 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14292
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014293 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14294 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
14295 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014296 /* Delete the PMKID CSR cache */
14297 if (eHAL_STATUS_SUCCESS !=
14298 sme_RoamDelPMKIDfromCache(halHandle,
14299 pAdapter->sessionId, pmksa->bssid, FALSE)) {
14300 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
14301 MAC_ADDR_ARRAY(pmksa->bssid));
14302 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014303 }
14304
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014305 EXIT();
14306 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014307}
14308
Wilson Yang6507c4e2013-10-01 20:11:19 -070014309
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014310static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
14311 struct cfg80211_pmksa *pmksa)
14312{
14313 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014314
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014315 vos_ssr_protect(__func__);
14316 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
14317 vos_ssr_unprotect(__func__);
14318
14319 return ret;
14320
14321}
14322
14323static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014324{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014325 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14326 tHalHandle halHandle;
14327 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014328 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014329
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014330 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070014331
14332 /* Validate pAdapter */
14333 if (NULL == pAdapter)
14334 {
14335 hddLog(VOS_TRACE_LEVEL_ERROR,
14336 "%s: Invalid Adapter" ,__func__);
14337 return -EINVAL;
14338 }
14339
14340 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14341 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014342 if (0 != status)
14343 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014344 return status;
14345 }
14346
14347 /*Retrieve halHandle*/
14348 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14349
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014350 /* Flush the PMKID cache in CSR */
14351 if (eHAL_STATUS_SUCCESS !=
14352 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
14353 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
14354 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014355 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014356 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080014357 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014358}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014359
14360static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
14361{
14362 int ret;
14363
14364 vos_ssr_protect(__func__);
14365 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
14366 vos_ssr_unprotect(__func__);
14367
14368 return ret;
14369}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014370#endif
14371
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014372#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014373static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14374 struct net_device *dev,
14375 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014376{
14377 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14378 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014379 hdd_context_t *pHddCtx;
14380 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014381
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014382 ENTER();
14383
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014384 if (NULL == pAdapter)
14385 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014386 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014387 return -ENODEV;
14388 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014389 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14390 ret = wlan_hdd_validate_context(pHddCtx);
14391 if (0 != ret)
14392 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014393 return ret;
14394 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014395 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014396 if (NULL == pHddStaCtx)
14397 {
14398 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
14399 return -EINVAL;
14400 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014401
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014402 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14403 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
14404 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014405 // Added for debug on reception of Re-assoc Req.
14406 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
14407 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014408 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014409 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080014410 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014411 }
14412
14413#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080014414 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014415 ftie->ie_len);
14416#endif
14417
14418 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014419 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14420 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014421 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014422
14423 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014424 return 0;
14425}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014426
14427static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14428 struct net_device *dev,
14429 struct cfg80211_update_ft_ies_params *ftie)
14430{
14431 int ret;
14432
14433 vos_ssr_protect(__func__);
14434 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
14435 vos_ssr_unprotect(__func__);
14436
14437 return ret;
14438}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014439#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014440
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014441#ifdef FEATURE_WLAN_SCAN_PNO
14442
14443void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
14444 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
14445{
14446 int ret;
14447 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
14448 hdd_context_t *pHddCtx;
14449
Nirav Shah80830bf2013-12-31 16:35:12 +053014450 ENTER();
14451
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014452 if (NULL == pAdapter)
14453 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014454 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014455 "%s: HDD adapter is Null", __func__);
14456 return ;
14457 }
14458
14459 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14460 if (NULL == pHddCtx)
14461 {
14462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14463 "%s: HDD context is Null!!!", __func__);
14464 return ;
14465 }
14466
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014467 spin_lock(&pHddCtx->schedScan_lock);
14468 if (TRUE == pHddCtx->isWiphySuspended)
14469 {
14470 pHddCtx->isSchedScanUpdatePending = TRUE;
14471 spin_unlock(&pHddCtx->schedScan_lock);
14472 hddLog(VOS_TRACE_LEVEL_INFO,
14473 "%s: Update cfg80211 scan database after it resume", __func__);
14474 return ;
14475 }
14476 spin_unlock(&pHddCtx->schedScan_lock);
14477
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014478 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
14479
14480 if (0 > ret)
14481 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
14482
14483 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14485 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014486}
14487
14488/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014489 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014490 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014491 */
14492static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
14493{
14494 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
14495 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014496 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014497 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14498 int status = 0;
14499 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
14500
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014501 /* The current firmware design does not allow PNO during any
14502 * active sessions. Hence, determine the active sessions
14503 * and return a failure.
14504 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014505 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
14506 {
14507 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014508 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014509
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014510 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
14511 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
14512 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
14513 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
14514 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053014515 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014516 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014517 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014518 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014519 }
14520 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14521 pAdapterNode = pNext;
14522 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014523 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014524}
14525
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014526void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
14527{
14528 hdd_adapter_t *pAdapter = callbackContext;
14529 hdd_context_t *pHddCtx;
14530
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014531 ENTER();
14532
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014533 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
14534 {
14535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14536 FL("Invalid adapter or adapter has invalid magic"));
14537 return;
14538 }
14539
14540 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14541 if (0 != wlan_hdd_validate_context(pHddCtx))
14542 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014543 return;
14544 }
14545
c_hpothub53c45d2014-08-18 16:53:14 +053014546 if (VOS_STATUS_SUCCESS != status)
14547 {
14548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014549 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053014550 pHddCtx->isPnoEnable = FALSE;
14551 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014552
14553 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
14554 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014555 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014556}
14557
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014558/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014559 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
14560 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014561 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014562static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014563 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14564{
14565 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014566 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014567 hdd_context_t *pHddCtx;
14568 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014569 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053014570 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
14571 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014572 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14573 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014574 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014575 hdd_config_t *pConfig = NULL;
14576 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014577
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014578 ENTER();
14579
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014580 if (NULL == pAdapter)
14581 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014582 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014583 "%s: HDD adapter is Null", __func__);
14584 return -ENODEV;
14585 }
14586
14587 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014588 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014589
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014590 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014591 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014592 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014593 }
14594
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014595 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014596 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14597 if (NULL == hHal)
14598 {
14599 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14600 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014601 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014602 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014603 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14604 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
14605 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053014606 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014607 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053014608 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014609 {
14610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14611 "%s: aborting the existing scan is unsuccessfull", __func__);
14612 return -EBUSY;
14613 }
14614
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014615 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014616 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014618 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014619 return -EBUSY;
14620 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014621
c_hpothu37f21312014-04-09 21:49:54 +053014622 if (TRUE == pHddCtx->isPnoEnable)
14623 {
14624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14625 FL("already PNO is enabled"));
14626 return -EBUSY;
14627 }
c_hpothu225aa7c2014-10-22 17:45:13 +053014628
14629 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
14630 {
14631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14632 "%s: abort ROC failed ", __func__);
14633 return -EBUSY;
14634 }
14635
c_hpothu37f21312014-04-09 21:49:54 +053014636 pHddCtx->isPnoEnable = TRUE;
14637
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014638 pnoRequest.enable = 1; /*Enable PNO */
14639 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014640
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014641 if (( !pnoRequest.ucNetworksCount ) ||
14642 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014643 {
14644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014645 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014646 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014647 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014648 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014649 goto error;
14650 }
14651
14652 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
14653 {
14654 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014655 "%s: Incorrect number of channels %d",
14656 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014657 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014658 goto error;
14659 }
14660
14661 /* Framework provides one set of channels(all)
14662 * common for all saved profile */
14663 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14664 channels_allowed, &num_channels_allowed))
14665 {
14666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14667 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014668 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014669 goto error;
14670 }
14671 /* Checking each channel against allowed channel list */
14672 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053014673 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014674 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014675 char chList [(request->n_channels*5)+1];
14676 int len;
14677 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014678 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014679 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014680 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014681 if (request->channels[i]->hw_value == channels_allowed[indx])
14682 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014683 if ((!pConfig->enableDFSPnoChnlScan) &&
14684 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
14685 {
14686 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14687 "%s : Dropping DFS channel : %d",
14688 __func__,channels_allowed[indx]);
14689 num_ignore_dfs_ch++;
14690 break;
14691 }
14692
Nirav Shah80830bf2013-12-31 16:35:12 +053014693 valid_ch[num_ch++] = request->channels[i]->hw_value;
14694 len += snprintf(chList+len, 5, "%d ",
14695 request->channels[i]->hw_value);
14696 break ;
14697 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014698 }
14699 }
Nirav Shah80830bf2013-12-31 16:35:12 +053014700 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014701
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014702 /*If all channels are DFS and dropped, then ignore the PNO request*/
14703 if (num_ignore_dfs_ch == request->n_channels)
14704 {
14705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14706 "%s : All requested channels are DFS channels", __func__);
14707 ret = -EINVAL;
14708 goto error;
14709 }
14710 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014711
14712 pnoRequest.aNetworks =
14713 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14714 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014715 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014716 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14717 FL("failed to allocate memory aNetworks %u"),
14718 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14719 goto error;
14720 }
14721 vos_mem_zero(pnoRequest.aNetworks,
14722 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14723
14724 /* Filling per profile params */
14725 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
14726 {
14727 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014728 request->match_sets[i].ssid.ssid_len;
14729
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014730 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
14731 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014732 {
14733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014734 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014735 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014736 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014737 goto error;
14738 }
14739
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014740 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014741 request->match_sets[i].ssid.ssid,
14742 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14744 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014745 i, pnoRequest.aNetworks[i].ssId.ssId);
14746 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
14747 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
14748 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014749
14750 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014751 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
14752 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014753
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014754 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014755 }
14756
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014757 for (i = 0; i < request->n_ssids; i++)
14758 {
14759 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014760 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014761 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014762 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014763 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014764 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014765 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014766 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014767 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014768 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014769 break;
14770 }
14771 j++;
14772 }
14773 }
14774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14775 "Number of hidden networks being Configured = %d",
14776 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080014778 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014779
14780 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14781 if (pnoRequest.p24GProbeTemplate == NULL)
14782 {
14783 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14784 FL("failed to allocate memory p24GProbeTemplate %u"),
14785 SIR_PNO_MAX_PB_REQ_SIZE);
14786 goto error;
14787 }
14788
14789 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14790 if (pnoRequest.p5GProbeTemplate == NULL)
14791 {
14792 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14793 FL("failed to allocate memory p5GProbeTemplate %u"),
14794 SIR_PNO_MAX_PB_REQ_SIZE);
14795 goto error;
14796 }
14797
14798 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14799 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14800
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053014801 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
14802 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014803 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014804 pnoRequest.us24GProbeTemplateLen = request->ie_len;
14805 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
14806 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014807
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014808 pnoRequest.us5GProbeTemplateLen = request->ie_len;
14809 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
14810 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014811 }
14812
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014813 /* Driver gets only one time interval which is hardcoded in
14814 * supplicant for 10000ms. Taking power consumption into account 6 timers
14815 * will be used, Timervalue is increased exponentially i.e 10,20,40,
14816 * 80,160,320 secs. And number of scan cycle for each timer
14817 * is configurable through INI param gPNOScanTimerRepeatValue.
14818 * If it is set to 0 only one timer will be used and PNO scan cycle
14819 * will be repeated after each interval specified by supplicant
14820 * till PNO is disabled.
14821 */
14822 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014823 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014824 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014825 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014826 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
14827
14828 tempInterval = (request->interval)/1000;
14829 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14830 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
14831 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014832 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014833 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014834 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014835 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014836 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014837 tempInterval *= 2;
14838 }
14839 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014840 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014841
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014842 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014843
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014844 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014845 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
14846 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014847 pAdapter->pno_req_status = 0;
14848
Nirav Shah80830bf2013-12-31 16:35:12 +053014849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14850 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014851 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
14852 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053014853
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014854 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014855 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014856 hdd_cfg80211_sched_scan_done_callback, pAdapter);
14857 if (eHAL_STATUS_SUCCESS != status)
14858 {
14859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014860 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014861 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014862 goto error;
14863 }
14864
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014865 ret = wait_for_completion_timeout(
14866 &pAdapter->pno_comp_var,
14867 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
14868 if (0 >= ret)
14869 {
14870 // Did not receive the response for PNO enable in time.
14871 // Assuming the PNO enable was success.
14872 // Returning error from here, because we timeout, results
14873 // in side effect of Wifi (Wifi Setting) not to work.
14874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14875 FL("Timed out waiting for PNO to be Enabled"));
14876 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014877 }
14878
14879 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053014880 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014881
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014882error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14884 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053014885 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014886 if (pnoRequest.aNetworks)
14887 vos_mem_free(pnoRequest.aNetworks);
14888 if (pnoRequest.p24GProbeTemplate)
14889 vos_mem_free(pnoRequest.p24GProbeTemplate);
14890 if (pnoRequest.p5GProbeTemplate)
14891 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014892
14893 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014894 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014895}
14896
14897/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014898 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
14899 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014900 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014901static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
14902 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14903{
14904 int ret;
14905
14906 vos_ssr_protect(__func__);
14907 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
14908 vos_ssr_unprotect(__func__);
14909
14910 return ret;
14911}
14912
14913/*
14914 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
14915 * Function to disable PNO
14916 */
14917static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014918 struct net_device *dev)
14919{
14920 eHalStatus status = eHAL_STATUS_FAILURE;
14921 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14922 hdd_context_t *pHddCtx;
14923 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014924 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014925 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014926
14927 ENTER();
14928
14929 if (NULL == pAdapter)
14930 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014932 "%s: HDD adapter is Null", __func__);
14933 return -ENODEV;
14934 }
14935
14936 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014937
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014938 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014939 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014940 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014941 "%s: HDD context is Null", __func__);
14942 return -ENODEV;
14943 }
14944
14945 /* The return 0 is intentional when isLogpInProgress and
14946 * isLoadUnloadInProgress. We did observe a crash due to a return of
14947 * failure in sched_scan_stop , especially for a case where the unload
14948 * of the happens at the same time. The function __cfg80211_stop_sched_scan
14949 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
14950 * success. If it returns a failure , then its next invocation due to the
14951 * clean up of the second interface will have the dev pointer corresponding
14952 * to the first one leading to a crash.
14953 */
14954 if (pHddCtx->isLogpInProgress)
14955 {
14956 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14957 "%s: LOGP in Progress. Ignore!!!", __func__);
14958 return ret;
14959 }
14960
Mihir Shete18156292014-03-11 15:38:30 +053014961 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014962 {
14963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14964 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14965 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014966 }
14967
14968 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14969 if (NULL == hHal)
14970 {
14971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14972 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014973 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014974 }
14975
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014976 pnoRequest.enable = 0; /* Disable PNO */
14977 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014978
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014979 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14980 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
14981 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014982 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014983 pAdapter->sessionId,
14984 NULL, pAdapter);
14985 if (eHAL_STATUS_SUCCESS != status)
14986 {
14987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14988 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014989 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014990 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014991 }
c_hpothu37f21312014-04-09 21:49:54 +053014992 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014993
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014994error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014995 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014996 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014997
14998 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014999 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015000}
15001
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053015002/*
15003 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
15004 * NL interface to disable PNO
15005 */
15006static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
15007 struct net_device *dev)
15008{
15009 int ret;
15010
15011 vos_ssr_protect(__func__);
15012 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
15013 vos_ssr_unprotect(__func__);
15014
15015 return ret;
15016}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015017#endif /*FEATURE_WLAN_SCAN_PNO*/
15018
15019
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015020#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015021#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015022static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15023 struct net_device *dev,
15024 u8 *peer, u8 action_code,
15025 u8 dialog_token,
15026 u16 status_code, u32 peer_capability,
15027 const u8 *buf, size_t len)
15028#else /* TDLS_MGMT_VERSION2 */
15029#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
15030static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15031 struct net_device *dev,
15032 const u8 *peer, u8 action_code,
15033 u8 dialog_token, u16 status_code,
15034 u32 peer_capability, bool initiator,
15035 const u8 *buf, size_t len)
15036#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
15037static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15038 struct net_device *dev,
15039 const u8 *peer, u8 action_code,
15040 u8 dialog_token, u16 status_code,
15041 u32 peer_capability, const u8 *buf,
15042 size_t len)
15043#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
15044static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15045 struct net_device *dev,
15046 u8 *peer, u8 action_code,
15047 u8 dialog_token,
15048 u16 status_code, u32 peer_capability,
15049 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015050#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015051static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15052 struct net_device *dev,
15053 u8 *peer, u8 action_code,
15054 u8 dialog_token,
15055 u16 status_code, const u8 *buf,
15056 size_t len)
15057#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015058#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015059{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015060 hdd_adapter_t *pAdapter;
15061 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015062 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070015063 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080015064 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070015065 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015066 int ret;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015067#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015068 u32 peer_capability = 0;
15069#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015070 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015071 hdd_station_ctx_t *pHddStaCtx = NULL;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015072
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015073 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15074 if (NULL == pAdapter)
15075 {
15076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15077 "%s: Adapter is NULL",__func__);
15078 return -EINVAL;
15079 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015080 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15081 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
15082 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015083
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015084 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015085 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015086 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015087 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015088 "Invalid arguments");
15089 return -EINVAL;
15090 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015091
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015092 if (pHddCtx->isLogpInProgress)
15093 {
15094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15095 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053015096 wlan_hdd_tdls_set_link_status(pAdapter,
15097 peer,
15098 eTDLS_LINK_IDLE,
15099 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015100 return -EBUSY;
15101 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015102
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015103 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
15104 {
15105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15106 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
15107 return -EAGAIN;
15108 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015109
Hoonki Lee27511902013-03-14 18:19:06 -070015110 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015111 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015112 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070015113 "%s: TDLS mode is disabled OR not enabled in FW."
15114 MAC_ADDRESS_STR " action %d declined.",
15115 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015116 return -ENOTSUPP;
15117 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015118
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015119 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15120
15121 if( NULL == pHddStaCtx )
15122 {
15123 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15124 "%s: HDD station context NULL ",__func__);
15125 return -EINVAL;
15126 }
15127
15128 /* STA should be connected and authenticated
15129 * before sending any TDLS frames
15130 */
15131 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
15132 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
15133 {
15134 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15135 "STA is not connected or unauthenticated. "
15136 "connState %u, uIsAuthenticated %u",
15137 pHddStaCtx->conn_info.connState,
15138 pHddStaCtx->conn_info.uIsAuthenticated);
15139 return -EAGAIN;
15140 }
15141
Hoonki Lee27511902013-03-14 18:19:06 -070015142 /* other than teardown frame, other mgmt frames are not sent if disabled */
15143 if (SIR_MAC_TDLS_TEARDOWN != action_code)
15144 {
15145 /* if tdls_mode is disabled to respond to peer's request */
15146 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
15147 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015148 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070015149 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015150 " TDLS mode is disabled. action %d declined.",
15151 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070015152
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015153 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070015154 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053015155
15156 if (vos_max_concurrent_connections_reached())
15157 {
15158 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15159 return -EINVAL;
15160 }
Hoonki Lee27511902013-03-14 18:19:06 -070015161 }
15162
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015163 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
15164 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053015165 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015166 {
15167 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015168 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015169 " TDLS setup is ongoing. action %d declined.",
15170 __func__, MAC_ADDR_ARRAY(peer), action_code);
15171 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015172 }
15173 }
15174
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015175 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
15176 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080015177 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015178 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15179 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080015180 {
15181 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
15182 we return error code at 'add_station()'. Hence we have this
15183 check again in addtion to add_station().
15184 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015185 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080015186 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015187 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15188 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015189 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
15190 __func__, MAC_ADDR_ARRAY(peer), action_code,
15191 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053015192 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080015193 }
15194 else
15195 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015196 /* maximum reached. tweak to send error code to peer and return
15197 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080015198 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015199 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15200 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015201 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
15202 __func__, MAC_ADDR_ARRAY(peer), status_code,
15203 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070015204 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015205 /* fall through to send setup resp with failure status
15206 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080015207 }
15208 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015209 else
15210 {
15211 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053015212 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015213 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015214 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015215 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015216 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
15217 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015218 return -EPERM;
15219 }
15220 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015221 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015222
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015223 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053015224 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015225 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
15226 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015227
Hoonki Leea34dd892013-02-05 22:56:02 -080015228 /*Except teardown responder will not be used so just make 0*/
15229 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015230 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080015231 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015232
15233 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015234 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015235
15236 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
15237 responder = pTdlsPeer->is_responder;
15238 else
Hoonki Leea34dd892013-02-05 22:56:02 -080015239 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015240 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053015241 "%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 -070015242 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
15243 dialog_token, status_code, len);
15244 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080015245 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015246 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015247
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015248 /* For explicit trigger of DIS_REQ come out of BMPS for
15249 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070015250 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015251 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
15252 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070015253 {
15254 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
15255 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015256 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015257 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015258 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
15259 if (status != VOS_STATUS_SUCCESS) {
15260 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
15261 }
Hoonki Lee14621352013-04-16 17:51:19 -070015262 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015263 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015264 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015265 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
15266 }
15267 }
Hoonki Lee14621352013-04-16 17:51:19 -070015268 }
15269
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015270 /* make sure doesn't call send_mgmt() while it is pending */
15271 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
15272 {
15273 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015274 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015275 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015276 ret = -EBUSY;
15277 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015278 }
15279
15280 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015281 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
15282
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015283 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
15284 pAdapter->sessionId, peer, action_code, dialog_token,
15285 status_code, peer_capability, (tANI_U8 *)buf, len,
15286 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015287
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015288 if (VOS_STATUS_SUCCESS != status)
15289 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015290 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15291 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015292 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015293 ret = -EINVAL;
15294 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015295 }
15296
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015297 if ((SIR_MAC_TDLS_DIS_REQ == action_code) ||
15298 (SIR_MAC_TDLS_DIS_RSP == action_code))
15299 {
15300 /* for DIS_REQ/DIS_RSP, supplicant don't consider the return status.
15301 * So we no need to wait for tdls_mgmt_comp for sending ack status.
15302 */
15303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15304 "%s: tx done for frm %u", __func__, action_code);
15305 return 0;
15306 }
15307
15308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15309 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
15310 WAIT_TIME_TDLS_MGMT);
15311
Hoonki Leed37cbb32013-04-20 00:31:14 -070015312 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
15313 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
15314
15315 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015316 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070015317 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070015318 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070015319 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015320 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080015321
15322 if (pHddCtx->isLogpInProgress)
15323 {
15324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15325 "%s: LOGP in Progress. Ignore!!!", __func__);
15326 return -EAGAIN;
15327 }
15328
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015329 ret = -EINVAL;
15330 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015331 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015332 else
15333 {
15334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15335 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
15336 __func__, rc, pAdapter->mgmtTxCompletionStatus);
15337 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015338
Gopichand Nakkala05922802013-03-14 12:23:19 -070015339 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070015340 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015341 ret = max_sta_failed;
15342 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070015343 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015344
Hoonki Leea34dd892013-02-05 22:56:02 -080015345 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
15346 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015347 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015348 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15349 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015350 }
15351 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
15352 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015353 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015354 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15355 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015356 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015357
15358 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015359
15360tx_failed:
15361 /* add_station will be called before sending TDLS_SETUP_REQ and
15362 * TDLS_SETUP_RSP and as part of add_station driver will enable
15363 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
15364 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
15365 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
15366 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
15367 */
15368
15369 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
15370 (SIR_MAC_TDLS_SETUP_RSP == action_code))
15371 wlan_hdd_tdls_check_bmps(pAdapter);
15372 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015373}
15374
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015375#if TDLS_MGMT_VERSION2
15376static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15377 u8 *peer, u8 action_code, u8 dialog_token,
15378 u16 status_code, u32 peer_capability,
15379 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015380#else /* TDLS_MGMT_VERSION2 */
15381#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
15382static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15383 struct net_device *dev,
15384 const u8 *peer, u8 action_code,
15385 u8 dialog_token, u16 status_code,
15386 u32 peer_capability, bool initiator,
15387 const u8 *buf, size_t len)
15388#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
15389static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15390 struct net_device *dev,
15391 const u8 *peer, u8 action_code,
15392 u8 dialog_token, u16 status_code,
15393 u32 peer_capability, const u8 *buf,
15394 size_t len)
15395#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
15396static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15397 struct net_device *dev,
15398 u8 *peer, u8 action_code,
15399 u8 dialog_token,
15400 u16 status_code, u32 peer_capability,
15401 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015402#else
15403static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15404 u8 *peer, u8 action_code, u8 dialog_token,
15405 u16 status_code, const u8 *buf, size_t len)
15406#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015407#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015408{
15409 int ret;
15410
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015411 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015412#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015413 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15414 dialog_token, status_code,
15415 peer_capability, buf, len);
15416#else /* TDLS_MGMT_VERSION2 */
15417#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
15418 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15419 dialog_token, status_code,
15420 peer_capability, initiator,
15421 buf, len);
15422#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
15423 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15424 dialog_token, status_code,
15425 peer_capability, buf, len);
15426#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
15427 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15428 dialog_token, status_code,
15429 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015430#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015431 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15432 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015433#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015434#endif
15435 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015436
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015437 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015438}
Atul Mittal115287b2014-07-08 13:26:33 +053015439
15440int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015441#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15442 const u8 *peer,
15443#else
Atul Mittal115287b2014-07-08 13:26:33 +053015444 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015445#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015446 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053015447 cfg80211_exttdls_callback callback)
15448{
15449
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015450 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053015451 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015452 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053015453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15454 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
15455 __func__, MAC_ADDR_ARRAY(peer));
15456
15457 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15458 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15459
15460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015461 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15462 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15463 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015464 return -ENOTSUPP;
15465 }
15466
15467 /* To cater the requirement of establishing the TDLS link
15468 * irrespective of the data traffic , get an entry of TDLS peer.
15469 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015470 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015471 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
15472 if (pTdlsPeer == NULL) {
15473 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15474 "%s: peer " MAC_ADDRESS_STR " not existing",
15475 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015476 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015477 return -EINVAL;
15478 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015479 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015480
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015481 /* check FW TDLS Off Channel capability */
15482 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015483 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015484 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015485 {
15486 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
15487 pTdlsPeer->peerParams.global_operating_class =
15488 tdls_peer_params->global_operating_class;
15489 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
15490 pTdlsPeer->peerParams.min_bandwidth_kbps =
15491 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015492 /* check configured channel is valid, non dfs and
15493 * not current operating channel */
15494 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
15495 tdls_peer_params->channel)) &&
15496 (pHddStaCtx) &&
15497 (tdls_peer_params->channel !=
15498 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015499 {
15500 pTdlsPeer->isOffChannelConfigured = TRUE;
15501 }
15502 else
15503 {
15504 pTdlsPeer->isOffChannelConfigured = FALSE;
15505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15506 "%s: Configured Tdls Off Channel is not valid", __func__);
15507
15508 }
15509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015510 "%s: tdls_off_channel %d isOffChannelConfigured %d "
15511 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015512 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015513 pTdlsPeer->isOffChannelConfigured,
15514 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015515 }
15516 else
15517 {
15518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015519 "%s: TDLS off channel FW capability %d, "
15520 "host capab %d or Invalid TDLS Peer Params", __func__,
15521 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
15522 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015523 }
15524
Atul Mittal115287b2014-07-08 13:26:33 +053015525 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
15526
15527 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15528 " %s TDLS Add Force Peer Failed",
15529 __func__);
15530 return -EINVAL;
15531 }
15532 /*EXT TDLS*/
15533
15534 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
15535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15536 " %s TDLS set callback Failed",
15537 __func__);
15538 return -EINVAL;
15539 }
15540
15541 return(0);
15542
15543}
15544
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015545int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
15546#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15547 const u8 *peer
15548#else
15549 u8 *peer
15550#endif
15551)
Atul Mittal115287b2014-07-08 13:26:33 +053015552{
15553
15554 hddTdlsPeer_t *pTdlsPeer;
15555 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15557 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
15558 __func__, MAC_ADDR_ARRAY(peer));
15559
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015560 if (0 != wlan_hdd_validate_context(pHddCtx)) {
15561 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
15562 return -EINVAL;
15563 }
15564
Atul Mittal115287b2014-07-08 13:26:33 +053015565 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15566 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15567
15568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015569 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15570 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15571 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015572 return -ENOTSUPP;
15573 }
15574
15575
15576 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15577
15578 if ( NULL == pTdlsPeer ) {
15579 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015580 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053015581 __func__, MAC_ADDR_ARRAY(peer));
15582 return -EINVAL;
15583 }
15584 else {
15585 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
15586 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015587 /* if channel switch is configured, reset
15588 the channel for this peer */
15589 if (TRUE == pTdlsPeer->isOffChannelConfigured)
15590 {
15591 pTdlsPeer->peerParams.channel = 0;
15592 pTdlsPeer->isOffChannelConfigured = FALSE;
15593 }
Atul Mittal115287b2014-07-08 13:26:33 +053015594 }
15595
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015596 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
15597 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053015598 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015599 }
Atul Mittal115287b2014-07-08 13:26:33 +053015600
15601 /*EXT TDLS*/
15602
15603 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
15604
15605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15606 " %s TDLS set callback Failed",
15607 __func__);
15608 return -EINVAL;
15609 }
15610 return(0);
15611
15612}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015613static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015614#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15615 const u8 *peer,
15616#else
15617 u8 *peer,
15618#endif
15619 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015620{
15621 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15622 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015623 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015624 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015625
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015626 ENTER();
15627
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015628 if (!pAdapter) {
15629 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15630 return -EINVAL;
15631 }
15632
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015633 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15634 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
15635 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015636 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015637 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015638 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070015639 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015640 return -EINVAL;
15641 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015642
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015643 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015644 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015645 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015646 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015647 }
15648
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015649
15650 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015651 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015652 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015653 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015654 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
15655 "Cannot process TDLS commands",
15656 pHddCtx->cfg_ini->fEnableTDLSSupport,
15657 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015658 return -ENOTSUPP;
15659 }
15660
15661 switch (oper) {
15662 case NL80211_TDLS_ENABLE_LINK:
15663 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015664 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015665 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015666 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053015667 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015668 tANI_U16 numCurrTdlsPeers = 0;
15669 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015670 tANI_U8 suppChannelLen = 0;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015671
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15673 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
15674 __func__, MAC_ADDR_ARRAY(peer));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015675 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015676 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015677 if ( NULL == pTdlsPeer ) {
15678 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15679 " (oper %d) not exsting. ignored",
15680 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15681 return -EINVAL;
15682 }
15683
15684 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15685 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15686 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15687 "NL80211_TDLS_ENABLE_LINK");
15688
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070015689 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
15690 {
15691 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
15692 MAC_ADDRESS_STR " failed",
15693 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
15694 return -EINVAL;
15695 }
15696
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015697 /* before starting tdls connection, set tdls
15698 * off channel established status to default value */
15699 pTdlsPeer->isOffChannelEstablished = FALSE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015700 /* TDLS Off Channel, Disable tdls channel switch,
15701 when there are more than one tdls link */
15702 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053015703 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015704 {
15705 /* get connected peer and send disable tdls off chan */
15706 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015707 if ((connPeer) &&
15708 (connPeer->isOffChannelSupported == TRUE) &&
15709 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015710 {
15711 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15712 "%s: More then one peer connected, Disable "
15713 "TDLS channel switch", __func__);
15714
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015715 connPeer->isOffChannelEstablished = FALSE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015716 ret = sme_SendTdlsChanSwitchReq(
15717 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015718 pAdapter->sessionId,
15719 connPeer->peerMac,
15720 connPeer->peerParams.channel,
15721 TDLS_OFF_CHANNEL_BW_OFFSET,
15722 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015723 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015724 hddLog(VOS_TRACE_LEVEL_ERROR,
15725 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015726 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015727 }
15728 else
15729 {
15730 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15731 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015732 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015733 "isOffChannelConfigured %d",
15734 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015735 (connPeer ? (connPeer->isOffChannelSupported)
15736 : -1),
15737 (connPeer ? (connPeer->isOffChannelConfigured)
15738 : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015739 }
15740 }
15741
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015742 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015743 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015744 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053015745
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015746 if (0 != wlan_hdd_tdls_get_link_establish_params(
15747 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015748 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015749 return -EINVAL;
15750 }
15751 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015752
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015753 ret = sme_SendTdlsLinkEstablishParams(
15754 WLAN_HDD_GET_HAL_CTX(pAdapter),
15755 pAdapter->sessionId, peer,
15756 &tdlsLinkEstablishParams);
15757 if (ret != VOS_STATUS_SUCCESS) {
15758 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
15759 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015760 /* Send TDLS peer UAPSD capabilities to the firmware and
15761 * register with the TL on after the response for this operation
15762 * is received .
15763 */
15764 ret = wait_for_completion_interruptible_timeout(
15765 &pAdapter->tdls_link_establish_req_comp,
15766 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
15767 if (ret <= 0)
15768 {
15769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015770 FL("Link Establish Request Failed Status %ld"),
15771 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015772 return -EINVAL;
15773 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015774 }
Atul Mittal115287b2014-07-08 13:26:33 +053015775 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15776 eTDLS_LINK_CONNECTED,
15777 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015778 staDesc.ucSTAId = pTdlsPeer->staId;
15779 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015780 ret = WLANTL_UpdateTdlsSTAClient(
15781 pHddCtx->pvosContext,
15782 &staDesc);
15783 if (ret != VOS_STATUS_SUCCESS) {
15784 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
15785 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053015786
Gopichand Nakkala471708b2013-06-04 20:03:01 +053015787 /* Mark TDLS client Authenticated .*/
15788 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
15789 pTdlsPeer->staId,
15790 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015791 if (VOS_STATUS_SUCCESS == status)
15792 {
Hoonki Lee14621352013-04-16 17:51:19 -070015793 if (pTdlsPeer->is_responder == 0)
15794 {
15795 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
15796
15797 wlan_hdd_tdls_timer_restart(pAdapter,
15798 &pTdlsPeer->initiatorWaitTimeoutTimer,
15799 WAIT_TIME_TDLS_INITIATOR);
15800 /* suspend initiator TX until it receives direct packet from the
15801 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015802 ret = WLANTL_SuspendDataTx(
15803 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15804 &staId, NULL);
15805 if (ret != VOS_STATUS_SUCCESS) {
15806 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
15807 }
Hoonki Lee14621352013-04-16 17:51:19 -070015808 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015809
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015810 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015811 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015812 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015813 suppChannelLen =
15814 tdlsLinkEstablishParams.supportedChannelsLen;
15815
15816 if ((suppChannelLen > 0) &&
15817 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
15818 {
15819 tANI_U8 suppPeerChannel = 0;
15820 int i = 0;
15821 for (i = 0U; i < suppChannelLen; i++)
15822 {
15823 suppPeerChannel =
15824 tdlsLinkEstablishParams.supportedChannels[i];
15825
15826 pTdlsPeer->isOffChannelSupported = FALSE;
15827 if (suppPeerChannel ==
15828 pTdlsPeer->peerParams.channel)
15829 {
15830 pTdlsPeer->isOffChannelSupported = TRUE;
15831 break;
15832 }
15833 }
15834 }
15835 else
15836 {
15837 pTdlsPeer->isOffChannelSupported = FALSE;
15838 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015839 }
15840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15841 "%s: TDLS channel switch request for channel "
15842 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015843 "%d isOffChannelSupported %d", __func__,
15844 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015845 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015846 suppChannelLen,
15847 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015848
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015849 /* TDLS Off Channel, Enable tdls channel switch,
15850 when their is only one tdls link and it supports */
15851 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15852 if ((numCurrTdlsPeers == 1) &&
15853 (TRUE == pTdlsPeer->isOffChannelSupported) &&
15854 (TRUE == pTdlsPeer->isOffChannelConfigured))
15855 {
15856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15857 "%s: Send TDLS channel switch request for channel %d",
15858 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015859
15860 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015861 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
15862 pAdapter->sessionId,
15863 pTdlsPeer->peerMac,
15864 pTdlsPeer->peerParams.channel,
15865 TDLS_OFF_CHANNEL_BW_OFFSET,
15866 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015867 if (ret != VOS_STATUS_SUCCESS) {
15868 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
15869 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015870 }
15871 else
15872 {
15873 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15874 "%s: TDLS channel switch request not sent"
15875 " numCurrTdlsPeers %d "
15876 "isOffChannelSupported %d "
15877 "isOffChannelConfigured %d",
15878 __func__, numCurrTdlsPeers,
15879 pTdlsPeer->isOffChannelSupported,
15880 pTdlsPeer->isOffChannelConfigured);
15881 }
15882
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015883 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015884 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015885
15886 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015887 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
15888 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015889 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015890 int ac;
15891 uint8 ucAc[4] = { WLANTL_AC_VO,
15892 WLANTL_AC_VI,
15893 WLANTL_AC_BK,
15894 WLANTL_AC_BE };
15895 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
15896 for(ac=0; ac < 4; ac++)
15897 {
15898 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15899 pTdlsPeer->staId, ucAc[ac],
15900 tlTid[ac], tlTid[ac], 0, 0,
15901 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015902 if (status != VOS_STATUS_SUCCESS) {
15903 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
15904 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015905 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015906 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015907 }
15908
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015909 }
15910 break;
15911 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080015912 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015913 tANI_U16 numCurrTdlsPeers = 0;
15914 hddTdlsPeer_t *connPeer = NULL;
15915
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15917 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
15918 __func__, MAC_ADDR_ARRAY(peer));
15919
Sunil Dutt41de4e22013-11-14 18:09:02 +053015920 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15921
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015922
Sunil Dutt41de4e22013-11-14 18:09:02 +053015923 if ( NULL == pTdlsPeer ) {
15924 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15925 " (oper %d) not exsting. ignored",
15926 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15927 return -EINVAL;
15928 }
15929
15930 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15931 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15932 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15933 "NL80211_TDLS_DISABLE_LINK");
15934
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015935 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080015936 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015937 long status;
15938
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015939 /* set tdls off channel status to false for this peer */
15940 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053015941 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15942 eTDLS_LINK_TEARING,
15943 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
15944 eTDLS_LINK_UNSPECIFIED:
15945 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015946 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
15947
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015948 status = sme_DeleteTdlsPeerSta(
15949 WLAN_HDD_GET_HAL_CTX(pAdapter),
15950 pAdapter->sessionId, peer );
15951 if (status != VOS_STATUS_SUCCESS) {
15952 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15953 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015954
15955 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
15956 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053015957 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053015958 eTDLS_LINK_IDLE,
15959 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015960 if (status <= 0)
15961 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15963 "%s: Del station failed status %ld",
15964 __func__, status);
15965 return -EPERM;
15966 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015967
15968 /* TDLS Off Channel, Enable tdls channel switch,
15969 when their is only one tdls link and it supports */
15970 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15971 if (numCurrTdlsPeers == 1)
15972 {
15973 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15974 if ((connPeer) &&
15975 (connPeer->isOffChannelSupported == TRUE) &&
15976 (connPeer->isOffChannelConfigured == TRUE))
15977 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015978 connPeer->isOffChannelEstablished = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015979 status = sme_SendTdlsChanSwitchReq(
15980 WLAN_HDD_GET_HAL_CTX(pAdapter),
15981 pAdapter->sessionId,
15982 connPeer->peerMac,
15983 connPeer->peerParams.channel,
15984 TDLS_OFF_CHANNEL_BW_OFFSET,
15985 TDLS_CHANNEL_SWITCH_ENABLE);
15986 if (status != VOS_STATUS_SUCCESS) {
15987 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
15988 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015989 }
15990 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15991 "%s: TDLS channel switch "
15992 "isOffChannelSupported %d "
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015993 "isOffChannelConfigured %d "
15994 "isOffChannelEstablished %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015995 __func__,
15996 (connPeer ? connPeer->isOffChannelSupported : -1),
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015997 (connPeer ? connPeer->isOffChannelConfigured : -1),
15998 (connPeer ? connPeer->isOffChannelEstablished : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015999 }
16000 else
16001 {
16002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16003 "%s: TDLS channel switch request not sent "
16004 "numCurrTdlsPeers %d ",
16005 __func__, numCurrTdlsPeers);
16006 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080016007 }
16008 else
16009 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016010 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16011 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080016012 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080016013 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016014 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016015 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053016016 {
Atul Mittal115287b2014-07-08 13:26:33 +053016017 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053016018
Atul Mittal115287b2014-07-08 13:26:33 +053016019 if (0 != status)
16020 {
16021 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053016022 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053016023 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053016024 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053016025 break;
16026 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016027 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053016028 {
Atul Mittal115287b2014-07-08 13:26:33 +053016029 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
16030 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016031 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053016032 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053016033
Atul Mittal115287b2014-07-08 13:26:33 +053016034 if (0 != status)
16035 {
16036 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053016037 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053016038 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053016039 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053016040 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053016041 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016042 case NL80211_TDLS_DISCOVERY_REQ:
16043 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053016045 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016046 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016047 return -ENOTSUPP;
16048 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16050 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016051 return -ENOTSUPP;
16052 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016053
16054 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016055 return 0;
16056}
Chilam NG571c65a2013-01-19 12:27:36 +053016057
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016058static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016059#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16060 const u8 *peer,
16061#else
16062 u8 *peer,
16063#endif
16064 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016065{
16066 int ret;
16067
16068 vos_ssr_protect(__func__);
16069 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
16070 vos_ssr_unprotect(__func__);
16071
16072 return ret;
16073}
16074
Chilam NG571c65a2013-01-19 12:27:36 +053016075int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
16076 struct net_device *dev, u8 *peer)
16077{
Arif Hussaina7c8e412013-11-20 11:06:42 -080016078 hddLog(VOS_TRACE_LEVEL_INFO,
16079 "tdls send discover req: "MAC_ADDRESS_STR,
16080 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053016081
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016082#if TDLS_MGMT_VERSION2
16083 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16084 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16085#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016086#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
16087 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16088 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
16089#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16090 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16091 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16092#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
16093 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16094 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16095#else
Chilam NG571c65a2013-01-19 12:27:36 +053016096 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16097 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016098#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016099#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053016100}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016101#endif
16102
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016103#ifdef WLAN_FEATURE_GTK_OFFLOAD
16104/*
16105 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
16106 * Callback rountine called upon receiving response for
16107 * get offload info
16108 */
16109void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
16110 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
16111{
16112
16113 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016114 tANI_U8 tempReplayCounter[8];
16115 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016116
16117 ENTER();
16118
16119 if (NULL == pAdapter)
16120 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053016121 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016122 "%s: HDD adapter is Null", __func__);
16123 return ;
16124 }
16125
16126 if (NULL == pGtkOffloadGetInfoRsp)
16127 {
16128 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16129 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
16130 return ;
16131 }
16132
16133 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
16134 {
16135 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16136 "%s: wlan Failed to get replay counter value",
16137 __func__);
16138 return ;
16139 }
16140
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016141 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16142 /* Update replay counter */
16143 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
16144 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
16145
16146 {
16147 /* changing from little to big endian since supplicant
16148 * works on big endian format
16149 */
16150 int i;
16151 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
16152
16153 for (i = 0; i < 8; i++)
16154 {
16155 tempReplayCounter[7-i] = (tANI_U8)p[i];
16156 }
16157 }
16158
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016159 /* Update replay counter to NL */
16160 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016161 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016162}
16163
16164/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016165 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016166 * This function is used to offload GTK rekeying job to the firmware.
16167 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016168int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016169 struct cfg80211_gtk_rekey_data *data)
16170{
16171 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16172 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16173 hdd_station_ctx_t *pHddStaCtx;
16174 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016175 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016176 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016177 eHalStatus status = eHAL_STATUS_FAILURE;
16178
16179 ENTER();
16180
16181 if (NULL == pAdapter)
16182 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016183 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016184 "%s: HDD adapter is Null", __func__);
16185 return -ENODEV;
16186 }
16187
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016188 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16189 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
16190 pAdapter->sessionId, pAdapter->device_mode));
16191
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016192 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016193 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016194 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016195 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016196 }
16197
16198 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16199 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
16200 if (NULL == hHal)
16201 {
16202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16203 "%s: HAL context is Null!!!", __func__);
16204 return -EAGAIN;
16205 }
16206
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016207 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
16208 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
16209 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
16210 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016211 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016212 {
16213 /* changing from big to little endian since driver
16214 * works on little endian format
16215 */
16216 tANI_U8 *p =
16217 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
16218 int i;
16219
16220 for (i = 0; i < 8; i++)
16221 {
16222 p[7-i] = data->replay_ctr[i];
16223 }
16224 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016225
16226 if (TRUE == pHddCtx->hdd_wlan_suspended)
16227 {
16228 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016229 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
16230 sizeof (tSirGtkOffloadParams));
16231 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016232 pAdapter->sessionId);
16233
16234 if (eHAL_STATUS_SUCCESS != status)
16235 {
16236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16237 "%s: sme_SetGTKOffload failed, returned %d",
16238 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053016239
16240 /* Need to clear any trace of key value in the memory.
16241 * Thus zero out the memory even though it is local
16242 * variable.
16243 */
16244 vos_mem_zero(&hddGtkOffloadReqParams,
16245 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016246 return status;
16247 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16249 "%s: sme_SetGTKOffload successfull", __func__);
16250 }
16251 else
16252 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16254 "%s: wlan not suspended GTKOffload request is stored",
16255 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016256 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016257
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053016258 /* Need to clear any trace of key value in the memory.
16259 * Thus zero out the memory even though it is local
16260 * variable.
16261 */
16262 vos_mem_zero(&hddGtkOffloadReqParams,
16263 sizeof(hddGtkOffloadReqParams));
16264
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016265 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016266 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016267}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016268
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016269int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
16270 struct cfg80211_gtk_rekey_data *data)
16271{
16272 int ret;
16273
16274 vos_ssr_protect(__func__);
16275 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
16276 vos_ssr_unprotect(__func__);
16277
16278 return ret;
16279}
16280#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016281/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016282 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016283 * This function is used to set access control policy
16284 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016285static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16286 struct net_device *dev,
16287 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016288{
16289 int i;
16290 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16291 hdd_hostapd_state_t *pHostapdState;
16292 tsap_Config_t *pConfig;
16293 v_CONTEXT_t pVosContext = NULL;
16294 hdd_context_t *pHddCtx;
16295 int status;
16296
16297 ENTER();
16298
16299 if (NULL == pAdapter)
16300 {
16301 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16302 "%s: HDD adapter is Null", __func__);
16303 return -ENODEV;
16304 }
16305
16306 if (NULL == params)
16307 {
16308 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16309 "%s: params is Null", __func__);
16310 return -EINVAL;
16311 }
16312
16313 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16314 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016315 if (0 != status)
16316 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016317 return status;
16318 }
16319
16320 pVosContext = pHddCtx->pvosContext;
16321 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
16322
16323 if (NULL == pHostapdState)
16324 {
16325 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16326 "%s: pHostapdState is Null", __func__);
16327 return -EINVAL;
16328 }
16329
16330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
16331 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016332 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16333 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
16334 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016335
16336 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
16337 {
16338 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
16339
16340 /* default value */
16341 pConfig->num_accept_mac = 0;
16342 pConfig->num_deny_mac = 0;
16343
16344 /**
16345 * access control policy
16346 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
16347 * listed in hostapd.deny file.
16348 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
16349 * listed in hostapd.accept file.
16350 */
16351 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
16352 {
16353 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
16354 }
16355 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
16356 {
16357 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
16358 }
16359 else
16360 {
16361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16362 "%s:Acl Policy : %d is not supported",
16363 __func__, params->acl_policy);
16364 return -ENOTSUPP;
16365 }
16366
16367 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
16368 {
16369 pConfig->num_accept_mac = params->n_acl_entries;
16370 for (i = 0; i < params->n_acl_entries; i++)
16371 {
16372 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16373 "** Add ACL MAC entry %i in WhiletList :"
16374 MAC_ADDRESS_STR, i,
16375 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16376
16377 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
16378 sizeof(qcmacaddr));
16379 }
16380 }
16381 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
16382 {
16383 pConfig->num_deny_mac = params->n_acl_entries;
16384 for (i = 0; i < params->n_acl_entries; i++)
16385 {
16386 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16387 "** Add ACL MAC entry %i in BlackList :"
16388 MAC_ADDRESS_STR, i,
16389 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16390
16391 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
16392 sizeof(qcmacaddr));
16393 }
16394 }
16395
16396 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
16397 {
16398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16399 "%s: SAP Set Mac Acl fail", __func__);
16400 return -EINVAL;
16401 }
16402 }
16403 else
16404 {
16405 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053016406 "%s: Invalid device_mode = %s (%d)",
16407 __func__, hdd_device_modetoString(pAdapter->device_mode),
16408 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016409 return -EINVAL;
16410 }
16411
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016412 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016413 return 0;
16414}
16415
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016416static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16417 struct net_device *dev,
16418 const struct cfg80211_acl_data *params)
16419{
16420 int ret;
16421 vos_ssr_protect(__func__);
16422 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
16423 vos_ssr_unprotect(__func__);
16424
16425 return ret;
16426}
16427
Leo Chang9056f462013-08-01 19:21:11 -070016428#ifdef WLAN_NL80211_TESTMODE
16429#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070016430void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070016431(
16432 void *pAdapter,
16433 void *indCont
16434)
16435{
Leo Changd9df8aa2013-09-26 13:32:26 -070016436 tSirLPHBInd *lphbInd;
16437 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053016438 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070016439
16440 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016441 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070016442
c_hpothu73f35e62014-04-18 13:40:08 +053016443 if (pAdapter == NULL)
16444 {
16445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16446 "%s: pAdapter is NULL\n",__func__);
16447 return;
16448 }
16449
Leo Chang9056f462013-08-01 19:21:11 -070016450 if (NULL == indCont)
16451 {
16452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016453 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070016454 return;
16455 }
16456
c_hpothu73f35e62014-04-18 13:40:08 +053016457 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070016458 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070016459 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053016460 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070016461 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070016462 GFP_ATOMIC);
16463 if (!skb)
16464 {
16465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16466 "LPHB timeout, NL buffer alloc fail");
16467 return;
16468 }
16469
Leo Changac3ba772013-10-07 09:47:04 -070016470 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070016471 {
16472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16473 "WLAN_HDD_TM_ATTR_CMD put fail");
16474 goto nla_put_failure;
16475 }
Leo Changac3ba772013-10-07 09:47:04 -070016476 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070016477 {
16478 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16479 "WLAN_HDD_TM_ATTR_TYPE put fail");
16480 goto nla_put_failure;
16481 }
Leo Changac3ba772013-10-07 09:47:04 -070016482 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070016483 sizeof(tSirLPHBInd), lphbInd))
16484 {
16485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16486 "WLAN_HDD_TM_ATTR_DATA put fail");
16487 goto nla_put_failure;
16488 }
Leo Chang9056f462013-08-01 19:21:11 -070016489 cfg80211_testmode_event(skb, GFP_ATOMIC);
16490 return;
16491
16492nla_put_failure:
16493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16494 "NLA Put fail");
16495 kfree_skb(skb);
16496
16497 return;
16498}
16499#endif /* FEATURE_WLAN_LPHB */
16500
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016501static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070016502{
16503 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
16504 int err = 0;
16505#ifdef FEATURE_WLAN_LPHB
16506 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070016507 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016508
16509 ENTER();
16510
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016511 err = wlan_hdd_validate_context(pHddCtx);
16512 if (0 != err)
16513 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016514 return err;
16515 }
Leo Chang9056f462013-08-01 19:21:11 -070016516#endif /* FEATURE_WLAN_LPHB */
16517
16518 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
16519 if (err)
16520 {
16521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16522 "%s Testmode INV ATTR", __func__);
16523 return err;
16524 }
16525
16526 if (!tb[WLAN_HDD_TM_ATTR_CMD])
16527 {
16528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16529 "%s Testmode INV CMD", __func__);
16530 return -EINVAL;
16531 }
16532
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016533 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16534 TRACE_CODE_HDD_CFG80211_TESTMODE,
16535 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070016536 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
16537 {
16538#ifdef FEATURE_WLAN_LPHB
16539 /* Low Power Heartbeat configuration request */
16540 case WLAN_HDD_TM_CMD_WLAN_HB:
16541 {
16542 int buf_len;
16543 void *buf;
16544 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080016545 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070016546
16547 if (!tb[WLAN_HDD_TM_ATTR_DATA])
16548 {
16549 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16550 "%s Testmode INV DATA", __func__);
16551 return -EINVAL;
16552 }
16553
16554 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
16555 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080016556
16557 hb_params_temp =(tSirLPHBReq *)buf;
16558 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
16559 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
16560 return -EINVAL;
16561
Leo Chang9056f462013-08-01 19:21:11 -070016562 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
16563 if (NULL == hb_params)
16564 {
16565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16566 "%s Request Buffer Alloc Fail", __func__);
16567 return -EINVAL;
16568 }
16569
16570 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070016571 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
16572 hb_params,
16573 wlan_hdd_cfg80211_lphb_ind_handler);
16574 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070016575 {
Leo Changd9df8aa2013-09-26 13:32:26 -070016576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16577 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070016578 vos_mem_free(hb_params);
16579 }
Leo Chang9056f462013-08-01 19:21:11 -070016580 return 0;
16581 }
16582#endif /* FEATURE_WLAN_LPHB */
16583 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16585 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070016586 return -EOPNOTSUPP;
16587 }
16588
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016589 EXIT();
16590 return err;
Leo Chang9056f462013-08-01 19:21:11 -070016591}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016592
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053016593static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
16594#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
16595 struct wireless_dev *wdev,
16596#endif
16597 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016598{
16599 int ret;
16600
16601 vos_ssr_protect(__func__);
16602 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
16603 vos_ssr_unprotect(__func__);
16604
16605 return ret;
16606}
Leo Chang9056f462013-08-01 19:21:11 -070016607#endif /* CONFIG_NL80211_TESTMODE */
16608
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016609static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016610 struct net_device *dev,
16611 int idx, struct survey_info *survey)
16612{
16613 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16614 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053016615 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016616 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053016617 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016618 v_S7_t snr,rssi;
16619 int status, i, j, filled = 0;
16620
16621 ENTER();
16622
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016623 if (NULL == pAdapter)
16624 {
16625 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16626 "%s: HDD adapter is Null", __func__);
16627 return -ENODEV;
16628 }
16629
16630 if (NULL == wiphy)
16631 {
16632 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16633 "%s: wiphy is Null", __func__);
16634 return -ENODEV;
16635 }
16636
16637 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16638 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016639 if (0 != status)
16640 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016641 return status;
16642 }
16643
Mihir Sheted9072e02013-08-21 17:02:29 +053016644 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16645
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016646 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053016647 0 != pAdapter->survey_idx ||
16648 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016649 {
16650 /* The survey dump ops when implemented completely is expected to
16651 * return a survey of all channels and the ops is called by the
16652 * kernel with incremental values of the argument 'idx' till it
16653 * returns -ENONET. But we can only support the survey for the
16654 * operating channel for now. survey_idx is used to track
16655 * that the ops is called only once and then return -ENONET for
16656 * the next iteration
16657 */
16658 pAdapter->survey_idx = 0;
16659 return -ENONET;
16660 }
16661
Mukul Sharma9d5233b2015-06-11 20:28:20 +053016662 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
16663 {
16664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16665 "%s: Roaming in progress, hence return ", __func__);
16666 return -ENONET;
16667 }
16668
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016669 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16670
16671 wlan_hdd_get_snr(pAdapter, &snr);
16672 wlan_hdd_get_rssi(pAdapter, &rssi);
16673
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016674 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16675 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
16676 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016677 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
16678 hdd_wlan_get_freq(channel, &freq);
16679
16680
16681 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
16682 {
16683 if (NULL == wiphy->bands[i])
16684 {
16685 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
16686 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
16687 continue;
16688 }
16689
16690 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
16691 {
16692 struct ieee80211_supported_band *band = wiphy->bands[i];
16693
16694 if (band->channels[j].center_freq == (v_U16_t)freq)
16695 {
16696 survey->channel = &band->channels[j];
16697 /* The Rx BDs contain SNR values in dB for the received frames
16698 * while the supplicant expects noise. So we calculate and
16699 * return the value of noise (dBm)
16700 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
16701 */
16702 survey->noise = rssi - snr;
16703 survey->filled = SURVEY_INFO_NOISE_DBM;
16704 filled = 1;
16705 }
16706 }
16707 }
16708
16709 if (filled)
16710 pAdapter->survey_idx = 1;
16711 else
16712 {
16713 pAdapter->survey_idx = 0;
16714 return -ENONET;
16715 }
16716
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016717 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016718 return 0;
16719}
16720
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016721static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
16722 struct net_device *dev,
16723 int idx, struct survey_info *survey)
16724{
16725 int ret;
16726
16727 vos_ssr_protect(__func__);
16728 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
16729 vos_ssr_unprotect(__func__);
16730
16731 return ret;
16732}
16733
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016734/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016735 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016736 * this is called when cfg80211 driver resume
16737 * driver updates latest sched_scan scan result(if any) to cfg80211 database
16738 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016739int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016740{
16741 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16742 hdd_adapter_t *pAdapter;
16743 hdd_adapter_list_node_t *pAdapterNode, *pNext;
16744 VOS_STATUS status = VOS_STATUS_SUCCESS;
16745
16746 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016747
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016748 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016749 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016750 return 0;
16751 }
16752
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016753 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
16754 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016755 spin_lock(&pHddCtx->schedScan_lock);
16756 pHddCtx->isWiphySuspended = FALSE;
16757 if (TRUE != pHddCtx->isSchedScanUpdatePending)
16758 {
16759 spin_unlock(&pHddCtx->schedScan_lock);
16760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16761 "%s: Return resume is not due to PNO indication", __func__);
16762 return 0;
16763 }
16764 // Reset flag to avoid updatating cfg80211 data old results again
16765 pHddCtx->isSchedScanUpdatePending = FALSE;
16766 spin_unlock(&pHddCtx->schedScan_lock);
16767
16768 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
16769
16770 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
16771 {
16772 pAdapter = pAdapterNode->pAdapter;
16773 if ( (NULL != pAdapter) &&
16774 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
16775 {
16776 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016777 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16779 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016780 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016781 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016782 {
16783 /* Acquire wakelock to handle the case where APP's tries to
16784 * suspend immediately after updating the scan results. Whis
16785 * results in app's is in suspended state and not able to
16786 * process the connect request to AP
16787 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053016788 hdd_prevent_suspend_timeout(2000,
16789 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016790 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016791 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016792
16793 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16794 "%s : cfg80211 scan result database updated", __func__);
16795
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016796 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016797 return 0;
16798
16799 }
16800 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16801 pAdapterNode = pNext;
16802 }
16803
16804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16805 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016806 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016807 return 0;
16808}
16809
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016810int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
16811{
16812 int ret;
16813
16814 vos_ssr_protect(__func__);
16815 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
16816 vos_ssr_unprotect(__func__);
16817
16818 return ret;
16819}
16820
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016821/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016822 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016823 * this is called when cfg80211 driver suspends
16824 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016825int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016826 struct cfg80211_wowlan *wow)
16827{
16828 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016829 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016830
16831 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016832
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016833 ret = wlan_hdd_validate_context(pHddCtx);
16834 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016835 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016836 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016837 }
16838
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016839
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016840 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16841 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
16842 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016843 pHddCtx->isWiphySuspended = TRUE;
16844
16845 EXIT();
16846
16847 return 0;
16848}
16849
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016850int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
16851 struct cfg80211_wowlan *wow)
16852{
16853 int ret;
16854
16855 vos_ssr_protect(__func__);
16856 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
16857 vos_ssr_unprotect(__func__);
16858
16859 return ret;
16860}
Jeff Johnson295189b2012-06-20 16:38:30 -070016861/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016862static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070016863{
16864 .add_virtual_intf = wlan_hdd_add_virtual_intf,
16865 .del_virtual_intf = wlan_hdd_del_virtual_intf,
16866 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
16867 .change_station = wlan_hdd_change_station,
16868#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
16869 .add_beacon = wlan_hdd_cfg80211_add_beacon,
16870 .del_beacon = wlan_hdd_cfg80211_del_beacon,
16871 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016872#else
16873 .start_ap = wlan_hdd_cfg80211_start_ap,
16874 .change_beacon = wlan_hdd_cfg80211_change_beacon,
16875 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070016876#endif
16877 .change_bss = wlan_hdd_cfg80211_change_bss,
16878 .add_key = wlan_hdd_cfg80211_add_key,
16879 .get_key = wlan_hdd_cfg80211_get_key,
16880 .del_key = wlan_hdd_cfg80211_del_key,
16881 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016882#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070016883 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016884#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016885 .scan = wlan_hdd_cfg80211_scan,
16886 .connect = wlan_hdd_cfg80211_connect,
16887 .disconnect = wlan_hdd_cfg80211_disconnect,
16888 .join_ibss = wlan_hdd_cfg80211_join_ibss,
16889 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
16890 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
16891 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
16892 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070016893 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
16894 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053016895 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070016896#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16897 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
16898 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
16899 .set_txq_params = wlan_hdd_set_txq_params,
16900#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016901 .get_station = wlan_hdd_cfg80211_get_station,
16902 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
16903 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016904 .add_station = wlan_hdd_cfg80211_add_station,
16905#ifdef FEATURE_WLAN_LFR
16906 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
16907 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
16908 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
16909#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016910#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
16911 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
16912#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016913#ifdef FEATURE_WLAN_TDLS
16914 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
16915 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
16916#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016917#ifdef WLAN_FEATURE_GTK_OFFLOAD
16918 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
16919#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016920#ifdef FEATURE_WLAN_SCAN_PNO
16921 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
16922 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
16923#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016924 .resume = wlan_hdd_cfg80211_resume_wlan,
16925 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016926 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070016927#ifdef WLAN_NL80211_TESTMODE
16928 .testmode_cmd = wlan_hdd_cfg80211_testmode,
16929#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016930 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070016931};
16932