blob: d51e7e001836429dac3ea4bd4951ce074a5d239d [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
Agarwal Ashish40f9b872015-09-01 16:17:35 +053011469 /*
11470 * Change conn_state to connecting before sme_RoamConnect(),
11471 * because sme_RoamConnect() has a direct path to call
11472 * hdd_smeRoamCallback(), which will change the conn_state
11473 * If direct path, conn_state will be accordingly changed
11474 * to NotConnected or Associated by either
11475 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
11476 * in sme_RoamCallback()
11477 * if sme_RomConnect is to be queued,
11478 * Connecting state will remain until it is completed.
11479 * If connection state is not changed,
11480 * connection state will remain in eConnectionState_NotConnected state.
11481 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
11482 * if conn state is eConnectionState_NotConnected.
11483 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
11484 * informed of connect result indication which is an issue.
11485 */
11486
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011487 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11488 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053011489 {
11490 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053011491 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011492 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
11493 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053011494 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011495 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011496 pAdapter->sessionId, pRoamProfile, &roamId);
11497
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011498 if ((eHAL_STATUS_SUCCESS != status) &&
11499 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11500 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011501
11502 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053011503 hddLog(VOS_TRACE_LEVEL_ERROR,
11504 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
11505 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011506 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011507 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011508 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011509 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011510
11511 pRoamProfile->ChannelInfo.ChannelList = NULL;
11512 pRoamProfile->ChannelInfo.numOfChannels = 0;
11513
Jeff Johnson295189b2012-06-20 16:38:30 -070011514 }
11515 else
11516 {
11517 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
11518 return -EINVAL;
11519 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080011520 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011521 return status;
11522}
11523
11524/*
11525 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
11526 * This function is used to set the authentication type (OPEN/SHARED).
11527 *
11528 */
11529static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
11530 enum nl80211_auth_type auth_type)
11531{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011532 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011533 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11534
11535 ENTER();
11536
11537 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011538 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070011539 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011540 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011541 hddLog(VOS_TRACE_LEVEL_INFO,
11542 "%s: set authentication type to AUTOSWITCH", __func__);
11543 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
11544 break;
11545
11546 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011547#ifdef WLAN_FEATURE_VOWIFI_11R
11548 case NL80211_AUTHTYPE_FT:
11549#endif /* WLAN_FEATURE_VOWIFI_11R */
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 OPEN", __func__);
11552 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11553 break;
11554
11555 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011556 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011557 "%s: set authentication type to SHARED", __func__);
11558 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
11559 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011560#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011561 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011562 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011563 "%s: set authentication type to CCKM WPA", __func__);
11564 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
11565 break;
11566#endif
11567
11568
11569 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011570 hddLog(VOS_TRACE_LEVEL_ERROR,
11571 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011572 auth_type);
11573 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
11574 return -EINVAL;
11575 }
11576
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011577 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011578 pHddStaCtx->conn_info.authType;
11579 return 0;
11580}
11581
11582/*
11583 * FUNCTION: wlan_hdd_set_akm_suite
11584 * This function is used to set the key mgmt type(PSK/8021x).
11585 *
11586 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011587static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011588 u32 key_mgmt
11589 )
11590{
11591 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11592 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053011593 /* Should be in ieee802_11_defs.h */
11594#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
11595#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070011596 /*set key mgmt type*/
11597 switch(key_mgmt)
11598 {
11599 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053011600 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011601#ifdef WLAN_FEATURE_VOWIFI_11R
11602 case WLAN_AKM_SUITE_FT_PSK:
11603#endif
11604 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070011605 __func__);
11606 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
11607 break;
11608
11609 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053011610 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011611#ifdef WLAN_FEATURE_VOWIFI_11R
11612 case WLAN_AKM_SUITE_FT_8021X:
11613#endif
11614 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011615 __func__);
11616 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11617 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011618#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011619#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
11620#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
11621 case WLAN_AKM_SUITE_CCKM:
11622 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
11623 __func__);
11624 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
11625 break;
11626#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070011627#ifndef WLAN_AKM_SUITE_OSEN
11628#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
11629 case WLAN_AKM_SUITE_OSEN:
11630 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
11631 __func__);
11632 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11633 break;
11634#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011635
11636 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011637 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011638 __func__, key_mgmt);
11639 return -EINVAL;
11640
11641 }
11642 return 0;
11643}
11644
11645/*
11646 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011647 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070011648 * (NONE/WEP40/WEP104/TKIP/CCMP).
11649 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011650static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
11651 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070011652 bool ucast
11653 )
11654{
11655 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011656 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011657 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11658
11659 ENTER();
11660
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011661 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011662 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053011663 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070011664 __func__, cipher);
11665 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11666 }
11667 else
11668 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011669
Jeff Johnson295189b2012-06-20 16:38:30 -070011670 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011671 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011672 {
11673 case IW_AUTH_CIPHER_NONE:
11674 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11675 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011676
Jeff Johnson295189b2012-06-20 16:38:30 -070011677 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011678 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070011679 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011680
Jeff Johnson295189b2012-06-20 16:38:30 -070011681 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011682 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070011683 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011684
Jeff Johnson295189b2012-06-20 16:38:30 -070011685 case WLAN_CIPHER_SUITE_TKIP:
11686 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
11687 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011688
Jeff Johnson295189b2012-06-20 16:38:30 -070011689 case WLAN_CIPHER_SUITE_CCMP:
11690 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11691 break;
11692#ifdef FEATURE_WLAN_WAPI
11693 case WLAN_CIPHER_SUITE_SMS4:
11694 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
11695 break;
11696#endif
11697
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011698#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011699 case WLAN_CIPHER_SUITE_KRK:
11700 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
11701 break;
11702#endif
11703 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011704 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011705 __func__, cipher);
11706 return -EOPNOTSUPP;
11707 }
11708 }
11709
11710 if (ucast)
11711 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011712 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011713 __func__, encryptionType);
11714 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11715 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011716 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011717 encryptionType;
11718 }
11719 else
11720 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011721 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011722 __func__, encryptionType);
11723 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
11724 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
11725 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
11726 }
11727
11728 return 0;
11729}
11730
11731
11732/*
11733 * FUNCTION: wlan_hdd_cfg80211_set_ie
11734 * This function is used to parse WPA/RSN IE's.
11735 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011736int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011737#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11738 const u8 *ie,
11739#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011740 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011741#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011742 size_t ie_len
11743 )
11744{
11745 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011746#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11747 const u8 *genie = ie;
11748#else
Jeff Johnson295189b2012-06-20 16:38:30 -070011749 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011750#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011751 v_U16_t remLen = ie_len;
11752#ifdef FEATURE_WLAN_WAPI
11753 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
11754 u16 *tmp;
11755 v_U16_t akmsuiteCount;
11756 int *akmlist;
11757#endif
11758 ENTER();
11759
11760 /* clear previous assocAddIE */
11761 pWextState->assocAddIE.length = 0;
11762 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011763 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011764
11765 while (remLen >= 2)
11766 {
11767 v_U16_t eLen = 0;
11768 v_U8_t elementId;
11769 elementId = *genie++;
11770 eLen = *genie++;
11771 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011772
Arif Hussain6d2a3322013-11-17 19:50:10 -080011773 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070011774 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011775
11776 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070011777 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011778 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011779 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 -070011780 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011781 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011782 "%s: Invalid WPA IE", __func__);
11783 return -EINVAL;
11784 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011785 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070011786 {
11787 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011788 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011789 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011790
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011791 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011792 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011793 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
11794 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011795 VOS_ASSERT(0);
11796 return -ENOMEM;
11797 }
11798 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11799 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11800 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011801
Jeff Johnson295189b2012-06-20 16:38:30 -070011802 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
11803 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11804 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11805 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011806 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
11807 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011808 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
11809 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11810 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
11811 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
11812 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
11813 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011814 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053011815 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070011816 {
11817 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011818 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011819 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011820
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011821 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011822 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011823 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11824 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011825 VOS_ASSERT(0);
11826 return -ENOMEM;
11827 }
11828 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11829 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11830 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011831
Jeff Johnson295189b2012-06-20 16:38:30 -070011832 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11833 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11834 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011835#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011836 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
11837 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011838 /*Consider WFD IE, only for P2P Client */
11839 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
11840 {
11841 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011842 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011843 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011844
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011845 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011846 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011847 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11848 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011849 VOS_ASSERT(0);
11850 return -ENOMEM;
11851 }
11852 // WFD IE is saved to Additional IE ; it should be accumulated to handle
11853 // WPS IE + P2P IE + WFD IE
11854 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11855 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011856
Jeff Johnson295189b2012-06-20 16:38:30 -070011857 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11858 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11859 }
11860#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011861 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011862 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011863 HS20_OUI_TYPE_SIZE)) )
11864 {
11865 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011866 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011867 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011868
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011869 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011870 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011871 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11872 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011873 VOS_ASSERT(0);
11874 return -ENOMEM;
11875 }
11876 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11877 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011878
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011879 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11880 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11881 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011882 /* Appending OSEN Information Element in Assiciation Request */
11883 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
11884 OSEN_OUI_TYPE_SIZE)) )
11885 {
11886 v_U16_t curAddIELen = pWextState->assocAddIE.length;
11887 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
11888 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011889
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011890 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011891 {
11892 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11893 "Need bigger buffer space");
11894 VOS_ASSERT(0);
11895 return -ENOMEM;
11896 }
11897 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11898 pWextState->assocAddIE.length += eLen + 2;
11899
11900 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
11901 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11902 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11903 }
11904
Abhishek Singh4322e622015-06-10 15:42:54 +053011905 /* Update only for WPA IE */
11906 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
11907 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011908
11909 /* populating as ADDIE in beacon frames */
11910 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011911 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011912 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
11913 {
11914 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11915 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
11916 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11917 {
11918 hddLog(LOGE,
11919 "Coldn't pass "
11920 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
11921 }
11922 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
11923 else
11924 hddLog(LOGE,
11925 "Could not pass on "
11926 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
11927
11928 /* IBSS mode doesn't contain params->proberesp_ies still
11929 beaconIE's need to be populated in probe response frames */
11930 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
11931 {
11932 u16 rem_probe_resp_ie_len = eLen + 2;
11933 u8 probe_rsp_ie_len[3] = {0};
11934 u8 counter = 0;
11935
11936 /* Check Probe Resp Length if it is greater then 255 then
11937 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
11938 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
11939 not able Store More then 255 bytes into One Variable */
11940
11941 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
11942 {
11943 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
11944 {
11945 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
11946 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
11947 }
11948 else
11949 {
11950 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
11951 rem_probe_resp_ie_len = 0;
11952 }
11953 }
11954
11955 rem_probe_resp_ie_len = 0;
11956
11957 if (probe_rsp_ie_len[0] > 0)
11958 {
11959 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11960 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
11961 (tANI_U8*)(genie - 2),
11962 probe_rsp_ie_len[0], NULL,
11963 eANI_BOOLEAN_FALSE)
11964 == eHAL_STATUS_FAILURE)
11965 {
11966 hddLog(LOGE,
11967 "Could not pass"
11968 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
11969 }
11970 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
11971 }
11972
11973 if (probe_rsp_ie_len[1] > 0)
11974 {
11975 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11976 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
11977 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11978 probe_rsp_ie_len[1], NULL,
11979 eANI_BOOLEAN_FALSE)
11980 == eHAL_STATUS_FAILURE)
11981 {
11982 hddLog(LOGE,
11983 "Could not pass"
11984 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
11985 }
11986 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
11987 }
11988
11989 if (probe_rsp_ie_len[2] > 0)
11990 {
11991 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11992 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
11993 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11994 probe_rsp_ie_len[2], NULL,
11995 eANI_BOOLEAN_FALSE)
11996 == eHAL_STATUS_FAILURE)
11997 {
11998 hddLog(LOGE,
11999 "Could not pass"
12000 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
12001 }
12002 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
12003 }
12004
12005 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
12006 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
12007 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
12008 {
12009 hddLog(LOGE,
12010 "Could not pass"
12011 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
12012 }
12013 }
12014 else
12015 {
12016 // Reset WNI_CFG_PROBE_RSP Flags
12017 wlan_hdd_reset_prob_rspies(pAdapter);
12018
12019 hddLog(VOS_TRACE_LEVEL_INFO,
12020 "%s: No Probe Response IE received in set beacon",
12021 __func__);
12022 }
12023 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070012024 break;
12025 case DOT11F_EID_RSN:
12026 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
12027 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
12028 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
12029 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
12030 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
12031 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053012032
12033 /* Appending Extended Capabilities with Interworking bit set
12034 * in Assoc Req.
12035 *
12036 * In assoc req this EXT Cap will only be taken into account if
12037 * interworkingService bit is set to 1. Currently
12038 * driver is only interested in interworkingService capability
12039 * from supplicant. If in future any other EXT Cap info is
12040 * required from supplicat, it needs to be handled while
12041 * sending Assoc Req in LIM.
12042 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012043 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012044 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012045 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012046 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012047 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012048
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053012049 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012050 {
Jeff Johnson902c9832012-12-10 14:28:09 -080012051 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
12052 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012053 VOS_ASSERT(0);
12054 return -ENOMEM;
12055 }
12056 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
12057 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012058
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012059 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
12060 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
12061 break;
12062 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012063#ifdef FEATURE_WLAN_WAPI
12064 case WLAN_EID_WAPI:
12065 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070012066 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070012067 pAdapter->wapi_info.nWapiMode);
12068 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012069 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070012070 akmsuiteCount = WPA_GET_LE16(tmp);
12071 tmp = tmp + 1;
12072 akmlist = (int *)(tmp);
12073 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
12074 {
12075 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
12076 }
12077 else
12078 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012079 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070012080 VOS_ASSERT(0);
12081 return -EINVAL;
12082 }
12083
12084 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
12085 {
12086 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012087 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012088 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012089 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012090 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012091 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012092 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012093 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012094 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
12095 }
12096 break;
12097#endif
12098 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012099 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012100 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012101 /* when Unknown IE is received we should break and continue
12102 * to the next IE in the buffer instead we were returning
12103 * so changing this to break */
12104 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012105 }
12106 genie += eLen;
12107 remLen -= eLen;
12108 }
12109 EXIT();
12110 return 0;
12111}
12112
12113/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053012114 * FUNCTION: hdd_isWPAIEPresent
12115 * Parse the received IE to find the WPA IE
12116 *
12117 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012118static bool hdd_isWPAIEPresent(
12119#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
12120 const u8 *ie,
12121#else
12122 u8 *ie,
12123#endif
12124 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053012125{
12126 v_U8_t eLen = 0;
12127 v_U16_t remLen = ie_len;
12128 v_U8_t elementId = 0;
12129
12130 while (remLen >= 2)
12131 {
12132 elementId = *ie++;
12133 eLen = *ie++;
12134 remLen -= 2;
12135 if (eLen > remLen)
12136 {
12137 hddLog(VOS_TRACE_LEVEL_ERROR,
12138 "%s: IE length is wrong %d", __func__, eLen);
12139 return FALSE;
12140 }
12141 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
12142 {
12143 /* OUI - 0x00 0X50 0XF2
12144 WPA Information Element - 0x01
12145 WPA version - 0x01*/
12146 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
12147 return TRUE;
12148 }
12149 ie += eLen;
12150 remLen -= eLen;
12151 }
12152 return FALSE;
12153}
12154
12155/*
Jeff Johnson295189b2012-06-20 16:38:30 -070012156 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012157 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012158 * parameters during connect operation.
12159 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012160int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012161 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012162 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012163{
12164 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012165 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012166 ENTER();
12167
12168 /*set wpa version*/
12169 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
12170
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012171 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070012172 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053012173 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070012174 {
12175 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12176 }
12177 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
12178 {
12179 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12180 }
12181 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012182
12183 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012184 pWextState->wpaVersion);
12185
12186 /*set authentication type*/
12187 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
12188
12189 if (0 > status)
12190 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012191 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012192 "%s: failed to set authentication type ", __func__);
12193 return status;
12194 }
12195
12196 /*set key mgmt type*/
12197 if (req->crypto.n_akm_suites)
12198 {
12199 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
12200 if (0 > status)
12201 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012202 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070012203 __func__);
12204 return status;
12205 }
12206 }
12207
12208 /*set pairwise cipher type*/
12209 if (req->crypto.n_ciphers_pairwise)
12210 {
12211 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
12212 req->crypto.ciphers_pairwise[0], true);
12213 if (0 > status)
12214 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012215 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012216 "%s: failed to set unicast cipher type", __func__);
12217 return status;
12218 }
12219 }
12220 else
12221 {
12222 /*Reset previous cipher suite to none*/
12223 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
12224 if (0 > status)
12225 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012226 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012227 "%s: failed to set unicast cipher type", __func__);
12228 return status;
12229 }
12230 }
12231
12232 /*set group cipher type*/
12233 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
12234 false);
12235
12236 if (0 > status)
12237 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012238 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070012239 __func__);
12240 return status;
12241 }
12242
Chet Lanctot186b5732013-03-18 10:26:30 -070012243#ifdef WLAN_FEATURE_11W
12244 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
12245#endif
12246
Jeff Johnson295189b2012-06-20 16:38:30 -070012247 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
12248 if (req->ie_len)
12249 {
12250 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
12251 if ( 0 > status)
12252 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012253 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012254 __func__);
12255 return status;
12256 }
12257 }
12258
12259 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012260 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012261 {
12262 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
12263 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
12264 )
12265 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012266 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070012267 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
12268 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012269 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012270 __func__);
12271 return -EOPNOTSUPP;
12272 }
12273 else
12274 {
12275 u8 key_len = req->key_len;
12276 u8 key_idx = req->key_idx;
12277
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012278 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012279 && (CSR_MAX_NUM_KEY > key_idx)
12280 )
12281 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012282 hddLog(VOS_TRACE_LEVEL_INFO,
12283 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012284 __func__, key_idx, key_len);
12285 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012286 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012287 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012288 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070012289 (u8)key_len;
12290 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
12291 }
12292 }
12293 }
12294 }
12295
12296 return status;
12297}
12298
12299/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012300 * FUNCTION: wlan_hdd_try_disconnect
12301 * This function is used to disconnect from previous
12302 * connection
12303 */
12304static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
12305{
12306 long ret = 0;
12307 hdd_station_ctx_t *pHddStaCtx;
12308 eMib_dot11DesiredBssType connectedBssType;
12309
12310 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12311
12312 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
12313
12314 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
12315 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
12316 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
12317 {
12318 /* Issue disconnect to CSR */
12319 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12320 if( eHAL_STATUS_SUCCESS ==
12321 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12322 pAdapter->sessionId,
12323 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
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 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
12336 {
12337 ret = wait_for_completion_interruptible_timeout(
12338 &pAdapter->disconnect_comp_var,
12339 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12340 if (0 >= ret)
12341 {
12342 hddLog(LOGE, FL("Failed to receive disconnect event"));
12343 return -EALREADY;
12344 }
12345 }
12346
12347 return 0;
12348}
12349
12350/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053012351 * FUNCTION: __wlan_hdd_cfg80211_connect
12352 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070012353 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012354static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012355 struct net_device *ndev,
12356 struct cfg80211_connect_params *req
12357 )
12358{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012359 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012360 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012361 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053012362 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012363
12364 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012365
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012366 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12367 TRACE_CODE_HDD_CFG80211_CONNECT,
12368 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012369 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012370 "%s: device_mode = %s (%d)", __func__,
12371 hdd_device_modetoString(pAdapter->device_mode),
12372 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012373
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012374 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012375 if (!pHddCtx)
12376 {
12377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12378 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053012379 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012380 }
12381
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012382 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012383 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012384 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012385 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012386 }
12387
Agarwal Ashish51325b52014-06-16 16:50:49 +053012388 if (vos_max_concurrent_connections_reached()) {
12389 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12390 return -ECONNREFUSED;
12391 }
12392
Jeff Johnson295189b2012-06-20 16:38:30 -070012393#ifdef WLAN_BTAMP_FEATURE
12394 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012395 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070012396 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012397 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012398 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080012399 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012400 }
12401#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012402
12403 //If Device Mode is Station Concurrent Sessions Exit BMps
12404 //P2P Mode will be taken care in Open/close adapter
12405 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012406 (vos_concurrent_open_sessions_running())) {
12407 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
12408 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012409 }
12410
12411 /*Try disconnecting if already in connected state*/
12412 status = wlan_hdd_try_disconnect(pAdapter);
12413 if ( 0 > status)
12414 {
12415 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12416 " connection"));
12417 return -EALREADY;
12418 }
12419
Jeff Johnson295189b2012-06-20 16:38:30 -070012420 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012421 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070012422
12423 if ( 0 > status)
12424 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012425 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070012426 __func__);
12427 return status;
12428 }
Mohit Khanna765234a2012-09-11 15:08:35 -070012429 if ( req->channel )
12430 {
12431 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
12432 req->ssid_len, req->bssid,
12433 req->channel->hw_value);
12434 }
12435 else
12436 {
12437 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012438 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070012439 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012440
Sushant Kaushikd7083982015-03-18 14:33:24 +053012441 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012442 {
12443 //ReEnable BMPS if disabled
12444 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
12445 (NULL != pHddCtx))
12446 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012447 if (pHddCtx->hdd_wlan_suspended)
12448 {
12449 hdd_set_pwrparams(pHddCtx);
12450 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012451 //ReEnable Bmps and Imps back
12452 hdd_enable_bmps_imps(pHddCtx);
12453 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053012454 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012455 return status;
12456 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012457 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012458 EXIT();
12459 return status;
12460}
12461
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012462static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
12463 struct net_device *ndev,
12464 struct cfg80211_connect_params *req)
12465{
12466 int ret;
12467 vos_ssr_protect(__func__);
12468 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
12469 vos_ssr_unprotect(__func__);
12470
12471 return ret;
12472}
Jeff Johnson295189b2012-06-20 16:38:30 -070012473
12474/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012475 * FUNCTION: wlan_hdd_disconnect
12476 * This function is used to issue a disconnect request to SME
12477 */
12478int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
12479{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012480 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012481 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012482 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012483 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012484
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012485 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012486
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012487 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012488 if (0 != status)
12489 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012490 return status;
12491 }
12492
Sushant Kaushikb4834d22015-07-15 15:29:05 +053012493 if (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)
12494 {
12495 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
12496 pAdapter->sessionId);
12497 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012498 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012499
Agarwal Ashish47d18112014-08-04 19:55:07 +053012500 /* Need to apply spin lock before decreasing active sessions
12501 * as there can be chance for double decrement if context switch
12502 * Calls hdd_DisConnectHandler.
12503 */
12504
12505 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012506 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
12507 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012508 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
12509 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053012510 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
12511 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012512
Abhishek Singhf4669da2014-05-26 15:07:49 +053012513 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053012514 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
12515
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012516 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012517
Mihir Shete182a0b22014-08-18 16:08:48 +053012518 /*
12519 * stop tx queues before deleting STA/BSS context from the firmware.
12520 * tx has to be disabled because the firmware can get busy dropping
12521 * the tx frames after BSS/STA has been deleted and will not send
12522 * back a response resulting in WDI timeout
12523 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053012524 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053012525 netif_tx_disable(pAdapter->dev);
12526 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012527
Mihir Shete182a0b22014-08-18 16:08:48 +053012528 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012529 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12530 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012531 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
12532 {
12533 hddLog(VOS_TRACE_LEVEL_INFO,
12534 FL("status = %d, already disconnected"),
12535 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012536
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012537 }
12538 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012539 {
12540 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012541 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012542 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012543 result = -EINVAL;
12544 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012545 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012546 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012547 &pAdapter->disconnect_comp_var,
12548 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012549 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012550 {
12551 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012552 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012553 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012554 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012555 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012556 {
12557 hddLog(VOS_TRACE_LEVEL_ERROR,
12558 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012559 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012560 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012561disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012562 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12563 FL("Set HDD connState to eConnectionState_NotConnected"));
12564 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
12565
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012566 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012567 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012568}
12569
12570
12571/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012572 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070012573 * This function is used to issue a disconnect request to SME
12574 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012575static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012576 struct net_device *dev,
12577 u16 reason
12578 )
12579{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012580 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012581 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012582 tCsrRoamProfile *pRoamProfile;
12583 hdd_station_ctx_t *pHddStaCtx;
12584 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012585#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012586 tANI_U8 staIdx;
12587#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012588
Jeff Johnson295189b2012-06-20 16:38:30 -070012589 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012590
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012591 if (!pAdapter) {
12592 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
12593 return -EINVAL;
12594 }
12595
12596 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12597 if (!pHddStaCtx) {
12598 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
12599 return -EINVAL;
12600 }
12601
12602 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12603 status = wlan_hdd_validate_context(pHddCtx);
12604 if (0 != status)
12605 {
12606 return status;
12607 }
12608
12609 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
12610
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012611 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12612 TRACE_CODE_HDD_CFG80211_DISCONNECT,
12613 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012614 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
12615 __func__, hdd_device_modetoString(pAdapter->device_mode),
12616 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012617
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012618 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
12619 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070012620
Jeff Johnson295189b2012-06-20 16:38:30 -070012621 if (NULL != pRoamProfile)
12622 {
12623 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012624 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
12625 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070012626 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012627 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070012628 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012629 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012630 switch(reason)
12631 {
12632 case WLAN_REASON_MIC_FAILURE:
12633 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
12634 break;
12635
12636 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
12637 case WLAN_REASON_DISASSOC_AP_BUSY:
12638 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
12639 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
12640 break;
12641
12642 case WLAN_REASON_PREV_AUTH_NOT_VALID:
12643 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053012644 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070012645 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
12646 break;
12647
Jeff Johnson295189b2012-06-20 16:38:30 -070012648 default:
12649 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
12650 break;
12651 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012652 pScanInfo = &pHddCtx->scan_info;
12653 if (pScanInfo->mScanPending)
12654 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012655 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012656 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053012657 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012658 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012659 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053012660 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012661#ifdef FEATURE_WLAN_TDLS
12662 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012663 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012664 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012665 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
12666 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012667 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012668 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012669 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012671 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012672 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012673 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012674 status = sme_DeleteTdlsPeerSta(
12675 WLAN_HDD_GET_HAL_CTX(pAdapter),
12676 pAdapter->sessionId,
12677 mac);
12678 if (status != eHAL_STATUS_SUCCESS) {
12679 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
12680 return -EPERM;
12681 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012682 }
12683 }
12684#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012685 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012686 status = wlan_hdd_disconnect(pAdapter, reasonCode);
12687 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070012688 {
12689 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012690 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012691 __func__, (int)status );
12692 return -EINVAL;
12693 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012694 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012695 else
12696 {
12697 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
12698 "called while in %d state", __func__,
12699 pHddStaCtx->conn_info.connState);
12700 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012701 }
12702 else
12703 {
12704 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
12705 }
12706
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012707 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012708 return status;
12709}
12710
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012711static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
12712 struct net_device *dev,
12713 u16 reason
12714 )
12715{
12716 int ret;
12717 vos_ssr_protect(__func__);
12718 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
12719 vos_ssr_unprotect(__func__);
12720
12721 return ret;
12722}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012723
Jeff Johnson295189b2012-06-20 16:38:30 -070012724/*
12725 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012726 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012727 * settings in IBSS mode.
12728 */
12729static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012730 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012731 struct cfg80211_ibss_params *params
12732 )
12733{
12734 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012735 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012736 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
12737 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012738
Jeff Johnson295189b2012-06-20 16:38:30 -070012739 ENTER();
12740
12741 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070012742 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070012743
12744 if (params->ie_len && ( NULL != params->ie) )
12745 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012746 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12747 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012748 {
12749 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12750 encryptionType = eCSR_ENCRYPT_TYPE_AES;
12751 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012752 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012753 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012754 tDot11fIEWPA dot11WPAIE;
12755 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012756 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012757
Wilson Yang00256342013-10-10 23:13:38 -070012758 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012759 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12760 params->ie_len, DOT11F_EID_WPA);
12761 if ( NULL != ie )
12762 {
12763 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12764 // Unpack the WPA IE
12765 //Skip past the EID byte and length byte - and four byte WiFi OUI
12766 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
12767 &ie[2+4],
12768 ie[1] - 4,
12769 &dot11WPAIE);
12770 /*Extract the multicast cipher, the encType for unicast
12771 cipher for wpa-none is none*/
12772 encryptionType =
12773 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
12774 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012775 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012776
Jeff Johnson295189b2012-06-20 16:38:30 -070012777 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
12778
12779 if (0 > status)
12780 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012781 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012782 __func__);
12783 return status;
12784 }
12785 }
12786
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012787 pWextState->roamProfile.AuthType.authType[0] =
12788 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012789 eCSR_AUTH_TYPE_OPEN_SYSTEM;
12790
12791 if (params->privacy)
12792 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012793 /* Security enabled IBSS, At this time there is no information available
12794 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070012795 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012796 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070012797 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012798 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070012799 *enable privacy bit in beacons */
12800
12801 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
12802 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012803 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
12804 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012805 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
12806 pWextState->roamProfile.EncryptionType.numEntries = 1;
12807 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012808 return status;
12809}
12810
12811/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012812 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012813 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012814 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012815static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012816 struct net_device *dev,
12817 struct cfg80211_ibss_params *params
12818 )
12819{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012820 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012821 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12822 tCsrRoamProfile *pRoamProfile;
12823 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012824 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12825 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012826 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070012827
12828 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012829
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012830 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12831 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
12832 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012833 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012834 "%s: device_mode = %s (%d)", __func__,
12835 hdd_device_modetoString(pAdapter->device_mode),
12836 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012837
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012838 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012839 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012840 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012841 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012842 }
12843
12844 if (NULL == pWextState)
12845 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012846 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012847 __func__);
12848 return -EIO;
12849 }
12850
Agarwal Ashish51325b52014-06-16 16:50:49 +053012851 if (vos_max_concurrent_connections_reached()) {
12852 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12853 return -ECONNREFUSED;
12854 }
12855
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012856 /*Try disconnecting if already in connected state*/
12857 status = wlan_hdd_try_disconnect(pAdapter);
12858 if ( 0 > status)
12859 {
12860 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12861 " IBSS connection"));
12862 return -EALREADY;
12863 }
12864
Jeff Johnson295189b2012-06-20 16:38:30 -070012865 pRoamProfile = &pWextState->roamProfile;
12866
12867 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
12868 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012869 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012870 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012871 return -EINVAL;
12872 }
12873
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012874 /* BSSID is provided by upper layers hence no need to AUTO generate */
12875 if (NULL != params->bssid) {
12876 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12877 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
12878 hddLog (VOS_TRACE_LEVEL_ERROR,
12879 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12880 return -EIO;
12881 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012882 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012883 }
krunal sonie9002db2013-11-25 14:24:17 -080012884 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
12885 {
12886 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12887 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
12888 {
12889 hddLog (VOS_TRACE_LEVEL_ERROR,
12890 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12891 return -EIO;
12892 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012893
12894 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080012895 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012896 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080012897 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012898
Jeff Johnson295189b2012-06-20 16:38:30 -070012899 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070012900 if (NULL !=
12901#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12902 params->chandef.chan)
12903#else
12904 params->channel)
12905#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012906 {
12907 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012908 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12909 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
12910 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12911 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012912
12913 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012914 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070012915 ieee80211_frequency_to_channel(
12916#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12917 params->chandef.chan->center_freq);
12918#else
12919 params->channel->center_freq);
12920#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012921
12922 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
12923 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070012924 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012925 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
12926 __func__);
12927 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070012928 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012929
12930 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012931 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012932 if (channelNum == validChan[indx])
12933 {
12934 break;
12935 }
12936 }
12937 if (indx >= numChans)
12938 {
12939 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012940 __func__, channelNum);
12941 return -EINVAL;
12942 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012943 /* Set the Operational Channel */
12944 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
12945 channelNum);
12946 pRoamProfile->ChannelInfo.numOfChannels = 1;
12947 pHddStaCtx->conn_info.operationChannel = channelNum;
12948 pRoamProfile->ChannelInfo.ChannelList =
12949 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070012950 }
12951
12952 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012953 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070012954 if (status < 0)
12955 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012956 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070012957 __func__);
12958 return status;
12959 }
12960
12961 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012962 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012963 params->ssid_len, params->bssid,
12964 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070012965
12966 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012967 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012968
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012969 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012970 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012971}
12972
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012973static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
12974 struct net_device *dev,
12975 struct cfg80211_ibss_params *params
12976 )
12977{
12978 int ret = 0;
12979
12980 vos_ssr_protect(__func__);
12981 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
12982 vos_ssr_unprotect(__func__);
12983
12984 return ret;
12985}
12986
Jeff Johnson295189b2012-06-20 16:38:30 -070012987/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012988 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012989 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012990 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012991static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012992 struct net_device *dev
12993 )
12994{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012995 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012996 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12997 tCsrRoamProfile *pRoamProfile;
12998 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012999 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013000
13001 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013002
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013003 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13004 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
13005 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013006 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013007 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013008 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013009 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013010 }
13011
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013012 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
13013 hdd_device_modetoString(pAdapter->device_mode),
13014 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070013015 if (NULL == pWextState)
13016 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013017 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070013018 __func__);
13019 return -EIO;
13020 }
13021
13022 pRoamProfile = &pWextState->roamProfile;
13023
13024 /* Issue disconnect only if interface type is set to IBSS */
13025 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
13026 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013027 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070013028 __func__);
13029 return -EINVAL;
13030 }
13031
13032 /* Issue Disconnect request */
13033 INIT_COMPLETION(pAdapter->disconnect_comp_var);
13034 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
13035 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
13036
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013037 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013038 return 0;
13039}
13040
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013041static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
13042 struct net_device *dev
13043 )
13044{
13045 int ret = 0;
13046
13047 vos_ssr_protect(__func__);
13048 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
13049 vos_ssr_unprotect(__func__);
13050
13051 return ret;
13052}
13053
Jeff Johnson295189b2012-06-20 16:38:30 -070013054/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013055 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070013056 * This function is used to set the phy parameters
13057 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
13058 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013059static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013060 u32 changed)
13061{
13062 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
13063 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013064 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013065
13066 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013067
13068 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013069 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
13070 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013071
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013072 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013073 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013074 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013075 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013076 }
13077
Jeff Johnson295189b2012-06-20 16:38:30 -070013078 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
13079 {
13080 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
13081 WNI_CFG_RTS_THRESHOLD_STAMAX :
13082 wiphy->rts_threshold;
13083
13084 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013085 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070013086 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013087 hddLog(VOS_TRACE_LEVEL_ERROR,
13088 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013089 __func__, rts_threshold);
13090 return -EINVAL;
13091 }
13092
13093 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
13094 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013095 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013096 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013097 hddLog(VOS_TRACE_LEVEL_ERROR,
13098 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013099 __func__, rts_threshold);
13100 return -EIO;
13101 }
13102
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013103 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013104 rts_threshold);
13105 }
13106
13107 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
13108 {
13109 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
13110 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
13111 wiphy->frag_threshold;
13112
13113 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013114 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013115 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013116 hddLog(VOS_TRACE_LEVEL_ERROR,
13117 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013118 frag_threshold);
13119 return -EINVAL;
13120 }
13121
13122 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
13123 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013124 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013125 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013126 hddLog(VOS_TRACE_LEVEL_ERROR,
13127 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013128 __func__, frag_threshold);
13129 return -EIO;
13130 }
13131
13132 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
13133 frag_threshold);
13134 }
13135
13136 if ((changed & WIPHY_PARAM_RETRY_SHORT)
13137 || (changed & WIPHY_PARAM_RETRY_LONG))
13138 {
13139 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
13140 wiphy->retry_short :
13141 wiphy->retry_long;
13142
13143 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
13144 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
13145 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013146 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013147 __func__, retry_value);
13148 return -EINVAL;
13149 }
13150
13151 if (changed & WIPHY_PARAM_RETRY_SHORT)
13152 {
13153 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
13154 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013155 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013156 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013157 hddLog(VOS_TRACE_LEVEL_ERROR,
13158 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013159 __func__, retry_value);
13160 return -EIO;
13161 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013162 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013163 __func__, retry_value);
13164 }
13165 else if (changed & WIPHY_PARAM_RETRY_SHORT)
13166 {
13167 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
13168 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013169 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013170 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013171 hddLog(VOS_TRACE_LEVEL_ERROR,
13172 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013173 __func__, retry_value);
13174 return -EIO;
13175 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013176 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013177 __func__, retry_value);
13178 }
13179 }
13180
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013181 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013182 return 0;
13183}
13184
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013185static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
13186 u32 changed)
13187{
13188 int ret;
13189
13190 vos_ssr_protect(__func__);
13191 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
13192 vos_ssr_unprotect(__func__);
13193
13194 return ret;
13195}
13196
Jeff Johnson295189b2012-06-20 16:38:30 -070013197/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013198 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013199 * This function is used to set the txpower
13200 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013201static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013202#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13203 struct wireless_dev *wdev,
13204#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013205#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013206 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013207#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013208 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013209#endif
13210 int dbm)
13211{
13212 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013213 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013214 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
13215 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013216 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013217
13218 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013219
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013220 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13221 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
13222 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013223 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013224 if (0 != status)
13225 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013226 return status;
13227 }
13228
13229 hHal = pHddCtx->hHal;
13230
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013231 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
13232 dbm, ccmCfgSetCallback,
13233 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013234 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013235 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013236 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
13237 return -EIO;
13238 }
13239
13240 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
13241 dbm);
13242
13243 switch(type)
13244 {
13245 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
13246 /* Fall through */
13247 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
13248 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
13249 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013250 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
13251 __func__);
13252 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070013253 }
13254 break;
13255 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013256 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070013257 __func__);
13258 return -EOPNOTSUPP;
13259 break;
13260 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013261 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
13262 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070013263 return -EIO;
13264 }
13265
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013266 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013267 return 0;
13268}
13269
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013270static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
13271#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13272 struct wireless_dev *wdev,
13273#endif
13274#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13275 enum tx_power_setting type,
13276#else
13277 enum nl80211_tx_power_setting type,
13278#endif
13279 int dbm)
13280{
13281 int ret;
13282 vos_ssr_protect(__func__);
13283 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
13284#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13285 wdev,
13286#endif
13287#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13288 type,
13289#else
13290 type,
13291#endif
13292 dbm);
13293 vos_ssr_unprotect(__func__);
13294
13295 return ret;
13296}
13297
Jeff Johnson295189b2012-06-20 16:38:30 -070013298/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013299 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013300 * This function is used to read the txpower
13301 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013302static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013303#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13304 struct wireless_dev *wdev,
13305#endif
13306 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070013307{
13308
13309 hdd_adapter_t *pAdapter;
13310 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013311 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013312
Jeff Johnsone7245742012-09-05 17:12:55 -070013313 ENTER();
13314
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013315 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013316 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013317 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013318 *dbm = 0;
13319 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013320 }
13321
Jeff Johnson295189b2012-06-20 16:38:30 -070013322 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
13323 if (NULL == pAdapter)
13324 {
13325 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
13326 return -ENOENT;
13327 }
13328
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053013329 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13330 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
13331 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070013332 wlan_hdd_get_classAstats(pAdapter);
13333 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
13334
Jeff Johnsone7245742012-09-05 17:12:55 -070013335 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013336 return 0;
13337}
13338
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013339static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
13340#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13341 struct wireless_dev *wdev,
13342#endif
13343 int *dbm)
13344{
13345 int ret;
13346
13347 vos_ssr_protect(__func__);
13348 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
13349#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13350 wdev,
13351#endif
13352 dbm);
13353 vos_ssr_unprotect(__func__);
13354
13355 return ret;
13356}
13357
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013358static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013359#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13360 const u8* mac,
13361#else
13362 u8* mac,
13363#endif
13364 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070013365{
13366 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13367 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13368 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053013369 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013370
13371 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
13372 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070013373
13374 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
13375 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
13376 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
13377 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
13378 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
13379 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
13380 tANI_U16 maxRate = 0;
13381 tANI_U16 myRate;
13382 tANI_U16 currentRate = 0;
13383 tANI_U8 maxSpeedMCS = 0;
13384 tANI_U8 maxMCSIdx = 0;
13385 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053013386 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013387 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013388 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013389
Leo Chang6f8870f2013-03-26 18:11:36 -070013390#ifdef WLAN_FEATURE_11AC
13391 tANI_U32 vht_mcs_map;
13392 eDataRate11ACMaxMcs vhtMaxMcs;
13393#endif /* WLAN_FEATURE_11AC */
13394
Jeff Johnsone7245742012-09-05 17:12:55 -070013395 ENTER();
13396
Jeff Johnson295189b2012-06-20 16:38:30 -070013397 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
13398 (0 == ssidlen))
13399 {
13400 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
13401 " Invalid ssidlen, %d", __func__, ssidlen);
13402 /*To keep GUI happy*/
13403 return 0;
13404 }
13405
Mukul Sharma811205f2014-07-09 21:07:30 +053013406 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
13407 {
13408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13409 "%s: Roaming in progress, so unable to proceed this request", __func__);
13410 return 0;
13411 }
13412
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013413 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013414 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013415 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013416 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013417 }
13418
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053013419 wlan_hdd_get_station_stats(pAdapter);
13420 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013421
Kiet Lam3b17fc82013-09-27 05:24:08 +053013422 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
13423 sinfo->filled |= STATION_INFO_SIGNAL;
13424
c_hpothu09f19542014-05-30 21:53:31 +053013425 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053013426 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
13427 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053013428 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053013429 {
13430 rate_flags = pAdapter->maxRateFlags;
13431 }
c_hpothu44ff4e02014-05-08 00:13:57 +053013432
Jeff Johnson295189b2012-06-20 16:38:30 -070013433 //convert to the UI units of 100kbps
13434 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
13435
13436#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070013437 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 -070013438 sinfo->signal,
13439 pCfg->reportMaxLinkSpeed,
13440 myRate,
13441 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013442 (int) pCfg->linkSpeedRssiMid,
13443 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070013444 (int) rate_flags,
13445 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013446#endif //LINKSPEED_DEBUG_ENABLED
13447
13448 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
13449 {
13450 // we do not want to necessarily report the current speed
13451 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
13452 {
13453 // report the max possible speed
13454 rssidx = 0;
13455 }
13456 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
13457 {
13458 // report the max possible speed with RSSI scaling
13459 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
13460 {
13461 // report the max possible speed
13462 rssidx = 0;
13463 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013464 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070013465 {
13466 // report middle speed
13467 rssidx = 1;
13468 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013469 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
13470 {
13471 // report middle speed
13472 rssidx = 2;
13473 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013474 else
13475 {
13476 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013477 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070013478 }
13479 }
13480 else
13481 {
13482 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
13483 hddLog(VOS_TRACE_LEVEL_ERROR,
13484 "%s: Invalid value for reportMaxLinkSpeed: %u",
13485 __func__, pCfg->reportMaxLinkSpeed);
13486 rssidx = 0;
13487 }
13488
13489 maxRate = 0;
13490
13491 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013492 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
13493 OperationalRates, &ORLeng))
13494 {
13495 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13496 /*To keep GUI happy*/
13497 return 0;
13498 }
13499
Jeff Johnson295189b2012-06-20 16:38:30 -070013500 for (i = 0; i < ORLeng; i++)
13501 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013502 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013503 {
13504 /* Validate Rate Set */
13505 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
13506 {
13507 currentRate = supported_data_rate[j].supported_rate[rssidx];
13508 break;
13509 }
13510 }
13511 /* Update MAX rate */
13512 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13513 }
13514
13515 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013516 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
13517 ExtendedRates, &ERLeng))
13518 {
13519 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13520 /*To keep GUI happy*/
13521 return 0;
13522 }
13523
Jeff Johnson295189b2012-06-20 16:38:30 -070013524 for (i = 0; i < ERLeng; i++)
13525 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013526 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013527 {
13528 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
13529 {
13530 currentRate = supported_data_rate[j].supported_rate[rssidx];
13531 break;
13532 }
13533 }
13534 /* Update MAX rate */
13535 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13536 }
c_hpothu79aab322014-07-14 21:11:01 +053013537
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013538 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053013539 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013540 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053013541 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070013542 {
c_hpothu79aab322014-07-14 21:11:01 +053013543 if (rate_flags & eHAL_TX_RATE_VHT80)
13544 mode = 2;
13545 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
13546 mode = 1;
13547 else
13548 mode = 0;
13549
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013550 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
13551 MCSRates, &MCSLeng))
13552 {
13553 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13554 /*To keep GUI happy*/
13555 return 0;
13556 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013557 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070013558#ifdef WLAN_FEATURE_11AC
13559 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013560 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070013561 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013562 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013563 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070013564 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070013565 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013566 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013567 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013568 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070013569 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013570 maxMCSIdx = 7;
13571 }
13572 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
13573 {
13574 maxMCSIdx = 8;
13575 }
13576 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
13577 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013578 //VHT20 is supporting 0~8
13579 if (rate_flags & eHAL_TX_RATE_VHT20)
13580 maxMCSIdx = 8;
13581 else
13582 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070013583 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013584
c_hpothu79aab322014-07-14 21:11:01 +053013585 if (0 != rssidx)/*check for scaled */
13586 {
13587 //get middle rate MCS index if rssi=1/2
13588 for (i=0; i <= maxMCSIdx; i++)
13589 {
13590 if (sinfo->signal <= rssiMcsTbl[mode][i])
13591 {
13592 maxMCSIdx = i;
13593 break;
13594 }
13595 }
13596 }
13597
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013598 if (rate_flags & eHAL_TX_RATE_VHT80)
13599 {
13600 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
13601 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
13602 }
13603 else if (rate_flags & eHAL_TX_RATE_VHT40)
13604 {
13605 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
13606 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
13607 }
13608 else if (rate_flags & eHAL_TX_RATE_VHT20)
13609 {
13610 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
13611 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
13612 }
13613
Leo Chang6f8870f2013-03-26 18:11:36 -070013614 maxSpeedMCS = 1;
13615 if (currentRate > maxRate)
13616 {
13617 maxRate = currentRate;
13618 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013619
Leo Chang6f8870f2013-03-26 18:11:36 -070013620 }
13621 else
13622#endif /* WLAN_FEATURE_11AC */
13623 {
13624 if (rate_flags & eHAL_TX_RATE_HT40)
13625 {
13626 rateFlag |= 1;
13627 }
13628 if (rate_flags & eHAL_TX_RATE_SGI)
13629 {
13630 rateFlag |= 2;
13631 }
13632
Girish Gowli01abcee2014-07-31 20:18:55 +053013633 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053013634 if (rssidx == 1 || rssidx == 2)
13635 {
13636 //get middle rate MCS index if rssi=1/2
13637 for (i=0; i <= 7; i++)
13638 {
13639 if (sinfo->signal <= rssiMcsTbl[mode][i])
13640 {
13641 temp = i+1;
13642 break;
13643 }
13644 }
13645 }
c_hpothu79aab322014-07-14 21:11:01 +053013646
13647 for (i = 0; i < MCSLeng; i++)
13648 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013649 for (j = 0; j < temp; j++)
13650 {
13651 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
13652 {
13653 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013654 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013655 break;
13656 }
13657 }
13658 if ((j < temp) && (currentRate > maxRate))
13659 {
13660 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070013661 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013662 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013663 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013664 }
13665 }
13666
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013667 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
13668 {
13669 maxRate = myRate;
13670 maxSpeedMCS = 1;
13671 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13672 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053013674 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070013675 {
13676 maxRate = myRate;
13677 if (rate_flags & eHAL_TX_RATE_LEGACY)
13678 {
13679 maxSpeedMCS = 0;
13680 }
13681 else
13682 {
13683 maxSpeedMCS = 1;
13684 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13685 }
13686 }
13687
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013688 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070013689 {
13690 sinfo->txrate.legacy = maxRate;
13691#ifdef LINKSPEED_DEBUG_ENABLED
13692 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
13693#endif //LINKSPEED_DEBUG_ENABLED
13694 }
13695 else
13696 {
13697 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070013698#ifdef WLAN_FEATURE_11AC
13699 sinfo->txrate.nss = 1;
13700 if (rate_flags & eHAL_TX_RATE_VHT80)
13701 {
13702 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013703 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070013704 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013705 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070013706 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013707 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13708 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13709 }
13710 else if (rate_flags & eHAL_TX_RATE_VHT20)
13711 {
13712 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13713 }
13714#endif /* WLAN_FEATURE_11AC */
13715 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
13716 {
13717 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13718 if (rate_flags & eHAL_TX_RATE_HT40)
13719 {
13720 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13721 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013722 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013723 if (rate_flags & eHAL_TX_RATE_SGI)
13724 {
13725 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13726 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013727
Jeff Johnson295189b2012-06-20 16:38:30 -070013728#ifdef LINKSPEED_DEBUG_ENABLED
13729 pr_info("Reporting MCS rate %d flags %x\n",
13730 sinfo->txrate.mcs,
13731 sinfo->txrate.flags );
13732#endif //LINKSPEED_DEBUG_ENABLED
13733 }
13734 }
13735 else
13736 {
13737 // report current rate instead of max rate
13738
13739 if (rate_flags & eHAL_TX_RATE_LEGACY)
13740 {
13741 //provide to the UI in units of 100kbps
13742 sinfo->txrate.legacy = myRate;
13743#ifdef LINKSPEED_DEBUG_ENABLED
13744 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
13745#endif //LINKSPEED_DEBUG_ENABLED
13746 }
13747 else
13748 {
13749 //must be MCS
13750 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013751#ifdef WLAN_FEATURE_11AC
13752 sinfo->txrate.nss = 1;
13753 if (rate_flags & eHAL_TX_RATE_VHT80)
13754 {
13755 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13756 }
13757 else
13758#endif /* WLAN_FEATURE_11AC */
13759 {
13760 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13761 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013762 if (rate_flags & eHAL_TX_RATE_SGI)
13763 {
13764 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13765 }
13766 if (rate_flags & eHAL_TX_RATE_HT40)
13767 {
13768 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13769 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013770#ifdef WLAN_FEATURE_11AC
13771 else if (rate_flags & eHAL_TX_RATE_VHT80)
13772 {
13773 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
13774 }
13775#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070013776#ifdef LINKSPEED_DEBUG_ENABLED
13777 pr_info("Reporting actual MCS rate %d flags %x\n",
13778 sinfo->txrate.mcs,
13779 sinfo->txrate.flags );
13780#endif //LINKSPEED_DEBUG_ENABLED
13781 }
13782 }
13783 sinfo->filled |= STATION_INFO_TX_BITRATE;
13784
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013785 sinfo->tx_packets =
13786 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
13787 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
13788 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
13789 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
13790
13791 sinfo->tx_retries =
13792 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
13793 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
13794 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
13795 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
13796
13797 sinfo->tx_failed =
13798 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
13799 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
13800 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
13801 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
13802
13803 sinfo->filled |=
13804 STATION_INFO_TX_PACKETS |
13805 STATION_INFO_TX_RETRIES |
13806 STATION_INFO_TX_FAILED;
13807
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013808 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13809 TRACE_CODE_HDD_CFG80211_GET_STA,
13810 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013811 EXIT();
13812 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013813}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013814#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
13815static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13816 const u8* mac, struct station_info *sinfo)
13817#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013818static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13819 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013820#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013821{
13822 int ret;
13823
13824 vos_ssr_protect(__func__);
13825 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
13826 vos_ssr_unprotect(__func__);
13827
13828 return ret;
13829}
13830
13831static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070013832 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070013833{
13834 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013835 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013836 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013837 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013838
Jeff Johnsone7245742012-09-05 17:12:55 -070013839 ENTER();
13840
Jeff Johnson295189b2012-06-20 16:38:30 -070013841 if (NULL == pAdapter)
13842 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013843 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013844 return -ENODEV;
13845 }
13846
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013847 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13848 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
13849 pAdapter->sessionId, timeout));
13850
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013851 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013852 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013853 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013854 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013855 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013856 }
13857
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013858 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
13859 (TRUE == pHddCtx->hdd_wlan_suspended) &&
13860 (pHddCtx->cfg_ini->fhostArpOffload) &&
13861 (eConnectionState_Associated ==
13862 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13863 {
Amar Singhald53568e2013-09-26 11:03:45 -070013864
13865 hddLog(VOS_TRACE_LEVEL_INFO,
13866 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053013867 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013868 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13869 {
13870 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013871 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013872 __func__, vos_status);
13873 }
13874 }
13875
Jeff Johnson295189b2012-06-20 16:38:30 -070013876 /**The get power cmd from the supplicant gets updated by the nl only
13877 *on successful execution of the function call
13878 *we are oppositely mapped w.r.t mode in the driver
13879 **/
13880 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
13881
13882 if (VOS_STATUS_E_FAILURE == vos_status)
13883 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013884 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13885 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013886 return -EINVAL;
13887 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013888 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013889 return 0;
13890}
13891
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013892static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
13893 struct net_device *dev, bool mode, int timeout)
13894{
13895 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013896
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013897 vos_ssr_protect(__func__);
13898 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
13899 vos_ssr_unprotect(__func__);
13900
13901 return ret;
13902}
Jeff Johnson295189b2012-06-20 16:38:30 -070013903#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013904static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
13905 struct net_device *netdev,
13906 u8 key_index)
13907{
13908 ENTER();
13909 return 0;
13910}
13911
Jeff Johnson295189b2012-06-20 16:38:30 -070013912static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013913 struct net_device *netdev,
13914 u8 key_index)
13915{
13916 int ret;
13917 vos_ssr_protect(__func__);
13918 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
13919 vos_ssr_unprotect(__func__);
13920 return ret;
13921}
13922#endif //LINUX_VERSION_CODE
13923
13924#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13925static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13926 struct net_device *dev,
13927 struct ieee80211_txq_params *params)
13928{
13929 ENTER();
13930 return 0;
13931}
13932#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13933static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13934 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013935{
Jeff Johnsone7245742012-09-05 17:12:55 -070013936 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070013937 return 0;
13938}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013939#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070013940
13941#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13942static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013943 struct net_device *dev,
13944 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013945{
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, dev, params);
13950 vos_ssr_unprotect(__func__);
13951 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013952}
13953#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13954static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
13955 struct ieee80211_txq_params *params)
13956{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013957 int ret;
13958
13959 vos_ssr_protect(__func__);
13960 ret = __wlan_hdd_set_txq_params(wiphy, params);
13961 vos_ssr_unprotect(__func__);
13962 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013963}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013964#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013965
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013966static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013967 struct net_device *dev,
13968 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070013969{
13970 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013971 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013972 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013973 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013974 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013975 v_CONTEXT_t pVosContext = NULL;
13976 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013977
Jeff Johnsone7245742012-09-05 17:12:55 -070013978 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013979
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013980 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070013981 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013982 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013983 return -EINVAL;
13984 }
13985
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013986 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13987 TRACE_CODE_HDD_CFG80211_DEL_STA,
13988 pAdapter->sessionId, pAdapter->device_mode));
13989
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013990 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13991 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013992 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013993 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013994 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013995 }
13996
Jeff Johnson295189b2012-06-20 16:38:30 -070013997 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013998 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013999 )
14000 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014001 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
14002 pSapCtx = VOS_GET_SAP_CB(pVosContext);
14003 if(pSapCtx == NULL){
14004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14005 FL("psapCtx is NULL"));
14006 return -ENOENT;
14007 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014008 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070014009 {
14010 v_U16_t i;
14011 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
14012 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014013 if ((pSapCtx->aStaInfo[i].isUsed) &&
14014 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070014015 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014016 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014017 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014018 ETHER_ADDR_LEN);
14019
Jeff Johnson295189b2012-06-20 16:38:30 -070014020 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080014021 "%s: Delete STA with MAC::"
14022 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014023 __func__,
14024 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
14025 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070014026 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014027 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014028 }
14029 }
14030 }
14031 else
14032 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014033
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014034 vos_status = hdd_softap_GetStaId(pAdapter,
14035 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014036 if (!VOS_IS_STATUS_SUCCESS(vos_status))
14037 {
14038 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080014039 "%s: Skip this DEL STA as this is not used::"
14040 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014041 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014042 return -ENOENT;
14043 }
14044
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014045 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014046 {
14047 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080014048 "%s: Skip this DEL STA as deauth is in progress::"
14049 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014050 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014051 return -ENOENT;
14052 }
14053
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014054 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014055
Jeff Johnson295189b2012-06-20 16:38:30 -070014056 hddLog(VOS_TRACE_LEVEL_INFO,
14057 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080014058 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014059 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014060 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014061
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014062 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014063 if (!VOS_IS_STATUS_SUCCESS(vos_status))
14064 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014065 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014066 hddLog(VOS_TRACE_LEVEL_INFO,
14067 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080014068 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014069 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014070 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014071 return -ENOENT;
14072 }
14073
Jeff Johnson295189b2012-06-20 16:38:30 -070014074 }
14075 }
14076
14077 EXIT();
14078
14079 return 0;
14080}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014081
14082#ifdef CFG80211_DEL_STA_V2
14083static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14084 struct net_device *dev,
14085 struct station_del_parameters *param)
14086#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014087#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
14088static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14089 struct net_device *dev, const u8 *mac)
14090#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014091static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14092 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014093#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014094#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014095{
14096 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014097 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070014098
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014099 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014100
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014101#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014102 if (NULL == param) {
14103 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014104 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014105 return -EINVAL;
14106 }
14107
14108 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
14109 param->subtype, &delStaParams);
14110
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014111#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053014112 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014113 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014114#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014115 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
14116
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014117 vos_ssr_unprotect(__func__);
14118
14119 return ret;
14120}
14121
14122static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014123 struct net_device *dev,
14124#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14125 const u8 *mac,
14126#else
14127 u8 *mac,
14128#endif
14129 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014130{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014131 hdd_adapter_t *pAdapter;
14132 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014133 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014134#ifdef FEATURE_WLAN_TDLS
14135 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014136
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014137 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014138
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014139 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14140 if (NULL == pAdapter)
14141 {
14142 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14143 "%s: Adapter is NULL",__func__);
14144 return -EINVAL;
14145 }
14146 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14147 status = wlan_hdd_validate_context(pHddCtx);
14148 if (0 != status)
14149 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014150 return status;
14151 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014152
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014153 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14154 TRACE_CODE_HDD_CFG80211_ADD_STA,
14155 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014156 mask = params->sta_flags_mask;
14157
14158 set = params->sta_flags_set;
14159
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014160 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014161 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
14162 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014163
14164 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
14165 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080014166 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014167 }
14168 }
14169#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014170 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014171 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014172}
14173
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014174#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
14175static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
14176 struct net_device *dev, const u8 *mac,
14177 struct station_parameters *params)
14178#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014179static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
14180 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014181#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014182{
14183 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014184
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014185 vos_ssr_protect(__func__);
14186 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
14187 vos_ssr_unprotect(__func__);
14188
14189 return ret;
14190}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014191#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070014192
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014193static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070014194 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014195{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014196 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14197 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014198 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014199 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014200 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014201 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070014202
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014203 ENTER();
14204
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014205 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014206 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014207 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014208 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014209 return -EINVAL;
14210 }
14211
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014212 if (!pmksa) {
14213 hddLog(LOGE, FL("pmksa is NULL"));
14214 return -EINVAL;
14215 }
14216
14217 if (!pmksa->bssid || !pmksa->pmkid) {
14218 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
14219 pmksa->bssid, pmksa->pmkid);
14220 return -EINVAL;
14221 }
14222
14223 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
14224 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14225
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014226 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14227 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014228 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014229 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014230 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014231 }
14232
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014233 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014234 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14235
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014236 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
14237 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014238
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014239 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014240 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014241 &pmk_id, 1, FALSE);
14242
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014243 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14244 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
14245 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014246
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014247 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014248 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014249}
14250
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014251static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
14252 struct cfg80211_pmksa *pmksa)
14253{
14254 int ret;
14255
14256 vos_ssr_protect(__func__);
14257 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
14258 vos_ssr_unprotect(__func__);
14259
14260 return ret;
14261}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014262
Wilson Yang6507c4e2013-10-01 20:11:19 -070014263
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014264static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070014265 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014266{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014267 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14268 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014269 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014270 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014271
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014272 ENTER();
14273
Wilson Yang6507c4e2013-10-01 20:11:19 -070014274 /* Validate pAdapter */
14275 if (NULL == pAdapter)
14276 {
14277 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
14278 return -EINVAL;
14279 }
14280
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014281 if (!pmksa) {
14282 hddLog(LOGE, FL("pmksa is NULL"));
14283 return -EINVAL;
14284 }
14285
14286 if (!pmksa->bssid) {
14287 hddLog(LOGE, FL("pmksa->bssid is NULL"));
14288 return -EINVAL;
14289 }
14290
Kiet Lam98c46a12014-10-31 15:34:57 -070014291 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
14292 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14293
Wilson Yang6507c4e2013-10-01 20:11:19 -070014294 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14295 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014296 if (0 != status)
14297 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014298 return status;
14299 }
14300
14301 /*Retrieve halHandle*/
14302 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14303
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014304 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14305 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
14306 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014307 /* Delete the PMKID CSR cache */
14308 if (eHAL_STATUS_SUCCESS !=
14309 sme_RoamDelPMKIDfromCache(halHandle,
14310 pAdapter->sessionId, pmksa->bssid, FALSE)) {
14311 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
14312 MAC_ADDR_ARRAY(pmksa->bssid));
14313 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014314 }
14315
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014316 EXIT();
14317 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014318}
14319
Wilson Yang6507c4e2013-10-01 20:11:19 -070014320
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014321static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
14322 struct cfg80211_pmksa *pmksa)
14323{
14324 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014325
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014326 vos_ssr_protect(__func__);
14327 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
14328 vos_ssr_unprotect(__func__);
14329
14330 return ret;
14331
14332}
14333
14334static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014335{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014336 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14337 tHalHandle halHandle;
14338 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014339 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014340
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014341 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070014342
14343 /* Validate pAdapter */
14344 if (NULL == pAdapter)
14345 {
14346 hddLog(VOS_TRACE_LEVEL_ERROR,
14347 "%s: Invalid Adapter" ,__func__);
14348 return -EINVAL;
14349 }
14350
14351 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14352 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014353 if (0 != status)
14354 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014355 return status;
14356 }
14357
14358 /*Retrieve halHandle*/
14359 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14360
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014361 /* Flush the PMKID cache in CSR */
14362 if (eHAL_STATUS_SUCCESS !=
14363 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
14364 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
14365 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014366 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014367 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080014368 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014369}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014370
14371static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
14372{
14373 int ret;
14374
14375 vos_ssr_protect(__func__);
14376 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
14377 vos_ssr_unprotect(__func__);
14378
14379 return ret;
14380}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014381#endif
14382
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014383#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014384static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14385 struct net_device *dev,
14386 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014387{
14388 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14389 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014390 hdd_context_t *pHddCtx;
14391 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014392
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014393 ENTER();
14394
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014395 if (NULL == pAdapter)
14396 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014397 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014398 return -ENODEV;
14399 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014400 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14401 ret = wlan_hdd_validate_context(pHddCtx);
14402 if (0 != ret)
14403 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014404 return ret;
14405 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014406 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014407 if (NULL == pHddStaCtx)
14408 {
14409 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
14410 return -EINVAL;
14411 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014412
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014413 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14414 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
14415 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014416 // Added for debug on reception of Re-assoc Req.
14417 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
14418 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014419 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014420 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080014421 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014422 }
14423
14424#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080014425 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014426 ftie->ie_len);
14427#endif
14428
14429 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014430 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14431 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014432 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014433
14434 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014435 return 0;
14436}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014437
14438static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14439 struct net_device *dev,
14440 struct cfg80211_update_ft_ies_params *ftie)
14441{
14442 int ret;
14443
14444 vos_ssr_protect(__func__);
14445 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
14446 vos_ssr_unprotect(__func__);
14447
14448 return ret;
14449}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014450#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014451
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014452#ifdef FEATURE_WLAN_SCAN_PNO
14453
14454void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
14455 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
14456{
14457 int ret;
14458 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
14459 hdd_context_t *pHddCtx;
14460
Nirav Shah80830bf2013-12-31 16:35:12 +053014461 ENTER();
14462
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014463 if (NULL == pAdapter)
14464 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014465 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014466 "%s: HDD adapter is Null", __func__);
14467 return ;
14468 }
14469
14470 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14471 if (NULL == pHddCtx)
14472 {
14473 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14474 "%s: HDD context is Null!!!", __func__);
14475 return ;
14476 }
14477
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014478 spin_lock(&pHddCtx->schedScan_lock);
14479 if (TRUE == pHddCtx->isWiphySuspended)
14480 {
14481 pHddCtx->isSchedScanUpdatePending = TRUE;
14482 spin_unlock(&pHddCtx->schedScan_lock);
14483 hddLog(VOS_TRACE_LEVEL_INFO,
14484 "%s: Update cfg80211 scan database after it resume", __func__);
14485 return ;
14486 }
14487 spin_unlock(&pHddCtx->schedScan_lock);
14488
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014489 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
14490
14491 if (0 > ret)
14492 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
14493
14494 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014495 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14496 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014497}
14498
14499/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014500 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014501 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014502 */
14503static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
14504{
14505 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
14506 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014507 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014508 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14509 int status = 0;
14510 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
14511
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014512 /* The current firmware design does not allow PNO during any
14513 * active sessions. Hence, determine the active sessions
14514 * and return a failure.
14515 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014516 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
14517 {
14518 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014519 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014520
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014521 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
14522 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
14523 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
14524 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
14525 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053014526 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014527 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014528 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014529 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014530 }
14531 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14532 pAdapterNode = pNext;
14533 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014534 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014535}
14536
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014537void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
14538{
14539 hdd_adapter_t *pAdapter = callbackContext;
14540 hdd_context_t *pHddCtx;
14541
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014542 ENTER();
14543
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014544 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
14545 {
14546 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14547 FL("Invalid adapter or adapter has invalid magic"));
14548 return;
14549 }
14550
14551 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14552 if (0 != wlan_hdd_validate_context(pHddCtx))
14553 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014554 return;
14555 }
14556
c_hpothub53c45d2014-08-18 16:53:14 +053014557 if (VOS_STATUS_SUCCESS != status)
14558 {
14559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014560 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053014561 pHddCtx->isPnoEnable = FALSE;
14562 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014563
14564 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
14565 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014566 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014567}
14568
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014569/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014570 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
14571 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014572 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014573static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014574 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14575{
14576 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014577 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014578 hdd_context_t *pHddCtx;
14579 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014580 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053014581 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
14582 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014583 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14584 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014585 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014586 hdd_config_t *pConfig = NULL;
14587 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014588
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014589 ENTER();
14590
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014591 if (NULL == pAdapter)
14592 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014593 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014594 "%s: HDD adapter is Null", __func__);
14595 return -ENODEV;
14596 }
14597
14598 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014599 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014600
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014601 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014602 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014603 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014604 }
14605
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014606 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014607 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14608 if (NULL == hHal)
14609 {
14610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14611 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014612 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014613 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014614 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14615 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
14616 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053014617 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014618 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053014619 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014620 {
14621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14622 "%s: aborting the existing scan is unsuccessfull", __func__);
14623 return -EBUSY;
14624 }
14625
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014626 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014627 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014629 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014630 return -EBUSY;
14631 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014632
c_hpothu37f21312014-04-09 21:49:54 +053014633 if (TRUE == pHddCtx->isPnoEnable)
14634 {
14635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14636 FL("already PNO is enabled"));
14637 return -EBUSY;
14638 }
c_hpothu225aa7c2014-10-22 17:45:13 +053014639
14640 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
14641 {
14642 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14643 "%s: abort ROC failed ", __func__);
14644 return -EBUSY;
14645 }
14646
c_hpothu37f21312014-04-09 21:49:54 +053014647 pHddCtx->isPnoEnable = TRUE;
14648
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014649 pnoRequest.enable = 1; /*Enable PNO */
14650 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014651
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014652 if (( !pnoRequest.ucNetworksCount ) ||
14653 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014654 {
14655 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014656 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014657 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014658 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014659 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014660 goto error;
14661 }
14662
14663 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
14664 {
14665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014666 "%s: Incorrect number of channels %d",
14667 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014668 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014669 goto error;
14670 }
14671
14672 /* Framework provides one set of channels(all)
14673 * common for all saved profile */
14674 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14675 channels_allowed, &num_channels_allowed))
14676 {
14677 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14678 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014679 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014680 goto error;
14681 }
14682 /* Checking each channel against allowed channel list */
14683 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053014684 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014685 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014686 char chList [(request->n_channels*5)+1];
14687 int len;
14688 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014689 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014690 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014691 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014692 if (request->channels[i]->hw_value == channels_allowed[indx])
14693 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014694 if ((!pConfig->enableDFSPnoChnlScan) &&
14695 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
14696 {
14697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14698 "%s : Dropping DFS channel : %d",
14699 __func__,channels_allowed[indx]);
14700 num_ignore_dfs_ch++;
14701 break;
14702 }
14703
Nirav Shah80830bf2013-12-31 16:35:12 +053014704 valid_ch[num_ch++] = request->channels[i]->hw_value;
14705 len += snprintf(chList+len, 5, "%d ",
14706 request->channels[i]->hw_value);
14707 break ;
14708 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014709 }
14710 }
Nirav Shah80830bf2013-12-31 16:35:12 +053014711 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014712
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014713 /*If all channels are DFS and dropped, then ignore the PNO request*/
14714 if (num_ignore_dfs_ch == request->n_channels)
14715 {
14716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14717 "%s : All requested channels are DFS channels", __func__);
14718 ret = -EINVAL;
14719 goto error;
14720 }
14721 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014722
14723 pnoRequest.aNetworks =
14724 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14725 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014726 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014727 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14728 FL("failed to allocate memory aNetworks %u"),
14729 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14730 goto error;
14731 }
14732 vos_mem_zero(pnoRequest.aNetworks,
14733 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14734
14735 /* Filling per profile params */
14736 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
14737 {
14738 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014739 request->match_sets[i].ssid.ssid_len;
14740
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014741 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
14742 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014743 {
14744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014745 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014746 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014747 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014748 goto error;
14749 }
14750
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014751 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014752 request->match_sets[i].ssid.ssid,
14753 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14755 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014756 i, pnoRequest.aNetworks[i].ssId.ssId);
14757 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
14758 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
14759 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014760
14761 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014762 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
14763 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014764
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014765 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014766 }
14767
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014768 for (i = 0; i < request->n_ssids; i++)
14769 {
14770 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014771 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014772 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014773 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014774 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014775 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014776 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014777 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014778 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014779 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014780 break;
14781 }
14782 j++;
14783 }
14784 }
14785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14786 "Number of hidden networks being Configured = %d",
14787 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014788 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080014789 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014790
14791 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14792 if (pnoRequest.p24GProbeTemplate == NULL)
14793 {
14794 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14795 FL("failed to allocate memory p24GProbeTemplate %u"),
14796 SIR_PNO_MAX_PB_REQ_SIZE);
14797 goto error;
14798 }
14799
14800 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14801 if (pnoRequest.p5GProbeTemplate == NULL)
14802 {
14803 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14804 FL("failed to allocate memory p5GProbeTemplate %u"),
14805 SIR_PNO_MAX_PB_REQ_SIZE);
14806 goto error;
14807 }
14808
14809 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14810 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14811
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053014812 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
14813 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014814 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014815 pnoRequest.us24GProbeTemplateLen = request->ie_len;
14816 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
14817 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014818
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014819 pnoRequest.us5GProbeTemplateLen = request->ie_len;
14820 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
14821 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014822 }
14823
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014824 /* Driver gets only one time interval which is hardcoded in
14825 * supplicant for 10000ms. Taking power consumption into account 6 timers
14826 * will be used, Timervalue is increased exponentially i.e 10,20,40,
14827 * 80,160,320 secs. And number of scan cycle for each timer
14828 * is configurable through INI param gPNOScanTimerRepeatValue.
14829 * If it is set to 0 only one timer will be used and PNO scan cycle
14830 * will be repeated after each interval specified by supplicant
14831 * till PNO is disabled.
14832 */
14833 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014834 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014835 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014836 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014837 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
14838
14839 tempInterval = (request->interval)/1000;
14840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14841 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
14842 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014843 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014844 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014845 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014846 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014847 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014848 tempInterval *= 2;
14849 }
14850 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014851 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014852
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014853 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014854
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014855 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014856 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
14857 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014858 pAdapter->pno_req_status = 0;
14859
Nirav Shah80830bf2013-12-31 16:35:12 +053014860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14861 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014862 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
14863 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053014864
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014865 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014866 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014867 hdd_cfg80211_sched_scan_done_callback, pAdapter);
14868 if (eHAL_STATUS_SUCCESS != status)
14869 {
14870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014871 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014872 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014873 goto error;
14874 }
14875
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014876 ret = wait_for_completion_timeout(
14877 &pAdapter->pno_comp_var,
14878 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
14879 if (0 >= ret)
14880 {
14881 // Did not receive the response for PNO enable in time.
14882 // Assuming the PNO enable was success.
14883 // Returning error from here, because we timeout, results
14884 // in side effect of Wifi (Wifi Setting) not to work.
14885 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14886 FL("Timed out waiting for PNO to be Enabled"));
14887 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014888 }
14889
14890 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053014891 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014892
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014893error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14895 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053014896 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014897 if (pnoRequest.aNetworks)
14898 vos_mem_free(pnoRequest.aNetworks);
14899 if (pnoRequest.p24GProbeTemplate)
14900 vos_mem_free(pnoRequest.p24GProbeTemplate);
14901 if (pnoRequest.p5GProbeTemplate)
14902 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014903
14904 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014905 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014906}
14907
14908/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014909 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
14910 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014911 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014912static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
14913 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14914{
14915 int ret;
14916
14917 vos_ssr_protect(__func__);
14918 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
14919 vos_ssr_unprotect(__func__);
14920
14921 return ret;
14922}
14923
14924/*
14925 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
14926 * Function to disable PNO
14927 */
14928static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014929 struct net_device *dev)
14930{
14931 eHalStatus status = eHAL_STATUS_FAILURE;
14932 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14933 hdd_context_t *pHddCtx;
14934 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014935 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014936 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014937
14938 ENTER();
14939
14940 if (NULL == pAdapter)
14941 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014942 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014943 "%s: HDD adapter is Null", __func__);
14944 return -ENODEV;
14945 }
14946
14947 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014948
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014949 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014950 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014951 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014952 "%s: HDD context is Null", __func__);
14953 return -ENODEV;
14954 }
14955
14956 /* The return 0 is intentional when isLogpInProgress and
14957 * isLoadUnloadInProgress. We did observe a crash due to a return of
14958 * failure in sched_scan_stop , especially for a case where the unload
14959 * of the happens at the same time. The function __cfg80211_stop_sched_scan
14960 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
14961 * success. If it returns a failure , then its next invocation due to the
14962 * clean up of the second interface will have the dev pointer corresponding
14963 * to the first one leading to a crash.
14964 */
14965 if (pHddCtx->isLogpInProgress)
14966 {
14967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14968 "%s: LOGP in Progress. Ignore!!!", __func__);
14969 return ret;
14970 }
14971
Mihir Shete18156292014-03-11 15:38:30 +053014972 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014973 {
14974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14975 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14976 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014977 }
14978
14979 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14980 if (NULL == hHal)
14981 {
14982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14983 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014984 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014985 }
14986
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014987 pnoRequest.enable = 0; /* Disable PNO */
14988 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014989
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014990 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14991 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
14992 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014993 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014994 pAdapter->sessionId,
14995 NULL, pAdapter);
14996 if (eHAL_STATUS_SUCCESS != status)
14997 {
14998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14999 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053015000 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053015001 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015002 }
c_hpothu37f21312014-04-09 21:49:54 +053015003 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015004
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053015005error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015006 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053015007 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015008
15009 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053015010 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015011}
15012
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053015013/*
15014 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
15015 * NL interface to disable PNO
15016 */
15017static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
15018 struct net_device *dev)
15019{
15020 int ret;
15021
15022 vos_ssr_protect(__func__);
15023 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
15024 vos_ssr_unprotect(__func__);
15025
15026 return ret;
15027}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015028#endif /*FEATURE_WLAN_SCAN_PNO*/
15029
15030
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015031#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015032#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015033static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15034 struct net_device *dev,
15035 u8 *peer, u8 action_code,
15036 u8 dialog_token,
15037 u16 status_code, u32 peer_capability,
15038 const u8 *buf, size_t len)
15039#else /* TDLS_MGMT_VERSION2 */
15040#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
15041static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15042 struct net_device *dev,
15043 const u8 *peer, u8 action_code,
15044 u8 dialog_token, u16 status_code,
15045 u32 peer_capability, bool initiator,
15046 const u8 *buf, size_t len)
15047#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
15048static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15049 struct net_device *dev,
15050 const u8 *peer, u8 action_code,
15051 u8 dialog_token, u16 status_code,
15052 u32 peer_capability, const u8 *buf,
15053 size_t len)
15054#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
15055static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15056 struct net_device *dev,
15057 u8 *peer, u8 action_code,
15058 u8 dialog_token,
15059 u16 status_code, u32 peer_capability,
15060 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015061#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015062static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15063 struct net_device *dev,
15064 u8 *peer, u8 action_code,
15065 u8 dialog_token,
15066 u16 status_code, const u8 *buf,
15067 size_t len)
15068#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015069#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015070{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015071 hdd_adapter_t *pAdapter;
15072 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015073 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070015074 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080015075 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070015076 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015077 int ret;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015078#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015079 u32 peer_capability = 0;
15080#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015081 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015082 hdd_station_ctx_t *pHddStaCtx = NULL;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015083
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015084 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15085 if (NULL == pAdapter)
15086 {
15087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15088 "%s: Adapter is NULL",__func__);
15089 return -EINVAL;
15090 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015091 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15092 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
15093 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015094
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015095 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015096 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015097 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015098 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015099 "Invalid arguments");
15100 return -EINVAL;
15101 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015102
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015103 if (pHddCtx->isLogpInProgress)
15104 {
15105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15106 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053015107 wlan_hdd_tdls_set_link_status(pAdapter,
15108 peer,
15109 eTDLS_LINK_IDLE,
15110 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015111 return -EBUSY;
15112 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015113
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015114 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
15115 {
15116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15117 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
15118 return -EAGAIN;
15119 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015120
Hoonki Lee27511902013-03-14 18:19:06 -070015121 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015122 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015123 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070015124 "%s: TDLS mode is disabled OR not enabled in FW."
15125 MAC_ADDRESS_STR " action %d declined.",
15126 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015127 return -ENOTSUPP;
15128 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015129
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015130 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15131
15132 if( NULL == pHddStaCtx )
15133 {
15134 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15135 "%s: HDD station context NULL ",__func__);
15136 return -EINVAL;
15137 }
15138
15139 /* STA should be connected and authenticated
15140 * before sending any TDLS frames
15141 */
15142 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
15143 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
15144 {
15145 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15146 "STA is not connected or unauthenticated. "
15147 "connState %u, uIsAuthenticated %u",
15148 pHddStaCtx->conn_info.connState,
15149 pHddStaCtx->conn_info.uIsAuthenticated);
15150 return -EAGAIN;
15151 }
15152
Hoonki Lee27511902013-03-14 18:19:06 -070015153 /* other than teardown frame, other mgmt frames are not sent if disabled */
15154 if (SIR_MAC_TDLS_TEARDOWN != action_code)
15155 {
15156 /* if tdls_mode is disabled to respond to peer's request */
15157 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
15158 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015159 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070015160 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015161 " TDLS mode is disabled. action %d declined.",
15162 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070015163
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015164 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070015165 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053015166
15167 if (vos_max_concurrent_connections_reached())
15168 {
15169 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15170 return -EINVAL;
15171 }
Hoonki Lee27511902013-03-14 18:19:06 -070015172 }
15173
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015174 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
15175 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053015176 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015177 {
15178 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015179 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015180 " TDLS setup is ongoing. action %d declined.",
15181 __func__, MAC_ADDR_ARRAY(peer), action_code);
15182 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015183 }
15184 }
15185
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015186 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
15187 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080015188 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015189 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15190 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080015191 {
15192 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
15193 we return error code at 'add_station()'. Hence we have this
15194 check again in addtion to add_station().
15195 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015196 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080015197 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015198 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15199 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015200 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
15201 __func__, MAC_ADDR_ARRAY(peer), action_code,
15202 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053015203 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080015204 }
15205 else
15206 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015207 /* maximum reached. tweak to send error code to peer and return
15208 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080015209 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015210 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15211 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015212 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
15213 __func__, MAC_ADDR_ARRAY(peer), status_code,
15214 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070015215 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015216 /* fall through to send setup resp with failure status
15217 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080015218 }
15219 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015220 else
15221 {
15222 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053015223 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015224 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015225 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015226 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015227 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
15228 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015229 return -EPERM;
15230 }
15231 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015232 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015233
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015234 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053015235 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015236 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
15237 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015238
Hoonki Leea34dd892013-02-05 22:56:02 -080015239 /*Except teardown responder will not be used so just make 0*/
15240 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015241 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080015242 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015243
15244 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015245 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015246
15247 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
15248 responder = pTdlsPeer->is_responder;
15249 else
Hoonki Leea34dd892013-02-05 22:56:02 -080015250 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015251 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053015252 "%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 -070015253 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
15254 dialog_token, status_code, len);
15255 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080015256 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015257 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015258
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015259 /* For explicit trigger of DIS_REQ come out of BMPS for
15260 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070015261 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015262 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
15263 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070015264 {
15265 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
15266 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015267 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015268 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015269 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
15270 if (status != VOS_STATUS_SUCCESS) {
15271 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
15272 }
Hoonki Lee14621352013-04-16 17:51:19 -070015273 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015274 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015275 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015276 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
15277 }
15278 }
Hoonki Lee14621352013-04-16 17:51:19 -070015279 }
15280
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015281 /* make sure doesn't call send_mgmt() while it is pending */
15282 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
15283 {
15284 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015285 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015286 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015287 ret = -EBUSY;
15288 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015289 }
15290
15291 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015292 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
15293
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015294 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
15295 pAdapter->sessionId, peer, action_code, dialog_token,
15296 status_code, peer_capability, (tANI_U8 *)buf, len,
15297 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015298
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015299 if (VOS_STATUS_SUCCESS != status)
15300 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015301 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15302 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015303 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015304 ret = -EINVAL;
15305 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015306 }
15307
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015308 if ((SIR_MAC_TDLS_DIS_REQ == action_code) ||
15309 (SIR_MAC_TDLS_DIS_RSP == action_code))
15310 {
15311 /* for DIS_REQ/DIS_RSP, supplicant don't consider the return status.
15312 * So we no need to wait for tdls_mgmt_comp for sending ack status.
15313 */
15314 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15315 "%s: tx done for frm %u", __func__, action_code);
15316 return 0;
15317 }
15318
15319 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15320 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
15321 WAIT_TIME_TDLS_MGMT);
15322
Hoonki Leed37cbb32013-04-20 00:31:14 -070015323 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
15324 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
15325
15326 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015327 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070015328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070015329 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070015330 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015331 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080015332
15333 if (pHddCtx->isLogpInProgress)
15334 {
15335 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15336 "%s: LOGP in Progress. Ignore!!!", __func__);
15337 return -EAGAIN;
15338 }
15339
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015340 ret = -EINVAL;
15341 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015342 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015343 else
15344 {
15345 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15346 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
15347 __func__, rc, pAdapter->mgmtTxCompletionStatus);
15348 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015349
Gopichand Nakkala05922802013-03-14 12:23:19 -070015350 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070015351 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015352 ret = max_sta_failed;
15353 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070015354 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015355
Hoonki Leea34dd892013-02-05 22:56:02 -080015356 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
15357 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015358 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015359 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15360 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015361 }
15362 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
15363 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015364 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015365 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15366 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015367 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015368
15369 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015370
15371tx_failed:
15372 /* add_station will be called before sending TDLS_SETUP_REQ and
15373 * TDLS_SETUP_RSP and as part of add_station driver will enable
15374 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
15375 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
15376 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
15377 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
15378 */
15379
15380 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
15381 (SIR_MAC_TDLS_SETUP_RSP == action_code))
15382 wlan_hdd_tdls_check_bmps(pAdapter);
15383 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015384}
15385
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015386#if TDLS_MGMT_VERSION2
15387static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15388 u8 *peer, u8 action_code, u8 dialog_token,
15389 u16 status_code, u32 peer_capability,
15390 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015391#else /* TDLS_MGMT_VERSION2 */
15392#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
15393static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15394 struct net_device *dev,
15395 const u8 *peer, u8 action_code,
15396 u8 dialog_token, u16 status_code,
15397 u32 peer_capability, bool initiator,
15398 const u8 *buf, size_t len)
15399#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
15400static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15401 struct net_device *dev,
15402 const u8 *peer, u8 action_code,
15403 u8 dialog_token, u16 status_code,
15404 u32 peer_capability, const u8 *buf,
15405 size_t len)
15406#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
15407static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15408 struct net_device *dev,
15409 u8 *peer, u8 action_code,
15410 u8 dialog_token,
15411 u16 status_code, u32 peer_capability,
15412 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015413#else
15414static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15415 u8 *peer, u8 action_code, u8 dialog_token,
15416 u16 status_code, const u8 *buf, size_t len)
15417#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015418#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015419{
15420 int ret;
15421
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015422 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015423#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015424 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15425 dialog_token, status_code,
15426 peer_capability, buf, len);
15427#else /* TDLS_MGMT_VERSION2 */
15428#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
15429 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15430 dialog_token, status_code,
15431 peer_capability, initiator,
15432 buf, len);
15433#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
15434 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15435 dialog_token, status_code,
15436 peer_capability, buf, len);
15437#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
15438 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15439 dialog_token, status_code,
15440 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015441#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015442 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15443 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015444#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015445#endif
15446 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015447
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015448 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015449}
Atul Mittal115287b2014-07-08 13:26:33 +053015450
15451int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015452#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15453 const u8 *peer,
15454#else
Atul Mittal115287b2014-07-08 13:26:33 +053015455 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015456#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015457 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053015458 cfg80211_exttdls_callback callback)
15459{
15460
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015461 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053015462 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015463 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053015464 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15465 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
15466 __func__, MAC_ADDR_ARRAY(peer));
15467
15468 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15469 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15470
15471 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015472 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15473 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15474 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015475 return -ENOTSUPP;
15476 }
15477
15478 /* To cater the requirement of establishing the TDLS link
15479 * irrespective of the data traffic , get an entry of TDLS peer.
15480 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015481 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015482 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
15483 if (pTdlsPeer == NULL) {
15484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15485 "%s: peer " MAC_ADDRESS_STR " not existing",
15486 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015487 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015488 return -EINVAL;
15489 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015490 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015491
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015492 /* check FW TDLS Off Channel capability */
15493 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015494 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015495 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015496 {
15497 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
15498 pTdlsPeer->peerParams.global_operating_class =
15499 tdls_peer_params->global_operating_class;
15500 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
15501 pTdlsPeer->peerParams.min_bandwidth_kbps =
15502 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015503 /* check configured channel is valid, non dfs and
15504 * not current operating channel */
15505 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
15506 tdls_peer_params->channel)) &&
15507 (pHddStaCtx) &&
15508 (tdls_peer_params->channel !=
15509 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015510 {
15511 pTdlsPeer->isOffChannelConfigured = TRUE;
15512 }
15513 else
15514 {
15515 pTdlsPeer->isOffChannelConfigured = FALSE;
15516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15517 "%s: Configured Tdls Off Channel is not valid", __func__);
15518
15519 }
15520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015521 "%s: tdls_off_channel %d isOffChannelConfigured %d "
15522 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015523 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015524 pTdlsPeer->isOffChannelConfigured,
15525 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015526 }
15527 else
15528 {
15529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015530 "%s: TDLS off channel FW capability %d, "
15531 "host capab %d or Invalid TDLS Peer Params", __func__,
15532 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
15533 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015534 }
15535
Atul Mittal115287b2014-07-08 13:26:33 +053015536 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
15537
15538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15539 " %s TDLS Add Force Peer Failed",
15540 __func__);
15541 return -EINVAL;
15542 }
15543 /*EXT TDLS*/
15544
15545 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
15546 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15547 " %s TDLS set callback Failed",
15548 __func__);
15549 return -EINVAL;
15550 }
15551
15552 return(0);
15553
15554}
15555
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015556int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
15557#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15558 const u8 *peer
15559#else
15560 u8 *peer
15561#endif
15562)
Atul Mittal115287b2014-07-08 13:26:33 +053015563{
15564
15565 hddTdlsPeer_t *pTdlsPeer;
15566 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15568 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
15569 __func__, MAC_ADDR_ARRAY(peer));
15570
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015571 if (0 != wlan_hdd_validate_context(pHddCtx)) {
15572 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
15573 return -EINVAL;
15574 }
15575
Atul Mittal115287b2014-07-08 13:26:33 +053015576 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15577 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15578
15579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015580 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15581 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15582 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015583 return -ENOTSUPP;
15584 }
15585
15586
15587 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15588
15589 if ( NULL == pTdlsPeer ) {
15590 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015591 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053015592 __func__, MAC_ADDR_ARRAY(peer));
15593 return -EINVAL;
15594 }
15595 else {
15596 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
15597 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015598 /* if channel switch is configured, reset
15599 the channel for this peer */
15600 if (TRUE == pTdlsPeer->isOffChannelConfigured)
15601 {
15602 pTdlsPeer->peerParams.channel = 0;
15603 pTdlsPeer->isOffChannelConfigured = FALSE;
15604 }
Atul Mittal115287b2014-07-08 13:26:33 +053015605 }
15606
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015607 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
15608 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053015609 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015610 }
Atul Mittal115287b2014-07-08 13:26:33 +053015611
15612 /*EXT TDLS*/
15613
15614 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
15615
15616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15617 " %s TDLS set callback Failed",
15618 __func__);
15619 return -EINVAL;
15620 }
15621 return(0);
15622
15623}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015624static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015625#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15626 const u8 *peer,
15627#else
15628 u8 *peer,
15629#endif
15630 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015631{
15632 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15633 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015634 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015635 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015636
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015637 ENTER();
15638
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015639 if (!pAdapter) {
15640 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15641 return -EINVAL;
15642 }
15643
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015644 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15645 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
15646 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015647 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015648 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015649 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070015650 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015651 return -EINVAL;
15652 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015653
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015654 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015655 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015656 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015657 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015658 }
15659
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015660
15661 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015662 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015663 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015664 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015665 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
15666 "Cannot process TDLS commands",
15667 pHddCtx->cfg_ini->fEnableTDLSSupport,
15668 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015669 return -ENOTSUPP;
15670 }
15671
15672 switch (oper) {
15673 case NL80211_TDLS_ENABLE_LINK:
15674 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015675 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015676 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015677 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053015678 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015679 tANI_U16 numCurrTdlsPeers = 0;
15680 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015681 tANI_U8 suppChannelLen = 0;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015682
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15684 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
15685 __func__, MAC_ADDR_ARRAY(peer));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015686 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015687 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015688 if ( NULL == pTdlsPeer ) {
15689 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15690 " (oper %d) not exsting. ignored",
15691 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15692 return -EINVAL;
15693 }
15694
15695 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15696 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15697 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15698 "NL80211_TDLS_ENABLE_LINK");
15699
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070015700 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
15701 {
15702 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
15703 MAC_ADDRESS_STR " failed",
15704 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
15705 return -EINVAL;
15706 }
15707
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015708 /* before starting tdls connection, set tdls
15709 * off channel established status to default value */
15710 pTdlsPeer->isOffChannelEstablished = FALSE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015711 /* TDLS Off Channel, Disable tdls channel switch,
15712 when there are more than one tdls link */
15713 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053015714 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015715 {
15716 /* get connected peer and send disable tdls off chan */
15717 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015718 if ((connPeer) &&
15719 (connPeer->isOffChannelSupported == TRUE) &&
15720 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015721 {
15722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15723 "%s: More then one peer connected, Disable "
15724 "TDLS channel switch", __func__);
15725
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015726 connPeer->isOffChannelEstablished = FALSE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015727 ret = sme_SendTdlsChanSwitchReq(
15728 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015729 pAdapter->sessionId,
15730 connPeer->peerMac,
15731 connPeer->peerParams.channel,
15732 TDLS_OFF_CHANNEL_BW_OFFSET,
15733 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015734 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015735 hddLog(VOS_TRACE_LEVEL_ERROR,
15736 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015737 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015738 }
15739 else
15740 {
15741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15742 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015743 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015744 "isOffChannelConfigured %d",
15745 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015746 (connPeer ? (connPeer->isOffChannelSupported)
15747 : -1),
15748 (connPeer ? (connPeer->isOffChannelConfigured)
15749 : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015750 }
15751 }
15752
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015753 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015754 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015755 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053015756
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015757 if (0 != wlan_hdd_tdls_get_link_establish_params(
15758 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015759 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015760 return -EINVAL;
15761 }
15762 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015763
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015764 ret = sme_SendTdlsLinkEstablishParams(
15765 WLAN_HDD_GET_HAL_CTX(pAdapter),
15766 pAdapter->sessionId, peer,
15767 &tdlsLinkEstablishParams);
15768 if (ret != VOS_STATUS_SUCCESS) {
15769 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
15770 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015771 /* Send TDLS peer UAPSD capabilities to the firmware and
15772 * register with the TL on after the response for this operation
15773 * is received .
15774 */
15775 ret = wait_for_completion_interruptible_timeout(
15776 &pAdapter->tdls_link_establish_req_comp,
15777 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
15778 if (ret <= 0)
15779 {
15780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015781 FL("Link Establish Request Failed Status %ld"),
15782 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015783 return -EINVAL;
15784 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015785 }
Atul Mittal115287b2014-07-08 13:26:33 +053015786 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15787 eTDLS_LINK_CONNECTED,
15788 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015789 staDesc.ucSTAId = pTdlsPeer->staId;
15790 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015791 ret = WLANTL_UpdateTdlsSTAClient(
15792 pHddCtx->pvosContext,
15793 &staDesc);
15794 if (ret != VOS_STATUS_SUCCESS) {
15795 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
15796 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053015797
Gopichand Nakkala471708b2013-06-04 20:03:01 +053015798 /* Mark TDLS client Authenticated .*/
15799 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
15800 pTdlsPeer->staId,
15801 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015802 if (VOS_STATUS_SUCCESS == status)
15803 {
Hoonki Lee14621352013-04-16 17:51:19 -070015804 if (pTdlsPeer->is_responder == 0)
15805 {
15806 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
15807
15808 wlan_hdd_tdls_timer_restart(pAdapter,
15809 &pTdlsPeer->initiatorWaitTimeoutTimer,
15810 WAIT_TIME_TDLS_INITIATOR);
15811 /* suspend initiator TX until it receives direct packet from the
15812 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015813 ret = WLANTL_SuspendDataTx(
15814 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15815 &staId, NULL);
15816 if (ret != VOS_STATUS_SUCCESS) {
15817 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
15818 }
Hoonki Lee14621352013-04-16 17:51:19 -070015819 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015820
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015821 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015822 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015823 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015824 suppChannelLen =
15825 tdlsLinkEstablishParams.supportedChannelsLen;
15826
15827 if ((suppChannelLen > 0) &&
15828 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
15829 {
15830 tANI_U8 suppPeerChannel = 0;
15831 int i = 0;
15832 for (i = 0U; i < suppChannelLen; i++)
15833 {
15834 suppPeerChannel =
15835 tdlsLinkEstablishParams.supportedChannels[i];
15836
15837 pTdlsPeer->isOffChannelSupported = FALSE;
15838 if (suppPeerChannel ==
15839 pTdlsPeer->peerParams.channel)
15840 {
15841 pTdlsPeer->isOffChannelSupported = TRUE;
15842 break;
15843 }
15844 }
15845 }
15846 else
15847 {
15848 pTdlsPeer->isOffChannelSupported = FALSE;
15849 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015850 }
15851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15852 "%s: TDLS channel switch request for channel "
15853 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015854 "%d isOffChannelSupported %d", __func__,
15855 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015856 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015857 suppChannelLen,
15858 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015859
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015860 /* TDLS Off Channel, Enable tdls channel switch,
15861 when their is only one tdls link and it supports */
15862 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15863 if ((numCurrTdlsPeers == 1) &&
15864 (TRUE == pTdlsPeer->isOffChannelSupported) &&
15865 (TRUE == pTdlsPeer->isOffChannelConfigured))
15866 {
15867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15868 "%s: Send TDLS channel switch request for channel %d",
15869 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015870
15871 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015872 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
15873 pAdapter->sessionId,
15874 pTdlsPeer->peerMac,
15875 pTdlsPeer->peerParams.channel,
15876 TDLS_OFF_CHANNEL_BW_OFFSET,
15877 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015878 if (ret != VOS_STATUS_SUCCESS) {
15879 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
15880 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015881 }
15882 else
15883 {
15884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15885 "%s: TDLS channel switch request not sent"
15886 " numCurrTdlsPeers %d "
15887 "isOffChannelSupported %d "
15888 "isOffChannelConfigured %d",
15889 __func__, numCurrTdlsPeers,
15890 pTdlsPeer->isOffChannelSupported,
15891 pTdlsPeer->isOffChannelConfigured);
15892 }
15893
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015894 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015895 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015896
15897 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015898 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
15899 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015900 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015901 int ac;
15902 uint8 ucAc[4] = { WLANTL_AC_VO,
15903 WLANTL_AC_VI,
15904 WLANTL_AC_BK,
15905 WLANTL_AC_BE };
15906 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
15907 for(ac=0; ac < 4; ac++)
15908 {
15909 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15910 pTdlsPeer->staId, ucAc[ac],
15911 tlTid[ac], tlTid[ac], 0, 0,
15912 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015913 if (status != VOS_STATUS_SUCCESS) {
15914 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
15915 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015916 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015917 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015918 }
15919
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015920 }
15921 break;
15922 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080015923 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015924 tANI_U16 numCurrTdlsPeers = 0;
15925 hddTdlsPeer_t *connPeer = NULL;
15926
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015927 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15928 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
15929 __func__, MAC_ADDR_ARRAY(peer));
15930
Sunil Dutt41de4e22013-11-14 18:09:02 +053015931 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15932
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015933
Sunil Dutt41de4e22013-11-14 18:09:02 +053015934 if ( NULL == pTdlsPeer ) {
15935 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15936 " (oper %d) not exsting. ignored",
15937 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15938 return -EINVAL;
15939 }
15940
15941 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15942 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15943 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15944 "NL80211_TDLS_DISABLE_LINK");
15945
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015946 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080015947 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015948 long status;
15949
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015950 /* set tdls off channel status to false for this peer */
15951 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053015952 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15953 eTDLS_LINK_TEARING,
15954 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
15955 eTDLS_LINK_UNSPECIFIED:
15956 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015957 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
15958
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015959 status = sme_DeleteTdlsPeerSta(
15960 WLAN_HDD_GET_HAL_CTX(pAdapter),
15961 pAdapter->sessionId, peer );
15962 if (status != VOS_STATUS_SUCCESS) {
15963 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15964 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015965
15966 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
15967 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053015968 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053015969 eTDLS_LINK_IDLE,
15970 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015971 if (status <= 0)
15972 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015973 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15974 "%s: Del station failed status %ld",
15975 __func__, status);
15976 return -EPERM;
15977 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015978
15979 /* TDLS Off Channel, Enable tdls channel switch,
15980 when their is only one tdls link and it supports */
15981 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15982 if (numCurrTdlsPeers == 1)
15983 {
15984 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15985 if ((connPeer) &&
15986 (connPeer->isOffChannelSupported == TRUE) &&
15987 (connPeer->isOffChannelConfigured == TRUE))
15988 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015989 connPeer->isOffChannelEstablished = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015990 status = sme_SendTdlsChanSwitchReq(
15991 WLAN_HDD_GET_HAL_CTX(pAdapter),
15992 pAdapter->sessionId,
15993 connPeer->peerMac,
15994 connPeer->peerParams.channel,
15995 TDLS_OFF_CHANNEL_BW_OFFSET,
15996 TDLS_CHANNEL_SWITCH_ENABLE);
15997 if (status != VOS_STATUS_SUCCESS) {
15998 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
15999 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016000 }
16001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16002 "%s: TDLS channel switch "
16003 "isOffChannelSupported %d "
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053016004 "isOffChannelConfigured %d "
16005 "isOffChannelEstablished %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016006 __func__,
16007 (connPeer ? connPeer->isOffChannelSupported : -1),
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053016008 (connPeer ? connPeer->isOffChannelConfigured : -1),
16009 (connPeer ? connPeer->isOffChannelEstablished : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016010 }
16011 else
16012 {
16013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16014 "%s: TDLS channel switch request not sent "
16015 "numCurrTdlsPeers %d ",
16016 __func__, numCurrTdlsPeers);
16017 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080016018 }
16019 else
16020 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16022 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080016023 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080016024 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016025 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016026 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053016027 {
Atul Mittal115287b2014-07-08 13:26:33 +053016028 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053016029
Atul Mittal115287b2014-07-08 13:26:33 +053016030 if (0 != status)
16031 {
16032 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053016033 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053016034 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053016035 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053016036 break;
16037 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016038 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053016039 {
Atul Mittal115287b2014-07-08 13:26:33 +053016040 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
16041 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016042 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053016043 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053016044
Atul Mittal115287b2014-07-08 13:26:33 +053016045 if (0 != status)
16046 {
16047 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053016048 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053016049 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053016050 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053016051 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053016052 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016053 case NL80211_TDLS_DISCOVERY_REQ:
16054 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053016056 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016057 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016058 return -ENOTSUPP;
16059 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16061 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016062 return -ENOTSUPP;
16063 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016064
16065 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016066 return 0;
16067}
Chilam NG571c65a2013-01-19 12:27:36 +053016068
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016069static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016070#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16071 const u8 *peer,
16072#else
16073 u8 *peer,
16074#endif
16075 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016076{
16077 int ret;
16078
16079 vos_ssr_protect(__func__);
16080 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
16081 vos_ssr_unprotect(__func__);
16082
16083 return ret;
16084}
16085
Chilam NG571c65a2013-01-19 12:27:36 +053016086int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
16087 struct net_device *dev, u8 *peer)
16088{
Arif Hussaina7c8e412013-11-20 11:06:42 -080016089 hddLog(VOS_TRACE_LEVEL_INFO,
16090 "tdls send discover req: "MAC_ADDRESS_STR,
16091 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053016092
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016093#if TDLS_MGMT_VERSION2
16094 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16095 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16096#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016097#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
16098 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16099 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
16100#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16101 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16102 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16103#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
16104 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16105 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16106#else
Chilam NG571c65a2013-01-19 12:27:36 +053016107 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16108 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016109#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016110#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053016111}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016112#endif
16113
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016114#ifdef WLAN_FEATURE_GTK_OFFLOAD
16115/*
16116 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
16117 * Callback rountine called upon receiving response for
16118 * get offload info
16119 */
16120void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
16121 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
16122{
16123
16124 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016125 tANI_U8 tempReplayCounter[8];
16126 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016127
16128 ENTER();
16129
16130 if (NULL == pAdapter)
16131 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053016132 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016133 "%s: HDD adapter is Null", __func__);
16134 return ;
16135 }
16136
16137 if (NULL == pGtkOffloadGetInfoRsp)
16138 {
16139 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16140 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
16141 return ;
16142 }
16143
16144 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
16145 {
16146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16147 "%s: wlan Failed to get replay counter value",
16148 __func__);
16149 return ;
16150 }
16151
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016152 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16153 /* Update replay counter */
16154 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
16155 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
16156
16157 {
16158 /* changing from little to big endian since supplicant
16159 * works on big endian format
16160 */
16161 int i;
16162 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
16163
16164 for (i = 0; i < 8; i++)
16165 {
16166 tempReplayCounter[7-i] = (tANI_U8)p[i];
16167 }
16168 }
16169
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016170 /* Update replay counter to NL */
16171 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016172 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016173}
16174
16175/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016176 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016177 * This function is used to offload GTK rekeying job to the firmware.
16178 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016179int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016180 struct cfg80211_gtk_rekey_data *data)
16181{
16182 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16183 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16184 hdd_station_ctx_t *pHddStaCtx;
16185 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016186 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016187 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016188 eHalStatus status = eHAL_STATUS_FAILURE;
16189
16190 ENTER();
16191
16192 if (NULL == pAdapter)
16193 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016194 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016195 "%s: HDD adapter is Null", __func__);
16196 return -ENODEV;
16197 }
16198
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016199 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16200 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
16201 pAdapter->sessionId, pAdapter->device_mode));
16202
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016203 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016204 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016205 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016206 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016207 }
16208
16209 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16210 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
16211 if (NULL == hHal)
16212 {
16213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16214 "%s: HAL context is Null!!!", __func__);
16215 return -EAGAIN;
16216 }
16217
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016218 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
16219 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
16220 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
16221 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016222 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016223 {
16224 /* changing from big to little endian since driver
16225 * works on little endian format
16226 */
16227 tANI_U8 *p =
16228 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
16229 int i;
16230
16231 for (i = 0; i < 8; i++)
16232 {
16233 p[7-i] = data->replay_ctr[i];
16234 }
16235 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016236
16237 if (TRUE == pHddCtx->hdd_wlan_suspended)
16238 {
16239 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016240 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
16241 sizeof (tSirGtkOffloadParams));
16242 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016243 pAdapter->sessionId);
16244
16245 if (eHAL_STATUS_SUCCESS != status)
16246 {
16247 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16248 "%s: sme_SetGTKOffload failed, returned %d",
16249 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053016250
16251 /* Need to clear any trace of key value in the memory.
16252 * Thus zero out the memory even though it is local
16253 * variable.
16254 */
16255 vos_mem_zero(&hddGtkOffloadReqParams,
16256 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016257 return status;
16258 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16260 "%s: sme_SetGTKOffload successfull", __func__);
16261 }
16262 else
16263 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16265 "%s: wlan not suspended GTKOffload request is stored",
16266 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016267 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016268
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053016269 /* Need to clear any trace of key value in the memory.
16270 * Thus zero out the memory even though it is local
16271 * variable.
16272 */
16273 vos_mem_zero(&hddGtkOffloadReqParams,
16274 sizeof(hddGtkOffloadReqParams));
16275
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016276 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016277 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016278}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016279
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016280int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
16281 struct cfg80211_gtk_rekey_data *data)
16282{
16283 int ret;
16284
16285 vos_ssr_protect(__func__);
16286 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
16287 vos_ssr_unprotect(__func__);
16288
16289 return ret;
16290}
16291#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016292/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016293 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016294 * This function is used to set access control policy
16295 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016296static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16297 struct net_device *dev,
16298 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016299{
16300 int i;
16301 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16302 hdd_hostapd_state_t *pHostapdState;
16303 tsap_Config_t *pConfig;
16304 v_CONTEXT_t pVosContext = NULL;
16305 hdd_context_t *pHddCtx;
16306 int status;
16307
16308 ENTER();
16309
16310 if (NULL == pAdapter)
16311 {
16312 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16313 "%s: HDD adapter is Null", __func__);
16314 return -ENODEV;
16315 }
16316
16317 if (NULL == params)
16318 {
16319 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16320 "%s: params is Null", __func__);
16321 return -EINVAL;
16322 }
16323
16324 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16325 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016326 if (0 != status)
16327 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016328 return status;
16329 }
16330
16331 pVosContext = pHddCtx->pvosContext;
16332 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
16333
16334 if (NULL == pHostapdState)
16335 {
16336 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16337 "%s: pHostapdState is Null", __func__);
16338 return -EINVAL;
16339 }
16340
16341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
16342 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016343 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16344 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
16345 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016346
16347 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
16348 {
16349 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
16350
16351 /* default value */
16352 pConfig->num_accept_mac = 0;
16353 pConfig->num_deny_mac = 0;
16354
16355 /**
16356 * access control policy
16357 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
16358 * listed in hostapd.deny file.
16359 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
16360 * listed in hostapd.accept file.
16361 */
16362 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
16363 {
16364 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
16365 }
16366 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
16367 {
16368 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
16369 }
16370 else
16371 {
16372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16373 "%s:Acl Policy : %d is not supported",
16374 __func__, params->acl_policy);
16375 return -ENOTSUPP;
16376 }
16377
16378 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
16379 {
16380 pConfig->num_accept_mac = params->n_acl_entries;
16381 for (i = 0; i < params->n_acl_entries; i++)
16382 {
16383 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16384 "** Add ACL MAC entry %i in WhiletList :"
16385 MAC_ADDRESS_STR, i,
16386 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16387
16388 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
16389 sizeof(qcmacaddr));
16390 }
16391 }
16392 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
16393 {
16394 pConfig->num_deny_mac = params->n_acl_entries;
16395 for (i = 0; i < params->n_acl_entries; i++)
16396 {
16397 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16398 "** Add ACL MAC entry %i in BlackList :"
16399 MAC_ADDRESS_STR, i,
16400 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16401
16402 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
16403 sizeof(qcmacaddr));
16404 }
16405 }
16406
16407 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
16408 {
16409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16410 "%s: SAP Set Mac Acl fail", __func__);
16411 return -EINVAL;
16412 }
16413 }
16414 else
16415 {
16416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053016417 "%s: Invalid device_mode = %s (%d)",
16418 __func__, hdd_device_modetoString(pAdapter->device_mode),
16419 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016420 return -EINVAL;
16421 }
16422
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016423 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016424 return 0;
16425}
16426
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016427static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16428 struct net_device *dev,
16429 const struct cfg80211_acl_data *params)
16430{
16431 int ret;
16432 vos_ssr_protect(__func__);
16433 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
16434 vos_ssr_unprotect(__func__);
16435
16436 return ret;
16437}
16438
Leo Chang9056f462013-08-01 19:21:11 -070016439#ifdef WLAN_NL80211_TESTMODE
16440#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070016441void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070016442(
16443 void *pAdapter,
16444 void *indCont
16445)
16446{
Leo Changd9df8aa2013-09-26 13:32:26 -070016447 tSirLPHBInd *lphbInd;
16448 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053016449 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070016450
16451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016452 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070016453
c_hpothu73f35e62014-04-18 13:40:08 +053016454 if (pAdapter == NULL)
16455 {
16456 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16457 "%s: pAdapter is NULL\n",__func__);
16458 return;
16459 }
16460
Leo Chang9056f462013-08-01 19:21:11 -070016461 if (NULL == indCont)
16462 {
16463 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016464 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070016465 return;
16466 }
16467
c_hpothu73f35e62014-04-18 13:40:08 +053016468 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070016469 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070016470 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053016471 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070016472 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070016473 GFP_ATOMIC);
16474 if (!skb)
16475 {
16476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16477 "LPHB timeout, NL buffer alloc fail");
16478 return;
16479 }
16480
Leo Changac3ba772013-10-07 09:47:04 -070016481 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070016482 {
16483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16484 "WLAN_HDD_TM_ATTR_CMD put fail");
16485 goto nla_put_failure;
16486 }
Leo Changac3ba772013-10-07 09:47:04 -070016487 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070016488 {
16489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16490 "WLAN_HDD_TM_ATTR_TYPE put fail");
16491 goto nla_put_failure;
16492 }
Leo Changac3ba772013-10-07 09:47:04 -070016493 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070016494 sizeof(tSirLPHBInd), lphbInd))
16495 {
16496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16497 "WLAN_HDD_TM_ATTR_DATA put fail");
16498 goto nla_put_failure;
16499 }
Leo Chang9056f462013-08-01 19:21:11 -070016500 cfg80211_testmode_event(skb, GFP_ATOMIC);
16501 return;
16502
16503nla_put_failure:
16504 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16505 "NLA Put fail");
16506 kfree_skb(skb);
16507
16508 return;
16509}
16510#endif /* FEATURE_WLAN_LPHB */
16511
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016512static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070016513{
16514 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
16515 int err = 0;
16516#ifdef FEATURE_WLAN_LPHB
16517 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070016518 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016519
16520 ENTER();
16521
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016522 err = wlan_hdd_validate_context(pHddCtx);
16523 if (0 != err)
16524 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016525 return err;
16526 }
Leo Chang9056f462013-08-01 19:21:11 -070016527#endif /* FEATURE_WLAN_LPHB */
16528
16529 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
16530 if (err)
16531 {
16532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16533 "%s Testmode INV ATTR", __func__);
16534 return err;
16535 }
16536
16537 if (!tb[WLAN_HDD_TM_ATTR_CMD])
16538 {
16539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16540 "%s Testmode INV CMD", __func__);
16541 return -EINVAL;
16542 }
16543
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016544 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16545 TRACE_CODE_HDD_CFG80211_TESTMODE,
16546 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070016547 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
16548 {
16549#ifdef FEATURE_WLAN_LPHB
16550 /* Low Power Heartbeat configuration request */
16551 case WLAN_HDD_TM_CMD_WLAN_HB:
16552 {
16553 int buf_len;
16554 void *buf;
16555 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080016556 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070016557
16558 if (!tb[WLAN_HDD_TM_ATTR_DATA])
16559 {
16560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16561 "%s Testmode INV DATA", __func__);
16562 return -EINVAL;
16563 }
16564
16565 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
16566 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080016567
16568 hb_params_temp =(tSirLPHBReq *)buf;
16569 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
16570 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
16571 return -EINVAL;
16572
Leo Chang9056f462013-08-01 19:21:11 -070016573 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
16574 if (NULL == hb_params)
16575 {
16576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16577 "%s Request Buffer Alloc Fail", __func__);
16578 return -EINVAL;
16579 }
16580
16581 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070016582 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
16583 hb_params,
16584 wlan_hdd_cfg80211_lphb_ind_handler);
16585 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070016586 {
Leo Changd9df8aa2013-09-26 13:32:26 -070016587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16588 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070016589 vos_mem_free(hb_params);
16590 }
Leo Chang9056f462013-08-01 19:21:11 -070016591 return 0;
16592 }
16593#endif /* FEATURE_WLAN_LPHB */
16594 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16596 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070016597 return -EOPNOTSUPP;
16598 }
16599
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016600 EXIT();
16601 return err;
Leo Chang9056f462013-08-01 19:21:11 -070016602}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016603
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053016604static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
16605#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
16606 struct wireless_dev *wdev,
16607#endif
16608 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016609{
16610 int ret;
16611
16612 vos_ssr_protect(__func__);
16613 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
16614 vos_ssr_unprotect(__func__);
16615
16616 return ret;
16617}
Leo Chang9056f462013-08-01 19:21:11 -070016618#endif /* CONFIG_NL80211_TESTMODE */
16619
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016620static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016621 struct net_device *dev,
16622 int idx, struct survey_info *survey)
16623{
16624 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16625 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053016626 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016627 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053016628 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016629 v_S7_t snr,rssi;
16630 int status, i, j, filled = 0;
16631
16632 ENTER();
16633
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016634 if (NULL == pAdapter)
16635 {
16636 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16637 "%s: HDD adapter is Null", __func__);
16638 return -ENODEV;
16639 }
16640
16641 if (NULL == wiphy)
16642 {
16643 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16644 "%s: wiphy is Null", __func__);
16645 return -ENODEV;
16646 }
16647
16648 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16649 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016650 if (0 != status)
16651 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016652 return status;
16653 }
16654
Mihir Sheted9072e02013-08-21 17:02:29 +053016655 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16656
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016657 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053016658 0 != pAdapter->survey_idx ||
16659 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016660 {
16661 /* The survey dump ops when implemented completely is expected to
16662 * return a survey of all channels and the ops is called by the
16663 * kernel with incremental values of the argument 'idx' till it
16664 * returns -ENONET. But we can only support the survey for the
16665 * operating channel for now. survey_idx is used to track
16666 * that the ops is called only once and then return -ENONET for
16667 * the next iteration
16668 */
16669 pAdapter->survey_idx = 0;
16670 return -ENONET;
16671 }
16672
Mukul Sharma9d5233b2015-06-11 20:28:20 +053016673 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
16674 {
16675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16676 "%s: Roaming in progress, hence return ", __func__);
16677 return -ENONET;
16678 }
16679
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016680 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16681
16682 wlan_hdd_get_snr(pAdapter, &snr);
16683 wlan_hdd_get_rssi(pAdapter, &rssi);
16684
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016685 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16686 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
16687 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016688 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
16689 hdd_wlan_get_freq(channel, &freq);
16690
16691
16692 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
16693 {
16694 if (NULL == wiphy->bands[i])
16695 {
16696 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
16697 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
16698 continue;
16699 }
16700
16701 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
16702 {
16703 struct ieee80211_supported_band *band = wiphy->bands[i];
16704
16705 if (band->channels[j].center_freq == (v_U16_t)freq)
16706 {
16707 survey->channel = &band->channels[j];
16708 /* The Rx BDs contain SNR values in dB for the received frames
16709 * while the supplicant expects noise. So we calculate and
16710 * return the value of noise (dBm)
16711 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
16712 */
16713 survey->noise = rssi - snr;
16714 survey->filled = SURVEY_INFO_NOISE_DBM;
16715 filled = 1;
16716 }
16717 }
16718 }
16719
16720 if (filled)
16721 pAdapter->survey_idx = 1;
16722 else
16723 {
16724 pAdapter->survey_idx = 0;
16725 return -ENONET;
16726 }
16727
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016728 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016729 return 0;
16730}
16731
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016732static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
16733 struct net_device *dev,
16734 int idx, struct survey_info *survey)
16735{
16736 int ret;
16737
16738 vos_ssr_protect(__func__);
16739 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
16740 vos_ssr_unprotect(__func__);
16741
16742 return ret;
16743}
16744
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016745/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016746 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016747 * this is called when cfg80211 driver resume
16748 * driver updates latest sched_scan scan result(if any) to cfg80211 database
16749 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016750int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016751{
16752 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16753 hdd_adapter_t *pAdapter;
16754 hdd_adapter_list_node_t *pAdapterNode, *pNext;
16755 VOS_STATUS status = VOS_STATUS_SUCCESS;
16756
16757 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016758
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016759 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016760 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016761 return 0;
16762 }
16763
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016764 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
16765 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016766 spin_lock(&pHddCtx->schedScan_lock);
16767 pHddCtx->isWiphySuspended = FALSE;
16768 if (TRUE != pHddCtx->isSchedScanUpdatePending)
16769 {
16770 spin_unlock(&pHddCtx->schedScan_lock);
16771 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16772 "%s: Return resume is not due to PNO indication", __func__);
16773 return 0;
16774 }
16775 // Reset flag to avoid updatating cfg80211 data old results again
16776 pHddCtx->isSchedScanUpdatePending = FALSE;
16777 spin_unlock(&pHddCtx->schedScan_lock);
16778
16779 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
16780
16781 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
16782 {
16783 pAdapter = pAdapterNode->pAdapter;
16784 if ( (NULL != pAdapter) &&
16785 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
16786 {
16787 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016788 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16790 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016791 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016792 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016793 {
16794 /* Acquire wakelock to handle the case where APP's tries to
16795 * suspend immediately after updating the scan results. Whis
16796 * results in app's is in suspended state and not able to
16797 * process the connect request to AP
16798 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053016799 hdd_prevent_suspend_timeout(2000,
16800 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016801 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016802 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016803
16804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16805 "%s : cfg80211 scan result database updated", __func__);
16806
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016807 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016808 return 0;
16809
16810 }
16811 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16812 pAdapterNode = pNext;
16813 }
16814
16815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16816 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016817 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016818 return 0;
16819}
16820
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016821int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
16822{
16823 int ret;
16824
16825 vos_ssr_protect(__func__);
16826 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
16827 vos_ssr_unprotect(__func__);
16828
16829 return ret;
16830}
16831
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016832/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016833 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016834 * this is called when cfg80211 driver suspends
16835 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016836int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016837 struct cfg80211_wowlan *wow)
16838{
16839 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016840 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016841
16842 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016843
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016844 ret = wlan_hdd_validate_context(pHddCtx);
16845 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016846 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016847 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016848 }
16849
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016850
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016851 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16852 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
16853 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016854 pHddCtx->isWiphySuspended = TRUE;
16855
16856 EXIT();
16857
16858 return 0;
16859}
16860
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016861int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
16862 struct cfg80211_wowlan *wow)
16863{
16864 int ret;
16865
16866 vos_ssr_protect(__func__);
16867 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
16868 vos_ssr_unprotect(__func__);
16869
16870 return ret;
16871}
Jeff Johnson295189b2012-06-20 16:38:30 -070016872/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016873static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070016874{
16875 .add_virtual_intf = wlan_hdd_add_virtual_intf,
16876 .del_virtual_intf = wlan_hdd_del_virtual_intf,
16877 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
16878 .change_station = wlan_hdd_change_station,
16879#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
16880 .add_beacon = wlan_hdd_cfg80211_add_beacon,
16881 .del_beacon = wlan_hdd_cfg80211_del_beacon,
16882 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016883#else
16884 .start_ap = wlan_hdd_cfg80211_start_ap,
16885 .change_beacon = wlan_hdd_cfg80211_change_beacon,
16886 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070016887#endif
16888 .change_bss = wlan_hdd_cfg80211_change_bss,
16889 .add_key = wlan_hdd_cfg80211_add_key,
16890 .get_key = wlan_hdd_cfg80211_get_key,
16891 .del_key = wlan_hdd_cfg80211_del_key,
16892 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016893#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070016894 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016895#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016896 .scan = wlan_hdd_cfg80211_scan,
16897 .connect = wlan_hdd_cfg80211_connect,
16898 .disconnect = wlan_hdd_cfg80211_disconnect,
16899 .join_ibss = wlan_hdd_cfg80211_join_ibss,
16900 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
16901 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
16902 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
16903 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070016904 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
16905 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053016906 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070016907#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16908 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
16909 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
16910 .set_txq_params = wlan_hdd_set_txq_params,
16911#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016912 .get_station = wlan_hdd_cfg80211_get_station,
16913 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
16914 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016915 .add_station = wlan_hdd_cfg80211_add_station,
16916#ifdef FEATURE_WLAN_LFR
16917 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
16918 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
16919 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
16920#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016921#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
16922 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
16923#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016924#ifdef FEATURE_WLAN_TDLS
16925 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
16926 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
16927#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016928#ifdef WLAN_FEATURE_GTK_OFFLOAD
16929 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
16930#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016931#ifdef FEATURE_WLAN_SCAN_PNO
16932 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
16933 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
16934#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016935 .resume = wlan_hdd_cfg80211_resume_wlan,
16936 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016937 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070016938#ifdef WLAN_NL80211_TESTMODE
16939 .testmode_cmd = wlan_hdd_cfg80211_testmode,
16940#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016941 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070016942};
16943