blob: 90c62ff76fe52aca53d7d63e46835e2664166f86 [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,
1077 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1078 pWifiIfaceStat->beaconRx) ||
1079 nla_put_u32(vendor_event,
1080 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1081 pWifiIfaceStat->mgmtRx) ||
1082 nla_put_u32(vendor_event,
1083 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1084 pWifiIfaceStat->mgmtActionRx) ||
1085 nla_put_u32(vendor_event,
1086 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1087 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301088 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301089 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1090 pWifiIfaceStat->rssiMgmt) ||
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_DATA,
1093 pWifiIfaceStat->rssiData) ||
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_ACK,
1096 pWifiIfaceStat->rssiAck))
1097 {
1098 hddLog(VOS_TRACE_LEVEL_ERROR,
1099 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301100 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301101 return FALSE;
1102 }
1103
1104 wmmInfo = nla_nest_start(vendor_event,
1105 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301106 if(!wmmInfo)
1107 {
1108 vos_mem_free(pWifiIfaceStatTL);
1109 return FALSE;
1110 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301111 for (i = 0; i < WIFI_AC_MAX; i++)
1112 {
1113 struct nlattr *wmmStats;
1114 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301115 if(!wmmStats)
1116 {
1117 vos_mem_free(pWifiIfaceStatTL);
1118 return FALSE;
1119 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301120 if (FALSE == put_wifi_wmm_ac_stat(
1121 &pWifiIfaceStat->AccessclassStats[i],
1122 vendor_event))
1123 {
1124 hddLog(VOS_TRACE_LEVEL_ERROR,
1125 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301126 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301127 return FALSE;
1128 }
1129
1130 nla_nest_end(vendor_event, wmmStats);
1131 }
1132 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301133 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301134 return TRUE;
1135}
1136
1137static tSirWifiInterfaceMode
1138 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1139{
1140 switch (deviceMode)
1141 {
1142 case WLAN_HDD_INFRA_STATION:
1143 return WIFI_INTERFACE_STA;
1144 case WLAN_HDD_SOFTAP:
1145 return WIFI_INTERFACE_SOFTAP;
1146 case WLAN_HDD_P2P_CLIENT:
1147 return WIFI_INTERFACE_P2P_CLIENT;
1148 case WLAN_HDD_P2P_GO:
1149 return WIFI_INTERFACE_P2P_GO;
1150 case WLAN_HDD_IBSS:
1151 return WIFI_INTERFACE_IBSS;
1152 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301153 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301154 }
1155}
1156
1157static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1158 tpSirWifiInterfaceInfo pInfo)
1159{
1160 v_U8_t *staMac = NULL;
1161 hdd_station_ctx_t *pHddStaCtx;
1162 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1163 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1164
1165 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1166
1167 vos_mem_copy(pInfo->macAddr,
1168 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1169
1170 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1171 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1172 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1173 {
1174 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1175 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1176 {
1177 pInfo->state = WIFI_DISCONNECTED;
1178 }
1179 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1180 {
1181 hddLog(VOS_TRACE_LEVEL_ERROR,
1182 "%s: Session ID %d, Connection is in progress", __func__,
1183 pAdapter->sessionId);
1184 pInfo->state = WIFI_ASSOCIATING;
1185 }
1186 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1187 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1188 {
1189 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1190 hddLog(VOS_TRACE_LEVEL_ERROR,
1191 "%s: client " MAC_ADDRESS_STR
1192 " is in the middle of WPS/EAPOL exchange.", __func__,
1193 MAC_ADDR_ARRAY(staMac));
1194 pInfo->state = WIFI_AUTHENTICATING;
1195 }
1196 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1197 {
1198 pInfo->state = WIFI_ASSOCIATED;
1199 vos_mem_copy(pInfo->bssid,
1200 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1201 vos_mem_copy(pInfo->ssid,
1202 pHddStaCtx->conn_info.SSID.SSID.ssId,
1203 pHddStaCtx->conn_info.SSID.SSID.length);
1204 //NULL Terminate the string.
1205 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1206 }
1207 }
1208 vos_mem_copy(pInfo->countryStr,
1209 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1210
1211 vos_mem_copy(pInfo->apCountryStr,
1212 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1213
1214 return TRUE;
1215}
1216
1217/*
1218 * hdd_link_layer_process_peer_stats () - This function is called after
1219 * receiving Link Layer Peer statistics from FW.This function converts
1220 * the firmware data to the NL data and sends the same to the kernel/upper
1221 * layers.
1222 */
1223static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1224 v_VOID_t *pData)
1225{
1226 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1227 tpSirWifiRateStat pWifiRateStat;
1228 tpSirWifiPeerStat pWifiPeerStat;
1229 tpSirWifiPeerInfo pWifiPeerInfo;
1230 struct nlattr *peerInfo;
1231 struct sk_buff *vendor_event;
1232 int status, i;
1233
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301234 ENTER();
1235
Sunil Duttc69bccb2014-05-26 21:30:20 +05301236 status = wlan_hdd_validate_context(pHddCtx);
1237 if (0 != status)
1238 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301239 return;
1240 }
1241
1242 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1243
1244 hddLog(VOS_TRACE_LEVEL_INFO,
1245 "LL_STATS_PEER_ALL : numPeers %u",
1246 pWifiPeerStat->numPeers);
1247 {
1248 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1249 {
1250 pWifiPeerInfo = (tpSirWifiPeerInfo)
1251 ((uint8 *)pWifiPeerStat->peerInfo +
1252 ( i * sizeof(tSirWifiPeerInfo)));
1253
Dasari Srinivas1be0c4e2014-10-19 13:03:41 +05301254 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) {
1255 pWifiPeerInfo->type = WIFI_PEER_AP;
1256 }
1257 if (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) {
1258 pWifiPeerInfo->type = WIFI_PEER_P2P_GO;
1259 }
1260
Sunil Duttc69bccb2014-05-26 21:30:20 +05301261 hddLog(VOS_TRACE_LEVEL_INFO,
1262 " %d) LL_STATS Channel Stats "
1263 " Peer Type %u "
1264 " peerMacAddress %pM "
1265 " capabilities 0x%x "
1266 " numRate %u ",
1267 i,
1268 pWifiPeerInfo->type,
1269 pWifiPeerInfo->peerMacAddress,
1270 pWifiPeerInfo->capabilities,
1271 pWifiPeerInfo->numRate);
1272 {
1273 int j;
1274 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1275 {
1276 pWifiRateStat = (tpSirWifiRateStat)
1277 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1278 ( j * sizeof(tSirWifiRateStat)));
1279
1280 hddLog(VOS_TRACE_LEVEL_INFO,
1281 " peer Rate Stats "
1282 " preamble %u "
1283 " nss %u "
1284 " bw %u "
1285 " rateMcsIdx %u "
1286 " reserved %u "
1287 " bitrate %u "
1288 " txMpdu %u "
1289 " rxMpdu %u "
1290 " mpduLost %u "
1291 " retries %u "
1292 " retriesShort %u "
1293 " retriesLong %u",
1294 pWifiRateStat->rate.preamble,
1295 pWifiRateStat->rate.nss,
1296 pWifiRateStat->rate.bw,
1297 pWifiRateStat->rate.rateMcsIdx,
1298 pWifiRateStat->rate.reserved,
1299 pWifiRateStat->rate.bitrate,
1300 pWifiRateStat->txMpdu,
1301 pWifiRateStat->rxMpdu,
1302 pWifiRateStat->mpduLost,
1303 pWifiRateStat->retries,
1304 pWifiRateStat->retriesShort,
1305 pWifiRateStat->retriesLong);
1306 }
1307 }
1308 }
1309 }
1310
1311 /*
1312 * Allocate a size of 4096 for the peer stats comprising
1313 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1314 * sizeof (tSirWifiRateStat).Each field is put with an
1315 * NL attribute.The size of 4096 is considered assuming
1316 * that number of rates shall not exceed beyond 50 with
1317 * the sizeof (tSirWifiRateStat) being 32.
1318 */
1319 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05301320#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
1321 NULL,
1322#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +05301323 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1324 QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX,
1325 GFP_KERNEL);
1326 if (!vendor_event)
1327 {
1328 hddLog(VOS_TRACE_LEVEL_ERROR,
1329 "%s: cfg80211_vendor_event_alloc failed",
1330 __func__);
1331 return;
1332 }
1333 if (nla_put_u32(vendor_event,
1334 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1335 pWifiPeerStat->numPeers))
1336 {
1337 hddLog(VOS_TRACE_LEVEL_ERROR,
1338 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1339 kfree_skb(vendor_event);
1340 return;
1341 }
1342
1343 peerInfo = nla_nest_start(vendor_event,
1344 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301345 if(!peerInfo)
1346 {
1347 hddLog(VOS_TRACE_LEVEL_ERROR,
1348 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1349 __func__);
1350 kfree_skb(vendor_event);
1351 return;
1352 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301353
1354 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1355 pWifiPeerStat->peerInfo);
1356
1357 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1358 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301359 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301360 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301361
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301362 if(!peers)
1363 {
1364 hddLog(VOS_TRACE_LEVEL_ERROR,
1365 "%s: peer stats put fail",
1366 __func__);
1367 kfree_skb(vendor_event);
1368 return;
1369 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301370 if (FALSE == put_wifi_peer_info(
1371 pWifiPeerInfo, vendor_event))
1372 {
1373 hddLog(VOS_TRACE_LEVEL_ERROR,
1374 "%s: put_wifi_peer_info put fail", __func__);
1375 kfree_skb(vendor_event);
1376 return;
1377 }
1378
1379 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1380 pWifiPeerStat->peerInfo +
1381 (i * sizeof(tSirWifiPeerInfo)) +
1382 (numRate * sizeof (tSirWifiRateStat)));
1383 nla_nest_end(vendor_event, peers);
1384 }
1385 nla_nest_end(vendor_event, peerInfo);
1386 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301387
1388 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 */
1419 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05301420#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
1421 NULL,
1422#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +05301423 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1424 QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX,
1425 GFP_KERNEL);
1426 if (!vendor_event)
1427 {
1428 hddLog(VOS_TRACE_LEVEL_ERROR,
1429 FL("cfg80211_vendor_event_alloc failed") );
1430 return;
1431 }
1432
1433 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1434
Dino Mycle3b9536d2014-07-09 22:05:24 +05301435
1436 if (FALSE == hdd_get_interface_info( pAdapter,
1437 &pWifiIfaceStat->info))
1438 {
1439 hddLog(VOS_TRACE_LEVEL_ERROR,
1440 FL("hdd_get_interface_info get fail") );
1441 kfree_skb(vendor_event);
1442 return;
1443 }
1444
1445 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1446 vendor_event))
1447 {
1448 hddLog(VOS_TRACE_LEVEL_ERROR,
1449 FL("put_wifi_iface_stats fail") );
1450 kfree_skb(vendor_event);
1451 return;
1452 }
1453
Sunil Duttc69bccb2014-05-26 21:30:20 +05301454 hddLog(VOS_TRACE_LEVEL_INFO,
1455 "WMI_LINK_STATS_IFACE Data");
1456
1457 hddLog(VOS_TRACE_LEVEL_INFO,
1458 "LL_STATS_IFACE: "
1459 " Mode %u "
1460 " MAC %pM "
1461 " State %u "
1462 " Roaming %u "
1463 " capabilities 0x%x "
1464 " SSID %s "
1465 " BSSID %pM",
1466 pWifiIfaceStat->info.mode,
1467 pWifiIfaceStat->info.macAddr,
1468 pWifiIfaceStat->info.state,
1469 pWifiIfaceStat->info.roaming,
1470 pWifiIfaceStat->info.capabilities,
1471 pWifiIfaceStat->info.ssid,
1472 pWifiIfaceStat->info.bssid);
1473
1474 hddLog(VOS_TRACE_LEVEL_INFO,
1475 " AP country str: %c%c%c",
1476 pWifiIfaceStat->info.apCountryStr[0],
1477 pWifiIfaceStat->info.apCountryStr[1],
1478 pWifiIfaceStat->info.apCountryStr[2]);
1479
1480
1481 hddLog(VOS_TRACE_LEVEL_INFO,
1482 " Country Str Association: %c%c%c",
1483 pWifiIfaceStat->info.countryStr[0],
1484 pWifiIfaceStat->info.countryStr[1],
1485 pWifiIfaceStat->info.countryStr[2]);
1486
1487 hddLog(VOS_TRACE_LEVEL_INFO,
1488 " beaconRx %u "
1489 " mgmtRx %u "
1490 " mgmtActionRx %u "
1491 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301492 " rssiMgmt %d "
1493 " rssiData %d "
1494 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301495 pWifiIfaceStat->beaconRx,
1496 pWifiIfaceStat->mgmtRx,
1497 pWifiIfaceStat->mgmtActionRx,
1498 pWifiIfaceStat->mgmtActionTx,
1499 pWifiIfaceStat->rssiMgmt,
1500 pWifiIfaceStat->rssiData,
1501 pWifiIfaceStat->rssiAck );
1502
1503
1504 {
1505 int i;
1506 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1507 {
1508 hddLog(VOS_TRACE_LEVEL_INFO,
1509
1510 " %d) LL_STATS IFACE: "
1511 " ac: %u txMpdu: %u "
1512 " rxMpdu: %u txMcast: %u "
1513 " rxMcast: %u rxAmpdu: %u "
1514 " txAmpdu: %u mpduLost: %u "
1515 " retries: %u retriesShort: %u "
1516 " retriesLong: %u contentionTimeMin: %u "
1517 " contentionTimeMax: %u contentionTimeAvg: %u "
1518 " contentionNumSamples: %u",
1519 i,
1520 pWifiIfaceStat->AccessclassStats[i].ac,
1521 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1522 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1523 pWifiIfaceStat->AccessclassStats[i].txMcast,
1524 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1525 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1526 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1527 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1528 pWifiIfaceStat->AccessclassStats[i].retries,
1529 pWifiIfaceStat->
1530 AccessclassStats[i].retriesShort,
1531 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1532 pWifiIfaceStat->
1533 AccessclassStats[i].contentionTimeMin,
1534 pWifiIfaceStat->
1535 AccessclassStats[i].contentionTimeMax,
1536 pWifiIfaceStat->
1537 AccessclassStats[i].contentionTimeAvg,
1538 pWifiIfaceStat->
1539 AccessclassStats[i].contentionNumSamples);
1540
1541 }
1542 }
1543
Sunil Duttc69bccb2014-05-26 21:30:20 +05301544 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301545
1546 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301547}
1548
1549/*
1550 * hdd_link_layer_process_radio_stats () - This function is called after
1551 * receiving Link Layer Radio statistics from FW.This function converts
1552 * the firmware data to the NL data and sends the same to the kernel/upper
1553 * layers.
1554 */
1555static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1556 v_VOID_t *pData)
1557{
1558 int status, i;
1559 tpSirWifiRadioStat pWifiRadioStat;
1560 tpSirWifiChannelStats pWifiChannelStats;
1561 struct sk_buff *vendor_event;
1562 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1563 struct nlattr *chList;
1564
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301565 ENTER();
1566
Sunil Duttc69bccb2014-05-26 21:30:20 +05301567 status = wlan_hdd_validate_context(pHddCtx);
1568 if (0 != status)
1569 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301570 return;
1571 }
1572 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1573
1574 hddLog(VOS_TRACE_LEVEL_INFO,
1575 "LL_STATS_RADIO"
1576 " radio is %d onTime is %u "
1577 " txTime is %u rxTime is %u "
1578 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301579 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301580 " onTimePnoScan is %u onTimeHs20 is %u "
1581 " numChannels is %u",
1582 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1583 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1584 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301585 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301586 pWifiRadioStat->onTimeRoamScan,
1587 pWifiRadioStat->onTimePnoScan,
1588 pWifiRadioStat->onTimeHs20,
1589 pWifiRadioStat->numChannels);
1590 /*
1591 * Allocate a size of 4096 for the Radio stats comprising
1592 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1593 * (tSirWifiChannelStats).Each channel data is put with an
1594 * NL attribute.The size of 4096 is considered assuming that
1595 * number of channels shall not exceed beyond 60 with the
1596 * sizeof (tSirWifiChannelStats) being 24 bytes.
1597 */
1598
1599 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05301600#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
1601 NULL,
1602#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +05301603 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN ,
1604 QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX,
1605 GFP_KERNEL);
1606
1607 if (!vendor_event)
1608 {
1609 hddLog(VOS_TRACE_LEVEL_ERROR,
1610 FL("cfg80211_vendor_event_alloc failed") );
1611 return;
1612 }
1613
1614 if (nla_put_u32(vendor_event,
1615 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1616 pWifiRadioStat->radio) ||
1617 nla_put_u32(vendor_event,
1618 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1619 pWifiRadioStat->onTime) ||
1620 nla_put_u32(vendor_event,
1621 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1622 pWifiRadioStat->txTime) ||
1623 nla_put_u32(vendor_event,
1624 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1625 pWifiRadioStat->rxTime) ||
1626 nla_put_u32(vendor_event,
1627 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1628 pWifiRadioStat->onTimeScan) ||
1629 nla_put_u32(vendor_event,
1630 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1631 pWifiRadioStat->onTimeNbd) ||
1632 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301633 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1634 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301635 nla_put_u32(vendor_event,
1636 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1637 pWifiRadioStat->onTimeRoamScan) ||
1638 nla_put_u32(vendor_event,
1639 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1640 pWifiRadioStat->onTimePnoScan) ||
1641 nla_put_u32(vendor_event,
1642 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1643 pWifiRadioStat->onTimeHs20) ||
1644 nla_put_u32(vendor_event,
1645 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1646 pWifiRadioStat->numChannels))
1647 {
1648 hddLog(VOS_TRACE_LEVEL_ERROR,
1649 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1650 kfree_skb(vendor_event);
1651 return ;
1652 }
1653
1654 chList = nla_nest_start(vendor_event,
1655 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301656 if(!chList)
1657 {
1658 hddLog(VOS_TRACE_LEVEL_ERROR,
1659 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1660 __func__);
1661 kfree_skb(vendor_event);
1662 return;
1663 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301664 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1665 {
1666 struct nlattr *chInfo;
1667
1668 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1669 pWifiRadioStat->channels +
1670 (i * sizeof(tSirWifiChannelStats)));
1671
1672 hddLog(VOS_TRACE_LEVEL_INFO,
1673 " %d) Channel Info"
1674 " width is %u "
1675 " CenterFreq %u "
1676 " CenterFreq0 %u "
1677 " CenterFreq1 %u "
1678 " onTime %u "
1679 " ccaBusyTime %u",
1680 i,
1681 pWifiChannelStats->channel.width,
1682 pWifiChannelStats->channel.centerFreq,
1683 pWifiChannelStats->channel.centerFreq0,
1684 pWifiChannelStats->channel.centerFreq1,
1685 pWifiChannelStats->onTime,
1686 pWifiChannelStats->ccaBusyTime);
1687
1688
1689 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301690 if(!chInfo)
1691 {
1692 hddLog(VOS_TRACE_LEVEL_ERROR,
1693 "%s: failed to put chInfo",
1694 __func__);
1695 kfree_skb(vendor_event);
1696 return;
1697 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301698
1699 if (nla_put_u32(vendor_event,
1700 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1701 pWifiChannelStats->channel.width) ||
1702 nla_put_u32(vendor_event,
1703 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1704 pWifiChannelStats->channel.centerFreq) ||
1705 nla_put_u32(vendor_event,
1706 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1707 pWifiChannelStats->channel.centerFreq0) ||
1708 nla_put_u32(vendor_event,
1709 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1710 pWifiChannelStats->channel.centerFreq1) ||
1711 nla_put_u32(vendor_event,
1712 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1713 pWifiChannelStats->onTime) ||
1714 nla_put_u32(vendor_event,
1715 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1716 pWifiChannelStats->ccaBusyTime))
1717 {
1718 hddLog(VOS_TRACE_LEVEL_ERROR,
1719 FL("cfg80211_vendor_event_alloc failed") );
1720 kfree_skb(vendor_event);
1721 return ;
1722 }
1723 nla_nest_end(vendor_event, chInfo);
1724 }
1725 nla_nest_end(vendor_event, chList);
1726
1727 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301728
1729 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301730 return;
1731}
1732
1733/*
1734 * hdd_link_layer_stats_ind_callback () - This function is called after
1735 * receiving Link Layer indications from FW.This callback converts the firmware
1736 * data to the NL data and send the same to the kernel/upper layers.
1737 */
1738static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1739 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301740 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301741{
Dino Mycled3d50022014-07-07 12:58:25 +05301742 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1743 hdd_adapter_t *pAdapter = NULL;
1744 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301745 int status;
1746
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301747 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301748
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301749 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301750 if (0 != status)
1751 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301752 return;
1753 }
1754
Dino Mycled3d50022014-07-07 12:58:25 +05301755 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1756 if (NULL == pAdapter)
1757 {
1758 hddLog(VOS_TRACE_LEVEL_ERROR,
1759 FL(" MAC address %pM does not exist with host"),
1760 macAddr);
1761 return;
1762 }
1763
Sunil Duttc69bccb2014-05-26 21:30:20 +05301764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301765 "%s: Interface: %s LLStats indType: %d", __func__,
1766 pAdapter->dev->name, indType);
1767
Sunil Duttc69bccb2014-05-26 21:30:20 +05301768 switch (indType)
1769 {
1770 case SIR_HAL_LL_STATS_RESULTS_RSP:
1771 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301772 hddLog(VOS_TRACE_LEVEL_INFO,
1773 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1774 hddLog(VOS_TRACE_LEVEL_INFO,
1775 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1776 linkLayerStatsResults->paramId);
1777 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301778 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1779 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301780 hddLog(VOS_TRACE_LEVEL_INFO,
1781 "LL_STATS RESULTS RESPONSE respId = %u",
1782 linkLayerStatsResults->respId);
1783 hddLog(VOS_TRACE_LEVEL_INFO,
1784 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1785 linkLayerStatsResults->moreResultToFollow);
1786 hddLog(VOS_TRACE_LEVEL_INFO,
1787 "LL_STATS RESULTS RESPONSE result = %p",
1788 linkLayerStatsResults->result);
1789 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1790 {
1791 hdd_link_layer_process_radio_stats(pAdapter,
1792 (v_VOID_t *)linkLayerStatsResults->result);
1793 }
1794 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1795 {
1796 hdd_link_layer_process_iface_stats(pAdapter,
1797 (v_VOID_t *)linkLayerStatsResults->result);
1798 }
1799 else if ( linkLayerStatsResults->paramId &
1800 WMI_LINK_STATS_ALL_PEER )
1801 {
1802 hdd_link_layer_process_peer_stats(pAdapter,
1803 (v_VOID_t *)linkLayerStatsResults->result);
1804 } /* WMI_LINK_STATS_ALL_PEER */
1805 else
1806 {
1807 hddLog(VOS_TRACE_LEVEL_ERROR,
1808 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1809 }
1810
1811 break;
1812 }
1813 default:
1814 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1815 break;
1816 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301817
1818 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301819 return;
1820}
1821
1822const struct
1823nla_policy
1824qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1825{
1826 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1827 { .type = NLA_U32 },
1828 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1829 { .type = NLA_U32 },
1830};
1831
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301832static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1833 struct wireless_dev *wdev,
1834 const void *data,
1835 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301836{
1837 int status;
1838 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301839 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301840 struct net_device *dev = wdev->netdev;
1841 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1842 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1843
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301844 ENTER();
1845
Sunil Duttc69bccb2014-05-26 21:30:20 +05301846 status = wlan_hdd_validate_context(pHddCtx);
1847 if (0 != status)
1848 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301849 return -EINVAL;
1850 }
1851
1852 if (NULL == pAdapter)
1853 {
1854 hddLog(VOS_TRACE_LEVEL_ERROR,
1855 FL("HDD adapter is Null"));
1856 return -ENODEV;
1857 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301858 /* check the LLStats Capability */
1859 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1860 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1861 {
1862 hddLog(VOS_TRACE_LEVEL_ERROR,
1863 FL("Link Layer Statistics not supported by Firmware"));
1864 return -EINVAL;
1865 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301866
1867 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1868 (struct nlattr *)data,
1869 data_len, qca_wlan_vendor_ll_set_policy))
1870 {
1871 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1872 return -EINVAL;
1873 }
1874 if (!tb_vendor
1875 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1876 {
1877 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1878 return -EINVAL;
1879 }
1880 if (!tb_vendor[
1881 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1882 {
1883 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1884 return -EINVAL;
1885 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301886 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301887 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301888
Dino Mycledf0a5d92014-07-04 09:41:55 +05301889 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301890 nla_get_u32(
1891 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1892
Dino Mycledf0a5d92014-07-04 09:41:55 +05301893 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301894 nla_get_u32(
1895 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1896
Dino Mycled3d50022014-07-07 12:58:25 +05301897 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1898 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301899
1900
1901 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301902 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301903 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301904 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301905 hddLog(VOS_TRACE_LEVEL_INFO,
1906 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301907 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301908 hddLog(VOS_TRACE_LEVEL_INFO,
1909 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301910 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301911
1912 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1913 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301914 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301915 {
1916 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1917 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301918 return -EINVAL;
1919
1920 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301921
Sunil Duttc69bccb2014-05-26 21:30:20 +05301922 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301923 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301924 {
1925 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1926 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301927 return -EINVAL;
1928 }
1929
1930 pAdapter->isLinkLayerStatsSet = 1;
1931
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301932 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301933 return 0;
1934}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301935static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1936 struct wireless_dev *wdev,
1937 const void *data,
1938 int data_len)
1939{
1940 int ret = 0;
1941
1942 vos_ssr_protect(__func__);
1943 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1944 vos_ssr_unprotect(__func__);
1945
1946 return ret;
1947}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301948
1949const struct
1950nla_policy
1951qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1952{
1953 /* Unsigned 32bit value provided by the caller issuing the GET stats
1954 * command. When reporting
1955 * the stats results, the driver uses the same value to indicate
1956 * which GET request the results
1957 * correspond to.
1958 */
1959 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1960
1961 /* Unsigned 32bit value . bit mask to identify what statistics are
1962 requested for retrieval */
1963 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1964};
1965
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301966static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1967 struct wireless_dev *wdev,
1968 const void *data,
1969 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301970{
1971 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1972 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301973 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301974 struct net_device *dev = wdev->netdev;
1975 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mukul Sharma10313ba2015-07-29 19:14:39 +05301976 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301977 int status;
1978
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301979 ENTER();
1980
Sunil Duttc69bccb2014-05-26 21:30:20 +05301981 status = wlan_hdd_validate_context(pHddCtx);
1982 if (0 != status)
1983 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301984 return -EINVAL ;
1985 }
1986
1987 if (NULL == pAdapter)
1988 {
1989 hddLog(VOS_TRACE_LEVEL_FATAL,
1990 "%s: HDD adapter is Null", __func__);
1991 return -ENODEV;
1992 }
Mukul Sharma10313ba2015-07-29 19:14:39 +05301993
1994 if (pHddStaCtx == NULL)
1995 {
1996 hddLog(VOS_TRACE_LEVEL_FATAL,
1997 "%s: HddStaCtx is Null", __func__);
1998 return -ENODEV;
1999 }
2000
Dino Mycledf0a5d92014-07-04 09:41:55 +05302001 /* check the LLStats Capability */
2002 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2003 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2004 {
2005 hddLog(VOS_TRACE_LEVEL_ERROR,
2006 FL("Link Layer Statistics not supported by Firmware"));
2007 return -EINVAL;
2008 }
2009
Sunil Duttc69bccb2014-05-26 21:30:20 +05302010
2011 if (!pAdapter->isLinkLayerStatsSet)
2012 {
2013 hddLog(VOS_TRACE_LEVEL_FATAL,
2014 "%s: isLinkLayerStatsSet : %d",
2015 __func__, pAdapter->isLinkLayerStatsSet);
2016 return -EINVAL;
2017 }
2018
Mukul Sharma10313ba2015-07-29 19:14:39 +05302019 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
2020 {
2021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2022 "%s: Roaming in progress, so unable to proceed this request", __func__);
2023 return -EBUSY;
2024 }
2025
Sunil Duttc69bccb2014-05-26 21:30:20 +05302026 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2027 (struct nlattr *)data,
2028 data_len, qca_wlan_vendor_ll_get_policy))
2029 {
2030 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2031 return -EINVAL;
2032 }
2033
2034 if (!tb_vendor
2035 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2036 {
2037 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2038 return -EINVAL;
2039 }
2040
2041 if (!tb_vendor
2042 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2043 {
2044 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
2045 return -EINVAL;
2046 }
2047
Sunil Duttc69bccb2014-05-26 21:30:20 +05302048
Dino Mycledf0a5d92014-07-04 09:41:55 +05302049 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302050 nla_get_u32( tb_vendor[
2051 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05302052 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302053 nla_get_u32( tb_vendor[
2054 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
2055
Dino Mycled3d50022014-07-07 12:58:25 +05302056 vos_mem_copy(linkLayerStatsGetReq.macAddr,
2057 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302058
2059 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302060 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302061 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302062 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302063 hddLog(VOS_TRACE_LEVEL_INFO,
2064 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302065 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302066
2067 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302068 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302069 {
2070 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2071 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302072 return -EINVAL;
2073 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302074
2075 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302076 return 0;
2077}
2078
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302079static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2080 struct wireless_dev *wdev,
2081 const void *data,
2082 int data_len)
2083{
2084 int ret = 0;
2085
2086 vos_ssr_protect(__func__);
2087 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
2088 vos_ssr_unprotect(__func__);
2089
2090 return ret;
2091}
2092
Sunil Duttc69bccb2014-05-26 21:30:20 +05302093const struct
2094nla_policy
2095qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
2096{
2097 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
2098 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
2099 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
2100 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
2101};
2102
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302103static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2104 struct wireless_dev *wdev,
2105 const void *data,
2106 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302107{
2108 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2109 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302110 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302111 struct net_device *dev = wdev->netdev;
2112 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2113 u32 statsClearReqMask;
2114 u8 stopReq;
2115 int status;
2116
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302117 ENTER();
2118
Sunil Duttc69bccb2014-05-26 21:30:20 +05302119 status = wlan_hdd_validate_context(pHddCtx);
2120 if (0 != status)
2121 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302122 return -EINVAL;
2123 }
2124
2125 if (NULL == pAdapter)
2126 {
2127 hddLog(VOS_TRACE_LEVEL_FATAL,
2128 "%s: HDD adapter is Null", __func__);
2129 return -ENODEV;
2130 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302131 /* check the LLStats Capability */
2132 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2133 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2134 {
2135 hddLog(VOS_TRACE_LEVEL_ERROR,
2136 FL("Enable LLStats Capability"));
2137 return -EINVAL;
2138 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302139
2140 if (!pAdapter->isLinkLayerStatsSet)
2141 {
2142 hddLog(VOS_TRACE_LEVEL_FATAL,
2143 "%s: isLinkLayerStatsSet : %d",
2144 __func__, pAdapter->isLinkLayerStatsSet);
2145 return -EINVAL;
2146 }
2147
2148 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2149 (struct nlattr *)data,
2150 data_len, qca_wlan_vendor_ll_clr_policy))
2151 {
2152 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2153 return -EINVAL;
2154 }
2155
2156 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2157
2158 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2159 {
2160 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2161 return -EINVAL;
2162
2163 }
2164
Sunil Duttc69bccb2014-05-26 21:30:20 +05302165
Dino Mycledf0a5d92014-07-04 09:41:55 +05302166 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302167 nla_get_u32(
2168 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2169
Dino Mycledf0a5d92014-07-04 09:41:55 +05302170 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302171 nla_get_u8(
2172 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2173
2174 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302175 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302176
Dino Mycled3d50022014-07-07 12:58:25 +05302177 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2178 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302179
2180 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302181 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302182 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302183 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302184 hddLog(VOS_TRACE_LEVEL_INFO,
2185 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302186 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302187 hddLog(VOS_TRACE_LEVEL_INFO,
2188 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302189 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302190
2191 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302192 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302193 {
2194 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302195 hdd_station_ctx_t *pHddStaCtx;
2196
2197 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2198 if (VOS_STATUS_SUCCESS !=
2199 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2200 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2201 {
2202 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2203 "WLANTL_ClearInterfaceStats Failed", __func__);
2204 return -EINVAL;
2205 }
2206 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2207 (statsClearReqMask & WIFI_STATS_IFACE)) {
2208 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2209 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2210 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2211 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2212 }
2213
Sunil Duttc69bccb2014-05-26 21:30:20 +05302214 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2215 2 * sizeof(u32) +
2216 NLMSG_HDRLEN);
2217
2218 if (temp_skbuff != NULL)
2219 {
2220
2221 if (nla_put_u32(temp_skbuff,
2222 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2223 statsClearReqMask) ||
2224 nla_put_u32(temp_skbuff,
2225 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2226 stopReq))
2227 {
2228 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2229 kfree_skb(temp_skbuff);
2230 return -EINVAL;
2231 }
2232 /* If the ask is to stop the stats collection as part of clear
2233 * (stopReq = 1) , ensure that no further requests of get
2234 * go to the firmware by having isLinkLayerStatsSet set to 0.
2235 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302236 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302237 * case the firmware is just asked to clear the statistics.
2238 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302239 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302240 pAdapter->isLinkLayerStatsSet = 0;
2241 return cfg80211_vendor_cmd_reply(temp_skbuff);
2242 }
2243 return -ENOMEM;
2244 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302245
2246 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302247 return -EINVAL;
2248}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302249static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2250 struct wireless_dev *wdev,
2251 const void *data,
2252 int data_len)
2253{
2254 int ret = 0;
2255
2256 vos_ssr_protect(__func__);
2257 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2258 vos_ssr_unprotect(__func__);
2259
2260 return ret;
2261
2262
2263}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302264#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2265
Dino Mycle6fb96c12014-06-10 11:52:40 +05302266#ifdef WLAN_FEATURE_EXTSCAN
2267static const struct nla_policy
2268wlan_hdd_extscan_config_policy
2269 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2270{
2271 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2272 { .type = NLA_U32 },
2273 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2274 { .type = NLA_U32 },
2275 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2276 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2277 { .type = NLA_U32 },
2278 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2279 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2280
2281 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2282 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2283 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2284 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2285 { .type = NLA_U8 },
2286 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2287 { .type = NLA_U32 },
2288 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2289 { .type = NLA_U32 },
2290 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2291 { .type = NLA_U32 },
2292 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] =
2293 { .type = NLA_U8 },
2294 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2295 { .type = NLA_U8 },
2296 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2297 { .type = NLA_U8 },
2298
2299 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2300 { .type = NLA_U32 },
2301 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2302 { .type = NLA_UNSPEC },
2303 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2304 { .type = NLA_S32 },
2305 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2306 { .type = NLA_S32 },
2307 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2308 { .type = NLA_U32 },
2309 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2310 { .type = NLA_U32 },
2311 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] =
2312 { .type = NLA_U32 },
2313 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]
2314 = { .type = NLA_U32 },
2315 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] =
2316 { .type = NLA_U32 },
2317 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type =
2318 NLA_U32 },
2319};
2320
2321static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg)
2322{
2323 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2324 struct sk_buff *skb = NULL;
2325 tpSirEXTScanCapabilitiesEvent pData =
2326 (tpSirEXTScanCapabilitiesEvent) pMsg;
2327
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302328 ENTER();
2329
2330 if (wlan_hdd_validate_context(pHddCtx))
2331 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302332 return;
2333 }
2334
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302335 if (!pMsg)
2336 {
2337 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2338 return;
2339 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302340 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302341#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2342 NULL,
2343#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302344 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2345 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
2346 GFP_KERNEL);
2347
2348 if (!skb) {
2349 hddLog(VOS_TRACE_LEVEL_ERROR,
2350 FL("cfg80211_vendor_event_alloc failed"));
2351 return;
2352 }
2353
2354 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2355 hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize);
2356 hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets);
2357 hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan);
2358 hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)",
2359 pData->maxRssiSampleSize);
2360 hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)",
2361 pData->maxScanReportingThreshold);
2362 hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs);
2363 hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)",
2364 pData->maxSignificantWifiChangeAPs);
2365 hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)",
2366 pData->maxBsidHistoryEntries);
2367
2368 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2369 pData->requestId) ||
2370 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) ||
2371 nla_put_u32(skb,
2372 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
2373 pData->scanCacheSize) ||
2374 nla_put_u32(skb,
2375 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
2376 pData->scanBuckets) ||
2377 nla_put_u32(skb,
2378 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
2379 pData->maxApPerScan) ||
2380 nla_put_u32(skb,
2381 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
2382 pData->maxRssiSampleSize) ||
2383 nla_put_u32(skb,
2384 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
2385 pData->maxScanReportingThreshold) ||
2386 nla_put_u32(skb,
2387 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS,
2388 pData->maxHotlistAPs) ||
2389 nla_put_u32(skb,
2390 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
2391 pData->maxSignificantWifiChangeAPs) ||
2392 nla_put_u32(skb,
2393 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
2394 pData->maxBsidHistoryEntries)) {
2395 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2396 goto nla_put_failure;
2397 }
2398
2399 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302400 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302401 return;
2402
2403nla_put_failure:
2404 kfree_skb(skb);
2405 return;
2406}
2407
2408
2409static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2410{
2411 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2412 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2413 struct sk_buff *skb = NULL;
2414 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
2415
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302416 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302417
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302418 if (wlan_hdd_validate_context(pHddCtx)){
2419 return;
2420 }
2421 if (!pMsg)
2422 {
2423 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302424 return;
2425 }
2426
2427 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302428#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2429 NULL,
2430#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302431 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2432 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
2433 GFP_KERNEL);
2434
2435 if (!skb) {
2436 hddLog(VOS_TRACE_LEVEL_ERROR,
2437 FL("cfg80211_vendor_event_alloc failed"));
2438 return;
2439 }
2440 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2441 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2442 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2443
2444 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2445 pData->requestId) ||
2446 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2447 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2448 goto nla_put_failure;
2449 }
2450
2451 /*
2452 * Store the Request ID for comparing with the requestID obtained
2453 * in other requests.HDD shall return a failure is the extscan_stop
2454 * request is issued with a different requestId as that of the
2455 * extscan_start request. Also, This requestId shall be used while
2456 * indicating the full scan results to the upper layers.
2457 * The requestId is stored with the assumption that the firmware
2458 * shall return the ext scan start request's requestId in ext scan
2459 * start response.
2460 */
2461 if (pData->status == 0)
2462 pMac->sme.extScanStartReqId = pData->requestId;
2463
2464
2465 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302466 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302467 return;
2468
2469nla_put_failure:
2470 kfree_skb(skb);
2471 return;
2472}
2473
2474
2475static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2476{
2477 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2478 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2479 struct sk_buff *skb = NULL;
2480
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302481 ENTER();
2482
2483 if (wlan_hdd_validate_context(pHddCtx)){
2484 return;
2485 }
2486 if (!pMsg)
2487 {
2488 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302489 return;
2490 }
2491
2492 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302493#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2494 NULL,
2495#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302496 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2497 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2498 GFP_KERNEL);
2499
2500 if (!skb) {
2501 hddLog(VOS_TRACE_LEVEL_ERROR,
2502 FL("cfg80211_vendor_event_alloc failed"));
2503 return;
2504 }
2505 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2506 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2507
2508 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2509 pData->requestId) ||
2510 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2511 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2512 goto nla_put_failure;
2513 }
2514
2515 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302516 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302517 return;
2518
2519nla_put_failure:
2520 kfree_skb(skb);
2521 return;
2522}
2523
2524
2525static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2526 void *pMsg)
2527{
2528 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2529 struct sk_buff *skb = NULL;
2530 tpSirEXTScanSetBssidHotListRspParams pData =
2531 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2532
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302533 ENTER();
2534
2535 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302536 return;
2537 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302538 if (!pMsg)
2539 {
2540 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2541 return;
2542 }
2543
Dino Mycle6fb96c12014-06-10 11:52:40 +05302544 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302545#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2546 NULL,
2547#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302548 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2549 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2550 GFP_KERNEL);
2551
2552 if (!skb) {
2553 hddLog(VOS_TRACE_LEVEL_ERROR,
2554 FL("cfg80211_vendor_event_alloc failed"));
2555 return;
2556 }
2557 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2558 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2559 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2560
2561 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2562 pData->requestId) ||
2563 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2564 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2565 goto nla_put_failure;
2566 }
2567
2568 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302569 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302570 return;
2571
2572nla_put_failure:
2573 kfree_skb(skb);
2574 return;
2575}
2576
2577static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2578 void *pMsg)
2579{
2580 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2581 struct sk_buff *skb = NULL;
2582 tpSirEXTScanResetBssidHotlistRspParams pData =
2583 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2584
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302585 ENTER();
2586
2587 if (wlan_hdd_validate_context(pHddCtx)) {
2588 return;
2589 }
2590 if (!pMsg)
2591 {
2592 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302593 return;
2594 }
2595
2596 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302597#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2598 NULL,
2599#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302600 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2601 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2602 GFP_KERNEL);
2603
2604 if (!skb) {
2605 hddLog(VOS_TRACE_LEVEL_ERROR,
2606 FL("cfg80211_vendor_event_alloc failed"));
2607 return;
2608 }
2609 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2610 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2611
2612 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2613 pData->requestId) ||
2614 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2615 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2616 goto nla_put_failure;
2617 }
2618
2619 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302620 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302621 return;
2622
2623nla_put_failure:
2624 kfree_skb(skb);
2625 return;
2626}
2627
2628
2629static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2630 void *pMsg)
2631{
2632 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2633 struct sk_buff *skb = NULL;
2634 tpSirEXTScanSetSignificantChangeRspParams pData =
2635 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2636
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302637 ENTER();
2638
2639 if (wlan_hdd_validate_context(pHddCtx)) {
2640 return;
2641 }
2642 if (!pMsg)
2643 {
2644 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302645 return;
2646 }
2647
2648 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302649#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2650 NULL,
2651#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302652 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2653 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2654 GFP_KERNEL);
2655
2656 if (!skb) {
2657 hddLog(VOS_TRACE_LEVEL_ERROR,
2658 FL("cfg80211_vendor_event_alloc failed"));
2659 return;
2660 }
2661 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2662 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2663 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2664
2665 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2666 pData->requestId) ||
2667 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2668 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2669 goto nla_put_failure;
2670 }
2671
2672 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302673 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302674 return;
2675
2676nla_put_failure:
2677 kfree_skb(skb);
2678 return;
2679}
2680
2681
2682static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2683 void *pMsg)
2684{
2685 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2686 struct sk_buff *skb = NULL;
2687 tpSirEXTScanResetSignificantChangeRspParams pData =
2688 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2689
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302690 ENTER();
2691
2692 if (wlan_hdd_validate_context(pHddCtx)) {
2693 return;
2694 }
2695 if (!pMsg)
2696 {
2697 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302698 return;
2699 }
2700
2701 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302702#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2703 NULL,
2704#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302705 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2706 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2707 GFP_KERNEL);
2708
2709 if (!skb) {
2710 hddLog(VOS_TRACE_LEVEL_ERROR,
2711 FL("cfg80211_vendor_event_alloc failed"));
2712 return;
2713 }
2714 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2715 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2716 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2717
2718 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2719 pData->requestId) ||
2720 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2721 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2722 goto nla_put_failure;
2723 }
2724
2725 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302726 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302727 return;
2728
2729nla_put_failure:
2730 kfree_skb(skb);
2731 return;
2732}
2733
2734static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2735 void *pMsg)
2736{
2737 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2738 struct sk_buff *skb = NULL;
2739 tANI_U32 i = 0, j, resultsPerEvent;
2740 tANI_S32 totalResults;
2741 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2742 tpSirWifiScanResult pSirWifiScanResult;
2743
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302744 ENTER();
2745
2746 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302747 return;
2748 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302749 if (!pMsg)
2750 {
2751 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2752 return;
2753 }
2754
Dino Mycle6fb96c12014-06-10 11:52:40 +05302755 totalResults = pData->numOfAps;
2756 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2757 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2758 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2759
2760 do{
2761 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2762 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2763 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2764
2765 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302766#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2767 NULL,
2768#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302769 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2770 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2771 GFP_KERNEL);
2772
2773 if (!skb) {
2774 hddLog(VOS_TRACE_LEVEL_ERROR,
2775 FL("cfg80211_vendor_event_alloc failed"));
2776 return;
2777 }
2778
2779 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2780
2781 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2782 pData->requestId) ||
2783 nla_put_u32(skb,
2784 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2785 resultsPerEvent)) {
2786 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2787 goto fail;
2788 }
2789 if (nla_put_u8(skb,
2790 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2791 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2792 {
2793 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2794 goto fail;
2795 }
2796
2797 if (resultsPerEvent) {
2798 struct nlattr *aps;
2799
2800 aps = nla_nest_start(skb,
2801 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2802 if (!aps)
2803 {
2804 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2805 goto fail;
2806 }
2807
2808 for (j = 0; j < resultsPerEvent; j++, i++) {
2809 struct nlattr *ap;
2810 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2811 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2812
2813 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2814 "Ssid (%s)"
2815 "Bssid: %pM "
2816 "Channel (%u)"
2817 "Rssi (%d)"
2818 "RTT (%u)"
2819 "RTT_SD (%u)",
2820 i,
2821 pSirWifiScanResult->ts,
2822 pSirWifiScanResult->ssid,
2823 pSirWifiScanResult->bssid,
2824 pSirWifiScanResult->channel,
2825 pSirWifiScanResult->rssi,
2826 pSirWifiScanResult->rtt,
2827 pSirWifiScanResult->rtt_sd);
2828
2829 ap = nla_nest_start(skb, j + 1);
2830 if (!ap)
2831 {
2832 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2833 goto fail;
2834 }
2835
2836 if (nla_put_u64(skb,
2837 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2838 pSirWifiScanResult->ts) )
2839 {
2840 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2841 goto fail;
2842 }
2843 if (nla_put(skb,
2844 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2845 sizeof(pSirWifiScanResult->ssid),
2846 pSirWifiScanResult->ssid) )
2847 {
2848 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2849 goto fail;
2850 }
2851 if (nla_put(skb,
2852 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2853 sizeof(pSirWifiScanResult->bssid),
2854 pSirWifiScanResult->bssid) )
2855 {
2856 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2857 goto fail;
2858 }
2859 if (nla_put_u32(skb,
2860 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2861 pSirWifiScanResult->channel) )
2862 {
2863 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2864 goto fail;
2865 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302866 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302867 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2868 pSirWifiScanResult->rssi) )
2869 {
2870 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2871 goto fail;
2872 }
2873 if (nla_put_u32(skb,
2874 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2875 pSirWifiScanResult->rtt) )
2876 {
2877 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2878 goto fail;
2879 }
2880 if (nla_put_u32(skb,
2881 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2882 pSirWifiScanResult->rtt_sd))
2883 {
2884 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2885 goto fail;
2886 }
2887
2888 nla_nest_end(skb, ap);
2889 }
2890 nla_nest_end(skb, aps);
2891
2892 }
2893 cfg80211_vendor_event(skb, GFP_KERNEL);
2894 } while (totalResults > 0);
2895
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302896 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302897 return;
2898fail:
2899 kfree_skb(skb);
2900 return;
2901}
2902
2903static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2904 void *pMsg)
2905{
2906 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2907 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2908 struct sk_buff *skb = NULL;
2909 tANI_U32 i;
2910
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302911 ENTER();
2912
2913 if (wlan_hdd_validate_context(pHddCtx)) {
2914 return;
2915 }
2916 if (!pMsg)
2917 {
2918 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302919 return;
2920 }
2921
2922 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302923#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2924 NULL,
2925#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302926 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2927 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
2928 GFP_KERNEL);
2929
2930 if (!skb) {
2931 hddLog(VOS_TRACE_LEVEL_ERROR,
2932 FL("cfg80211_vendor_event_alloc failed"));
2933 return;
2934 }
2935 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2936 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2937 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2938 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2939
2940 for (i = 0; i < pData->numOfAps; i++) {
2941 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2942 "Ssid (%s) "
2943 "Bssid (" MAC_ADDRESS_STR ") "
2944 "Channel (%u) "
2945 "Rssi (%d) "
2946 "RTT (%u) "
2947 "RTT_SD (%u) ",
2948 i,
2949 pData->ap[i].ts,
2950 pData->ap[i].ssid,
2951 MAC_ADDR_ARRAY(pData->ap[i].bssid),
2952 pData->ap[i].channel,
2953 pData->ap[i].rssi,
2954 pData->ap[i].rtt,
2955 pData->ap[i].rtt_sd);
2956 }
2957
2958 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2959 pData->requestId) ||
2960 nla_put_u32(skb,
2961 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2962 pData->numOfAps)) {
2963 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2964 goto fail;
2965 }
2966 if (pData->numOfAps) {
2967 struct nlattr *aps;
2968
2969 aps = nla_nest_start(skb,
2970 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2971 if (!aps)
2972 goto fail;
2973
2974 for (i = 0; i < pData->numOfAps; i++) {
2975 struct nlattr *ap;
2976
2977 ap = nla_nest_start(skb, i + 1);
2978 if (!ap)
2979 goto fail;
2980
2981 if (nla_put_u64(skb,
2982 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2983 pData->ap[i].ts) ||
2984 nla_put(skb,
2985 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2986 sizeof(pData->ap[i].ssid),
2987 pData->ap[i].ssid) ||
2988 nla_put(skb,
2989 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2990 sizeof(pData->ap[i].bssid),
2991 pData->ap[i].bssid) ||
2992 nla_put_u32(skb,
2993 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2994 pData->ap[i].channel) ||
2995 nla_put_s32(skb,
2996 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2997 pData->ap[i].rssi) ||
2998 nla_put_u32(skb,
2999 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3000 pData->ap[i].rtt) ||
3001 nla_put_u32(skb,
3002 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3003 pData->ap[i].rtt_sd))
3004 goto fail;
3005
3006 nla_nest_end(skb, ap);
3007 }
3008 nla_nest_end(skb, aps);
3009
3010 if (nla_put_u8(skb,
3011 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3012 pData->moreData))
3013 goto fail;
3014 }
3015
3016 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303017 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303018 return;
3019
3020fail:
3021 kfree_skb(skb);
3022 return;
3023
3024}
3025static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
3026 void *pMsg)
3027{
3028 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3029 struct sk_buff *skb = NULL;
3030 tANI_U32 i, j;
3031 tpSirWifiSignificantChangeEvent pData =
3032 (tpSirWifiSignificantChangeEvent) pMsg;
3033
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303034 ENTER();
3035
3036 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303037 return;
3038 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303039 if (!pMsg)
3040 {
3041 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3042 return;
3043 }
3044
Dino Mycle6fb96c12014-06-10 11:52:40 +05303045 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303046#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3047 NULL,
3048#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303049 EXTSCAN_EVENT_BUF_SIZE,
3050 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
3051 GFP_KERNEL);
3052
3053 if (!skb) {
3054 hddLog(VOS_TRACE_LEVEL_ERROR,
3055 FL("cfg80211_vendor_event_alloc failed"));
3056 return;
3057 }
3058 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3059 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3060 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
3061 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
3062 pData->numSigRssiBss);
3063 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
3064
3065 for (i = 0; i < pData->numSigRssiBss; i++) {
3066 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
3067 " num RSSI %u ",
3068 i, pData->sigRssiResult[i].bssid,
3069 pData->sigRssiResult[i].channel,
3070 pData->sigRssiResult[i].numRssi);
3071
3072 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
3073
3074 hddLog(VOS_TRACE_LEVEL_INFO,
3075 " [%d]",
Dino Myclec8f3f332014-07-21 16:48:27 +05303076 pData->sigRssiResult[i].rssi[j]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303077
3078 }
3079 }
3080
3081
3082 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3083 pData->requestId) ||
3084 nla_put_u32(skb,
3085 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3086 pData->numSigRssiBss)) {
3087 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3088 goto fail;
3089 }
3090
3091 if (pData->numSigRssiBss) {
3092 struct nlattr *aps;
3093 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3094 if (!aps)
3095 goto fail;
3096 for (i = 0; i < pData->numSigRssiBss; i++) {
3097 struct nlattr *ap;
3098
3099 ap = nla_nest_start(skb, i);
3100 if (!ap)
3101 goto fail;
3102 if (nla_put(skb,
3103 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
3104 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
3105 nla_put_u32(skb,
3106 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
3107 pData->sigRssiResult[i].channel) ||
3108 nla_put_u32(skb,
3109 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
3110 pData->sigRssiResult[i].numRssi) ||
3111 nla_put(skb,
3112 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
3113 sizeof(s32) * pData->sigRssiResult[i].numRssi,
3114 pData->sigRssiResult[i].rssi))
3115 goto fail;
3116 nla_nest_end(skb, ap);
3117 }
3118 nla_nest_end(skb, aps);
3119 if (nla_put_u8(skb,
3120 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3121 pData->moreData))
3122 goto fail;
3123 }
3124 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303125 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303126 return;
3127fail:
3128 kfree_skb(skb);
3129 return;
3130}
3131
3132static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3133 void *pMsg)
3134{
3135 struct sk_buff *skb;
3136 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3137 tpSirWifiFullScanResultEvent pData =
3138 (tpSirWifiFullScanResultEvent) (pMsg);
3139
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303140 ENTER();
3141
3142 if (wlan_hdd_validate_context(pHddCtx)) {
3143 return;
3144 }
3145 if (!pMsg)
3146 {
3147 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303148 return;
3149 }
3150
3151 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303152#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3153 NULL,
3154#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303155 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3156 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3157 GFP_KERNEL);
3158
3159 if (!skb) {
3160 hddLog(VOS_TRACE_LEVEL_ERROR,
3161 FL("cfg80211_vendor_event_alloc failed"));
3162 return;
3163 }
3164
3165 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3166 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3167 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3168 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3169 "Ssid (%s)"
3170 "Bssid (" MAC_ADDRESS_STR ")"
3171 "Channel (%u)"
3172 "Rssi (%d)"
3173 "RTT (%u)"
3174 "RTT_SD (%u)"),
3175 pData->ap.ts,
3176 pData->ap.ssid,
3177 MAC_ADDR_ARRAY(pData->ap.bssid),
3178 pData->ap.channel,
3179 pData->ap.rssi,
3180 pData->ap.rtt,
3181 pData->ap.rtt_sd);
3182 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3183 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3184 pData->requestId) ||
3185 nla_put_u64(skb,
3186 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3187 pData->ap.ts) ||
3188 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3189 sizeof(pData->ap.ssid),
3190 pData->ap.ssid) ||
3191 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3192 WNI_CFG_BSSID_LEN,
3193 pData->ap.bssid) ||
3194 nla_put_u32(skb,
3195 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3196 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303197 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303198 pData->ap.rssi) ||
3199 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3200 pData->ap.rtt) ||
3201 nla_put_u32(skb,
3202 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3203 pData->ap.rtt_sd) ||
3204 nla_put_u16(skb,
3205 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3206 pData->ap.beaconPeriod) ||
3207 nla_put_u16(skb,
3208 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3209 pData->ap.capability) ||
3210 nla_put_u32(skb,
3211 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3212 pData->ieLength))
3213 {
3214 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3215 goto nla_put_failure;
3216 }
3217 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3218 pData->ieLength,
3219 pData->ie))
3220 {
3221 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3222 goto nla_put_failure;
3223 }
3224
3225 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303226 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303227 return;
3228
3229nla_put_failure:
3230 kfree_skb(skb);
3231 return;
3232}
3233
3234static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3235 void *pMsg)
3236{
3237 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3238 struct sk_buff *skb = NULL;
3239 tpSirEXTScanResultsAvailableIndParams pData =
3240 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3241
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303242 ENTER();
3243
3244 if (wlan_hdd_validate_context(pHddCtx)){
3245 return;
3246 }
3247 if (!pMsg)
3248 {
3249 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303250 return;
3251 }
3252
3253 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303254#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3255 NULL,
3256#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303257 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3258 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3259 GFP_KERNEL);
3260
3261 if (!skb) {
3262 hddLog(VOS_TRACE_LEVEL_ERROR,
3263 FL("cfg80211_vendor_event_alloc failed"));
3264 return;
3265 }
3266
3267 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3268 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3269 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3270 pData->numResultsAvailable);
3271 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3272 pData->requestId) ||
3273 nla_put_u32(skb,
3274 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3275 pData->numResultsAvailable)) {
3276 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3277 goto nla_put_failure;
3278 }
3279
3280 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303281 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303282 return;
3283
3284nla_put_failure:
3285 kfree_skb(skb);
3286 return;
3287}
3288
3289static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3290{
3291 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3292 struct sk_buff *skb = NULL;
3293 tpSirEXTScanProgressIndParams pData =
3294 (tpSirEXTScanProgressIndParams) pMsg;
3295
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303296 ENTER();
3297
3298 if (wlan_hdd_validate_context(pHddCtx)){
3299 return;
3300 }
3301 if (!pMsg)
3302 {
3303 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303304 return;
3305 }
3306
3307 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303308#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3309 NULL,
3310#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303311 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3312 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3313 GFP_KERNEL);
3314
3315 if (!skb) {
3316 hddLog(VOS_TRACE_LEVEL_ERROR,
3317 FL("cfg80211_vendor_event_alloc failed"));
3318 return;
3319 }
3320 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3321 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3322 pData->extScanEventType);
3323 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3324 pData->status);
3325
3326 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3327 pData->extScanEventType) ||
3328 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303329 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3330 pData->requestId) ||
3331 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303332 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3333 pData->status)) {
3334 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3335 goto nla_put_failure;
3336 }
3337
3338 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303339 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303340 return;
3341
3342nla_put_failure:
3343 kfree_skb(skb);
3344 return;
3345}
3346
3347void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3348 void *pMsg)
3349{
3350 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3351
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303352 ENTER();
3353
Dino Mycle6fb96c12014-06-10 11:52:40 +05303354 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303355 return;
3356 }
3357
3358 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3359
3360
3361 switch(evType) {
3362 case SIR_HAL_EXTSCAN_START_RSP:
3363 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3364 break;
3365
3366 case SIR_HAL_EXTSCAN_STOP_RSP:
3367 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3368 break;
3369 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3370 /* There is no need to send this response to upper layer
3371 Just log the message */
3372 hddLog(VOS_TRACE_LEVEL_INFO,
3373 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3374 break;
3375 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3376 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3377 break;
3378
3379 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3380 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3381 break;
3382
3383 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
3384 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
3385 break;
3386
3387 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
3388 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
3389 break;
3390 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
3391 wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg);
3392 break;
3393 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3394 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3395 break;
3396 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3397 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3398 break;
3399 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3400 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3401 break;
3402 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3403 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3404 break;
3405 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
3406 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
3407 break;
3408 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3409 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3410 break;
3411 default:
3412 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3413 break;
3414 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303415 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303416}
3417
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303418static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3419 struct wireless_dev *wdev,
3420 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303421{
Dino Myclee8843b32014-07-04 14:21:45 +05303422 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303423 struct net_device *dev = wdev->netdev;
3424 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3425 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3426 struct nlattr
3427 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3428 eHalStatus status;
3429
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303430 ENTER();
3431
Dino Mycle6fb96c12014-06-10 11:52:40 +05303432 status = wlan_hdd_validate_context(pHddCtx);
3433 if (0 != status)
3434 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303435 return -EINVAL;
3436 }
Dino Myclee8843b32014-07-04 14:21:45 +05303437 /* check the EXTScan Capability */
3438 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3439 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3440 {
3441 hddLog(VOS_TRACE_LEVEL_ERROR,
3442 FL("EXTScan not enabled/supported by Firmware"));
3443 return -EINVAL;
3444 }
3445
Dino Mycle6fb96c12014-06-10 11:52:40 +05303446 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3447 data, dataLen,
3448 wlan_hdd_extscan_config_policy)) {
3449 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3450 return -EINVAL;
3451 }
3452
3453 /* Parse and fetch request Id */
3454 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3455 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3456 return -EINVAL;
3457 }
3458
Dino Mycle6fb96c12014-06-10 11:52:40 +05303459
Dino Myclee8843b32014-07-04 14:21:45 +05303460 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303461 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303462 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303463
Dino Myclee8843b32014-07-04 14:21:45 +05303464 reqMsg.sessionId = pAdapter->sessionId;
3465 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303466
Dino Myclee8843b32014-07-04 14:21:45 +05303467 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303468 if (!HAL_STATUS_SUCCESS(status)) {
3469 hddLog(VOS_TRACE_LEVEL_ERROR,
3470 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303471 return -EINVAL;
3472 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303473 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303474 return 0;
3475}
3476
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303477static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3478 struct wireless_dev *wdev,
3479 const void *data, int dataLen)
3480{
3481 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303482
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303483 vos_ssr_protect(__func__);
3484 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3485 vos_ssr_unprotect(__func__);
3486
3487 return ret;
3488}
3489
3490static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3491 struct wireless_dev *wdev,
3492 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303493{
Dino Myclee8843b32014-07-04 14:21:45 +05303494 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303495 struct net_device *dev = wdev->netdev;
3496 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3497 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3498 struct nlattr
3499 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3500 eHalStatus status;
3501
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303502 ENTER();
3503
Dino Mycle6fb96c12014-06-10 11:52:40 +05303504 status = wlan_hdd_validate_context(pHddCtx);
3505 if (0 != status)
3506 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303507 return -EINVAL;
3508 }
Dino Myclee8843b32014-07-04 14:21:45 +05303509 /* check the EXTScan Capability */
3510 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3511 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3512 {
3513 hddLog(VOS_TRACE_LEVEL_ERROR,
3514 FL("EXTScan not enabled/supported by Firmware"));
3515 return -EINVAL;
3516 }
3517
Dino Mycle6fb96c12014-06-10 11:52:40 +05303518 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3519 data, dataLen,
3520 wlan_hdd_extscan_config_policy)) {
3521 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3522 return -EINVAL;
3523 }
3524 /* Parse and fetch request Id */
3525 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3526 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3527 return -EINVAL;
3528 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303529
Dino Myclee8843b32014-07-04 14:21:45 +05303530 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303531 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3532
Dino Myclee8843b32014-07-04 14:21:45 +05303533 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303534
Dino Myclee8843b32014-07-04 14:21:45 +05303535 reqMsg.sessionId = pAdapter->sessionId;
3536 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303537
3538 /* Parse and fetch flush parameter */
3539 if (!tb
3540 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3541 {
3542 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3543 goto failed;
3544 }
Dino Myclee8843b32014-07-04 14:21:45 +05303545 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303546 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3547
Dino Myclee8843b32014-07-04 14:21:45 +05303548 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303549
Dino Myclee8843b32014-07-04 14:21:45 +05303550 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303551 if (!HAL_STATUS_SUCCESS(status)) {
3552 hddLog(VOS_TRACE_LEVEL_ERROR,
3553 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303554 return -EINVAL;
3555 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303556 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303557 return 0;
3558
3559failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303560 return -EINVAL;
3561}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303562static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3563 struct wireless_dev *wdev,
3564 const void *data, int dataLen)
3565{
3566 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303567
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303568 vos_ssr_protect(__func__);
3569 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3570 vos_ssr_unprotect(__func__);
3571
3572 return ret;
3573}
3574
3575static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303576 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303577 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303578{
3579 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3580 struct net_device *dev = wdev->netdev;
3581 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3582 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3583 struct nlattr
3584 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3585 struct nlattr
3586 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3587 struct nlattr *apTh;
3588 eHalStatus status;
3589 tANI_U8 i = 0;
3590 int rem;
3591
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303592 ENTER();
3593
Dino Mycle6fb96c12014-06-10 11:52:40 +05303594 status = wlan_hdd_validate_context(pHddCtx);
3595 if (0 != status)
3596 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303597 return -EINVAL;
3598 }
Dino Myclee8843b32014-07-04 14:21:45 +05303599 /* check the EXTScan Capability */
3600 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3601 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3602 {
3603 hddLog(VOS_TRACE_LEVEL_ERROR,
3604 FL("EXTScan not enabled/supported by Firmware"));
3605 return -EINVAL;
3606 }
3607
Dino Mycle6fb96c12014-06-10 11:52:40 +05303608 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3609 data, dataLen,
3610 wlan_hdd_extscan_config_policy)) {
3611 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3612 return -EINVAL;
3613 }
3614
3615 /* Parse and fetch request Id */
3616 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3617 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3618 return -EINVAL;
3619 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303620 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3621 vos_mem_malloc(sizeof(*pReqMsg));
3622 if (!pReqMsg) {
3623 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3624 return -ENOMEM;
3625 }
3626
Dino Myclee8843b32014-07-04 14:21:45 +05303627
Dino Mycle6fb96c12014-06-10 11:52:40 +05303628 pReqMsg->requestId = nla_get_u32(
3629 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3630 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3631
3632 /* Parse and fetch number of APs */
3633 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3634 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3635 goto fail;
3636 }
3637
3638 pReqMsg->sessionId = pAdapter->sessionId;
3639 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3640
3641 pReqMsg->numAp = nla_get_u32(
3642 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3643 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3644
3645 nla_for_each_nested(apTh,
3646 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3647 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3648 nla_data(apTh), nla_len(apTh),
3649 NULL)) {
3650 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3651 goto fail;
3652 }
3653
3654 /* Parse and fetch MAC address */
3655 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3656 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3657 goto fail;
3658 }
3659 memcpy(pReqMsg->ap[i].bssid, nla_data(
3660 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3661 sizeof(tSirMacAddr));
3662 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3663
3664 /* Parse and fetch low RSSI */
3665 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3666 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3667 goto fail;
3668 }
3669 pReqMsg->ap[i].low = nla_get_s32(
3670 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3671 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3672
3673 /* Parse and fetch high RSSI */
3674 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3675 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3676 goto fail;
3677 }
3678 pReqMsg->ap[i].high = nla_get_s32(
3679 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3680 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3681 pReqMsg->ap[i].high);
3682
3683 /* Parse and fetch channel */
3684 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3685 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3686 goto fail;
3687 }
3688 pReqMsg->ap[i].channel = nla_get_u32(
3689 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3690 hddLog(VOS_TRACE_LEVEL_INFO,
3691 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3692 i++;
3693 }
3694 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3695 if (!HAL_STATUS_SUCCESS(status)) {
3696 hddLog(VOS_TRACE_LEVEL_ERROR,
3697 FL("sme_SetBssHotlist failed(err=%d)"), status);
3698 vos_mem_free(pReqMsg);
3699 return -EINVAL;
3700 }
3701
Dino Myclee8843b32014-07-04 14:21:45 +05303702 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303703 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303704 return 0;
3705
3706fail:
3707 vos_mem_free(pReqMsg);
3708 return -EINVAL;
3709}
3710
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303711static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3712 struct wireless_dev *wdev,
3713 const void *data, int dataLen)
3714{
3715 int ret = 0;
3716
3717 vos_ssr_protect(__func__);
3718 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3719 dataLen);
3720 vos_ssr_unprotect(__func__);
3721
3722 return ret;
3723}
3724
3725static int __wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303726 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303727 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303728{
3729 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3730 struct net_device *dev = wdev->netdev;
3731 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3732 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3733 struct nlattr
3734 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3735 struct nlattr
3736 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3737 struct nlattr *apTh;
3738 eHalStatus status;
3739 int i = 0;
3740 int rem;
3741
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303742 ENTER();
3743
Dino Mycle6fb96c12014-06-10 11:52:40 +05303744 status = wlan_hdd_validate_context(pHddCtx);
3745 if (0 != status)
3746 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303747 return -EINVAL;
3748 }
Dino Myclee8843b32014-07-04 14:21:45 +05303749 /* check the EXTScan Capability */
3750 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3751 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3752 {
3753 hddLog(VOS_TRACE_LEVEL_ERROR,
3754 FL("EXTScan not enabled/supported by Firmware"));
3755 return -EINVAL;
3756 }
3757
Dino Mycle6fb96c12014-06-10 11:52:40 +05303758 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3759 data, dataLen,
3760 wlan_hdd_extscan_config_policy)) {
3761 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3762 return -EINVAL;
3763 }
3764
3765 /* Parse and fetch request Id */
3766 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3767 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3768 return -EINVAL;
3769 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303770 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303771 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303772 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303773 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3774 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303775 }
3776
Dino Myclee8843b32014-07-04 14:21:45 +05303777
3778
Dino Mycle6fb96c12014-06-10 11:52:40 +05303779 pReqMsg->requestId = nla_get_u32(
3780 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3781 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3782
3783 /* Parse and fetch RSSI sample size */
3784 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3785 {
3786 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3787 goto fail;
3788 }
3789 pReqMsg->rssiSampleSize = nla_get_u32(
3790 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3791 hddLog(VOS_TRACE_LEVEL_INFO,
3792 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3793
3794 /* Parse and fetch lost AP sample size */
3795 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3796 {
3797 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3798 goto fail;
3799 }
3800 pReqMsg->lostApSampleSize = nla_get_u32(
3801 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3802 hddLog(VOS_TRACE_LEVEL_INFO,
3803 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3804 /* Parse and fetch minimum Breaching */
3805 if (!tb
3806 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3807 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3808 goto fail;
3809 }
3810 pReqMsg->minBreaching = nla_get_u32(
3811 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3812 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3813
3814 /* Parse and fetch number of APs */
3815 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3816 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3817 goto fail;
3818 }
3819 pReqMsg->numAp = nla_get_u32(
3820 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3821 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3822
3823 pReqMsg->sessionId = pAdapter->sessionId;
3824 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3825
3826 nla_for_each_nested(apTh,
3827 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3828 if(nla_parse(tb2,
3829 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3830 nla_data(apTh), nla_len(apTh),
3831 NULL)) {
3832 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3833 goto fail;
3834 }
3835
3836 /* Parse and fetch MAC address */
3837 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3838 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3839 goto fail;
3840 }
3841 memcpy(pReqMsg->ap[i].bssid, nla_data(
3842 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3843 sizeof(tSirMacAddr));
3844
3845 /* Parse and fetch low RSSI */
3846 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3847 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3848 goto fail;
3849 }
3850 pReqMsg->ap[i].low = nla_get_s32(
3851 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3852 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3853
3854 /* Parse and fetch high RSSI */
3855 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3856 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3857 goto fail;
3858 }
3859 pReqMsg->ap[i].high = nla_get_s32(
3860 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3861 hddLog(VOS_TRACE_LEVEL_INFO,
3862 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
3863
3864 /* Parse and fetch channel */
3865 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3866 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3867 goto fail;
3868 }
3869 pReqMsg->ap[i].channel = nla_get_u32(
3870 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3871 hddLog(VOS_TRACE_LEVEL_INFO,
3872 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3873 i++;
3874 }
3875
3876 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
3877 if (!HAL_STATUS_SUCCESS(status)) {
3878 hddLog(VOS_TRACE_LEVEL_ERROR,
3879 FL("sme_SetSignificantChange failed(err=%d)"), status);
3880 vos_mem_free(pReqMsg);
3881 return -EINVAL;
3882 }
Dino Myclee8843b32014-07-04 14:21:45 +05303883 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303884 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303885 return 0;
3886
3887fail:
3888 vos_mem_free(pReqMsg);
3889 return -EINVAL;
3890}
3891
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303892static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
3893 struct wireless_dev *wdev,
3894 const void *data, int dataLen)
3895{
3896 int ret = 0;
3897
3898 vos_ssr_protect(__func__);
3899 ret = __wlan_hdd_cfg80211_extscan_set_significant_change(wiphy, wdev, data,
3900 dataLen);
3901 vos_ssr_unprotect(__func__);
3902
3903 return ret;
3904}
3905
3906static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303907 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303908 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303909{
3910 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3911 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3912 tANI_U8 numChannels = 0;
3913 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3914 tANI_U32 requestId;
3915 tWifiBand wifiBand;
3916 eHalStatus status;
3917 struct sk_buff *replySkb;
3918 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303919 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303920
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303921 ENTER();
3922
Dino Mycle6fb96c12014-06-10 11:52:40 +05303923 status = wlan_hdd_validate_context(pHddCtx);
3924 if (0 != status)
3925 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303926 return -EINVAL;
3927 }
Dino Myclee8843b32014-07-04 14:21:45 +05303928
Dino Mycle6fb96c12014-06-10 11:52:40 +05303929 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3930 data, dataLen,
3931 wlan_hdd_extscan_config_policy)) {
3932 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3933 return -EINVAL;
3934 }
3935
3936 /* Parse and fetch request Id */
3937 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3938 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3939 return -EINVAL;
3940 }
3941 requestId = nla_get_u32(
3942 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3943 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3944
3945 /* Parse and fetch wifi band */
3946 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3947 {
3948 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3949 return -EINVAL;
3950 }
3951 wifiBand = nla_get_u32(
3952 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3953 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3954
3955 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
3956 wifiBand, ChannelList,
3957 &numChannels);
3958 if (eHAL_STATUS_SUCCESS != status) {
3959 hddLog(VOS_TRACE_LEVEL_ERROR,
3960 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
3961 return -EINVAL;
3962 }
3963 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
3964 for (i = 0; i < numChannels; i++)
3965 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
3966
3967 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
3968 sizeof(u32) * numChannels +
3969 NLMSG_HDRLEN);
3970
3971 if (!replySkb) {
3972 hddLog(VOS_TRACE_LEVEL_ERROR,
3973 FL("valid channels: buffer alloc fail"));
3974 return -EINVAL;
3975 }
3976 if (nla_put_u32(replySkb,
3977 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
3978 numChannels) ||
3979 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
3980 sizeof(u32) * numChannels, ChannelList)) {
3981
3982 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3983 kfree_skb(replySkb);
3984 return -EINVAL;
3985 }
3986
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303987 ret = cfg80211_vendor_cmd_reply(replySkb);
3988
3989 EXIT();
3990 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303991}
3992
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303993static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
3994 struct wireless_dev *wdev,
3995 const void *data, int dataLen)
3996{
3997 int ret = 0;
3998
3999 vos_ssr_protect(__func__);
4000 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
4001 dataLen);
4002 vos_ssr_unprotect(__func__);
4003
4004 return ret;
4005}
4006
4007static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304008 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304009 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304010{
Dino Myclee8843b32014-07-04 14:21:45 +05304011 tpSirEXTScanStartReqParams pReqMsg = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304012 struct net_device *dev = wdev->netdev;
4013 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4014 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4015 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4016 struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4017 struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4018 struct nlattr *buckets;
4019 struct nlattr *channels;
4020 int rem1;
4021 int rem2;
4022 eHalStatus status;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304023 tANI_U32 j = 0, index = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304024
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304025 ENTER();
4026
Dino Mycle6fb96c12014-06-10 11:52:40 +05304027 status = wlan_hdd_validate_context(pHddCtx);
4028 if (0 != status)
4029 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304030 return -EINVAL;
4031 }
Dino Myclee8843b32014-07-04 14:21:45 +05304032 /* check the EXTScan Capability */
4033 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4034 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4035 {
4036 hddLog(VOS_TRACE_LEVEL_ERROR,
4037 FL("EXTScan not enabled/supported by Firmware"));
4038 return -EINVAL;
4039 }
4040
Dino Mycle6fb96c12014-06-10 11:52:40 +05304041 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4042 data, dataLen,
4043 wlan_hdd_extscan_config_policy)) {
4044 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4045 return -EINVAL;
4046 }
4047
4048 /* Parse and fetch request Id */
4049 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4050 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4051 return -EINVAL;
4052 }
4053
Dino Myclee8843b32014-07-04 14:21:45 +05304054 pReqMsg = (tpSirEXTScanStartReqParams)
4055 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304056 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304057 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4058 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304059 }
4060
4061 pReqMsg->requestId = nla_get_u32(
4062 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4063 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4064
4065 pReqMsg->sessionId = pAdapter->sessionId;
4066 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4067
4068 /* Parse and fetch base period */
4069 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) {
4070 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4071 goto fail;
4072 }
4073 pReqMsg->basePeriod = nla_get_u32(
4074 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]);
4075 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4076 pReqMsg->basePeriod);
4077
4078 /* Parse and fetch max AP per scan */
4079 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) {
4080 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4081 goto fail;
4082 }
4083 pReqMsg->maxAPperScan = nla_get_u32(
4084 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]);
4085 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4086 pReqMsg->maxAPperScan);
4087
4088 /* Parse and fetch report threshold */
4089 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) {
4090 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4091 goto fail;
4092 }
4093 pReqMsg->reportThreshold = nla_get_u8(
4094 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]);
4095 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
4096 pReqMsg->reportThreshold);
4097
4098 /* Parse and fetch number of buckets */
4099 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) {
4100 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4101 goto fail;
4102 }
4103 pReqMsg->numBuckets = nla_get_u8(
4104 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]);
4105 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4106 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4107 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4108 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4109 }
4110 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4111 pReqMsg->numBuckets);
4112 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4113 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4114 goto fail;
4115 }
4116
4117 nla_for_each_nested(buckets,
4118 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4119 if(nla_parse(bucket,
4120 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4121 nla_data(buckets), nla_len(buckets), NULL)) { //policy
4122 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4123 goto fail;
4124 }
4125
4126 /* Parse and fetch bucket spec */
4127 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4128 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed"));
4129 goto fail;
4130 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304131
4132 pReqMsg->buckets[index].bucket = nla_get_u8(
4133 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4134
4135 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"),
4136 pReqMsg->buckets[index].bucket);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304137
4138 /* Parse and fetch wifi band */
4139 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4140 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4141 goto fail;
4142 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304143 pReqMsg->buckets[index].band = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304144 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4145 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304146 pReqMsg->buckets[index].band);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304147
4148 /* Parse and fetch period */
4149 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4150 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed"));
4151 goto fail;
4152 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304153 pReqMsg->buckets[index].period = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304154 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4155 hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304156 pReqMsg->buckets[index].period);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304157
4158 /* Parse and fetch report events */
4159 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4160 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed"));
4161 goto fail;
4162 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304163 pReqMsg->buckets[index].reportEvents = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304164 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4165 hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304166 pReqMsg->buckets[index].reportEvents);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304167
4168 /* Parse and fetch number of channels */
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304169 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS])
4170 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304171 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed"));
4172 goto fail;
4173 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304174 pReqMsg->buckets[index].numChannels = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304175 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4176 hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304177 pReqMsg->buckets[index].numChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304178
4179 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4180 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed"));
4181 goto fail;
4182 }
4183
4184 j = 0;
4185 nla_for_each_nested(channels,
4186 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4187 if(nla_parse(channel,
4188 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4189 nla_data(channels), nla_len(channels),
4190 NULL)) { //wlan_hdd_extscan_config_policy here
4191 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4192 goto fail;
4193 }
4194
4195 /* Parse and fetch channel */
4196 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4197 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4198 goto fail;
4199 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304200 pReqMsg->buckets[index].channels[j].channel = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304201 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4202 hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304203 pReqMsg->buckets[index].channels[j].channel);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304204
4205 /* Parse and fetch dwell time */
4206 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4207 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed"));
4208 goto fail;
4209 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304210 pReqMsg->buckets[index].channels[j].dwellTimeMs = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304211 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4212 hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304213 pReqMsg->buckets[index].channels[j].dwellTimeMs);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304214
4215 /* Parse and fetch channel spec passive */
4216 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4217 hddLog(VOS_TRACE_LEVEL_ERROR,
4218 FL("attr channel spec passive failed"));
4219 goto fail;
4220 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304221 pReqMsg->buckets[index].channels[j].passive = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304222 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4223 hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304224 pReqMsg->buckets[index].channels[j].passive);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304225 j++;
4226 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304227 index++;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304228 }
4229 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4230 if (!HAL_STATUS_SUCCESS(status)) {
4231 hddLog(VOS_TRACE_LEVEL_ERROR,
4232 FL("sme_EXTScanStart failed(err=%d)"), status);
4233 vos_mem_free(pReqMsg);
4234 return -EINVAL;
4235 }
4236
Dino Myclee8843b32014-07-04 14:21:45 +05304237 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304238 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304239 return 0;
4240
4241fail:
4242 vos_mem_free(pReqMsg);
4243 return -EINVAL;
4244}
4245
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304246static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4247 struct wireless_dev *wdev,
4248 const void *data, int dataLen)
4249{
4250 int ret = 0;
4251
4252 vos_ssr_protect(__func__);
4253 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4254 vos_ssr_unprotect(__func__);
4255
4256 return ret;
4257}
4258
4259static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304260 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304261 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304262{
Dino Myclee8843b32014-07-04 14:21:45 +05304263 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304264 struct net_device *dev = wdev->netdev;
4265 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4266 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4267 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4268 eHalStatus status;
4269
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304270 ENTER();
4271
Dino Mycle6fb96c12014-06-10 11:52:40 +05304272 status = wlan_hdd_validate_context(pHddCtx);
4273 if (0 != status)
4274 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304275 return -EINVAL;
4276 }
Dino Myclee8843b32014-07-04 14:21:45 +05304277 /* check the EXTScan Capability */
4278 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4279 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4280 {
4281 hddLog(VOS_TRACE_LEVEL_ERROR,
4282 FL("EXTScan not enabled/supported by Firmware"));
4283 return -EINVAL;
4284 }
4285
Dino Mycle6fb96c12014-06-10 11:52:40 +05304286 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4287 data, dataLen,
4288 wlan_hdd_extscan_config_policy)) {
4289 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4290 return -EINVAL;
4291 }
4292
4293 /* Parse and fetch request Id */
4294 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4295 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4296 return -EINVAL;
4297 }
4298
Dino Myclee8843b32014-07-04 14:21:45 +05304299 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304300 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304301 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304302
Dino Myclee8843b32014-07-04 14:21:45 +05304303 reqMsg.sessionId = pAdapter->sessionId;
4304 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304305
Dino Myclee8843b32014-07-04 14:21:45 +05304306 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304307 if (!HAL_STATUS_SUCCESS(status)) {
4308 hddLog(VOS_TRACE_LEVEL_ERROR,
4309 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304310 return -EINVAL;
4311 }
4312
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304313 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304314 return 0;
4315}
4316
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304317static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4318 struct wireless_dev *wdev,
4319 const void *data, int dataLen)
4320{
4321 int ret = 0;
4322
4323 vos_ssr_protect(__func__);
4324 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4325 vos_ssr_unprotect(__func__);
4326
4327 return ret;
4328}
4329
4330static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304331 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304332 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304333{
Dino Myclee8843b32014-07-04 14:21:45 +05304334 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304335 struct net_device *dev = wdev->netdev;
4336 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4337 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4338 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4339 eHalStatus status;
4340
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304341 ENTER();
4342
Dino Mycle6fb96c12014-06-10 11:52:40 +05304343 status = wlan_hdd_validate_context(pHddCtx);
4344 if (0 != status)
4345 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304346 return -EINVAL;
4347 }
Dino Myclee8843b32014-07-04 14:21:45 +05304348 /* check the EXTScan Capability */
4349 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4350 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4351 {
4352 hddLog(VOS_TRACE_LEVEL_ERROR,
4353 FL("EXTScan not enabled/supported by Firmware"));
4354 return -EINVAL;
4355 }
4356
Dino Mycle6fb96c12014-06-10 11:52:40 +05304357 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4358 data, dataLen,
4359 wlan_hdd_extscan_config_policy)) {
4360 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4361 return -EINVAL;
4362 }
4363
4364 /* Parse and fetch request Id */
4365 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4366 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4367 return -EINVAL;
4368 }
4369
Dino Myclee8843b32014-07-04 14:21:45 +05304370 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304371 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304372 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304373
Dino Myclee8843b32014-07-04 14:21:45 +05304374 reqMsg.sessionId = pAdapter->sessionId;
4375 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304376
Dino Myclee8843b32014-07-04 14:21:45 +05304377 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304378 if (!HAL_STATUS_SUCCESS(status)) {
4379 hddLog(VOS_TRACE_LEVEL_ERROR,
4380 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304381 return -EINVAL;
4382 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304383 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304384 return 0;
4385}
4386
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304387static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4388 struct wireless_dev *wdev,
4389 const void *data, int dataLen)
4390{
4391 int ret = 0;
4392
4393 vos_ssr_protect(__func__);
4394 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4395 vos_ssr_unprotect(__func__);
4396
4397 return ret;
4398}
4399
4400static int __wlan_hdd_cfg80211_extscan_reset_significant_change(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304401 struct wiphy *wiphy,
4402 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304403 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304404{
Dino Myclee8843b32014-07-04 14:21:45 +05304405 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304406 struct net_device *dev = wdev->netdev;
4407 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4408 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4409 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4410 eHalStatus status;
4411
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304412 ENTER();
4413
Dino Mycle6fb96c12014-06-10 11:52:40 +05304414 status = wlan_hdd_validate_context(pHddCtx);
4415 if (0 != status)
4416 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304417 return -EINVAL;
4418 }
Dino Myclee8843b32014-07-04 14:21:45 +05304419 /* check the EXTScan Capability */
4420 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4421 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4422 {
4423 hddLog(VOS_TRACE_LEVEL_ERROR,
4424 FL("EXTScan not enabled/supported by Firmware"));
4425 return -EINVAL;
4426 }
4427
Dino Mycle6fb96c12014-06-10 11:52:40 +05304428 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4429 data, dataLen,
4430 wlan_hdd_extscan_config_policy)) {
4431 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4432 return -EINVAL;
4433 }
4434
4435 /* Parse and fetch request Id */
4436 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4437 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4438 return -EINVAL;
4439 }
4440
Dino Mycle6fb96c12014-06-10 11:52:40 +05304441
Dino Myclee8843b32014-07-04 14:21:45 +05304442 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304443 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304444 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304445
Dino Myclee8843b32014-07-04 14:21:45 +05304446 reqMsg.sessionId = pAdapter->sessionId;
4447 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304448
Dino Myclee8843b32014-07-04 14:21:45 +05304449 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304450 if (!HAL_STATUS_SUCCESS(status)) {
4451 hddLog(VOS_TRACE_LEVEL_ERROR,
4452 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304453 return -EINVAL;
4454 }
4455
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304456 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304457 return 0;
4458}
4459
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304460static int wlan_hdd_cfg80211_extscan_reset_significant_change(
4461 struct wiphy *wiphy,
4462 struct wireless_dev *wdev,
4463 const void *data, int dataLen)
4464{
4465 int ret = 0;
4466
4467 vos_ssr_protect(__func__);
4468 ret = __wlan_hdd_cfg80211_extscan_reset_significant_change(wiphy,
4469 wdev, data,
4470 dataLen);
4471 vos_ssr_unprotect(__func__);
4472
4473 return ret;
4474}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304475#endif /* WLAN_FEATURE_EXTSCAN */
4476
Atul Mittal115287b2014-07-08 13:26:33 +05304477/*EXT TDLS*/
4478static const struct nla_policy
4479wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4480{
4481 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4482 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4483 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4484 {.type = NLA_S32 },
4485 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4486 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4487
4488};
4489
4490static const struct nla_policy
4491wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4492{
4493 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4494
4495};
4496
4497static const struct nla_policy
4498wlan_hdd_tdls_config_state_change_policy[
4499 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4500{
4501 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4502 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4503 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304504 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4505 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4506 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304507
4508};
4509
4510static const struct nla_policy
4511wlan_hdd_tdls_config_get_status_policy[
4512 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4513{
4514 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4515 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4516 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304517 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4518 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4519 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304520
4521};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304522
4523static const struct nla_policy
4524wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4525{
4526 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4527};
4528
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304529static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304530 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304531 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304532 int data_len)
4533{
4534
4535 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4536 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4537
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304538 ENTER();
4539
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304540 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304541 return -EINVAL;
4542 }
4543 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05304544 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304545 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304546 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304547 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05304548 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304549 return -ENOTSUPP;
4550 }
4551
4552 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4553 data, data_len, wlan_hdd_mac_config)) {
4554 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4555 return -EINVAL;
4556 }
4557
4558 /* Parse and fetch mac address */
4559 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4560 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4561 return -EINVAL;
4562 }
4563
4564 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4565 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4566 VOS_MAC_ADDR_LAST_3_BYTES);
4567
Siddharth Bhal76972212014-10-15 16:22:51 +05304568 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4569
4570 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304571 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4572 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304573 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4574 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4575 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4576 {
4577 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4578 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4579 VOS_MAC_ADDRESS_LEN);
4580 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304581 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304582
Siddharth Bhal76972212014-10-15 16:22:51 +05304583 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
4584 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304585 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4586 }
4587
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304588 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304589 return 0;
4590}
4591
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304592static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4593 struct wireless_dev *wdev,
4594 const void *data,
4595 int data_len)
4596{
4597 int ret = 0;
4598
4599 vos_ssr_protect(__func__);
4600 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
4601 vos_ssr_unprotect(__func__);
4602
4603 return ret;
4604}
4605
4606static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304607 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304608 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304609 int data_len)
4610{
4611 u8 peer[6] = {0};
4612 struct net_device *dev = wdev->netdev;
4613 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4614 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4615 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4616 eHalStatus ret;
4617 tANI_S32 state;
4618 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304619 tANI_S32 global_operating_class = 0;
4620 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304621 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304622 int retVal;
4623
4624 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304625
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304626 if (!pAdapter) {
4627 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4628 return -EINVAL;
4629 }
4630
Atul Mittal115287b2014-07-08 13:26:33 +05304631 ret = wlan_hdd_validate_context(pHddCtx);
4632 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304633 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304634 return -EINVAL;
4635 }
4636 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304637 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304638 return -ENOTSUPP;
4639 }
4640 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4641 data, data_len,
4642 wlan_hdd_tdls_config_get_status_policy)) {
4643 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4644 return -EINVAL;
4645 }
4646
4647 /* Parse and fetch mac address */
4648 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4649 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4650 return -EINVAL;
4651 }
4652
4653 memcpy(peer, nla_data(
4654 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4655 sizeof(peer));
4656 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4657
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05304658 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05304659
Atul Mittal115287b2014-07-08 13:26:33 +05304660 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304661 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304662 NLMSG_HDRLEN);
4663
4664 if (!skb) {
4665 hddLog(VOS_TRACE_LEVEL_ERROR,
4666 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4667 return -EINVAL;
4668 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304669 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 +05304670 reason,
4671 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304672 global_operating_class,
4673 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304674 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304675 if (nla_put_s32(skb,
4676 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4677 state) ||
4678 nla_put_s32(skb,
4679 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4680 reason) ||
4681 nla_put_s32(skb,
4682 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4683 global_operating_class) ||
4684 nla_put_s32(skb,
4685 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4686 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304687
4688 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4689 goto nla_put_failure;
4690 }
4691
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304692 retVal = cfg80211_vendor_cmd_reply(skb);
4693 EXIT();
4694 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05304695
4696nla_put_failure:
4697 kfree_skb(skb);
4698 return -EINVAL;
4699}
4700
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304701static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4702 struct wireless_dev *wdev,
4703 const void *data,
4704 int data_len)
4705{
4706 int ret = 0;
4707
4708 vos_ssr_protect(__func__);
4709 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
4710 vos_ssr_unprotect(__func__);
4711
4712 return ret;
4713}
4714
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05304715static int wlan_hdd_cfg80211_exttdls_callback(
4716#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
4717 const tANI_U8* mac,
4718#else
4719 tANI_U8* mac,
4720#endif
Atul Mittal115287b2014-07-08 13:26:33 +05304721 tANI_S32 state,
4722 tANI_S32 reason,
4723 void *ctx)
4724{
4725 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05304726 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304727 tANI_S32 global_operating_class = 0;
4728 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304729 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05304730
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304731 ENTER();
4732
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304733 if (!pAdapter) {
4734 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4735 return -EINVAL;
4736 }
4737
4738 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05304739 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304740 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304741 return -EINVAL;
4742 }
4743
4744 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304745 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304746 return -ENOTSUPP;
4747 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05304748 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
4749#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
4750 NULL,
4751#endif
Atul Mittal115287b2014-07-08 13:26:33 +05304752 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4753 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4754 GFP_KERNEL);
4755
4756 if (!skb) {
4757 hddLog(VOS_TRACE_LEVEL_ERROR,
4758 FL("cfg80211_vendor_event_alloc failed"));
4759 return -EINVAL;
4760 }
4761 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304762 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4763 reason,
4764 state,
4765 global_operating_class,
4766 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304767 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4768 MAC_ADDR_ARRAY(mac));
4769
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304770 if (nla_put(skb,
4771 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4772 VOS_MAC_ADDR_SIZE, mac) ||
4773 nla_put_s32(skb,
4774 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4775 state) ||
4776 nla_put_s32(skb,
4777 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4778 reason) ||
4779 nla_put_s32(skb,
4780 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4781 channel) ||
4782 nla_put_s32(skb,
4783 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4784 global_operating_class)
4785 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304786 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4787 goto nla_put_failure;
4788 }
4789
4790 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304791 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05304792 return (0);
4793
4794nla_put_failure:
4795 kfree_skb(skb);
4796 return -EINVAL;
4797}
4798
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304799static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304800 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304801 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304802 int data_len)
4803{
4804 u8 peer[6] = {0};
4805 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304806 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4807 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4808 eHalStatus status;
4809 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304810 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304811 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304812
4813 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304814
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304815 if (!dev) {
4816 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4817 return -EINVAL;
4818 }
4819
4820 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4821 if (!pAdapter) {
4822 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4823 return -EINVAL;
4824 }
4825
Atul Mittal115287b2014-07-08 13:26:33 +05304826 status = wlan_hdd_validate_context(pHddCtx);
4827 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304828 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304829 return -EINVAL;
4830 }
4831 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304832 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304833 return -ENOTSUPP;
4834 }
4835 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4836 data, data_len,
4837 wlan_hdd_tdls_config_enable_policy)) {
4838 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4839 return -EINVAL;
4840 }
4841
4842 /* Parse and fetch mac address */
4843 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4844 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4845 return -EINVAL;
4846 }
4847
4848 memcpy(peer, nla_data(
4849 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4850 sizeof(peer));
4851 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4852
4853 /* Parse and fetch channel */
4854 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4855 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4856 return -EINVAL;
4857 }
4858 pReqMsg.channel = nla_get_s32(
4859 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4860 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4861
4862 /* Parse and fetch global operating class */
4863 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4864 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4865 return -EINVAL;
4866 }
4867 pReqMsg.global_operating_class = nla_get_s32(
4868 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4869 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4870 pReqMsg.global_operating_class);
4871
4872 /* Parse and fetch latency ms */
4873 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4874 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4875 return -EINVAL;
4876 }
4877 pReqMsg.max_latency_ms = nla_get_s32(
4878 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4879 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4880 pReqMsg.max_latency_ms);
4881
4882 /* Parse and fetch required bandwidth kbps */
4883 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4884 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4885 return -EINVAL;
4886 }
4887
4888 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4889 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4890 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4891 pReqMsg.min_bandwidth_kbps);
4892
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304893 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05304894 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05304895 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304896 wlan_hdd_cfg80211_exttdls_callback);
4897
4898 EXIT();
4899 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304900}
4901
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304902static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4903 struct wireless_dev *wdev,
4904 const void *data,
4905 int data_len)
4906{
4907 int ret = 0;
4908
4909 vos_ssr_protect(__func__);
4910 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
4911 vos_ssr_unprotect(__func__);
4912
4913 return ret;
4914}
4915
4916static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304917 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304918 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304919 int data_len)
4920{
4921 u8 peer[6] = {0};
4922 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304923 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4924 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4925 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304926 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304927 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304928
4929 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304930
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304931 if (!dev) {
4932 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4933 return -EINVAL;
4934 }
4935
4936 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4937 if (!pAdapter) {
4938 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
4939 return -EINVAL;
4940 }
4941
Atul Mittal115287b2014-07-08 13:26:33 +05304942 status = wlan_hdd_validate_context(pHddCtx);
4943 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304944 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304945 return -EINVAL;
4946 }
4947 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304948 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304949 return -ENOTSUPP;
4950 }
4951 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4952 data, data_len,
4953 wlan_hdd_tdls_config_disable_policy)) {
4954 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4955 return -EINVAL;
4956 }
4957 /* Parse and fetch mac address */
4958 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
4959 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4960 return -EINVAL;
4961 }
4962
4963 memcpy(peer, nla_data(
4964 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
4965 sizeof(peer));
4966 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4967
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304968 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
4969
4970 EXIT();
4971 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304972}
4973
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304974static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
4975 struct wireless_dev *wdev,
4976 const void *data,
4977 int data_len)
4978{
4979 int ret = 0;
4980
4981 vos_ssr_protect(__func__);
4982 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
4983 vos_ssr_unprotect(__func__);
4984
4985 return ret;
4986}
4987
Dasari Srinivas7875a302014-09-26 17:50:57 +05304988static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304989__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05304990 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304991 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05304992{
4993 struct net_device *dev = wdev->netdev;
4994 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4995 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4996 struct sk_buff *skb = NULL;
4997 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304998 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05304999
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305000 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305001
5002 ret = wlan_hdd_validate_context(pHddCtx);
5003 if (0 != ret)
5004 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305005 return ret;
5006 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305007 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
5008 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
5009 fset |= WIFI_FEATURE_INFRA;
5010 }
5011
5012 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
5013 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
5014 fset |= WIFI_FEATURE_INFRA_5G;
5015 }
5016
5017#ifdef WLAN_FEATURE_P2P
5018 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
5019 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
5020 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
5021 fset |= WIFI_FEATURE_P2P;
5022 }
5023#endif
5024
5025 /* Soft-AP is supported currently by default */
5026 fset |= WIFI_FEATURE_SOFT_AP;
5027
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05305028 /* HOTSPOT is a supplicant feature, enable it by default */
5029 fset |= WIFI_FEATURE_HOTSPOT;
5030
Dasari Srinivas7875a302014-09-26 17:50:57 +05305031#ifdef WLAN_FEATURE_EXTSCAN
5032 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
5033 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
5034 hddLog(LOG1, FL("EXTScan is supported by firmware"));
5035 fset |= WIFI_FEATURE_EXTSCAN;
5036 }
5037#endif
5038
Dasari Srinivas7875a302014-09-26 17:50:57 +05305039 if (sme_IsFeatureSupportedByFW(NAN)) {
5040 hddLog(LOG1, FL("NAN is supported by firmware"));
5041 fset |= WIFI_FEATURE_NAN;
5042 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305043
5044 /* D2D RTT is not supported currently by default */
5045 if (sme_IsFeatureSupportedByFW(RTT)) {
5046 hddLog(LOG1, FL("RTT is supported by firmware"));
5047 fset |= WIFI_FEATURE_D2AP_RTT;
5048 }
5049
5050#ifdef FEATURE_WLAN_BATCH_SCAN
5051 if (fset & WIFI_FEATURE_EXTSCAN) {
5052 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5053 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5054 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5055 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5056 fset |= WIFI_FEATURE_BATCH_SCAN;
5057 }
5058#endif
5059
5060#ifdef FEATURE_WLAN_SCAN_PNO
5061 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5062 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5063 hddLog(LOG1, FL("PNO is supported by firmware"));
5064 fset |= WIFI_FEATURE_PNO;
5065 }
5066#endif
5067
5068 /* STA+STA is supported currently by default */
5069 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5070
5071#ifdef FEATURE_WLAN_TDLS
5072 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5073 sme_IsFeatureSupportedByFW(TDLS)) {
5074 hddLog(LOG1, FL("TDLS is supported by firmware"));
5075 fset |= WIFI_FEATURE_TDLS;
5076 }
5077
5078 /* TDLS_OFFCHANNEL is not supported currently by default */
5079#endif
5080
5081#ifdef WLAN_AP_STA_CONCURRENCY
5082 /* AP+STA concurrency is supported currently by default */
5083 fset |= WIFI_FEATURE_AP_STA;
5084#endif
5085
5086 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5087 NLMSG_HDRLEN);
5088
5089 if (!skb) {
5090 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5091 return -EINVAL;
5092 }
5093 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5094
5095 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5096 hddLog(LOGE, FL("nla put fail"));
5097 goto nla_put_failure;
5098 }
5099
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305100 ret = cfg80211_vendor_cmd_reply(skb);
5101 EXIT();
5102 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305103
5104nla_put_failure:
5105 kfree_skb(skb);
5106 return -EINVAL;
5107}
5108
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305109static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305110wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5111 struct wireless_dev *wdev,
5112 const void *data, int data_len)
5113{
5114 int ret = 0;
5115
5116 vos_ssr_protect(__func__);
5117 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5118 vos_ssr_unprotect(__func__);
5119
5120 return ret;
5121}
5122
5123static int
5124__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305125 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305126 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305127{
5128 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5129 uint8_t i, feature_sets, max_feature_sets;
5130 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5131 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305132 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5133 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305134
5135 ENTER();
5136
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305137 ret = wlan_hdd_validate_context(pHddCtx);
5138 if (0 != ret)
5139 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305140 return ret;
5141 }
5142
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305143 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5144 data, data_len, NULL)) {
5145 hddLog(LOGE, FL("Invalid ATTR"));
5146 return -EINVAL;
5147 }
5148
5149 /* Parse and fetch max feature set */
5150 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5151 hddLog(LOGE, FL("Attr max feature set size failed"));
5152 return -EINVAL;
5153 }
5154 max_feature_sets = nla_get_u32(
5155 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5156 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5157
5158 /* Fill feature combination matrix */
5159 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305160 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5161 WIFI_FEATURE_P2P;
5162
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305163 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5164 WIFI_FEATURE_SOFT_AP;
5165
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305166 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5167 WIFI_FEATURE_SOFT_AP;
5168
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305169 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5170 WIFI_FEATURE_SOFT_AP |
5171 WIFI_FEATURE_P2P;
5172
5173 /* Add more feature combinations here */
5174
5175 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5176 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5177 hddLog(LOG1, "Feature set matrix");
5178 for (i = 0; i < feature_sets; i++)
5179 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5180
5181 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5182 sizeof(u32) * feature_sets +
5183 NLMSG_HDRLEN);
5184
5185 if (reply_skb) {
5186 if (nla_put_u32(reply_skb,
5187 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5188 feature_sets) ||
5189 nla_put(reply_skb,
5190 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5191 sizeof(u32) * feature_sets, feature_set_matrix)) {
5192 hddLog(LOGE, FL("nla put fail"));
5193 kfree_skb(reply_skb);
5194 return -EINVAL;
5195 }
5196
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305197 ret = cfg80211_vendor_cmd_reply(reply_skb);
5198 EXIT();
5199 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305200 }
5201 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5202 return -ENOMEM;
5203
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305204}
5205
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305206static int
5207wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5208 struct wireless_dev *wdev,
5209 const void *data, int data_len)
5210{
5211 int ret = 0;
5212
5213 vos_ssr_protect(__func__);
5214 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5215 data_len);
5216 vos_ssr_unprotect(__func__);
5217
5218 return ret;
5219}
5220
Agarwal Ashish738843c2014-09-25 12:27:56 +05305221static const struct nla_policy
5222wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5223 +1] =
5224{
5225 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5226};
5227
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305228static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305229 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305230 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305231 int data_len)
5232{
5233 struct net_device *dev = wdev->netdev;
5234 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5235 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5236 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5237 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5238 eHalStatus status;
5239 u32 dfsFlag = 0;
5240
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305241 ENTER();
5242
Agarwal Ashish738843c2014-09-25 12:27:56 +05305243 status = wlan_hdd_validate_context(pHddCtx);
5244 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305245 return -EINVAL;
5246 }
5247 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5248 data, data_len,
5249 wlan_hdd_set_no_dfs_flag_config_policy)) {
5250 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5251 return -EINVAL;
5252 }
5253
5254 /* Parse and fetch required bandwidth kbps */
5255 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5256 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5257 return -EINVAL;
5258 }
5259
5260 dfsFlag = nla_get_u32(
5261 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5262 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
5263 dfsFlag);
5264
5265 pHddCtx->disable_dfs_flag = dfsFlag;
5266
5267 sme_disable_dfs_channel(hHal, dfsFlag);
5268 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305269
5270 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05305271 return 0;
5272}
Atul Mittal115287b2014-07-08 13:26:33 +05305273
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305274static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
5275 struct wireless_dev *wdev,
5276 const void *data,
5277 int data_len)
5278{
5279 int ret = 0;
5280
5281 vos_ssr_protect(__func__);
5282 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
5283 vos_ssr_unprotect(__func__);
5284
5285 return ret;
5286
5287}
5288
Mukul Sharma2a271632014-10-13 14:59:01 +05305289const struct
5290nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
5291{
5292 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
5293 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
5294};
5295
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305296static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05305297 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05305298{
5299
5300 u8 bssid[6] = {0};
5301 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5302 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5303 eHalStatus status = eHAL_STATUS_SUCCESS;
5304 v_U32_t isFwrRoamEnabled = FALSE;
5305 int ret;
5306
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305307 ENTER();
5308
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305309 ret = wlan_hdd_validate_context(pHddCtx);
5310 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305311 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05305312 }
5313
5314 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
5315 data, data_len,
5316 qca_wlan_vendor_attr);
5317 if (ret){
5318 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5319 return -EINVAL;
5320 }
5321
5322 /* Parse and fetch Enable flag */
5323 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
5324 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
5325 return -EINVAL;
5326 }
5327
5328 isFwrRoamEnabled = nla_get_u32(
5329 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
5330
5331 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
5332
5333 /* Parse and fetch bssid */
5334 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
5335 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
5336 return -EINVAL;
5337 }
5338
5339 memcpy(bssid, nla_data(
5340 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
5341 sizeof(bssid));
5342 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
5343
5344 //Update roaming
5345 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305346 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05305347 return status;
5348}
5349
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305350static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
5351 struct wireless_dev *wdev, const void *data, int data_len)
5352{
5353 int ret = 0;
5354
5355 vos_ssr_protect(__func__);
5356 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
5357 vos_ssr_unprotect(__func__);
5358
5359 return ret;
5360}
5361
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305362/**
5363 * __wlan_hdd_cfg80211_setband() - set band
5364 * @wiphy: Pointer to wireless phy
5365 * @wdev: Pointer to wireless device
5366 * @data: Pointer to data
5367 * @data_len: Data length
5368 *
5369 * Return: 0 on success, negative errno on failure
5370 */
5371static int
5372__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5373 struct wireless_dev *wdev,
5374 const void *data,
5375 int data_len)
5376{
5377 struct net_device *dev = wdev->netdev;
5378 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5379 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5380 int ret;
5381 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
5382 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
5383
5384 ENTER();
5385
5386 ret = wlan_hdd_validate_context(hdd_ctx);
5387 if (0 != ret) {
5388 hddLog(LOGE, FL("HDD context is not valid"));
5389 return ret;
5390 }
5391
5392 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
5393 policy)) {
5394 hddLog(LOGE, FL("Invalid ATTR"));
5395 return -EINVAL;
5396 }
5397
5398 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
5399 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
5400 return -EINVAL;
5401 }
5402
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05305403 hdd_ctx->isSetBandByNL = TRUE;
5404 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305405 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05305406 hdd_ctx->isSetBandByNL = FALSE;
5407
5408 EXIT();
5409 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305410}
5411
5412/**
5413 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
5414 * @wiphy: wiphy structure pointer
5415 * @wdev: Wireless device structure pointer
5416 * @data: Pointer to the data received
5417 * @data_len: Length of @data
5418 *
5419 * Return: 0 on success; errno on failure
5420 */
5421static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5422 struct wireless_dev *wdev,
5423 const void *data,
5424 int data_len)
5425{
5426 int ret = 0;
5427
5428 vos_ssr_protect(__func__);
5429 ret = __wlan_hdd_cfg80211_setband(wiphy,
5430 wdev, data, data_len);
5431 vos_ssr_unprotect(__func__);
5432
5433 return ret;
5434}
5435
Sunil Duttc69bccb2014-05-26 21:30:20 +05305436const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
5437{
Mukul Sharma2a271632014-10-13 14:59:01 +05305438 {
5439 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5440 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
5441 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5442 WIPHY_VENDOR_CMD_NEED_NETDEV |
5443 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305444 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05305445 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305446
5447 {
5448 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5449 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
5450 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5451 WIPHY_VENDOR_CMD_NEED_NETDEV |
5452 WIPHY_VENDOR_CMD_NEED_RUNNING,
5453 .doit = wlan_hdd_cfg80211_nan_request
5454 },
5455
Sunil Duttc69bccb2014-05-26 21:30:20 +05305456#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5457 {
5458 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5459 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
5460 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5461 WIPHY_VENDOR_CMD_NEED_NETDEV |
5462 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305463 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05305464 },
5465
5466 {
5467 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5468 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
5469 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5470 WIPHY_VENDOR_CMD_NEED_NETDEV |
5471 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305472 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05305473 },
5474
5475 {
5476 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5477 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
5478 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5479 WIPHY_VENDOR_CMD_NEED_NETDEV |
5480 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305481 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05305482 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305483#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305484#ifdef WLAN_FEATURE_EXTSCAN
5485 {
5486 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5487 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
5488 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5489 WIPHY_VENDOR_CMD_NEED_NETDEV |
5490 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305491 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05305492 },
5493 {
5494 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5495 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
5496 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5497 WIPHY_VENDOR_CMD_NEED_NETDEV |
5498 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305499 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05305500 },
5501 {
5502 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5503 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
5504 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5505 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305506 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05305507 },
5508 {
5509 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5510 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
5511 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5512 WIPHY_VENDOR_CMD_NEED_NETDEV |
5513 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305514 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05305515 },
5516 {
5517 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5518 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
5519 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5520 WIPHY_VENDOR_CMD_NEED_NETDEV |
5521 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305522 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05305523 },
5524 {
5525 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5526 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
5527 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5528 WIPHY_VENDOR_CMD_NEED_NETDEV |
5529 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305530 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305531 },
5532 {
5533 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5534 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
5535 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5536 WIPHY_VENDOR_CMD_NEED_NETDEV |
5537 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305538 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305539 },
5540 {
5541 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5542 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
5543 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5544 WIPHY_VENDOR_CMD_NEED_NETDEV |
5545 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305546 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305547 },
5548 {
5549 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5550 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
5551 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5552 WIPHY_VENDOR_CMD_NEED_NETDEV |
5553 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305554 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305555 },
5556#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305557/*EXT TDLS*/
5558 {
5559 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5560 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
5561 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5562 WIPHY_VENDOR_CMD_NEED_NETDEV |
5563 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305564 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05305565 },
5566 {
5567 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5568 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
5569 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5570 WIPHY_VENDOR_CMD_NEED_NETDEV |
5571 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305572 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05305573 },
5574 {
5575 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5576 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
5577 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5578 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305579 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05305580 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05305581 {
5582 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5583 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
5584 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5585 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305586 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05305587 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05305588 {
5589 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5590 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
5591 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5592 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305593 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05305594 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305595 {
5596 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5597 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
5598 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5599 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305600 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305601 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305602 {
5603 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5604 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
5605 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5606 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305607 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305608 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305609 {
5610 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5611 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
5612 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5613 WIPHY_VENDOR_CMD_NEED_NETDEV |
5614 WIPHY_VENDOR_CMD_NEED_RUNNING,
5615 .doit = wlan_hdd_cfg80211_setband
5616 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05305617};
5618
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005619/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05305620static const
5621struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005622{
5623#ifdef FEATURE_WLAN_CH_AVOID
5624 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05305625 .vendor_id = QCA_NL80211_VENDOR_ID,
5626 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005627 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305628#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
5629#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5630 {
5631 /* Index = 1*/
5632 .vendor_id = QCA_NL80211_VENDOR_ID,
5633 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
5634 },
5635 {
5636 /* Index = 2*/
5637 .vendor_id = QCA_NL80211_VENDOR_ID,
5638 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
5639 },
5640 {
5641 /* Index = 3*/
5642 .vendor_id = QCA_NL80211_VENDOR_ID,
5643 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
5644 },
5645 {
5646 /* Index = 4*/
5647 .vendor_id = QCA_NL80211_VENDOR_ID,
5648 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
5649 },
5650 {
5651 /* Index = 5*/
5652 .vendor_id = QCA_NL80211_VENDOR_ID,
5653 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
5654 },
5655 {
5656 /* Index = 6*/
5657 .vendor_id = QCA_NL80211_VENDOR_ID,
5658 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
5659 },
5660#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305661#ifdef WLAN_FEATURE_EXTSCAN
5662 {
5663 .vendor_id = QCA_NL80211_VENDOR_ID,
5664 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
5665 },
5666 {
5667 .vendor_id = QCA_NL80211_VENDOR_ID,
5668 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
5669 },
5670 {
5671 .vendor_id = QCA_NL80211_VENDOR_ID,
5672 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
5673 },
5674 {
5675 .vendor_id = QCA_NL80211_VENDOR_ID,
5676 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
5677 },
5678 {
5679 .vendor_id = QCA_NL80211_VENDOR_ID,
5680 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
5681 },
5682 {
5683 .vendor_id = QCA_NL80211_VENDOR_ID,
5684 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
5685 },
5686 {
5687 .vendor_id = QCA_NL80211_VENDOR_ID,
5688 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
5689 },
5690 {
5691 .vendor_id = QCA_NL80211_VENDOR_ID,
5692 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
5693 },
5694 {
5695 .vendor_id = QCA_NL80211_VENDOR_ID,
5696 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
5697 },
5698 {
5699 .vendor_id = QCA_NL80211_VENDOR_ID,
5700 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
5701 },
5702 {
5703 .vendor_id = QCA_NL80211_VENDOR_ID,
5704 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
5705 },
5706 {
5707 .vendor_id = QCA_NL80211_VENDOR_ID,
5708 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
5709 },
5710 {
5711 .vendor_id = QCA_NL80211_VENDOR_ID,
5712 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
5713 },
5714#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305715/*EXT TDLS*/
5716 {
5717 .vendor_id = QCA_NL80211_VENDOR_ID,
5718 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
5719 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305720
5721 {
5722 .vendor_id = QCA_NL80211_VENDOR_ID,
5723 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
5724 },
5725
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005726};
5727
Jeff Johnson295189b2012-06-20 16:38:30 -07005728/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305729 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305730 * This function is called by hdd_wlan_startup()
5731 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305732 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07005733 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305734struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07005735{
5736 struct wiphy *wiphy;
5737 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305738 /*
5739 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07005740 */
5741 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
5742
5743 if (!wiphy)
5744 {
5745 /* Print error and jump into err label and free the memory */
5746 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
5747 return NULL;
5748 }
5749
Sunil Duttc69bccb2014-05-26 21:30:20 +05305750
Jeff Johnson295189b2012-06-20 16:38:30 -07005751 return wiphy;
5752}
5753
5754/*
5755 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305756 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 * private ioctl to change the band value
5758 */
5759int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
5760{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305761 int i, j;
5762 eNVChannelEnabledType channelEnabledState;
5763
Jeff Johnsone7245742012-09-05 17:12:55 -07005764 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305765
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305766 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005767 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305768
5769 if (NULL == wiphy->bands[i])
5770 {
5771 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5772 __func__, i);
5773 continue;
5774 }
5775
5776 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5777 {
5778 struct ieee80211_supported_band *band = wiphy->bands[i];
5779
5780 channelEnabledState = vos_nv_getChannelEnabledState(
5781 band->channels[j].hw_value);
5782
5783 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
5784 {
Abhishek Singh678227a2014-11-04 10:52:38 +05305785 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305786 continue;
5787 }
5788 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
5789 {
5790 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5791 continue;
5792 }
5793
5794 if (NV_CHANNEL_DISABLE == channelEnabledState ||
5795 NV_CHANNEL_INVALID == channelEnabledState)
5796 {
5797 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5798 }
5799 else if (NV_CHANNEL_DFS == channelEnabledState)
5800 {
5801 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5802 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
5803 }
5804 else
5805 {
5806 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
5807 |IEEE80211_CHAN_RADAR);
5808 }
5809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 }
5811 return 0;
5812}
5813/*
5814 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305815 * This function is called by hdd_wlan_startup()
5816 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07005817 * This function is used to initialize and register wiphy structure.
5818 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305819int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005820 struct wiphy *wiphy,
5821 hdd_config_t *pCfg
5822 )
5823{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305824 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305825 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5826
Jeff Johnsone7245742012-09-05 17:12:55 -07005827 ENTER();
5828
Jeff Johnson295189b2012-06-20 16:38:30 -07005829 /* Now bind the underlying wlan device with wiphy */
5830 set_wiphy_dev(wiphy, dev);
5831
5832 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005833
Kiet Lam6c583332013-10-14 05:37:09 +05305834#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07005835 /* the flag for the other case would be initialzed in
5836 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07005837 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05305838#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005839
Amar Singhalfddc28c2013-09-05 13:03:40 -07005840 /* This will disable updating of NL channels from passive to
5841 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305842#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
5843 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
5844#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07005845 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305846#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07005847
Amar Singhala49cbc52013-10-08 18:37:44 -07005848
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005849#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07005850 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
5851 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
5852 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07005853 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305854#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
5855 wiphy->regulatory_flags = REGULATORY_COUNTRY_IE_IGNORE;
5856#else
5857 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
5858#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005859#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005860
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005861#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005862 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08005863#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005864 || pCfg->isFastRoamIniFeatureEnabled
5865#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005866#ifdef FEATURE_WLAN_ESE
5867 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005868#endif
5869 )
5870 {
5871 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
5872 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08005873#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005874#ifdef FEATURE_WLAN_TDLS
5875 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
5876 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
5877#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305878#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05305879 if (pCfg->configPNOScanSupport)
5880 {
5881 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
5882 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
5883 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
5884 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
5885 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305886#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005887
Abhishek Singh10d85972015-04-17 10:27:23 +05305888#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5889 wiphy->features |= NL80211_FEATURE_HT_IBSS;
5890#endif
5891
Amar Singhalfddc28c2013-09-05 13:03:40 -07005892#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005893 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
5894 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07005895 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005896 driver need to determine what to do with both
5897 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07005898
5899 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07005900#else
5901 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005902#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005903
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305904 wiphy->max_scan_ssids = MAX_SCAN_SSID;
5905
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05305906 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07005907
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305908 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
5909
Jeff Johnson295189b2012-06-20 16:38:30 -07005910 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05305911 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
5912 | BIT(NL80211_IFTYPE_ADHOC)
5913 | BIT(NL80211_IFTYPE_P2P_CLIENT)
5914 | BIT(NL80211_IFTYPE_P2P_GO)
5915 | BIT(NL80211_IFTYPE_AP);
5916
5917 if (VOS_MONITOR_MODE == hdd_get_conparam())
5918 {
5919 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
5920 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005921
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305922 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005923 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305924#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5925 if( pCfg->enableMCC )
5926 {
5927 /* Currently, supports up to two channels */
5928 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005929
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305930 if( !pCfg->allowMCCGODiffBI )
5931 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005932
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305933 }
5934 wiphy->iface_combinations = &wlan_hdd_iface_combination;
5935 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005936#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305937 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005938
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 /* Before registering we need to update the ht capabilitied based
5940 * on ini values*/
5941 if( !pCfg->ShortGI20MhzEnable )
5942 {
5943 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5944 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5945 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5946 }
5947
5948 if( !pCfg->ShortGI40MhzEnable )
5949 {
5950 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
5951 }
5952
5953 if( !pCfg->nChannelBondingMode5GHz )
5954 {
5955 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5956 }
5957
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305958 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305959 if (true == hdd_is_5g_supported(pHddCtx))
5960 {
5961 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
5962 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305963
5964 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
5965 {
5966
5967 if (NULL == wiphy->bands[i])
5968 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05305969 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305970 __func__, i);
5971 continue;
5972 }
5973
5974 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5975 {
5976 struct ieee80211_supported_band *band = wiphy->bands[i];
5977
5978 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
5979 {
5980 // Enable social channels for P2P
5981 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
5982 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5983 else
5984 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5985 continue;
5986 }
5987 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
5988 {
5989 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5990 continue;
5991 }
5992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 }
5994 /*Initialise the supported cipher suite details*/
5995 wiphy->cipher_suites = hdd_cipher_suites;
5996 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
5997
5998 /*signal strength in mBm (100*dBm) */
5999 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
6000
6001#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05306002 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07006003#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006004
Sunil Duttc69bccb2014-05-26 21:30:20 +05306005 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
6006 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08006007 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
6008 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
6009
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306010 EXIT();
6011 return 0;
6012}
6013
6014/* In this function we are registering wiphy. */
6015int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
6016{
6017 ENTER();
6018 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 if (0 > wiphy_register(wiphy))
6020 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306021 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
6023 return -EIO;
6024 }
6025
6026 EXIT();
6027 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306028}
Jeff Johnson295189b2012-06-20 16:38:30 -07006029
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306030/* In this function we are updating channel list when,
6031 regulatory domain is FCC and country code is US.
6032 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
6033 As per FCC smart phone is not a indoor device.
6034 GO should not opeate on indoor channels */
6035void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
6036{
6037 int j;
6038 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6039 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
6040 //Default counrtycode from NV at the time of wiphy initialization.
6041 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
6042 &defaultCountryCode[0]))
6043 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006044 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306045 }
6046 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
6047 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306048 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
6049 {
6050 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
6051 return;
6052 }
6053 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
6054 {
6055 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
6056 // Mark UNII -1 band channel as passive
6057 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
6058 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
6059 }
6060 }
6061}
6062
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05306063/* This function registers for all frame which supplicant is interested in */
6064void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07006065{
Jeff Johnson295189b2012-06-20 16:38:30 -07006066 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6067 /* Register for all P2P action, public action etc frames */
6068 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
6069
Jeff Johnsone7245742012-09-05 17:12:55 -07006070 ENTER();
6071
Jeff Johnson295189b2012-06-20 16:38:30 -07006072 /* Right now we are registering these frame when driver is getting
6073 initialized. Once we will move to 2.6.37 kernel, in which we have
6074 frame register ops, we will move this code as a part of that */
6075 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306076 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6078
6079 /* GAS Initial Response */
6080 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6081 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306082
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 /* GAS Comeback Request */
6084 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6085 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6086
6087 /* GAS Comeback Response */
6088 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6089 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6090
6091 /* P2P Public Action */
6092 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306093 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006094 P2P_PUBLIC_ACTION_FRAME_SIZE );
6095
6096 /* P2P Action */
6097 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6098 (v_U8_t*)P2P_ACTION_FRAME,
6099 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07006100
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05306101 /* WNM BSS Transition Request frame */
6102 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6103 (v_U8_t*)WNM_BSS_ACTION_FRAME,
6104 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006105
6106 /* WNM-Notification */
6107 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6108 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6109 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006110}
6111
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05306112void wlan_hdd_cfg80211_deregister_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 */
6124
6125 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6126 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6127
6128 /* GAS Initial Response */
6129 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6130 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306131
Jeff Johnson295189b2012-06-20 16:38:30 -07006132 /* GAS Comeback Request */
6133 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6134 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6135
6136 /* GAS Comeback Response */
6137 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6138 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6139
6140 /* P2P Public Action */
6141 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306142 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006143 P2P_PUBLIC_ACTION_FRAME_SIZE );
6144
6145 /* P2P Action */
6146 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6147 (v_U8_t*)P2P_ACTION_FRAME,
6148 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006149 /* WNM-Notification */
6150 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6151 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6152 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006153}
6154
6155#ifdef FEATURE_WLAN_WAPI
6156void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05306157 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006158{
6159 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6160 tCsrRoamSetKey setKey;
6161 v_BOOL_t isConnected = TRUE;
6162 int status = 0;
6163 v_U32_t roamId= 0xFF;
6164 tANI_U8 *pKeyPtr = NULL;
6165 int n = 0;
6166
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306167 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
6168 __func__, hdd_device_modetoString(pAdapter->device_mode),
6169 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006170
Gopichand Nakkalae7480202013-02-11 15:24:22 +05306171 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006172 setKey.keyId = key_index; // Store Key ID
6173 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
6174 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
6175 setKey.paeRole = 0 ; // the PAE role
6176 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
6177 {
6178 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
6179 }
6180 else
6181 {
6182 isConnected = hdd_connIsConnected(pHddStaCtx);
6183 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
6184 }
6185 setKey.keyLength = key_Len;
6186 pKeyPtr = setKey.Key;
6187 memcpy( pKeyPtr, key, key_Len);
6188
Arif Hussain6d2a3322013-11-17 19:50:10 -08006189 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 __func__, key_Len);
6191 for (n = 0 ; n < key_Len; n++)
6192 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
6193 __func__,n,setKey.Key[n]);
6194
6195 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6196 if ( isConnected )
6197 {
6198 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
6199 pAdapter->sessionId, &setKey, &roamId );
6200 }
6201 if ( status != 0 )
6202 {
6203 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6204 "[%4d] sme_RoamSetKey returned ERROR status= %d",
6205 __LINE__, status );
6206 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6207 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05306208 /* Need to clear any trace of key value in the memory.
6209 * Thus zero out the memory even though it is local
6210 * variable.
6211 */
6212 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006213}
6214#endif /* FEATURE_WLAN_WAPI*/
6215
6216#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306217int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 beacon_data_t **ppBeacon,
6219 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006220#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306221int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006222 beacon_data_t **ppBeacon,
6223 struct cfg80211_beacon_data *params,
6224 int dtim_period)
6225#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306226{
Jeff Johnson295189b2012-06-20 16:38:30 -07006227 int size;
6228 beacon_data_t *beacon = NULL;
6229 beacon_data_t *old = NULL;
6230 int head_len,tail_len;
6231
Jeff Johnsone7245742012-09-05 17:12:55 -07006232 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306234 {
6235 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6236 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006237 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306238 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006239
6240 old = pAdapter->sessionCtx.ap.beacon;
6241
6242 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306243 {
6244 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6245 FL("session(%d) old and new heads points to NULL"),
6246 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006247 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306248 }
6249
6250 if (params->tail && !params->tail_len)
6251 {
6252 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6253 FL("tail_len is zero but tail is not NULL"));
6254 return -EINVAL;
6255 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006256
Jeff Johnson295189b2012-06-20 16:38:30 -07006257#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
6258 /* Kernel 3.0 is not updating dtim_period for set beacon */
6259 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306260 {
6261 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6262 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006263 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006265#endif
6266
6267 if(params->head)
6268 head_len = params->head_len;
6269 else
6270 head_len = old->head_len;
6271
6272 if(params->tail || !old)
6273 tail_len = params->tail_len;
6274 else
6275 tail_len = old->tail_len;
6276
6277 size = sizeof(beacon_data_t) + head_len + tail_len;
6278
6279 beacon = kzalloc(size, GFP_KERNEL);
6280
6281 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306282 {
6283 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6284 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306286 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006287
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006288#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006289 if(params->dtim_period || !old )
6290 beacon->dtim_period = params->dtim_period;
6291 else
6292 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006293#else
6294 if(dtim_period || !old )
6295 beacon->dtim_period = dtim_period;
6296 else
6297 beacon->dtim_period = old->dtim_period;
6298#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306299
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
6301 beacon->tail = beacon->head + head_len;
6302 beacon->head_len = head_len;
6303 beacon->tail_len = tail_len;
6304
6305 if(params->head) {
6306 memcpy (beacon->head,params->head,beacon->head_len);
6307 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306308 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 if(old)
6310 memcpy (beacon->head,old->head,beacon->head_len);
6311 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306312
Jeff Johnson295189b2012-06-20 16:38:30 -07006313 if(params->tail) {
6314 memcpy (beacon->tail,params->tail,beacon->tail_len);
6315 }
6316 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306317 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07006318 memcpy (beacon->tail,old->tail,beacon->tail_len);
6319 }
6320
6321 *ppBeacon = beacon;
6322
6323 kfree(old);
6324
6325 return 0;
6326
6327}
Jeff Johnson295189b2012-06-20 16:38:30 -07006328
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05306329v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
6330#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
6331 const v_U8_t *pIes,
6332#else
6333 v_U8_t *pIes,
6334#endif
6335 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006336{
6337 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05306338 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306340
Jeff Johnson295189b2012-06-20 16:38:30 -07006341 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306342 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 elem_id = ptr[0];
6344 elem_len = ptr[1];
6345 left -= 2;
6346 if(elem_len > left)
6347 {
6348 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006349 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006350 eid,elem_len,left);
6351 return NULL;
6352 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306353 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006354 {
6355 return ptr;
6356 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306357
Jeff Johnson295189b2012-06-20 16:38:30 -07006358 left -= elem_len;
6359 ptr += (elem_len + 2);
6360 }
6361 return NULL;
6362}
6363
Jeff Johnson295189b2012-06-20 16:38:30 -07006364/* Check if rate is 11g rate or not */
6365static int wlan_hdd_rate_is_11g(u8 rate)
6366{
Sanjay Devnani28322e22013-06-21 16:13:40 -07006367 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 u8 i;
6369 for (i = 0; i < 8; i++)
6370 {
6371 if(rate == gRateArray[i])
6372 return TRUE;
6373 }
6374 return FALSE;
6375}
6376
6377/* Check for 11g rate and set proper 11g only mode */
6378static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
6379 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
6380{
6381 u8 i, num_rates = pIe[0];
6382
6383 pIe += 1;
6384 for ( i = 0; i < num_rates; i++)
6385 {
6386 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
6387 {
6388 /* If rate set have 11g rate than change the mode to 11G */
6389 *pSapHw_mode = eSAP_DOT11_MODE_11g;
6390 if (pIe[i] & BASIC_RATE_MASK)
6391 {
6392 /* If we have 11g rate as basic rate, it means mode
6393 is 11g only mode.
6394 */
6395 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
6396 *pCheckRatesfor11g = FALSE;
6397 }
6398 }
6399 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
6400 {
6401 *require_ht = TRUE;
6402 }
6403 }
6404 return;
6405}
6406
6407static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
6408{
6409 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6410 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6411 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6412 u8 checkRatesfor11g = TRUE;
6413 u8 require_ht = FALSE;
6414 u8 *pIe=NULL;
6415
6416 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
6417
6418 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
6419 pBeacon->head_len, WLAN_EID_SUPP_RATES);
6420 if (pIe != NULL)
6421 {
6422 pIe += 1;
6423 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6424 &pConfig->SapHw_mode);
6425 }
6426
6427 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6428 WLAN_EID_EXT_SUPP_RATES);
6429 if (pIe != NULL)
6430 {
6431
6432 pIe += 1;
6433 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6434 &pConfig->SapHw_mode);
6435 }
6436
6437 if( pConfig->channel > 14 )
6438 {
6439 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
6440 }
6441
6442 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6443 WLAN_EID_HT_CAPABILITY);
6444
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306445 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006446 {
6447 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
6448 if(require_ht)
6449 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
6450 }
6451}
6452
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306453static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
6454 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
6455{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006456 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306457 v_U8_t *pIe = NULL;
6458 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6459
6460 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
6461 pBeacon->tail, pBeacon->tail_len);
6462
6463 if (pIe)
6464 {
6465 ielen = pIe[1] + 2;
6466 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6467 {
6468 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
6469 }
6470 else
6471 {
6472 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
6473 return -EINVAL;
6474 }
6475 *total_ielen += ielen;
6476 }
6477 return 0;
6478}
6479
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006480static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
6481 v_U8_t *genie, v_U8_t *total_ielen)
6482{
6483 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6484 int left = pBeacon->tail_len;
6485 v_U8_t *ptr = pBeacon->tail;
6486 v_U8_t elem_id, elem_len;
6487 v_U16_t ielen = 0;
6488
6489 if ( NULL == ptr || 0 == left )
6490 return;
6491
6492 while (left >= 2)
6493 {
6494 elem_id = ptr[0];
6495 elem_len = ptr[1];
6496 left -= 2;
6497 if (elem_len > left)
6498 {
6499 hddLog( VOS_TRACE_LEVEL_ERROR,
6500 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
6501 elem_id, elem_len, left);
6502 return;
6503 }
6504 if (IE_EID_VENDOR == elem_id)
6505 {
6506 /* skipping the VSIE's which we don't want to include or
6507 * it will be included by existing code
6508 */
6509 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
6510#ifdef WLAN_FEATURE_WFD
6511 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
6512#endif
6513 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6514 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6515 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
6516 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6517 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
6518 {
6519 ielen = ptr[1] + 2;
6520 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6521 {
6522 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
6523 *total_ielen += ielen;
6524 }
6525 else
6526 {
6527 hddLog( VOS_TRACE_LEVEL_ERROR,
6528 "IE Length is too big "
6529 "IEs eid=%d elem_len=%d total_ie_lent=%d",
6530 elem_id, elem_len, *total_ielen);
6531 }
6532 }
6533 }
6534
6535 left -= elem_len;
6536 ptr += (elem_len + 2);
6537 }
6538 return;
6539}
6540
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006541#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006542static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6543 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006544#else
6545static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6546 struct cfg80211_beacon_data *params)
6547#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006548{
6549 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306550 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006551 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07006552 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006553
6554 genie = vos_mem_malloc(MAX_GENIE_LEN);
6555
6556 if(genie == NULL) {
6557
6558 return -ENOMEM;
6559 }
6560
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306561 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6562 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006563 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306564 hddLog(LOGE,
6565 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306566 ret = -EINVAL;
6567 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006568 }
6569
6570#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306571 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6572 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
6573 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306574 hddLog(LOGE,
6575 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306576 ret = -EINVAL;
6577 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006578 }
6579#endif
6580
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306581 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6582 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006583 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306584 hddLog(LOGE,
6585 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306586 ret = -EINVAL;
6587 goto done;
6588 }
6589
6590 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
6591 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006592 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006593 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006594
6595 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6596 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
6597 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6598 {
6599 hddLog(LOGE,
6600 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006601 ret = -EINVAL;
6602 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006603 }
6604
6605 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6606 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6607 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6608 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6609 ==eHAL_STATUS_FAILURE)
6610 {
6611 hddLog(LOGE,
6612 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006613 ret = -EINVAL;
6614 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006615 }
6616
6617 // Added for ProResp IE
6618 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
6619 {
6620 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
6621 u8 probe_rsp_ie_len[3] = {0};
6622 u8 counter = 0;
6623 /* Check Probe Resp Length if it is greater then 255 then Store
6624 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
6625 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
6626 Store More then 255 bytes into One Variable.
6627 */
6628 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6629 {
6630 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6631 {
6632 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6633 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6634 }
6635 else
6636 {
6637 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6638 rem_probe_resp_ie_len = 0;
6639 }
6640 }
6641
6642 rem_probe_resp_ie_len = 0;
6643
6644 if (probe_rsp_ie_len[0] > 0)
6645 {
6646 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6647 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6648 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6649 probe_rsp_ie_len[0], NULL,
6650 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6651 {
6652 hddLog(LOGE,
6653 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006654 ret = -EINVAL;
6655 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006656 }
6657 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6658 }
6659
6660 if (probe_rsp_ie_len[1] > 0)
6661 {
6662 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6663 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6664 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6665 probe_rsp_ie_len[1], NULL,
6666 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6667 {
6668 hddLog(LOGE,
6669 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006670 ret = -EINVAL;
6671 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006672 }
6673 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6674 }
6675
6676 if (probe_rsp_ie_len[2] > 0)
6677 {
6678 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6679 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6680 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6681 probe_rsp_ie_len[2], NULL,
6682 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6683 {
6684 hddLog(LOGE,
6685 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006686 ret = -EINVAL;
6687 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006688 }
6689 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6690 }
6691
6692 if (probe_rsp_ie_len[1] == 0 )
6693 {
6694 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6695 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
6696 eANI_BOOLEAN_FALSE) )
6697 {
6698 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006699 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006700 }
6701 }
6702
6703 if (probe_rsp_ie_len[2] == 0 )
6704 {
6705 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6706 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
6707 eANI_BOOLEAN_FALSE) )
6708 {
6709 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006710 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006711 }
6712 }
6713
6714 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6715 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6716 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6717 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6718 == eHAL_STATUS_FAILURE)
6719 {
6720 hddLog(LOGE,
6721 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006722 ret = -EINVAL;
6723 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006724 }
6725 }
6726 else
6727 {
6728 // Reset WNI_CFG_PROBE_RSP Flags
6729 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
6730
6731 hddLog(VOS_TRACE_LEVEL_INFO,
6732 "%s: No Probe Response IE received in set beacon",
6733 __func__);
6734 }
6735
6736 // Added for AssocResp IE
6737 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
6738 {
6739 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6740 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
6741 params->assocresp_ies_len, NULL,
6742 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6743 {
6744 hddLog(LOGE,
6745 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006746 ret = -EINVAL;
6747 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 }
6749
6750 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6751 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
6752 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6753 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6754 == eHAL_STATUS_FAILURE)
6755 {
6756 hddLog(LOGE,
6757 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006758 ret = -EINVAL;
6759 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006760 }
6761 }
6762 else
6763 {
6764 hddLog(VOS_TRACE_LEVEL_INFO,
6765 "%s: No Assoc Response IE received in set beacon",
6766 __func__);
6767
6768 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6769 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6770 eANI_BOOLEAN_FALSE) )
6771 {
6772 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006773 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006774 }
6775 }
6776
Jeff Johnsone7245742012-09-05 17:12:55 -07006777done:
Jeff Johnson295189b2012-06-20 16:38:30 -07006778 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306779 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006780}
Jeff Johnson295189b2012-06-20 16:38:30 -07006781
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306782/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006783 * FUNCTION: wlan_hdd_validate_operation_channel
6784 * called by wlan_hdd_cfg80211_start_bss() and
6785 * wlan_hdd_cfg80211_set_channel()
6786 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306787 * channel list.
6788 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07006789VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006790{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306791
Jeff Johnson295189b2012-06-20 16:38:30 -07006792 v_U32_t num_ch = 0;
6793 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6794 u32 indx = 0;
6795 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306796 v_U8_t fValidChannel = FALSE, count = 0;
6797 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306798
Jeff Johnson295189b2012-06-20 16:38:30 -07006799 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6800
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306801 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006802 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306803 /* Validate the channel */
6804 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006805 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306806 if ( channel == rfChannels[count].channelNum )
6807 {
6808 fValidChannel = TRUE;
6809 break;
6810 }
6811 }
6812 if (fValidChannel != TRUE)
6813 {
6814 hddLog(VOS_TRACE_LEVEL_ERROR,
6815 "%s: Invalid Channel [%d]", __func__, channel);
6816 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006817 }
6818 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306819 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006820 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306821 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6822 valid_ch, &num_ch))
6823 {
6824 hddLog(VOS_TRACE_LEVEL_ERROR,
6825 "%s: failed to get valid channel list", __func__);
6826 return VOS_STATUS_E_FAILURE;
6827 }
6828 for (indx = 0; indx < num_ch; indx++)
6829 {
6830 if (channel == valid_ch[indx])
6831 {
6832 break;
6833 }
6834 }
6835
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306836 if (indx >= num_ch)
6837 {
6838 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6839 {
6840 eCsrBand band;
6841 unsigned int freq;
6842
6843 sme_GetFreqBand(hHal, &band);
6844
6845 if (eCSR_BAND_5G == band)
6846 {
6847#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
6848 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
6849 {
6850 freq = ieee80211_channel_to_frequency(channel,
6851 IEEE80211_BAND_2GHZ);
6852 }
6853 else
6854 {
6855 freq = ieee80211_channel_to_frequency(channel,
6856 IEEE80211_BAND_5GHZ);
6857 }
6858#else
6859 freq = ieee80211_channel_to_frequency(channel);
6860#endif
6861 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
6862 return VOS_STATUS_SUCCESS;
6863 }
6864 }
6865
6866 hddLog(VOS_TRACE_LEVEL_ERROR,
6867 "%s: Invalid Channel [%d]", __func__, channel);
6868 return VOS_STATUS_E_FAILURE;
6869 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006870 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306871
Jeff Johnson295189b2012-06-20 16:38:30 -07006872 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306873
Jeff Johnson295189b2012-06-20 16:38:30 -07006874}
6875
Viral Modi3a32cc52013-02-08 11:14:52 -08006876/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306877 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08006878 * This function is used to set the channel number
6879 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306880static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08006881 struct ieee80211_channel *chan,
6882 enum nl80211_channel_type channel_type
6883 )
6884{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306885 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08006886 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07006887 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08006888 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306889 hdd_context_t *pHddCtx;
6890 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006891
6892 ENTER();
6893
6894 if( NULL == dev )
6895 {
6896 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006897 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006898 return -ENODEV;
6899 }
6900 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306901
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306902 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6903 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
6904 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08006905 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306906 "%s: device_mode = %s (%d) freq = %d", __func__,
6907 hdd_device_modetoString(pAdapter->device_mode),
6908 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306909
6910 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6911 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306912 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08006913 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306914 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006915 }
6916
6917 /*
6918 * Do freq to chan conversion
6919 * TODO: for 11a
6920 */
6921
6922 channel = ieee80211_frequency_to_channel(freq);
6923
6924 /* Check freq range */
6925 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
6926 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
6927 {
6928 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006929 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08006930 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
6931 WNI_CFG_CURRENT_CHANNEL_STAMAX);
6932 return -EINVAL;
6933 }
6934
6935 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6936
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05306937 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
6938 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08006939 {
6940 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
6941 {
6942 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006943 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08006944 return -EINVAL;
6945 }
6946 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6947 "%s: set channel to [%d] for device mode =%d",
6948 __func__, channel,pAdapter->device_mode);
6949 }
6950 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08006951 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08006952 )
6953 {
6954 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6955 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
6956 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6957
6958 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
6959 {
6960 /* Link is up then return cant set channel*/
6961 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006962 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006963 return -EINVAL;
6964 }
6965
6966 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
6967 pHddStaCtx->conn_info.operationChannel = channel;
6968 pRoamProfile->ChannelInfo.ChannelList =
6969 &pHddStaCtx->conn_info.operationChannel;
6970 }
6971 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08006972 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08006973 )
6974 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306975 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6976 {
6977 if(VOS_STATUS_SUCCESS !=
6978 wlan_hdd_validate_operation_channel(pAdapter,channel))
6979 {
6980 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006981 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306982 return -EINVAL;
6983 }
6984 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6985 }
6986 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08006987 {
6988 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
6989
6990 /* If auto channel selection is configured as enable/ 1 then ignore
6991 channel set by supplicant
6992 */
6993 if ( cfg_param->apAutoChannelSelection )
6994 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306995 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
6996 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08006997 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306998 "%s: set channel to auto channel (0) for device mode =%s (%d)",
6999 __func__, hdd_device_modetoString(pAdapter->device_mode),
7000 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08007001 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307002 else
7003 {
7004 if(VOS_STATUS_SUCCESS !=
7005 wlan_hdd_validate_operation_channel(pAdapter,channel))
7006 {
7007 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007008 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307009 return -EINVAL;
7010 }
7011 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
7012 }
Viral Modi3a32cc52013-02-08 11:14:52 -08007013 }
7014 }
7015 else
7016 {
7017 hddLog(VOS_TRACE_LEVEL_FATAL,
7018 "%s: Invalid device mode failed to set valid channel", __func__);
7019 return -EINVAL;
7020 }
7021 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307022 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08007023}
7024
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05307025static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
7026 struct net_device *dev,
7027 struct ieee80211_channel *chan,
7028 enum nl80211_channel_type channel_type
7029 )
7030{
7031 int ret;
7032
7033 vos_ssr_protect(__func__);
7034 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
7035 vos_ssr_unprotect(__func__);
7036
7037 return ret;
7038}
7039
Jeff Johnson295189b2012-06-20 16:38:30 -07007040#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7041static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
7042 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007043#else
7044static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
7045 struct cfg80211_beacon_data *params,
7046 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307047 enum nl80211_hidden_ssid hidden_ssid,
7048 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007049#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007050{
7051 tsap_Config_t *pConfig;
7052 beacon_data_t *pBeacon = NULL;
7053 struct ieee80211_mgmt *pMgmt_frame;
7054 v_U8_t *pIe=NULL;
7055 v_U16_t capab_info;
7056 eCsrAuthType RSNAuthType;
7057 eCsrEncryptionType RSNEncryptType;
7058 eCsrEncryptionType mcRSNEncryptType;
7059 int status = VOS_STATUS_SUCCESS;
7060 tpWLAN_SAPEventCB pSapEventCallback;
7061 hdd_hostapd_state_t *pHostapdState;
7062 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
7063 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307064 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007065 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307066 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07007067 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08007068 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05307069 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07007070 v_BOOL_t MFPCapable = VOS_FALSE;
7071 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307072 v_BOOL_t sapEnable11AC =
7073 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07007074 ENTER();
7075
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307076 iniConfig = pHddCtx->cfg_ini;
7077
Jeff Johnson295189b2012-06-20 16:38:30 -07007078 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
7079
7080 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
7081
7082 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
7083
7084 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
7085
7086 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
7087
7088 //channel is already set in the set_channel Call back
7089 //pConfig->channel = pCommitConfig->channel;
7090
7091 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307092 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
7094
7095 pConfig->dtim_period = pBeacon->dtim_period;
7096
Arif Hussain6d2a3322013-11-17 19:50:10 -08007097 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07007098 pConfig->dtim_period);
7099
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08007100 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07007101 {
7102 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007103 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05307104 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
7105 {
7106 tANI_BOOLEAN restartNeeded;
7107 pConfig->ieee80211d = 1;
7108 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
7109 sme_setRegInfo(hHal, pConfig->countryCode);
7110 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
7111 }
7112 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07007113 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07007114 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007115 pConfig->ieee80211d = 1;
7116 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
7117 sme_setRegInfo(hHal, pConfig->countryCode);
7118 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07007119 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007120 else
7121 {
7122 pConfig->ieee80211d = 0;
7123 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307124 /*
7125 * If auto channel is configured i.e. channel is 0,
7126 * so skip channel validation.
7127 */
7128 if( AUTO_CHANNEL_SELECT != pConfig->channel )
7129 {
7130 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
7131 {
7132 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007133 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307134 return -EINVAL;
7135 }
7136 }
7137 else
7138 {
7139 if(1 != pHddCtx->is_dynamic_channel_range_set)
7140 {
7141 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
7142 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
7143 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
7144 }
7145 pHddCtx->is_dynamic_channel_range_set = 0;
7146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007147 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007148 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007149 {
7150 pConfig->ieee80211d = 0;
7151 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307152
7153#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7154 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7155 pConfig->authType = eSAP_OPEN_SYSTEM;
7156 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7157 pConfig->authType = eSAP_SHARED_KEY;
7158 else
7159 pConfig->authType = eSAP_AUTO_SWITCH;
7160#else
7161 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7162 pConfig->authType = eSAP_OPEN_SYSTEM;
7163 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7164 pConfig->authType = eSAP_SHARED_KEY;
7165 else
7166 pConfig->authType = eSAP_AUTO_SWITCH;
7167#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007168
7169 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307170
7171 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07007172 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
7173
7174 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
7175
7176 /*Set wps station to configured*/
7177 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
7178
7179 if(pIe)
7180 {
7181 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
7182 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007183 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07007184 return -EINVAL;
7185 }
7186 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
7187 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007188 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07007189 /* Check 15 bit of WPS IE as it contain information for wps state
7190 * WPS state
7191 */
7192 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
7193 {
7194 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
7195 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
7196 {
7197 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
7198 }
7199 }
7200 }
7201 else
7202 {
7203 pConfig->wps_state = SAP_WPS_DISABLED;
7204 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307205 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07007206
c_hpothufe599e92014-06-16 11:38:55 +05307207 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7208 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7209 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
7210 eCSR_ENCRYPT_TYPE_NONE;
7211
Jeff Johnson295189b2012-06-20 16:38:30 -07007212 pConfig->RSNWPAReqIELength = 0;
7213 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307214 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007215 WLAN_EID_RSN);
7216 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307217 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007218 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7219 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7220 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307221 /* The actual processing may eventually be more extensive than
7222 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07007223 * by the app.
7224 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307225 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007226 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7227 &RSNEncryptType,
7228 &mcRSNEncryptType,
7229 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007230 &MFPCapable,
7231 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007232 pConfig->pRSNWPAReqIE[1]+2,
7233 pConfig->pRSNWPAReqIE );
7234
7235 if( VOS_STATUS_SUCCESS == status )
7236 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307237 /* Now copy over all the security attributes you have
7238 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007239 * */
7240 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7241 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7242 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7243 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307244 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007245 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007246 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7247 }
7248 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307249
Jeff Johnson295189b2012-06-20 16:38:30 -07007250 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7251 pBeacon->tail, pBeacon->tail_len);
7252
7253 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
7254 {
7255 if (pConfig->pRSNWPAReqIE)
7256 {
7257 /*Mixed mode WPA/WPA2*/
7258 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
7259 pConfig->RSNWPAReqIELength += pIe[1] + 2;
7260 }
7261 else
7262 {
7263 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7264 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7265 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307266 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007267 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7268 &RSNEncryptType,
7269 &mcRSNEncryptType,
7270 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007271 &MFPCapable,
7272 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007273 pConfig->pRSNWPAReqIE[1]+2,
7274 pConfig->pRSNWPAReqIE );
7275
7276 if( VOS_STATUS_SUCCESS == status )
7277 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307278 /* Now copy over all the security attributes you have
7279 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007280 * */
7281 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7282 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7283 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7284 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307285 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007286 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007287 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7288 }
7289 }
7290 }
7291
Jeff Johnson4416a782013-03-25 14:17:50 -07007292 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
7293 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
7294 return -EINVAL;
7295 }
7296
Jeff Johnson295189b2012-06-20 16:38:30 -07007297 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
7298
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007299#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007300 if (params->ssid != NULL)
7301 {
7302 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
7303 pConfig->SSIDinfo.ssid.length = params->ssid_len;
7304 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7305 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7306 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007307#else
7308 if (ssid != NULL)
7309 {
7310 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
7311 pConfig->SSIDinfo.ssid.length = ssid_len;
7312 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7313 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7314 }
7315#endif
7316
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307317 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07007318 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307319
Jeff Johnson295189b2012-06-20 16:38:30 -07007320 /* default value */
7321 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
7322 pConfig->num_accept_mac = 0;
7323 pConfig->num_deny_mac = 0;
7324
7325 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7326 pBeacon->tail, pBeacon->tail_len);
7327
7328 /* pIe for black list is following form:
7329 type : 1 byte
7330 length : 1 byte
7331 OUI : 4 bytes
7332 acl type : 1 byte
7333 no of mac addr in black list: 1 byte
7334 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307335 */
7336 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007337 {
7338 pConfig->SapMacaddr_acl = pIe[6];
7339 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007340 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007341 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307342 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
7343 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007344 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7345 for (i = 0; i < pConfig->num_deny_mac; i++)
7346 {
7347 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7348 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307349 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007350 }
7351 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7352 pBeacon->tail, pBeacon->tail_len);
7353
7354 /* pIe for white list is following form:
7355 type : 1 byte
7356 length : 1 byte
7357 OUI : 4 bytes
7358 acl type : 1 byte
7359 no of mac addr in white list: 1 byte
7360 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307361 */
7362 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007363 {
7364 pConfig->SapMacaddr_acl = pIe[6];
7365 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007366 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007367 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307368 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
7369 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007370 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7371 for (i = 0; i < pConfig->num_accept_mac; i++)
7372 {
7373 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7374 acl_entry++;
7375 }
7376 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307377
Jeff Johnson295189b2012-06-20 16:38:30 -07007378 wlan_hdd_set_sapHwmode(pHostapdAdapter);
7379
Jeff Johnsone7245742012-09-05 17:12:55 -07007380#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007381 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307382 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
7383 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05307384 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
7385 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007386 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
7387 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307388 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
7389 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07007390 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307391 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007392 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307393 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007394
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307395 /* If ACS disable and selected channel <= 14
7396 * OR
7397 * ACS enabled and ACS operating band is choosen as 2.4
7398 * AND
7399 * VHT in 2.4G Disabled
7400 * THEN
7401 * Fallback to 11N mode
7402 */
7403 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
7404 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05307405 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307406 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007407 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307408 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
7409 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007410 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
7411 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007412 }
7413#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307414
Jeff Johnson295189b2012-06-20 16:38:30 -07007415 // ht_capab is not what the name conveys,this is used for protection bitmap
7416 pConfig->ht_capab =
7417 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
7418
7419 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
7420 {
7421 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
7422 return -EINVAL;
7423 }
7424
7425 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307426 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07007427 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
7428 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307429 pConfig->obssProtEnabled =
7430 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07007431
Chet Lanctot8cecea22014-02-11 19:09:36 -08007432#ifdef WLAN_FEATURE_11W
7433 pConfig->mfpCapable = MFPCapable;
7434 pConfig->mfpRequired = MFPRequired;
7435 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
7436 pConfig->mfpCapable, pConfig->mfpRequired);
7437#endif
7438
Arif Hussain6d2a3322013-11-17 19:50:10 -08007439 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07007440 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007441 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
7442 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
7443 (int)pConfig->channel);
7444 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
7445 pConfig->SapHw_mode, pConfig->privacy,
7446 pConfig->authType);
7447 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
7448 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
7449 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
7450 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07007451
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307452 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007453 {
7454 //Bss already started. just return.
7455 //TODO Probably it should update some beacon params.
7456 hddLog( LOGE, "Bss Already started...Ignore the request");
7457 EXIT();
7458 return 0;
7459 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307460
Agarwal Ashish51325b52014-06-16 16:50:49 +05307461 if (vos_max_concurrent_connections_reached()) {
7462 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7463 return -EINVAL;
7464 }
7465
Jeff Johnson295189b2012-06-20 16:38:30 -07007466 pConfig->persona = pHostapdAdapter->device_mode;
7467
Peng Xu2446a892014-09-05 17:21:18 +05307468 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
7469 if ( NULL != psmeConfig)
7470 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307471 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05307472 sme_GetConfigParam(hHal, psmeConfig);
7473 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307474#ifdef WLAN_FEATURE_AP_HT40_24G
7475 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
7476 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
7477 && pHddCtx->cfg_ini->apHT40_24GEnabled)
7478 {
7479 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
7480 sme_UpdateConfig (hHal, psmeConfig);
7481 }
7482#endif
Peng Xu2446a892014-09-05 17:21:18 +05307483 vos_mem_free(psmeConfig);
7484 }
Peng Xuafc34e32014-09-25 13:23:55 +05307485 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05307486
Jeff Johnson295189b2012-06-20 16:38:30 -07007487 pSapEventCallback = hdd_hostapd_SAPEventCB;
7488 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
7489 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
7490 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007491 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007492 return -EINVAL;
7493 }
7494
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307495 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07007496 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
7497
7498 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307499
Jeff Johnson295189b2012-06-20 16:38:30 -07007500 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307501 {
7502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007503 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07007504 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007505 VOS_ASSERT(0);
7506 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307507
Jeff Johnson295189b2012-06-20 16:38:30 -07007508 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05307509 /* Initialize WMM configuation */
7510 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307511 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007512
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007513#ifdef WLAN_FEATURE_P2P_DEBUG
7514 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
7515 {
7516 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
7517 {
7518 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7519 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007520 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007521 }
7522 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
7523 {
7524 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7525 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007526 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007527 }
7528 }
7529#endif
7530
Jeff Johnson295189b2012-06-20 16:38:30 -07007531 pHostapdState->bCommit = TRUE;
7532 EXIT();
7533
7534 return 0;
7535}
7536
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007537#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307538static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307539 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 struct beacon_parameters *params)
7541{
7542 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307543 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307544 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007545
7546 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307547
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307548 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7549 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
7550 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307551 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
7552 hdd_device_modetoString(pAdapter->device_mode),
7553 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007554
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307555 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7556 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307557 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007558 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307559 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007560 }
7561
Agarwal Ashish51325b52014-06-16 16:50:49 +05307562 if (vos_max_concurrent_connections_reached()) {
7563 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7564 return -EINVAL;
7565 }
7566
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307567 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007568 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007569 )
7570 {
7571 beacon_data_t *old,*new;
7572
7573 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307574
Jeff Johnson295189b2012-06-20 16:38:30 -07007575 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307576 {
7577 hddLog(VOS_TRACE_LEVEL_WARN,
7578 FL("already beacon info added to session(%d)"),
7579 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007580 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007582
7583 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7584
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307585 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07007586 {
7587 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007588 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007589 return -EINVAL;
7590 }
7591
7592 pAdapter->sessionCtx.ap.beacon = new;
7593
7594 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7595 }
7596
7597 EXIT();
7598 return status;
7599}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307600
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307601static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
7602 struct net_device *dev,
7603 struct beacon_parameters *params)
7604{
7605 int ret;
7606
7607 vos_ssr_protect(__func__);
7608 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
7609 vos_ssr_unprotect(__func__);
7610
7611 return ret;
7612}
7613
7614static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007615 struct net_device *dev,
7616 struct beacon_parameters *params)
7617{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307618 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307619 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7620 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307621 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007622
7623 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307624
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307625 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7626 TRACE_CODE_HDD_CFG80211_SET_BEACON,
7627 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
7628 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7629 __func__, hdd_device_modetoString(pAdapter->device_mode),
7630 pAdapter->device_mode);
7631
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307632 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7633 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307634 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007635 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307636 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007637 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307638
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307639 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007640 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307641 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007642 {
7643 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307644
Jeff Johnson295189b2012-06-20 16:38:30 -07007645 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307646
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307648 {
7649 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7650 FL("session(%d) old and new heads points to NULL"),
7651 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007652 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307653 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007654
7655 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7656
7657 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307658 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007659 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 return -EINVAL;
7661 }
7662
7663 pAdapter->sessionCtx.ap.beacon = new;
7664
7665 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7666 }
7667
7668 EXIT();
7669 return status;
7670}
7671
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307672static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
7673 struct net_device *dev,
7674 struct beacon_parameters *params)
7675{
7676 int ret;
7677
7678 vos_ssr_protect(__func__);
7679 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
7680 vos_ssr_unprotect(__func__);
7681
7682 return ret;
7683}
7684
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007685#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7686
7687#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307688static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007689 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007690#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307691static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007692 struct net_device *dev)
7693#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007694{
7695 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07007696 hdd_context_t *pHddCtx = NULL;
7697 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307698 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307699 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007700
7701 ENTER();
7702
7703 if (NULL == pAdapter)
7704 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307705 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007706 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007707 return -ENODEV;
7708 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007709
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307710 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7711 TRACE_CODE_HDD_CFG80211_STOP_AP,
7712 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307713 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7714 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307715 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007716 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307717 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07007718 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007719
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007720 pScanInfo = &pHddCtx->scan_info;
7721
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307722 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7723 __func__, hdd_device_modetoString(pAdapter->device_mode),
7724 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007725
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307726 ret = wlan_hdd_scan_abort(pAdapter);
7727
Girish Gowli4bf7a632014-06-12 13:42:11 +05307728 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07007729 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307730 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7731 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307732
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307733 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07007734 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7736 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08007737
Jeff Johnsone7245742012-09-05 17:12:55 -07007738 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307739 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07007740 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307741 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07007742 }
7743
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05307744 /* Delete all associated STAs before stopping AP/P2P GO */
7745 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05307746 hdd_hostapd_stop(dev);
7747
Jeff Johnson295189b2012-06-20 16:38:30 -07007748 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007749 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007750 )
7751 {
7752 beacon_data_t *old;
7753
7754 old = pAdapter->sessionCtx.ap.beacon;
7755
7756 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307757 {
7758 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7759 FL("session(%d) beacon data points to NULL"),
7760 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007761 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007763
Jeff Johnson295189b2012-06-20 16:38:30 -07007764 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007765
7766 mutex_lock(&pHddCtx->sap_lock);
7767 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7768 {
Jeff Johnson4416a782013-03-25 14:17:50 -07007769 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007770 {
7771 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7772
7773 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
7774
7775 if (!VOS_IS_STATUS_SUCCESS(status))
7776 {
7777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007778 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007779 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307780 }
7781 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007782 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307783 /* BSS stopped, clear the active sessions for this device mode */
7784 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007785 }
7786 mutex_unlock(&pHddCtx->sap_lock);
7787
7788 if(status != VOS_STATUS_SUCCESS)
7789 {
7790 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007791 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007792 return -EINVAL;
7793 }
7794
Jeff Johnson4416a782013-03-25 14:17:50 -07007795 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007796 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
7797 ==eHAL_STATUS_FAILURE)
7798 {
7799 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007800 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007801 }
7802
Jeff Johnson4416a782013-03-25 14:17:50 -07007803 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007804 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7805 eANI_BOOLEAN_FALSE) )
7806 {
7807 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007808 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007809 }
7810
7811 // Reset WNI_CFG_PROBE_RSP Flags
7812 wlan_hdd_reset_prob_rspies(pAdapter);
7813
7814 pAdapter->sessionCtx.ap.beacon = NULL;
7815 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007816#ifdef WLAN_FEATURE_P2P_DEBUG
7817 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
7818 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
7819 {
7820 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
7821 "GO got removed");
7822 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
7823 }
7824#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007825 }
7826 EXIT();
7827 return status;
7828}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007829
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307830#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7831static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
7832 struct net_device *dev)
7833{
7834 int ret;
7835
7836 vos_ssr_protect(__func__);
7837 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
7838 vos_ssr_unprotect(__func__);
7839
7840 return ret;
7841}
7842#else
7843static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
7844 struct net_device *dev)
7845{
7846 int ret;
7847
7848 vos_ssr_protect(__func__);
7849 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
7850 vos_ssr_unprotect(__func__);
7851
7852 return ret;
7853}
7854#endif
7855
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007856#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
7857
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307858static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307859 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007860 struct cfg80211_ap_settings *params)
7861{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307862 hdd_adapter_t *pAdapter;
7863 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307864 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007865
7866 ENTER();
7867
Girish Gowlib143d7a2015-02-18 19:39:55 +05307868 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007869 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307870 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05307871 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307872 return -ENODEV;
7873 }
7874
7875 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7876 if (NULL == pAdapter)
7877 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307878 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307879 "%s: HDD adapter is Null", __func__);
7880 return -ENODEV;
7881 }
7882
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307883 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7884 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
7885 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307886 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
7887 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307888 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307889 "%s: HDD adapter magic is invalid", __func__);
7890 return -ENODEV;
7891 }
7892
7893 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307894 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307895 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307896 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307897 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307898 }
7899
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307900 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
7901 __func__, hdd_device_modetoString(pAdapter->device_mode),
7902 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307903
7904 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007905 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007906 )
7907 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307908 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007909
7910 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307911
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007912 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307913 {
7914 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7915 FL("already beacon info added to session(%d)"),
7916 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007917 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307918 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007919
Girish Gowlib143d7a2015-02-18 19:39:55 +05307920#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7921 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7922 &new,
7923 &params->beacon);
7924#else
7925 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7926 &new,
7927 &params->beacon,
7928 params->dtim_period);
7929#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007930
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307931 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007932 {
7933 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307934 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007935 return -EINVAL;
7936 }
7937 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08007938#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07007939 wlan_hdd_cfg80211_set_channel(wiphy, dev,
7940#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
7941 params->channel, params->channel_type);
7942#else
7943 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
7944#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08007945#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007946 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307947 params->ssid_len, params->hidden_ssid,
7948 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007949 }
7950
7951 EXIT();
7952 return status;
7953}
7954
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307955static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
7956 struct net_device *dev,
7957 struct cfg80211_ap_settings *params)
7958{
7959 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007960
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307961 vos_ssr_protect(__func__);
7962 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
7963 vos_ssr_unprotect(__func__);
7964
7965 return ret;
7966}
7967
7968static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007969 struct net_device *dev,
7970 struct cfg80211_beacon_data *params)
7971{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307972 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307973 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307974 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007975
7976 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307977
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307978 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7979 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
7980 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007981 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007982 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307983
7984 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7985 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307986 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007987 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307988 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007989 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007990
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307991 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007992 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307993 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007994 {
7995 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307996
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007997 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307998
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007999 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308000 {
8001 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8002 FL("session(%d) beacon data points to NULL"),
8003 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008004 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308005 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008006
8007 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
8008
8009 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308010 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008011 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008012 return -EINVAL;
8013 }
8014
8015 pAdapter->sessionCtx.ap.beacon = new;
8016
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05308017 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
8018 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008019 }
8020
8021 EXIT();
8022 return status;
8023}
8024
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308025static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
8026 struct net_device *dev,
8027 struct cfg80211_beacon_data *params)
8028{
8029 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008030
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308031 vos_ssr_protect(__func__);
8032 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
8033 vos_ssr_unprotect(__func__);
8034
8035 return ret;
8036}
8037
8038#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008039
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308040static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 struct net_device *dev,
8042 struct bss_parameters *params)
8043{
8044 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308045 hdd_context_t *pHddCtx;
8046 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008047
8048 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308049
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308050 if (NULL == pAdapter)
8051 {
8052 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8053 "%s: HDD adapter is Null", __func__);
8054 return -ENODEV;
8055 }
8056 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308057 ret = wlan_hdd_validate_context(pHddCtx);
8058 if (0 != ret)
8059 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308060 return ret;
8061 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308062 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8063 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
8064 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308065 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8066 __func__, hdd_device_modetoString(pAdapter->device_mode),
8067 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008068
8069 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008070 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308071 )
Jeff Johnson295189b2012-06-20 16:38:30 -07008072 {
8073 /* ap_isolate == -1 means that in change bss, upper layer doesn't
8074 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308075 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07008076 {
8077 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308078 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008079 }
8080
8081 EXIT();
8082 return 0;
8083}
8084
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308085static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
8086 struct net_device *dev,
8087 struct bss_parameters *params)
8088{
8089 int ret;
8090
8091 vos_ssr_protect(__func__);
8092 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
8093 vos_ssr_unprotect(__func__);
8094
8095 return ret;
8096}
Kiet Lam10841362013-11-01 11:36:50 +05308097/* FUNCTION: wlan_hdd_change_country_code_cd
8098* to wait for contry code completion
8099*/
8100void* wlan_hdd_change_country_code_cb(void *pAdapter)
8101{
8102 hdd_adapter_t *call_back_pAdapter = pAdapter;
8103 complete(&call_back_pAdapter->change_country_code);
8104 return NULL;
8105}
8106
Jeff Johnson295189b2012-06-20 16:38:30 -07008107/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308108 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07008109 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
8110 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308111int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008112 struct net_device *ndev,
8113 enum nl80211_iftype type,
8114 u32 *flags,
8115 struct vif_params *params
8116 )
8117{
8118 struct wireless_dev *wdev;
8119 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008120 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07008121 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008122 tCsrRoamProfile *pRoamProfile = NULL;
8123 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308124 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008125 eMib_dot11DesiredBssType connectedBssType;
8126 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308127 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008128
8129 ENTER();
8130
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308131 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008132 {
8133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8134 "%s: Adapter context is null", __func__);
8135 return VOS_STATUS_E_FAILURE;
8136 }
8137
8138 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8139 if (!pHddCtx)
8140 {
8141 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8142 "%s: HDD context is null", __func__);
8143 return VOS_STATUS_E_FAILURE;
8144 }
8145
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308146 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8147 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
8148 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308149 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308150 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07008151 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308152 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008153 }
8154
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308155 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8156 __func__, hdd_device_modetoString(pAdapter->device_mode),
8157 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008158
Agarwal Ashish51325b52014-06-16 16:50:49 +05308159 if (vos_max_concurrent_connections_reached()) {
8160 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
8161 return -EINVAL;
8162 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308163 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07008164 wdev = ndev->ieee80211_ptr;
8165
8166#ifdef WLAN_BTAMP_FEATURE
8167 if((NL80211_IFTYPE_P2P_CLIENT == type)||
8168 (NL80211_IFTYPE_ADHOC == type)||
8169 (NL80211_IFTYPE_AP == type)||
8170 (NL80211_IFTYPE_P2P_GO == type))
8171 {
8172 pHddCtx->isAmpAllowed = VOS_FALSE;
8173 // stop AMP traffic
8174 status = WLANBAP_StopAmp();
8175 if(VOS_STATUS_SUCCESS != status )
8176 {
8177 pHddCtx->isAmpAllowed = VOS_TRUE;
8178 hddLog(VOS_TRACE_LEVEL_FATAL,
8179 "%s: Failed to stop AMP", __func__);
8180 return -EINVAL;
8181 }
8182 }
8183#endif //WLAN_BTAMP_FEATURE
8184 /* Reset the current device mode bit mask*/
8185 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
8186
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05308187 /* Notify Mode change in case of concurrency.
8188 * Below function invokes TDLS teardown Functionality Since TDLS is
8189 * not Supported in case of concurrency i.e Once P2P session
8190 * is detected disable offchannel and teardown TDLS links
8191 */
8192 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
8193
Jeff Johnson295189b2012-06-20 16:38:30 -07008194 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008195 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07008196 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07008197 )
8198 {
8199 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008200 if (!pWextState)
8201 {
8202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8203 "%s: pWextState is null", __func__);
8204 return VOS_STATUS_E_FAILURE;
8205 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008206 pRoamProfile = &pWextState->roamProfile;
8207 LastBSSType = pRoamProfile->BSSType;
8208
8209 switch (type)
8210 {
8211 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008212 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008213 hddLog(VOS_TRACE_LEVEL_INFO,
8214 "%s: setting interface Type to INFRASTRUCTURE", __func__);
8215 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07008216#ifdef WLAN_FEATURE_11AC
8217 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
8218 {
8219 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
8220 }
8221#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308222 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07008223 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008224 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008225 //Check for sub-string p2p to confirm its a p2p interface
8226 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308227 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +05308228#ifdef FEATURE_WLAN_TDLS
8229 mutex_lock(&pHddCtx->tdls_lock);
8230 wlan_hdd_tdls_exit(pAdapter, TRUE);
8231 mutex_unlock(&pHddCtx->tdls_lock);
8232#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008233 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8234 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8235 }
8236 else
8237 {
8238 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008239 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008240 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008241 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05308242
Jeff Johnson295189b2012-06-20 16:38:30 -07008243 case NL80211_IFTYPE_ADHOC:
8244 hddLog(VOS_TRACE_LEVEL_INFO,
8245 "%s: setting interface Type to ADHOC", __func__);
8246 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
8247 pRoamProfile->phyMode =
8248 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07008249 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008250 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +05308251 hdd_set_ibss_ops( pAdapter );
8252 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +05308253
8254 status = hdd_sta_id_hash_attach(pAdapter);
8255 if (VOS_STATUS_SUCCESS != status) {
8256 hddLog(VOS_TRACE_LEVEL_ERROR,
8257 FL("Failed to initialize hash for IBSS"));
8258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008259 break;
8260
8261 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008262 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008263 {
8264 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8265 "%s: setting interface Type to %s", __func__,
8266 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
8267
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008268 //Cancel any remain on channel for GO mode
8269 if (NL80211_IFTYPE_P2P_GO == type)
8270 {
8271 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
8272 }
Mohit Khanna0f232092012-09-11 14:46:08 -07008273 if (NL80211_IFTYPE_AP == type)
8274 {
8275 /* As Loading WLAN Driver one interface being created for p2p device
8276 * address. This will take one HW STA and the max number of clients
8277 * that can connect to softAP will be reduced by one. so while changing
8278 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
8279 * interface as it is not required in SoftAP mode.
8280 */
8281
8282 // Get P2P Adapter
8283 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
8284
8285 if (pP2pAdapter)
8286 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05308287 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +05308288 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07008289 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
8290 }
8291 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05308292 //Disable IMPS & BMPS for SAP/GO
8293 if(VOS_STATUS_E_FAILURE ==
8294 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
8295 {
8296 //Fail to Exit BMPS
8297 VOS_ASSERT(0);
8298 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05308299
8300 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
8301
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308302#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07008303
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308304 /* A Mutex Lock is introduced while changing the mode to
8305 * protect the concurrent access for the Adapters by TDLS
8306 * module.
8307 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308308 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308309#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008310 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +05308311 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008312 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07008313 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8314 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308315#ifdef FEATURE_WLAN_TDLS
8316 mutex_unlock(&pHddCtx->tdls_lock);
8317#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008318 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
8319 (pConfig->apRandomBssidEnabled))
8320 {
8321 /* To meet Android requirements create a randomized
8322 MAC address of the form 02:1A:11:Fx:xx:xx */
8323 get_random_bytes(&ndev->dev_addr[3], 3);
8324 ndev->dev_addr[0] = 0x02;
8325 ndev->dev_addr[1] = 0x1A;
8326 ndev->dev_addr[2] = 0x11;
8327 ndev->dev_addr[3] |= 0xF0;
8328 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
8329 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08008330 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
8331 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008332 }
8333
Jeff Johnson295189b2012-06-20 16:38:30 -07008334 hdd_set_ap_ops( pAdapter->dev );
8335
Kiet Lam10841362013-11-01 11:36:50 +05308336 /* This is for only SAP mode where users can
8337 * control country through ini.
8338 * P2P GO follows station country code
8339 * acquired during the STA scanning. */
8340 if((NL80211_IFTYPE_AP == type) &&
8341 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
8342 {
8343 int status = 0;
8344 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
8345 "%s: setting country code from INI ", __func__);
8346 init_completion(&pAdapter->change_country_code);
8347 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
8348 (void *)(tSmeChangeCountryCallback)
8349 wlan_hdd_change_country_code_cb,
8350 pConfig->apCntryCode, pAdapter,
8351 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05308352 eSIR_FALSE,
8353 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05308354 if (eHAL_STATUS_SUCCESS == status)
8355 {
8356 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308357 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05308358 &pAdapter->change_country_code,
8359 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308360 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05308361 {
8362 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308363 FL("SME Timed out while setting country code %ld"),
8364 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08008365
8366 if (pHddCtx->isLogpInProgress)
8367 {
8368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8369 "%s: LOGP in Progress. Ignore!!!", __func__);
8370 return -EAGAIN;
8371 }
Kiet Lam10841362013-11-01 11:36:50 +05308372 }
8373 }
8374 else
8375 {
8376 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008377 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05308378 return -EINVAL;
8379 }
8380 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008381 status = hdd_init_ap_mode(pAdapter);
8382 if(status != VOS_STATUS_SUCCESS)
8383 {
8384 hddLog(VOS_TRACE_LEVEL_FATAL,
8385 "%s: Error initializing the ap mode", __func__);
8386 return -EINVAL;
8387 }
8388 hdd_set_conparam(1);
8389
Nirav Shah7e3c8132015-06-22 23:51:42 +05308390 status = hdd_sta_id_hash_attach(pAdapter);
8391 if (VOS_STATUS_SUCCESS != status)
8392 {
8393 hddLog(VOS_TRACE_LEVEL_ERROR,
8394 FL("Failed to initialize hash for AP"));
8395 return -EINVAL;
8396 }
8397
Jeff Johnson295189b2012-06-20 16:38:30 -07008398 /*interface type changed update in wiphy structure*/
8399 if(wdev)
8400 {
8401 wdev->iftype = type;
8402 pHddCtx->change_iface = type;
8403 }
8404 else
8405 {
8406 hddLog(VOS_TRACE_LEVEL_ERROR,
8407 "%s: ERROR !!!! Wireless dev is NULL", __func__);
8408 return -EINVAL;
8409 }
8410 goto done;
8411 }
8412
8413 default:
8414 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8415 __func__);
8416 return -EOPNOTSUPP;
8417 }
8418 }
8419 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008420 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07008421 )
8422 {
8423 switch(type)
8424 {
8425 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008426 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008427 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05308428
8429 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308430#ifdef FEATURE_WLAN_TDLS
8431
8432 /* A Mutex Lock is introduced while changing the mode to
8433 * protect the concurrent access for the Adapters by TDLS
8434 * module.
8435 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308436 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308437#endif
c_hpothu002231a2015-02-05 14:58:51 +05308438 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008439 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008440 //Check for sub-string p2p to confirm its a p2p interface
8441 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008442 {
8443 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8444 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8445 }
8446 else
8447 {
8448 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008449 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008451 hdd_set_conparam(0);
8452 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008453 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
8454 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308455#ifdef FEATURE_WLAN_TDLS
8456 mutex_unlock(&pHddCtx->tdls_lock);
8457#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05308458 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008459 if( VOS_STATUS_SUCCESS != status )
8460 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07008461 /* In case of JB, for P2P-GO, only change interface will be called,
8462 * This is the right place to enable back bmps_imps()
8463 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308464 if (pHddCtx->hdd_wlan_suspended)
8465 {
8466 hdd_set_pwrparams(pHddCtx);
8467 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008468 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008469 goto done;
8470 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008471 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008472 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008473 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8474 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008475 goto done;
8476 default:
8477 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8478 __func__);
8479 return -EOPNOTSUPP;
8480
8481 }
8482
8483 }
8484 else
8485 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308486 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
8487 __func__, hdd_device_modetoString(pAdapter->device_mode),
8488 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008489 return -EOPNOTSUPP;
8490 }
8491
8492
8493 if(pRoamProfile)
8494 {
8495 if ( LastBSSType != pRoamProfile->BSSType )
8496 {
8497 /*interface type changed update in wiphy structure*/
8498 wdev->iftype = type;
8499
8500 /*the BSS mode changed, We need to issue disconnect
8501 if connected or in IBSS disconnect state*/
8502 if ( hdd_connGetConnectedBssType(
8503 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
8504 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
8505 {
8506 /*need to issue a disconnect to CSR.*/
8507 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8508 if( eHAL_STATUS_SUCCESS ==
8509 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8510 pAdapter->sessionId,
8511 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
8512 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308513 ret = wait_for_completion_interruptible_timeout(
8514 &pAdapter->disconnect_comp_var,
8515 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8516 if (ret <= 0)
8517 {
8518 hddLog(VOS_TRACE_LEVEL_ERROR,
8519 FL("wait on disconnect_comp_var failed %ld"), ret);
8520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008521 }
8522 }
8523 }
8524 }
8525
8526done:
8527 /*set bitmask based on updated value*/
8528 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07008529
8530 /* Only STA mode support TM now
8531 * all other mode, TM feature should be disabled */
8532 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
8533 (~VOS_STA & pHddCtx->concurrency_mode) )
8534 {
8535 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
8536 }
8537
Jeff Johnson295189b2012-06-20 16:38:30 -07008538#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308539 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05308540 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07008541 {
8542 //we are ok to do AMP
8543 pHddCtx->isAmpAllowed = VOS_TRUE;
8544 }
8545#endif //WLAN_BTAMP_FEATURE
8546 EXIT();
8547 return 0;
8548}
8549
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308550/*
8551 * FUNCTION: wlan_hdd_cfg80211_change_iface
8552 * wrapper function to protect the actual implementation from SSR.
8553 */
8554int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
8555 struct net_device *ndev,
8556 enum nl80211_iftype type,
8557 u32 *flags,
8558 struct vif_params *params
8559 )
8560{
8561 int ret;
8562
8563 vos_ssr_protect(__func__);
8564 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
8565 vos_ssr_unprotect(__func__);
8566
8567 return ret;
8568}
8569
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008570#ifdef FEATURE_WLAN_TDLS
8571static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308572 struct net_device *dev,
8573#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
8574 const u8 *mac,
8575#else
8576 u8 *mac,
8577#endif
8578 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008579{
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008580 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008581 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308582 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308583 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308584 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308585 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008586
8587 ENTER();
8588
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308589 if (!dev) {
8590 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
8591 return -EINVAL;
8592 }
8593
8594 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8595 if (!pAdapter) {
8596 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
8597 return -EINVAL;
8598 }
8599
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308600 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008601 {
8602 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8603 "Invalid arguments");
8604 return -EINVAL;
8605 }
Hoonki Lee27511902013-03-14 18:19:06 -07008606
8607 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
8608 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
8609 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308610 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -07008611 "%s: TDLS mode is disabled OR not enabled in FW."
8612 MAC_ADDRESS_STR " Request declined.",
8613 __func__, MAC_ADDR_ARRAY(mac));
8614 return -ENOTSUPP;
8615 }
8616
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008617 if (pHddCtx->isLogpInProgress)
8618 {
8619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8620 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05308621 wlan_hdd_tdls_set_link_status(pAdapter,
8622 mac,
8623 eTDLS_LINK_IDLE,
8624 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008625 return -EBUSY;
8626 }
8627
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308628 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05308629 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008630
8631 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308632 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008633 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
8634 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308635 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008636 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008637 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308638 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008639
8640 /* in add station, we accept existing valid staId if there is */
8641 if ((0 == update) &&
8642 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
8643 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008644 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308645 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008646 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008647 " link_status %d. staId %d. add station ignored.",
8648 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
8649 return 0;
8650 }
8651 /* in change station, we accept only when staId is valid */
8652 if ((1 == update) &&
8653 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
8654 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
8655 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308656 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008657 "%s: " MAC_ADDRESS_STR
8658 " link status %d. staId %d. change station %s.",
8659 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
8660 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
8661 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008662 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008663
8664 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05308665 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008666 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008667 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8668 "%s: " MAC_ADDRESS_STR
8669 " TDLS setup is ongoing. Request declined.",
8670 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07008671 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008672 }
8673
8674 /* first to check if we reached to maximum supported TDLS peer.
8675 TODO: for now, return -EPERM looks working fine,
8676 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308677 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
8678 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008679 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008680 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8681 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308682 " TDLS Max peer already connected. Request declined."
8683 " Num of peers (%d), Max allowed (%d).",
8684 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
8685 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008686 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008687 }
8688 else
8689 {
8690 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308691 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008692 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008693 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008694 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8695 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
8696 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008697 return -EPERM;
8698 }
8699 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008700 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05308701 wlan_hdd_tdls_set_link_status(pAdapter,
8702 mac,
8703 eTDLS_LINK_CONNECTING,
8704 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008705
Jeff Johnsond75fe012013-04-06 10:53:06 -07008706 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308707 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008708 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008710 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008711 if(StaParams->htcap_present)
8712 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308713 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008714 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308715 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008716 "ht_capa->extended_capabilities: %0x",
8717 StaParams->HTCap.extendedHtCapInfo);
8718 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008720 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308721 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008722 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008723 if(StaParams->vhtcap_present)
8724 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008726 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
8727 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
8728 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
8729 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008730 {
8731 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008732 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008733 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308734 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008735 "[%d]: %x ", i, StaParams->supported_rates[i]);
8736 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07008737 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308738 else if ((1 == update) && (NULL == StaParams))
8739 {
8740 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8741 "%s : update is true, but staParams is NULL. Error!", __func__);
8742 return -EPERM;
8743 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008744
8745 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
8746
8747 if (!update)
8748 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308749 /*Before adding sta make sure that device exited from BMPS*/
8750 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8751 {
8752 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8753 "%s: Adding tdls peer sta. Disable BMPS", __func__);
8754 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8755 if (status != VOS_STATUS_SUCCESS) {
8756 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
8757 }
8758 }
8759
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308760 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008761 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308762 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308763 hddLog(VOS_TRACE_LEVEL_ERROR,
8764 FL("Failed to add TDLS peer STA. Enable Bmps"));
8765 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308766 return -EPERM;
8767 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008768 }
8769 else
8770 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308771 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008772 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308773 if (ret != eHAL_STATUS_SUCCESS) {
8774 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
8775 return -EPERM;
8776 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008777 }
8778
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308779 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008780 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
8781
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308782 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008783 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308785 "%s: timeout waiting for tdls add station indication %ld",
8786 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008787 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008788 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308789
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008790 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
8791 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008793 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008794 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008795 }
8796
8797 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008798
8799error:
Atul Mittal115287b2014-07-08 13:26:33 +05308800 wlan_hdd_tdls_set_link_status(pAdapter,
8801 mac,
8802 eTDLS_LINK_IDLE,
8803 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008804 return -EPERM;
8805
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008806}
8807#endif
8808
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308809static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008810 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308811#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
8812 const u8 *mac,
8813#else
Jeff Johnson295189b2012-06-20 16:38:30 -07008814 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308815#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008816 struct station_parameters *params)
8817{
8818 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308819 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308820 hdd_context_t *pHddCtx;
8821 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008822 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308823 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008824#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008825 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008826 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308827 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008828#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008829
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308830 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308831
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308832 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308833 if ((NULL == pAdapter))
8834 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308835 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308836 "invalid adapter ");
8837 return -EINVAL;
8838 }
8839
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308840 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8841 TRACE_CODE_HDD_CHANGE_STATION,
8842 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05308843 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308844
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308845 ret = wlan_hdd_validate_context(pHddCtx);
8846 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +05308847 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308848 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308849 }
8850
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308851 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8852
8853 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008854 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8856 "invalid HDD station context");
8857 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008859 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
8860
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008861 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
8862 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07008863 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008864 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07008865 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308866 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008867 WLANTL_STA_AUTHENTICATED);
8868
Gopichand Nakkala29149562013-05-10 21:43:41 +05308869 if (status != VOS_STATUS_SUCCESS)
8870 {
8871 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8872 "%s: Not able to change TL state to AUTHENTICATED", __func__);
8873 return -EINVAL;
8874 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008875 }
8876 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07008877 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
8878 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308879#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008880 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
8881 StaParams.capability = params->capability;
8882 StaParams.uapsd_queues = params->uapsd_queues;
8883 StaParams.max_sp = params->max_sp;
8884
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308885 /* Convert (first channel , number of channels) tuple to
8886 * the total list of channels. This goes with the assumption
8887 * that if the first channel is < 14, then the next channels
8888 * are an incremental of 1 else an incremental of 4 till the number
8889 * of channels.
8890 */
8891 if (0 != params->supported_channels_len) {
8892 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
8893 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
8894 {
8895 int wifi_chan_index;
8896 StaParams.supported_channels[j] = params->supported_channels[i];
8897 wifi_chan_index =
8898 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
8899 no_of_channels = params->supported_channels[i+1];
8900 for(k=1; k <= no_of_channels; k++)
8901 {
8902 StaParams.supported_channels[j+1] =
8903 StaParams.supported_channels[j] + wifi_chan_index;
8904 j+=1;
8905 }
8906 }
8907 StaParams.supported_channels_len = j;
8908 }
8909 vos_mem_copy(StaParams.supported_oper_classes,
8910 params->supported_oper_classes,
8911 params->supported_oper_classes_len);
8912 StaParams.supported_oper_classes_len =
8913 params->supported_oper_classes_len;
8914
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008915 if (0 != params->ext_capab_len)
8916 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
8917 sizeof(StaParams.extn_capability));
8918
8919 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008920 {
8921 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008922 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008923 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008924
8925 StaParams.supported_rates_len = params->supported_rates_len;
8926
8927 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
8928 * The supported_rates array , for all the structures propogating till Add Sta
8929 * to the firmware has to be modified , if the supplicant (ieee80211) is
8930 * modified to send more rates.
8931 */
8932
8933 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
8934 */
8935 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
8936 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
8937
8938 if (0 != StaParams.supported_rates_len) {
8939 int i = 0;
8940 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
8941 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008942 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008943 "Supported Rates with Length %d", StaParams.supported_rates_len);
8944 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008945 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008946 "[%d]: %0x", i, StaParams.supported_rates[i]);
8947 }
8948
8949 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008950 {
8951 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008952 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008953 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008954
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008955 if (0 != params->ext_capab_len ) {
8956 /*Define A Macro : TODO Sunil*/
8957 if ((1<<4) & StaParams.extn_capability[3]) {
8958 isBufSta = 1;
8959 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308960 /* TDLS Channel Switching Support */
8961 if ((1<<6) & StaParams.extn_capability[3]) {
8962 isOffChannelSupported = 1;
8963 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008964 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308965 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
8966 &StaParams, isBufSta,
8967 isOffChannelSupported);
8968
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308969 if (VOS_STATUS_SUCCESS != status) {
8970 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8971 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
8972 return -EINVAL;
8973 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008974 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
8975
8976 if (VOS_STATUS_SUCCESS != status) {
8977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8978 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
8979 return -EINVAL;
8980 }
8981 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008982#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05308983 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008984 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008985 return status;
8986}
8987
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308988#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
8989static int wlan_hdd_change_station(struct wiphy *wiphy,
8990 struct net_device *dev,
8991 const u8 *mac,
8992 struct station_parameters *params)
8993#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308994static int wlan_hdd_change_station(struct wiphy *wiphy,
8995 struct net_device *dev,
8996 u8 *mac,
8997 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308998#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308999{
9000 int ret;
9001
9002 vos_ssr_protect(__func__);
9003 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
9004 vos_ssr_unprotect(__func__);
9005
9006 return ret;
9007}
9008
Jeff Johnson295189b2012-06-20 16:38:30 -07009009/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309010 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009011 * This function is used to initialize the key information
9012 */
9013#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309014static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009015 struct net_device *ndev,
9016 u8 key_index, bool pairwise,
9017 const u8 *mac_addr,
9018 struct key_params *params
9019 )
9020#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309021static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009022 struct net_device *ndev,
9023 u8 key_index, const u8 *mac_addr,
9024 struct key_params *params
9025 )
9026#endif
9027{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009028 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07009029 tCsrRoamSetKey setKey;
9030 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309031 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009032 v_U32_t roamId= 0xFF;
9033 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009034 hdd_hostapd_state_t *pHostapdState;
9035 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009036 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309037 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009038
9039 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309040
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309041 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9042 TRACE_CODE_HDD_CFG80211_ADD_KEY,
9043 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309044 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9045 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309046 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009047 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309048 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009049 }
9050
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309051 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9052 __func__, hdd_device_modetoString(pAdapter->device_mode),
9053 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009054
9055 if (CSR_MAX_NUM_KEY <= key_index)
9056 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009057 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009058 key_index);
9059
9060 return -EINVAL;
9061 }
9062
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009063 if (CSR_MAX_KEY_LEN < params->key_len)
9064 {
9065 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
9066 params->key_len);
9067
9068 return -EINVAL;
9069 }
9070
9071 hddLog(VOS_TRACE_LEVEL_INFO,
9072 "%s: called with key index = %d & key length %d",
9073 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07009074
9075 /*extract key idx, key len and key*/
9076 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9077 setKey.keyId = key_index;
9078 setKey.keyLength = params->key_len;
9079 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
9080
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009081 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07009082 {
9083 case WLAN_CIPHER_SUITE_WEP40:
9084 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
9085 break;
9086
9087 case WLAN_CIPHER_SUITE_WEP104:
9088 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
9089 break;
9090
9091 case WLAN_CIPHER_SUITE_TKIP:
9092 {
9093 u8 *pKey = &setKey.Key[0];
9094 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
9095
9096 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
9097
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009098 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07009099
9100 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009101 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07009102 |--------------|----------|----------|
9103 <---16bytes---><--8bytes--><--8bytes-->
9104
9105 */
9106 /*Sme expects the 32 bytes key to be in the below order
9107
9108 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009109 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07009110 |--------------|----------|----------|
9111 <---16bytes---><--8bytes--><--8bytes-->
9112 */
9113 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009114 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07009115
9116 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009117 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009118
9119 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009120 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009121
9122
9123 break;
9124 }
9125
9126 case WLAN_CIPHER_SUITE_CCMP:
9127 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
9128 break;
9129
9130#ifdef FEATURE_WLAN_WAPI
9131 case WLAN_CIPHER_SUITE_SMS4:
9132 {
9133 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9134 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
9135 params->key, params->key_len);
9136 return 0;
9137 }
9138#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009139
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009140#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009141 case WLAN_CIPHER_SUITE_KRK:
9142 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
9143 break;
9144#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009145
9146#ifdef WLAN_FEATURE_11W
9147 case WLAN_CIPHER_SUITE_AES_CMAC:
9148 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07009149 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07009150#endif
9151
Jeff Johnson295189b2012-06-20 16:38:30 -07009152 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009153 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07009154 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309155 status = -EOPNOTSUPP;
9156 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009157 }
9158
9159 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
9160 __func__, setKey.encType);
9161
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009162 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07009163#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9164 (!pairwise)
9165#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009166 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07009167#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009168 )
9169 {
9170 /* set group key*/
9171 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9172 "%s- %d: setting Broadcast key",
9173 __func__, __LINE__);
9174 setKey.keyDirection = eSIR_RX_ONLY;
9175 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9176 }
9177 else
9178 {
9179 /* set pairwise key*/
9180 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9181 "%s- %d: setting pairwise key",
9182 __func__, __LINE__);
9183 setKey.keyDirection = eSIR_TX_RX;
9184 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9185 }
9186 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
9187 {
9188 setKey.keyDirection = eSIR_TX_RX;
9189 /*Set the group key*/
9190 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9191 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009192
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009193 if ( 0 != status )
9194 {
9195 hddLog(VOS_TRACE_LEVEL_ERROR,
9196 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309197 status = -EINVAL;
9198 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009199 }
9200 /*Save the keys here and call sme_RoamSetKey for setting
9201 the PTK after peer joins the IBSS network*/
9202 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
9203 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309204 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009205 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05309206 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
9207 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
9208 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009209 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009210 if( pHostapdState->bssState == BSS_START )
9211 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009212 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9213 vos_status = wlan_hdd_check_ula_done(pAdapter);
9214
9215 if ( vos_status != VOS_STATUS_SUCCESS )
9216 {
9217 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9218 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9219 __LINE__, vos_status );
9220
9221 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9222
9223 status = -EINVAL;
9224 goto end;
9225 }
9226
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 status = WLANSAP_SetKeySta( pVosContext, &setKey);
9228
9229 if ( status != eHAL_STATUS_SUCCESS )
9230 {
9231 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9232 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9233 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309234 status = -EINVAL;
9235 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009236 }
9237 }
9238
9239 /* Saving WEP keys */
9240 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
9241 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
9242 {
9243 //Save the wep key in ap context. Issue setkey after the BSS is started.
9244 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9245 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
9246 }
9247 else
9248 {
9249 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009250 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009251 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
9252 }
9253 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009254 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9255 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009256 {
9257 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9258 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9259
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309260#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9261 if (!pairwise)
9262#else
9263 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9264#endif
9265 {
9266 /* set group key*/
9267 if (pHddStaCtx->roam_info.deferKeyComplete)
9268 {
9269 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9270 "%s- %d: Perform Set key Complete",
9271 __func__, __LINE__);
9272 hdd_PerformRoamSetKeyComplete(pAdapter);
9273 }
9274 }
9275
Jeff Johnson295189b2012-06-20 16:38:30 -07009276 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
9277
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08009278 pWextState->roamProfile.Keys.defaultIndex = key_index;
9279
9280
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009281 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009282 params->key, params->key_len);
9283
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309284
Jeff Johnson295189b2012-06-20 16:38:30 -07009285 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9286
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309287 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009288 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309289 __func__, setKey.peerMac[0], setKey.peerMac[1],
9290 setKey.peerMac[2], setKey.peerMac[3],
9291 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009292 setKey.keyDirection);
9293
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009294 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +05309295
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009296 if ( vos_status != VOS_STATUS_SUCCESS )
9297 {
9298 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009299 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9300 __LINE__, vos_status );
9301
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009302 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009303
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009304 status = -EINVAL;
9305 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009306
9307 }
9308
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009309#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309310 /* The supplicant may attempt to set the PTK once pre-authentication
9311 is done. Save the key in the UMAC and include it in the ADD BSS
9312 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009313 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309314 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009315 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309316 hddLog(VOS_TRACE_LEVEL_INFO_MED,
9317 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309318 status = 0;
9319 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309320 }
9321 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
9322 {
9323 hddLog(VOS_TRACE_LEVEL_ERROR,
9324 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309325 status = -EINVAL;
9326 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009327 }
9328#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07009329
9330 /* issue set key request to SME*/
9331 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9332 pAdapter->sessionId, &setKey, &roamId );
9333
9334 if ( 0 != status )
9335 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309336 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009337 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
9338 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309339 status = -EINVAL;
9340 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009341 }
9342
9343
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309344 /* in case of IBSS as there was no information available about WEP keys during
9345 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07009346 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309347 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
9348 !( ( IW_AUTH_KEY_MGMT_802_1X
9349 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07009350 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
9351 )
9352 &&
9353 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
9354 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
9355 )
9356 )
9357 {
9358 setKey.keyDirection = eSIR_RX_ONLY;
9359 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9360
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309361 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009362 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309363 __func__, setKey.peerMac[0], setKey.peerMac[1],
9364 setKey.peerMac[2], setKey.peerMac[3],
9365 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009366 setKey.keyDirection);
9367
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309368 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009369 pAdapter->sessionId, &setKey, &roamId );
9370
9371 if ( 0 != status )
9372 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309373 hddLog(VOS_TRACE_LEVEL_ERROR,
9374 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009375 __func__, status);
9376 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309377 status = -EINVAL;
9378 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009379 }
9380 }
9381 }
9382
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309383end:
9384 /* Need to clear any trace of key value in the memory.
9385 * Thus zero out the memory even though it is local
9386 * variable.
9387 */
9388 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309389 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309390 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009391}
9392
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309393#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9394static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9395 struct net_device *ndev,
9396 u8 key_index, bool pairwise,
9397 const u8 *mac_addr,
9398 struct key_params *params
9399 )
9400#else
9401static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9402 struct net_device *ndev,
9403 u8 key_index, const u8 *mac_addr,
9404 struct key_params *params
9405 )
9406#endif
9407{
9408 int ret;
9409 vos_ssr_protect(__func__);
9410#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9411 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
9412 mac_addr, params);
9413#else
9414 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
9415 params);
9416#endif
9417 vos_ssr_unprotect(__func__);
9418
9419 return ret;
9420}
9421
Jeff Johnson295189b2012-06-20 16:38:30 -07009422/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309423 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009424 * This function is used to get the key information
9425 */
9426#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309427static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309428 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009429 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309430 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009431 const u8 *mac_addr, void *cookie,
9432 void (*callback)(void *cookie, struct key_params*)
9433 )
9434#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309435static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309436 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009437 struct net_device *ndev,
9438 u8 key_index, const u8 *mac_addr, void *cookie,
9439 void (*callback)(void *cookie, struct key_params*)
9440 )
9441#endif
9442{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309443 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309444 hdd_wext_state_t *pWextState = NULL;
9445 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009446 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309447 hdd_context_t *pHddCtx;
9448 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009449
9450 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309451
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309452 if (NULL == pAdapter)
9453 {
9454 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9455 "%s: HDD adapter is Null", __func__);
9456 return -ENODEV;
9457 }
9458
9459 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9460 ret = wlan_hdd_validate_context(pHddCtx);
9461 if (0 != ret)
9462 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309463 return ret;
9464 }
9465
9466 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9467 pRoamProfile = &(pWextState->roamProfile);
9468
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309469 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9470 __func__, hdd_device_modetoString(pAdapter->device_mode),
9471 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309472
Jeff Johnson295189b2012-06-20 16:38:30 -07009473 memset(&params, 0, sizeof(params));
9474
9475 if (CSR_MAX_NUM_KEY <= key_index)
9476 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309477 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07009478 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009480
9481 switch(pRoamProfile->EncryptionType.encryptionType[0])
9482 {
9483 case eCSR_ENCRYPT_TYPE_NONE:
9484 params.cipher = IW_AUTH_CIPHER_NONE;
9485 break;
9486
9487 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
9488 case eCSR_ENCRYPT_TYPE_WEP40:
9489 params.cipher = WLAN_CIPHER_SUITE_WEP40;
9490 break;
9491
9492 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
9493 case eCSR_ENCRYPT_TYPE_WEP104:
9494 params.cipher = WLAN_CIPHER_SUITE_WEP104;
9495 break;
9496
9497 case eCSR_ENCRYPT_TYPE_TKIP:
9498 params.cipher = WLAN_CIPHER_SUITE_TKIP;
9499 break;
9500
9501 case eCSR_ENCRYPT_TYPE_AES:
9502 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
9503 break;
9504
9505 default:
9506 params.cipher = IW_AUTH_CIPHER_NONE;
9507 break;
9508 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309509
c_hpothuaaf19692014-05-17 17:01:48 +05309510 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9511 TRACE_CODE_HDD_CFG80211_GET_KEY,
9512 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309513
Jeff Johnson295189b2012-06-20 16:38:30 -07009514 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
9515 params.seq_len = 0;
9516 params.seq = NULL;
9517 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
9518 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309519 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009520 return 0;
9521}
9522
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309523#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9524static int wlan_hdd_cfg80211_get_key(
9525 struct wiphy *wiphy,
9526 struct net_device *ndev,
9527 u8 key_index, bool pairwise,
9528 const u8 *mac_addr, void *cookie,
9529 void (*callback)(void *cookie, struct key_params*)
9530 )
9531#else
9532static int wlan_hdd_cfg80211_get_key(
9533 struct wiphy *wiphy,
9534 struct net_device *ndev,
9535 u8 key_index, const u8 *mac_addr, void *cookie,
9536 void (*callback)(void *cookie, struct key_params*)
9537 )
9538#endif
9539{
9540 int ret;
9541
9542 vos_ssr_protect(__func__);
9543#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9544 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
9545 mac_addr, cookie, callback);
9546#else
9547 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
9548 callback);
9549#endif
9550 vos_ssr_unprotect(__func__);
9551
9552 return ret;
9553}
9554
Jeff Johnson295189b2012-06-20 16:38:30 -07009555/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309556 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009557 * This function is used to delete the key information
9558 */
9559#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309560static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009561 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309562 u8 key_index,
9563 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009564 const u8 *mac_addr
9565 )
9566#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309567static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009568 struct net_device *ndev,
9569 u8 key_index,
9570 const u8 *mac_addr
9571 )
9572#endif
9573{
9574 int status = 0;
9575
9576 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309577 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009578 //it is observed that this is invalidating peer
9579 //key index whenever re-key is done. This is affecting data link.
9580 //It should be ok to ignore del_key.
9581#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309582 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
9583 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009584 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
9585 tCsrRoamSetKey setKey;
9586 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309587
Jeff Johnson295189b2012-06-20 16:38:30 -07009588 ENTER();
9589
9590 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
9591 __func__,pAdapter->device_mode);
9592
9593 if (CSR_MAX_NUM_KEY <= key_index)
9594 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309595 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009596 key_index);
9597
9598 return -EINVAL;
9599 }
9600
9601 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9602 setKey.keyId = key_index;
9603
9604 if (mac_addr)
9605 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9606 else
9607 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
9608
9609 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
9610
9611 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009612 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309613 )
9614 {
9615
9616 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07009617 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9618 if( pHostapdState->bssState == BSS_START)
9619 {
9620 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309621
Jeff Johnson295189b2012-06-20 16:38:30 -07009622 if ( status != eHAL_STATUS_SUCCESS )
9623 {
9624 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9625 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9626 __LINE__, status );
9627 }
9628 }
9629 }
9630 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309631 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07009632 )
9633 {
9634 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9635
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309636 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9637
9638 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009639 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309640 __func__, setKey.peerMac[0], setKey.peerMac[1],
9641 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07009642 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309643 if(pAdapter->sessionCtx.station.conn_info.connState ==
9644 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07009645 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309646 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009647 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309648
Jeff Johnson295189b2012-06-20 16:38:30 -07009649 if ( 0 != status )
9650 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309651 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009652 "%s: sme_RoamSetKey failure, returned %d",
9653 __func__, status);
9654 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9655 return -EINVAL;
9656 }
9657 }
9658 }
9659#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07009660 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009661 return status;
9662}
9663
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309664#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9665static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9666 struct net_device *ndev,
9667 u8 key_index,
9668 bool pairwise,
9669 const u8 *mac_addr
9670 )
9671#else
9672static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9673 struct net_device *ndev,
9674 u8 key_index,
9675 const u8 *mac_addr
9676 )
9677#endif
9678{
9679 int ret;
9680
9681 vos_ssr_protect(__func__);
9682#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9683 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
9684 mac_addr);
9685#else
9686 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
9687#endif
9688 vos_ssr_unprotect(__func__);
9689
9690 return ret;
9691}
9692
Jeff Johnson295189b2012-06-20 16:38:30 -07009693/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309694 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009695 * This function is used to set the default tx key index
9696 */
9697#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309698static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009699 struct net_device *ndev,
9700 u8 key_index,
9701 bool unicast, bool multicast)
9702#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309703static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009704 struct net_device *ndev,
9705 u8 key_index)
9706#endif
9707{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309708 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309709 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05309710 hdd_wext_state_t *pWextState;
9711 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309712 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009713
9714 ENTER();
9715
Gopichand Nakkala29149562013-05-10 21:43:41 +05309716 if ((NULL == pAdapter))
9717 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309718 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05309719 "invalid adapter");
9720 return -EINVAL;
9721 }
9722
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309723 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9724 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
9725 pAdapter->sessionId, key_index));
9726
Gopichand Nakkala29149562013-05-10 21:43:41 +05309727 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9728 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9729
9730 if ((NULL == pWextState) || (NULL == pHddStaCtx))
9731 {
9732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9733 "invalid Wext state or HDD context");
9734 return -EINVAL;
9735 }
9736
Arif Hussain6d2a3322013-11-17 19:50:10 -08009737 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009738 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309739
Jeff Johnson295189b2012-06-20 16:38:30 -07009740 if (CSR_MAX_NUM_KEY <= key_index)
9741 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309742 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009743 key_index);
9744
9745 return -EINVAL;
9746 }
9747
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309748 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9749 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309750 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009751 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309752 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009753 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309754
Jeff Johnson295189b2012-06-20 16:38:30 -07009755 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07009756 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309757 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009758 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05309759 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08009760 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309761 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08009762 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009763 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309764 {
9765 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07009766 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309767
Jeff Johnson295189b2012-06-20 16:38:30 -07009768 tCsrRoamSetKey setKey;
9769 v_U32_t roamId= 0xFF;
9770 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309771
9772 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009773 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309774
Jeff Johnson295189b2012-06-20 16:38:30 -07009775 Keys->defaultIndex = (u8)key_index;
9776 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9777 setKey.keyId = key_index;
9778 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309779
9780 vos_mem_copy(&setKey.Key[0],
9781 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009782 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309783
Gopichand Nakkala29149562013-05-10 21:43:41 +05309784 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309785
9786 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07009787 &pHddStaCtx->conn_info.bssId[0],
9788 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309789
Gopichand Nakkala29149562013-05-10 21:43:41 +05309790 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
9791 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
9792 eCSR_ENCRYPT_TYPE_WEP104)
9793 {
9794 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
9795 even though ap is configured for WEP-40 encryption. In this canse the key length
9796 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
9797 type(104) and switching encryption type to 40*/
9798 pWextState->roamProfile.EncryptionType.encryptionType[0] =
9799 eCSR_ENCRYPT_TYPE_WEP40;
9800 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
9801 eCSR_ENCRYPT_TYPE_WEP40;
9802 }
9803
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309804 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07009805 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309806
Jeff Johnson295189b2012-06-20 16:38:30 -07009807 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309808 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009809 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309810
Jeff Johnson295189b2012-06-20 16:38:30 -07009811 if ( 0 != status )
9812 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309813 hddLog(VOS_TRACE_LEVEL_ERROR,
9814 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009815 status);
9816 return -EINVAL;
9817 }
9818 }
9819 }
9820
9821 /* In SoftAp mode setting key direction for default mode */
9822 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
9823 {
9824 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
9825 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
9826 (eCSR_ENCRYPT_TYPE_AES !=
9827 pWextState->roamProfile.EncryptionType.encryptionType[0])
9828 )
9829 {
9830 /* Saving key direction for default key index to TX default */
9831 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9832 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
9833 }
9834 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309835 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009836 return status;
9837}
9838
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309839#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9840static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9841 struct net_device *ndev,
9842 u8 key_index,
9843 bool unicast, bool multicast)
9844#else
9845static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9846 struct net_device *ndev,
9847 u8 key_index)
9848#endif
9849{
9850 int ret;
9851 vos_ssr_protect(__func__);
9852#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9853 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
9854 multicast);
9855#else
9856 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
9857#endif
9858 vos_ssr_unprotect(__func__);
9859
9860 return ret;
9861}
9862
Jeff Johnson295189b2012-06-20 16:38:30 -07009863/*
9864 * FUNCTION: wlan_hdd_cfg80211_inform_bss
9865 * This function is used to inform the BSS details to nl80211 interface.
9866 */
9867static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
9868 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
9869{
9870 struct net_device *dev = pAdapter->dev;
9871 struct wireless_dev *wdev = dev->ieee80211_ptr;
9872 struct wiphy *wiphy = wdev->wiphy;
9873 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
9874 int chan_no;
9875 int ie_length;
9876 const char *ie;
9877 unsigned int freq;
9878 struct ieee80211_channel *chan;
9879 int rssi = 0;
9880 struct cfg80211_bss *bss = NULL;
9881
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 if( NULL == pBssDesc )
9883 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009884 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009885 return bss;
9886 }
9887
9888 chan_no = pBssDesc->channelId;
9889 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
9890 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
9891
9892 if( NULL == ie )
9893 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009894 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009895 return bss;
9896 }
9897
9898#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
9899 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
9900 {
9901 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9902 }
9903 else
9904 {
9905 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9906 }
9907#else
9908 freq = ieee80211_channel_to_frequency(chan_no);
9909#endif
9910
9911 chan = __ieee80211_get_channel(wiphy, freq);
9912
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05309913 if (!chan) {
9914 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
9915 return NULL;
9916 }
9917
Abhishek Singhaee43942014-06-16 18:55:47 +05309918 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07009919
Anand N Sunkad9f80b742015-07-30 20:05:51 +05309920 return cfg80211_inform_bss(wiphy, chan,
9921#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
9922 CFG80211_BSS_FTYPE_UNKNOWN,
9923#endif
9924 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309925 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07009926 pBssDesc->capabilityInfo,
9927 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05309928 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07009929}
9930
9931
9932
9933/*
9934 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
9935 * This function is used to inform the BSS details to nl80211 interface.
9936 */
9937struct cfg80211_bss*
9938wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
9939 tSirBssDescription *bss_desc
9940 )
9941{
9942 /*
9943 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
9944 already exists in bss data base of cfg80211 for that particular BSS ID.
9945 Using cfg80211_inform_bss_frame to update the bss entry instead of
9946 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
9947 now there is no possibility to get the mgmt(probe response) frame from PE,
9948 converting bss_desc to ieee80211_mgmt(probe response) and passing to
9949 cfg80211_inform_bss_frame.
9950 */
9951 struct net_device *dev = pAdapter->dev;
9952 struct wireless_dev *wdev = dev->ieee80211_ptr;
9953 struct wiphy *wiphy = wdev->wiphy;
9954 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009955#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9956 qcom_ie_age *qie_age = NULL;
9957 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
9958#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009960#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009961 const char *ie =
9962 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
9963 unsigned int freq;
9964 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309965 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009966 struct cfg80211_bss *bss_status = NULL;
9967 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
9968 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07009969 hdd_context_t *pHddCtx;
9970 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07009971#ifdef WLAN_OPEN_SOURCE
9972 struct timespec ts;
9973#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009974
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309975
Wilson Yangf80a0542013-10-07 13:02:37 -07009976 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9977 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -07009978 if (0 != status)
9979 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009980 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009981 }
9982
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309983 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07009984 if (!mgmt)
9985 {
9986 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9987 "%s: memory allocation failed ", __func__);
9988 return NULL;
9989 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009990
Jeff Johnson295189b2012-06-20 16:38:30 -07009991 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07009992
9993#ifdef WLAN_OPEN_SOURCE
9994 /* Android does not want the timestamp from the frame.
9995 Instead it wants a monotonic increasing value */
9996 get_monotonic_boottime(&ts);
9997 mgmt->u.probe_resp.timestamp =
9998 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
9999#else
10000 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070010001 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
10002 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070010003
10004#endif
10005
Jeff Johnson295189b2012-06-20 16:38:30 -070010006 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
10007 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080010008
10009#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
10010 /* GPS Requirement: need age ie per entry. Using vendor specific. */
10011 /* Assuming this is the last IE, copy at the end */
10012 ie_length -=sizeof(qcom_ie_age);
10013 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
10014 qie_age->element_id = QCOM_VENDOR_IE_ID;
10015 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
10016 qie_age->oui_1 = QCOM_OUI1;
10017 qie_age->oui_2 = QCOM_OUI2;
10018 qie_age->oui_3 = QCOM_OUI3;
10019 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
10020 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
10021#endif
10022
Jeff Johnson295189b2012-06-20 16:38:30 -070010023 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053010024 if (bss_desc->fProbeRsp)
10025 {
10026 mgmt->frame_control |=
10027 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
10028 }
10029 else
10030 {
10031 mgmt->frame_control |=
10032 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
10033 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010034
10035#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010036 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070010037 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
10038 {
10039 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
10040 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010041 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070010042 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
10043
10044 {
10045 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
10046 }
10047 else
10048 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010049 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
10050 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070010051 kfree(mgmt);
10052 return NULL;
10053 }
10054#else
10055 freq = ieee80211_channel_to_frequency(chan_no);
10056#endif
10057 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080010058 /*when the band is changed on the fly using the GUI, three things are done
10059 * 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)
10060 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
10061 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
10062 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
10063 * and discards the channels correponding to previous band and calls back with zero bss results.
10064 * 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
10065 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
10066 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
10067 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
10068 * So drop the bss and continue to next bss.
10069 */
10070 if(chan == NULL)
10071 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010072 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -070010073 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080010074 return NULL;
10075 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053010076 /*To keep the rssi icon of the connected AP in the scan window
10077 *and the rssi icon of the wireless networks in sync
10078 * */
10079 if (( eConnectionState_Associated ==
10080 pAdapter->sessionCtx.station.conn_info.connState ) &&
10081 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
10082 pAdapter->sessionCtx.station.conn_info.bssId,
10083 WNI_CFG_BSSID_LEN)) &&
10084 (pHddCtx->hdd_wlan_suspended == FALSE))
10085 {
10086 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
10087 rssi = (pAdapter->rssi * 100);
10088 }
10089 else
10090 {
10091 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
10092 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010093
Nirav Shah20ac06f2013-12-12 18:14:06 +053010094 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053010095 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
10096 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053010097
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
10099 frame_len, rssi, GFP_KERNEL);
10100 kfree(mgmt);
10101 return bss_status;
10102}
10103
10104/*
10105 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
10106 * This function is used to update the BSS data base of CFG8011
10107 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010108struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070010109 tCsrRoamInfo *pRoamInfo
10110 )
10111{
10112 tCsrRoamConnectedProfile roamProfile;
10113 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10114 struct cfg80211_bss *bss = NULL;
10115
10116 ENTER();
10117
10118 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
10119 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
10120
10121 if (NULL != roamProfile.pBssDesc)
10122 {
Girish Gowlif4b68022014-08-28 23:18:57 +053010123 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10124 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010125
10126 if (NULL == bss)
10127 {
10128 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
10129 __func__);
10130 }
10131
10132 sme_RoamFreeConnectProfile(hHal, &roamProfile);
10133 }
10134 else
10135 {
10136 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
10137 __func__);
10138 }
10139 return bss;
10140}
10141
10142/*
10143 * FUNCTION: wlan_hdd_cfg80211_update_bss
10144 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010145static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
10146 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070010147 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010148{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010149 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010150 tCsrScanResultInfo *pScanResult;
10151 eHalStatus status = 0;
10152 tScanResultHandle pResult;
10153 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070010154 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010155 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070010156 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010157
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010158 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10159 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
10160 NO_SESSION, pAdapter->sessionId));
10161
Wilson Yangf80a0542013-10-07 13:02:37 -070010162 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10163
10164 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -070010165 {
Wilson Yangf80a0542013-10-07 13:02:37 -070010166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10167 "%s:LOGP in Progress. Ignore!!!",__func__);
10168 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010169 }
10170
Wilson Yangf80a0542013-10-07 13:02:37 -070010171
10172 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +053010173 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -070010174 {
10175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10176 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
10177 return VOS_STATUS_E_PERM;
10178 }
10179
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010180 if (pAdapter->request != NULL)
10181 {
10182 if ((pAdapter->request->n_ssids == 1)
10183 && (pAdapter->request->ssids != NULL)
10184 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
10185 is_p2p_scan = true;
10186 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010187 /*
10188 * start getting scan results and populate cgf80211 BSS database
10189 */
10190 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
10191
10192 /* no scan results */
10193 if (NULL == pResult)
10194 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010195 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
10196 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053010197 wlan_hdd_get_frame_logs(pAdapter,
10198 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070010199 return status;
10200 }
10201
10202 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
10203
10204 while (pScanResult)
10205 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010206 /*
10207 * cfg80211_inform_bss() is not updating ie field of bss entry, if
10208 * entry already exists in bss data base of cfg80211 for that
10209 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
10210 * bss entry instead of cfg80211_inform_bss, But this call expects
10211 * mgmt packet as input. As of now there is no possibility to get
10212 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070010213 * ieee80211_mgmt(probe response) and passing to c
10214 * fg80211_inform_bss_frame.
10215 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010216 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
10217 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
10218 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010219 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10220 continue; //Skip the non p2p bss entries
10221 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010222 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10223 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010224
Jeff Johnson295189b2012-06-20 16:38:30 -070010225
10226 if (NULL == bss_status)
10227 {
10228 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010229 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010230 }
10231 else
10232 {
Yue Maf49ba872013-08-19 12:04:25 -070010233 cfg80211_put_bss(
10234#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10235 wiphy,
10236#endif
10237 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010238 }
10239
10240 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10241 }
10242
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010243 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010244 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010245 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010246}
10247
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010248void
10249hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
10250{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010251 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080010252 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010253} /****** end hddPrintMacAddr() ******/
10254
10255void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010256hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010257{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010258 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010259 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010260 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
10261 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
10262 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010263} /****** end hddPrintPmkId() ******/
10264
10265//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
10266//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
10267
10268//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
10269//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
10270
10271#define dump_bssid(bssid) \
10272 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010273 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
10274 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010275 }
10276
10277#define dump_pmkid(pMac, pmkid) \
10278 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010279 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
10280 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010281 }
10282
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070010283#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010284/*
10285 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
10286 * This function is used to notify the supplicant of a new PMKSA candidate.
10287 */
10288int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010289 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010290 int index, bool preauth )
10291{
Jeff Johnsone7245742012-09-05 17:12:55 -070010292#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010293 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010294 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010295
10296 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070010297 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010298
10299 if( NULL == pRoamInfo )
10300 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010301 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010302 return -EINVAL;
10303 }
10304
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010305 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
10306 {
10307 dump_bssid(pRoamInfo->bssid);
10308 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010309 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010310 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010311#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010312 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010313}
10314#endif //FEATURE_WLAN_LFR
10315
Yue Maef608272013-04-08 23:09:17 -070010316#ifdef FEATURE_WLAN_LFR_METRICS
10317/*
10318 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
10319 * 802.11r/LFR metrics reporting function to report preauth initiation
10320 *
10321 */
10322#define MAX_LFR_METRICS_EVENT_LENGTH 100
10323VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
10324 tCsrRoamInfo *pRoamInfo)
10325{
10326 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10327 union iwreq_data wrqu;
10328
10329 ENTER();
10330
10331 if (NULL == pAdapter)
10332 {
10333 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10334 return VOS_STATUS_E_FAILURE;
10335 }
10336
10337 /* create the event */
10338 memset(&wrqu, 0, sizeof(wrqu));
10339 memset(metrics_notification, 0, sizeof(metrics_notification));
10340
10341 wrqu.data.pointer = metrics_notification;
10342 wrqu.data.length = scnprintf(metrics_notification,
10343 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
10344 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10345
10346 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10347
10348 EXIT();
10349
10350 return VOS_STATUS_SUCCESS;
10351}
10352
10353/*
10354 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
10355 * 802.11r/LFR metrics reporting function to report preauth completion
10356 * or failure
10357 */
10358VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
10359 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
10360{
10361 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10362 union iwreq_data wrqu;
10363
10364 ENTER();
10365
10366 if (NULL == pAdapter)
10367 {
10368 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10369 return VOS_STATUS_E_FAILURE;
10370 }
10371
10372 /* create the event */
10373 memset(&wrqu, 0, sizeof(wrqu));
10374 memset(metrics_notification, 0, sizeof(metrics_notification));
10375
10376 scnprintf(metrics_notification, sizeof(metrics_notification),
10377 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
10378 MAC_ADDR_ARRAY(pRoamInfo->bssid));
10379
10380 if (1 == preauth_status)
10381 strncat(metrics_notification, " TRUE", 5);
10382 else
10383 strncat(metrics_notification, " FALSE", 6);
10384
10385 wrqu.data.pointer = metrics_notification;
10386 wrqu.data.length = strlen(metrics_notification);
10387
10388 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10389
10390 EXIT();
10391
10392 return VOS_STATUS_SUCCESS;
10393}
10394
10395/*
10396 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
10397 * 802.11r/LFR metrics reporting function to report handover initiation
10398 *
10399 */
10400VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
10401 tCsrRoamInfo *pRoamInfo)
10402{
10403 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10404 union iwreq_data wrqu;
10405
10406 ENTER();
10407
10408 if (NULL == pAdapter)
10409 {
10410 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10411 return VOS_STATUS_E_FAILURE;
10412 }
10413
10414 /* create the event */
10415 memset(&wrqu, 0, sizeof(wrqu));
10416 memset(metrics_notification, 0, sizeof(metrics_notification));
10417
10418 wrqu.data.pointer = metrics_notification;
10419 wrqu.data.length = scnprintf(metrics_notification,
10420 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
10421 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10422
10423 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10424
10425 EXIT();
10426
10427 return VOS_STATUS_SUCCESS;
10428}
10429#endif
10430
Jeff Johnson295189b2012-06-20 16:38:30 -070010431/*
10432 * FUNCTION: hdd_cfg80211_scan_done_callback
10433 * scanning callback function, called after finishing scan
10434 *
10435 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010436static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070010437 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
10438{
10439 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010440 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070010441 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010442 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010443 struct cfg80211_scan_request *req = NULL;
10444 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010445 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010446 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010447 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010448 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010449
10450 ENTER();
10451
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010452 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053010453 if (NULL == pHddCtx) {
10454 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010455 goto allow_suspend;
10456 }
10457
10458 pScanInfo = &pHddCtx->scan_info;
10459
Jeff Johnson295189b2012-06-20 16:38:30 -070010460 hddLog(VOS_TRACE_LEVEL_INFO,
10461 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080010462 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010463 __func__, halHandle, pContext, (int) scanId, (int) status);
10464
Kiet Lamac06e2c2013-10-23 16:25:07 +053010465 pScanInfo->mScanPendingCounter = 0;
10466
Jeff Johnson295189b2012-06-20 16:38:30 -070010467 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010468 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070010469 &pScanInfo->scan_req_completion_event,
10470 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010471 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070010472 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010473 hddLog(VOS_TRACE_LEVEL_ERROR,
10474 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070010475 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010476 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010477 }
10478
Yue Maef608272013-04-08 23:09:17 -070010479 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010480 {
10481 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010482 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010483 }
10484
10485 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010486 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070010487 {
10488 hddLog(VOS_TRACE_LEVEL_INFO,
10489 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010490 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070010491 (int) scanId);
10492 }
10493
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010494 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010495 pAdapter);
10496
10497 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010498 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010499
10500
10501 /* If any client wait scan result through WEXT
10502 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010503 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070010504 {
10505 /* The other scan request waiting for current scan finish
10506 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010507 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010508 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010509 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070010510 }
10511 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010512 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010513 {
10514 struct net_device *dev = pAdapter->dev;
10515 union iwreq_data wrqu;
10516 int we_event;
10517 char *msg;
10518
10519 memset(&wrqu, '\0', sizeof(wrqu));
10520 we_event = SIOCGIWSCAN;
10521 msg = NULL;
10522 wireless_send_event(dev, we_event, &wrqu, msg);
10523 }
10524 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010525 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010526
10527 /* Get the Scan Req */
10528 req = pAdapter->request;
10529
10530 if (!req)
10531 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010532 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010533 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010534 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010535 }
10536
Jeff Johnson295189b2012-06-20 16:38:30 -070010537 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070010538 /* Scan is no longer pending */
10539 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010540
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010541 /* last_scan_timestamp is used to decide if new scan
10542 * is needed or not on station interface. If last station
10543 * scan time and new station scan time is less then
10544 * last_scan_timestamp ; driver will return cached scan.
10545 */
10546 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
10547 {
10548 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
10549
10550 if ( req->n_channels )
10551 {
10552 for (i = 0; i < req->n_channels ; i++ )
10553 {
10554 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
10555 }
10556 /* store no of channel scanned */
10557 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
10558 }
10559
10560 }
10561
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070010562 /*
10563 * cfg80211_scan_done informing NL80211 about completion
10564 * of scanning
10565 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010566 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
10567 {
10568 aborted = true;
10569 }
10570 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080010571 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070010572
Siddharth Bhal76972212014-10-15 16:22:51 +053010573 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
10574 /* Generate new random mac addr for next scan */
10575 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
10576 hdd_processSpoofMacAddrRequest(pHddCtx);
10577 }
10578
Jeff Johnsone7245742012-09-05 17:12:55 -070010579allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010580 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010581 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070010582
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010583 /* Acquire wakelock to handle the case where APP's tries to suspend
10584 * immediatly after the driver gets connect request(i.e after scan)
10585 * from supplicant, this result in app's is suspending and not able
10586 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010587 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010588
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010589#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010590 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010591#endif
10592
Jeff Johnson295189b2012-06-20 16:38:30 -070010593 EXIT();
10594 return 0;
10595}
10596
10597/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053010598 * FUNCTION: hdd_isConnectionInProgress
10599 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010600 *
10601 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010602v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010603{
10604 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10605 hdd_station_ctx_t *pHddStaCtx = NULL;
10606 hdd_adapter_t *pAdapter = NULL;
10607 VOS_STATUS status = 0;
10608 v_U8_t staId = 0;
10609 v_U8_t *staMac = NULL;
10610
c_hpothu9b781ba2013-12-30 20:57:45 +053010611 if (TRUE == pHddCtx->btCoexModeSet)
10612 {
10613 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053010614 FL("BTCoex Mode operation in progress"));
10615 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053010616 }
10617
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010618 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10619
10620 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10621 {
10622 pAdapter = pAdapterNode->pAdapter;
10623
10624 if( pAdapter )
10625 {
10626 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010627 "%s: Adapter with device mode %s (%d) exists",
10628 __func__, hdd_device_modetoString(pAdapter->device_mode),
10629 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010630 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053010631 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10632 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
10633 (eConnectionState_Connecting ==
10634 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
10635 {
10636 hddLog(VOS_TRACE_LEVEL_ERROR,
10637 "%s: %p(%d) Connection is in progress", __func__,
10638 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10639 return VOS_TRUE;
10640 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010641 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053010642 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010643 {
10644 hddLog(VOS_TRACE_LEVEL_ERROR,
10645 "%s: %p(%d) Reassociation is in progress", __func__,
10646 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10647 return VOS_TRUE;
10648 }
10649 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010650 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10651 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010652 {
10653 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10654 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010655 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010656 {
10657 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
10658 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010659 "%s: client " MAC_ADDRESS_STR
10660 " is in the middle of WPS/EAPOL exchange.", __func__,
10661 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010662 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010663 }
10664 }
10665 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
10666 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
10667 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010668 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10669 ptSapContext pSapCtx = NULL;
10670 pSapCtx = VOS_GET_SAP_CB(pVosContext);
10671 if(pSapCtx == NULL){
10672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10673 FL("psapCtx is NULL"));
10674 return VOS_FALSE;
10675 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010676 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
10677 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010678 if ((pSapCtx->aStaInfo[staId].isUsed) &&
10679 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010680 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010681 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010682
10683 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010684 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
10685 "middle of WPS/EAPOL exchange.", __func__,
10686 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010687 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010688 }
10689 }
10690 }
10691 }
10692 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10693 pAdapterNode = pNext;
10694 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053010695 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010696}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010697
10698/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010699 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070010700 * this scan respond to scan trigger and update cfg80211 scan database
10701 * later, scan dump command can be used to recieve scan results
10702 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010703int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010704#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10705 struct net_device *dev,
10706#endif
10707 struct cfg80211_scan_request *request)
10708{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010709 hdd_adapter_t *pAdapter = NULL;
10710 hdd_context_t *pHddCtx = NULL;
10711 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010712 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010713 tCsrScanRequest scanRequest;
10714 tANI_U8 *channelList = NULL, i;
10715 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010716 int status;
10717 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010718 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010719 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053010720 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010721 bool is_p2p_scan = false;
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010722 v_S7_t rssi=0;
10723 hdd_station_ctx_t *pHddStaCtx=NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010724
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010725#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
10726 struct net_device *dev = NULL;
10727 if (NULL == request)
10728 {
10729 hddLog(VOS_TRACE_LEVEL_ERROR,
10730 "%s: scan req param null", __func__);
10731 return -EINVAL;
10732 }
10733 dev = request->wdev->netdev;
10734#endif
10735
10736 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
10737 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
10738 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10739
Jeff Johnson295189b2012-06-20 16:38:30 -070010740 ENTER();
10741
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010742 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10743 __func__, hdd_device_modetoString(pAdapter->device_mode),
10744 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010745
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010746 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010747 if (0 != status)
10748 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010749 return status;
10750 }
10751
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010752 if (NULL == pwextBuf)
10753 {
10754 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
10755 __func__);
10756 return -EIO;
10757 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010758 cfg_param = pHddCtx->cfg_ini;
10759 pScanInfo = &pHddCtx->scan_info;
10760
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010761 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10762 if ( (pHddStaCtx != NULL) && (TRUE == hdd_connIsConnected(pHddStaCtx)))
10763 {
10764 wlan_hdd_get_roam_rssi(pAdapter, &rssi);
10765 hddLog(VOS_TRACE_LEVEL_INFO, FL("rssi: %d"), rssi);
10766 }
10767
Jeff Johnson295189b2012-06-20 16:38:30 -070010768#ifdef WLAN_BTAMP_FEATURE
10769 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010770 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070010771 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010772 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010773 "%s: No scanning when AMP is on", __func__);
10774 return -EOPNOTSUPP;
10775 }
10776#endif
10777 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010778 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010779 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010780 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010781 "%s: Not scanning on device_mode = %s (%d)",
10782 __func__, hdd_device_modetoString(pAdapter->device_mode),
10783 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010784 return -EOPNOTSUPP;
10785 }
10786
10787 if (TRUE == pScanInfo->mScanPending)
10788 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010789 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
10790 {
10791 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
10792 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010793 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010794 }
10795
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010796 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070010797 //Channel and action frame is pending
10798 //Otherwise Cancel Remain On Channel and allow Scan
10799 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010800 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070010801 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010802 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010803 return -EBUSY;
10804 }
10805
Jeff Johnson295189b2012-06-20 16:38:30 -070010806 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
10807 {
10808 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080010809 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010810 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010811 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010812 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
10813 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010814 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010815 "%s: MAX TM Level Scan not allowed", __func__);
10816 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010817 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010818 }
10819 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
10820
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010821 /* Check if scan is allowed at this point of time.
10822 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010823 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010824 {
10825 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
10826 return -EBUSY;
10827 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010828
Jeff Johnson295189b2012-06-20 16:38:30 -070010829 vos_mem_zero( &scanRequest, sizeof(scanRequest));
10830
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010831 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
10832 * Becasue of this, driver is assuming that this is not wildcard scan and so
10833 * is not aging out the scan results.
10834 */
10835 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070010836 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010837 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010838 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010839
10840 if ((request->ssids) && (0 < request->n_ssids))
10841 {
10842 tCsrSSIDInfo *SsidInfo;
10843 int j;
10844 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
10845 /* Allocate num_ssid tCsrSSIDInfo structure */
10846 SsidInfo = scanRequest.SSIDs.SSIDList =
10847 ( tCsrSSIDInfo *)vos_mem_malloc(
10848 request->n_ssids*sizeof(tCsrSSIDInfo));
10849
10850 if(NULL == scanRequest.SSIDs.SSIDList)
10851 {
10852 hddLog(VOS_TRACE_LEVEL_ERROR,
10853 "%s: memory alloc failed SSIDInfo buffer", __func__);
10854 return -ENOMEM;
10855 }
10856
10857 /* copy all the ssid's and their length */
10858 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
10859 {
10860 /* get the ssid length */
10861 SsidInfo->SSID.length = request->ssids[j].ssid_len;
10862 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
10863 SsidInfo->SSID.length);
10864 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
10865 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
10866 j, SsidInfo->SSID.ssId);
10867 }
10868 /* set the scan type to active */
10869 scanRequest.scanType = eSIR_ACTIVE_SCAN;
10870 }
10871 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070010872 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010873 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10874 TRACE_CODE_HDD_CFG80211_SCAN,
10875 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070010876 /* set the scan type to active */
10877 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010878 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010879 else
10880 {
10881 /*Set the scan type to default type, in this case it is ACTIVE*/
10882 scanRequest.scanType = pScanInfo->scan_mode;
10883 }
10884 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
10885 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070010886
10887 /* set BSSType to default type */
10888 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
10889
10890 /*TODO: scan the requested channels only*/
10891
10892 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010893 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070010894 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010895 hddLog(VOS_TRACE_LEVEL_WARN,
10896 "No of Scan Channels exceeded limit: %d", request->n_channels);
10897 request->n_channels = MAX_CHANNEL;
10898 }
10899
10900 hddLog(VOS_TRACE_LEVEL_INFO,
10901 "No of Scan Channels: %d", request->n_channels);
10902
10903
10904 if( request->n_channels )
10905 {
10906 char chList [(request->n_channels*5)+1];
10907 int len;
10908 channelList = vos_mem_malloc( request->n_channels );
10909 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053010910 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010911 hddLog(VOS_TRACE_LEVEL_ERROR,
10912 "%s: memory alloc failed channelList", __func__);
10913 status = -ENOMEM;
10914 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053010915 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010916
10917 for( i = 0, len = 0; i < request->n_channels ; i++ )
10918 {
10919 channelList[i] = request->channels[i]->hw_value;
10920 len += snprintf(chList+len, 5, "%d ", channelList[i]);
10921 }
10922
Nirav Shah20ac06f2013-12-12 18:14:06 +053010923 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010924 "Channel-List: %s ", chList);
10925 }
c_hpothu53512302014-04-15 18:49:53 +053010926
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010927 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
10928 scanRequest.ChannelInfo.ChannelList = channelList;
10929
10930 /* set requestType to full scan */
10931 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
10932
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010933 /* if there is back to back scan happening in driver with in
10934 * nDeferScanTimeInterval interval driver should defer new scan request
10935 * and should provide last cached scan results instead of new channel list.
10936 * This rule is not applicable if scan is p2p scan.
10937 * This condition will work only in case when last request no of channels
10938 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053010939 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053010940 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010941 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010942
Sushant Kaushik86592172015-04-27 16:35:03 +053010943 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
10944 /* if wps ie is NULL , then only defer scan */
10945 if ( pWpsIe == NULL &&
10946 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053010947 {
10948 if ( pScanInfo->last_scan_timestamp !=0 &&
10949 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
10950 {
10951 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
10952 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
10953 vos_mem_compare(pScanInfo->last_scan_channelList,
10954 channelList, pScanInfo->last_scan_numChannels))
10955 {
10956 hddLog(VOS_TRACE_LEVEL_WARN,
10957 " New and old station scan time differ is less then %u",
10958 pHddCtx->cfg_ini->nDeferScanTimeInterval);
10959
10960 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010961 pAdapter);
10962
Agarwal Ashish57e84372014-12-05 18:26:53 +053010963 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010964 "Return old cached scan as all channels and no of channels are same");
10965
Agarwal Ashish57e84372014-12-05 18:26:53 +053010966 if (0 > ret)
10967 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010968
Agarwal Ashish57e84372014-12-05 18:26:53 +053010969 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010970
10971 status = eHAL_STATUS_SUCCESS;
10972 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053010973 }
10974 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010975 }
10976
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010977 /* Flush the scan results(only p2p beacons) for STA scan and P2P
10978 * search (Flush on both full scan and social scan but not on single
10979 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
10980 */
10981
10982 /* Supplicant does single channel scan after 8-way handshake
10983 * and in that case driver shoudnt flush scan results. If
10984 * driver flushes the scan results here and unfortunately if
10985 * the AP doesnt respond to our probe req then association
10986 * fails which is not desired
10987 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010988 if ((request->n_ssids == 1)
10989 && (request->ssids != NULL)
10990 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
10991 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010992
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010993 if( is_p2p_scan ||
10994 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010995 {
10996 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
10997 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
10998 pAdapter->sessionId );
10999 }
11000
11001 if( request->ie_len )
11002 {
11003 /* save this for future association (join requires this) */
11004 /*TODO: Array needs to be converted to dynamic allocation,
11005 * as multiple ie.s can be sent in cfg80211_scan_request structure
11006 * CR 597966
11007 */
11008 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
11009 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
11010 pScanInfo->scanAddIE.length = request->ie_len;
11011
11012 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11013 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
11014 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070011015 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011016 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070011017 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011018 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
11019 memcpy( pwextBuf->roamProfile.addIEScan,
11020 request->ie, request->ie_len);
11021 }
11022 else
11023 {
11024 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
11025 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070011026 }
11027
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011028 }
11029 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
11030 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
11031
11032 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
11033 request->ie_len);
11034 if (pP2pIe != NULL)
11035 {
11036#ifdef WLAN_FEATURE_P2P_DEBUG
11037 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
11038 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
11039 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053011040 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011041 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
11042 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
11043 "Go nego completed to Connection is started");
11044 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
11045 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053011046 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011047 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
11048 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070011049 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011050 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
11051 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
11052 "Disconnected state to Connection is started");
11053 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
11054 "for 4way Handshake");
11055 }
11056#endif
11057
11058 /* no_cck will be set during p2p find to disable 11b rates */
11059 if(TRUE == request->no_cck)
11060 {
11061 hddLog(VOS_TRACE_LEVEL_INFO,
11062 "%s: This is a P2P Search", __func__);
11063 scanRequest.p2pSearch = 1;
11064
11065 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053011066 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011067 /* set requestType to P2P Discovery */
11068 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
11069 }
11070
11071 /*
11072 Skip Dfs Channel in case of P2P Search
11073 if it is set in ini file
11074 */
11075 if(cfg_param->skipDfsChnlInP2pSearch)
11076 {
11077 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053011078 }
11079 else
11080 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011081 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053011082 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011083
Agarwal Ashish4f616132013-12-30 23:32:50 +053011084 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011085 }
11086 }
11087
11088 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
11089
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053011090#ifdef FEATURE_WLAN_TDLS
11091 /* if tdls disagree scan right now, return immediately.
11092 tdls will schedule the scan when scan is allowed. (return SUCCESS)
11093 or will reject the scan if any TDLS is in progress. (return -EBUSY)
11094 */
11095 status = wlan_hdd_tdls_scan_callback (pAdapter,
11096 wiphy,
11097#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11098 dev,
11099#endif
11100 request);
11101 if(status <= 0)
11102 {
11103 if(!status)
11104 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
11105 "scan rejected %d", __func__, status);
11106 else
11107 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
11108 __func__, status);
11109
11110 return status;
11111 }
11112#endif
11113
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070011114 /* acquire the wakelock to avoid the apps suspend during the scan. To
11115 * address the following issues.
11116 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
11117 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
11118 * for long time, this result in apps running at full power for long time.
11119 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
11120 * be stuck in full power because of resume BMPS
11121 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011122 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070011123
Nirav Shah20ac06f2013-12-12 18:14:06 +053011124 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
11125 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011126 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
11127 scanRequest.requestType, scanRequest.scanType,
11128 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053011129 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
11130
Siddharth Bhal76972212014-10-15 16:22:51 +053011131 if (pHddCtx->spoofMacAddr.isEnabled)
11132 {
11133 hddLog(VOS_TRACE_LEVEL_INFO,
11134 "%s: MAC Spoofing enabled for current scan", __func__);
11135 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
11136 * to fill TxBds for probe request during current scan
11137 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011138 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053011139 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011140
11141 if(status != VOS_STATUS_SUCCESS)
11142 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011143 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011144 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053011145#ifdef FEATURE_WLAN_TDLS
11146 wlan_hdd_tdls_scan_done_callback(pAdapter);
11147#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011148 goto free_mem;
11149 }
Siddharth Bhal76972212014-10-15 16:22:51 +053011150 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053011151 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070011152 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011153 pAdapter->sessionId, &scanRequest, &scanId,
11154 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070011155
Jeff Johnson295189b2012-06-20 16:38:30 -070011156 if (eHAL_STATUS_SUCCESS != status)
11157 {
11158 hddLog(VOS_TRACE_LEVEL_ERROR,
11159 "%s: sme_ScanRequest returned error %d", __func__, status);
11160 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011161 if(eHAL_STATUS_RESOURCES == status)
11162 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053011163 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
11164 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011165 status = -EBUSY;
11166 } else {
11167 status = -EIO;
11168 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011169 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053011170
11171#ifdef FEATURE_WLAN_TDLS
11172 wlan_hdd_tdls_scan_done_callback(pAdapter);
11173#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011174 goto free_mem;
11175 }
11176
11177 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053011178 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011179 pAdapter->request = request;
11180 pScanInfo->scanId = scanId;
11181
11182 complete(&pScanInfo->scan_req_completion_event);
11183
11184free_mem:
11185 if( scanRequest.SSIDs.SSIDList )
11186 {
11187 vos_mem_free(scanRequest.SSIDs.SSIDList);
11188 }
11189
11190 if( channelList )
11191 vos_mem_free( channelList );
11192
11193 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011194 return status;
11195}
11196
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011197int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
11198#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11199 struct net_device *dev,
11200#endif
11201 struct cfg80211_scan_request *request)
11202{
11203 int ret;
11204
11205 vos_ssr_protect(__func__);
11206 ret = __wlan_hdd_cfg80211_scan(wiphy,
11207#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11208 dev,
11209#endif
11210 request);
11211 vos_ssr_unprotect(__func__);
11212
11213 return ret;
11214}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011215
11216void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
11217{
11218 v_U8_t iniDot11Mode =
11219 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
11220 eHddDot11Mode hddDot11Mode = iniDot11Mode;
11221
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011222 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
11223 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011224 switch ( iniDot11Mode )
11225 {
11226 case eHDD_DOT11_MODE_AUTO:
11227 case eHDD_DOT11_MODE_11ac:
11228 case eHDD_DOT11_MODE_11ac_ONLY:
11229#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053011230 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
11231 sme_IsFeatureSupportedByFW(DOT11AC) )
11232 hddDot11Mode = eHDD_DOT11_MODE_11ac;
11233 else
11234 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011235#else
11236 hddDot11Mode = eHDD_DOT11_MODE_11n;
11237#endif
11238 break;
11239 case eHDD_DOT11_MODE_11n:
11240 case eHDD_DOT11_MODE_11n_ONLY:
11241 hddDot11Mode = eHDD_DOT11_MODE_11n;
11242 break;
11243 default:
11244 hddDot11Mode = iniDot11Mode;
11245 break;
11246 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011247#ifdef WLAN_FEATURE_AP_HT40_24G
11248 if (operationChannel > SIR_11B_CHANNEL_END)
11249#endif
11250 {
11251 /* This call decides required channel bonding mode */
11252 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011253 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
11254 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011255 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011256}
11257
Jeff Johnson295189b2012-06-20 16:38:30 -070011258/*
11259 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011260 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011261 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011262int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011263 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070011264{
11265 int status = 0;
11266 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080011267 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011268 v_U32_t roamId;
11269 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070011270 eCsrAuthType RSNAuthType;
11271
11272 ENTER();
11273
11274 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080011275 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11276
11277 status = wlan_hdd_validate_context(pHddCtx);
11278 if (status)
11279 {
Yue Mae36e3552014-03-05 17:06:20 -080011280 return status;
11281 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011282
Jeff Johnson295189b2012-06-20 16:38:30 -070011283 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
11284 {
11285 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
11286 return -EINVAL;
11287 }
11288
11289 pRoamProfile = &pWextState->roamProfile;
11290
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011291 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070011292 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011293 hdd_station_ctx_t *pHddStaCtx;
11294 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011295
Siddharth Bhalda0d1622015-04-24 15:47:49 +053011296 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
11297
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011298 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070011299 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
11300 {
11301 /*QoS not enabled in cfg file*/
11302 pRoamProfile->uapsd_mask = 0;
11303 }
11304 else
11305 {
11306 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011307 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070011308 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
11309 }
11310
11311 pRoamProfile->SSIDs.numOfSSIDs = 1;
11312 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
11313 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011314 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070011315 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
11316 ssid, ssid_len);
11317
11318 if (bssid)
11319 {
11320 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
11321 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
11322 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011323 /* Save BSSID in seperate variable as well, as RoamProfile
11324 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070011325 case of join failure we should send valid BSSID to supplicant
11326 */
11327 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
11328 WNI_CFG_BSSID_LEN);
11329 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070011330 else
11331 {
11332 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
11333 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011334
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011335 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
11336 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011337 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
11338 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011339 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011340 /*set gen ie*/
11341 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
11342 /*set auth*/
11343 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
11344 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011345#ifdef FEATURE_WLAN_WAPI
11346 if (pAdapter->wapi_info.nWapiMode)
11347 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011348 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011349 switch (pAdapter->wapi_info.wapiAuthMode)
11350 {
11351 case WAPI_AUTH_MODE_PSK:
11352 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011353 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011354 pAdapter->wapi_info.wapiAuthMode);
11355 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
11356 break;
11357 }
11358 case WAPI_AUTH_MODE_CERT:
11359 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011360 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011361 pAdapter->wapi_info.wapiAuthMode);
11362 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
11363 break;
11364 }
11365 } // End of switch
11366 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
11367 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
11368 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011369 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011370 pRoamProfile->AuthType.numEntries = 1;
11371 pRoamProfile->EncryptionType.numEntries = 1;
11372 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11373 pRoamProfile->mcEncryptionType.numEntries = 1;
11374 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11375 }
11376 }
11377#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011378#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011379 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011380 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11381 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
11382 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011383 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
11384 sizeof (tSirGtkOffloadParams));
11385 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011386 }
11387#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011388 pRoamProfile->csrPersona = pAdapter->device_mode;
11389
Jeff Johnson32d95a32012-09-10 13:15:23 -070011390 if( operatingChannel )
11391 {
11392 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
11393 pRoamProfile->ChannelInfo.numOfChannels = 1;
11394 }
Chet Lanctot186b5732013-03-18 10:26:30 -070011395 else
11396 {
11397 pRoamProfile->ChannelInfo.ChannelList = NULL;
11398 pRoamProfile->ChannelInfo.numOfChannels = 0;
11399 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011400 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
11401 {
11402 hdd_select_cbmode(pAdapter,operatingChannel);
11403 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011404
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011405 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
11406 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011407 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011408 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011409 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
11410 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011411 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11412 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053011413 {
11414 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11415 "%s: Set HDD connState to eConnectionState_Connecting",
11416 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011417 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
11418 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053011419 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011420 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011421 pAdapter->sessionId, pRoamProfile, &roamId);
11422
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011423 if ((eHAL_STATUS_SUCCESS != status) &&
11424 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11425 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011426
11427 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011428 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
11429 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
11430 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011431 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011432 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011433 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011434
11435 pRoamProfile->ChannelInfo.ChannelList = NULL;
11436 pRoamProfile->ChannelInfo.numOfChannels = 0;
11437
Jeff Johnson295189b2012-06-20 16:38:30 -070011438 }
11439 else
11440 {
11441 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
11442 return -EINVAL;
11443 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080011444 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011445 return status;
11446}
11447
11448/*
11449 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
11450 * This function is used to set the authentication type (OPEN/SHARED).
11451 *
11452 */
11453static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
11454 enum nl80211_auth_type auth_type)
11455{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011456 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011457 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11458
11459 ENTER();
11460
11461 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011462 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070011463 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011464 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011465 hddLog(VOS_TRACE_LEVEL_INFO,
11466 "%s: set authentication type to AUTOSWITCH", __func__);
11467 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
11468 break;
11469
11470 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011471#ifdef WLAN_FEATURE_VOWIFI_11R
11472 case NL80211_AUTHTYPE_FT:
11473#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011474 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011475 "%s: set authentication type to OPEN", __func__);
11476 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11477 break;
11478
11479 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011480 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011481 "%s: set authentication type to SHARED", __func__);
11482 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
11483 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011484#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011485 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011486 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011487 "%s: set authentication type to CCKM WPA", __func__);
11488 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
11489 break;
11490#endif
11491
11492
11493 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011494 hddLog(VOS_TRACE_LEVEL_ERROR,
11495 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011496 auth_type);
11497 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
11498 return -EINVAL;
11499 }
11500
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011501 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011502 pHddStaCtx->conn_info.authType;
11503 return 0;
11504}
11505
11506/*
11507 * FUNCTION: wlan_hdd_set_akm_suite
11508 * This function is used to set the key mgmt type(PSK/8021x).
11509 *
11510 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011511static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011512 u32 key_mgmt
11513 )
11514{
11515 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11516 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053011517 /* Should be in ieee802_11_defs.h */
11518#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
11519#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070011520 /*set key mgmt type*/
11521 switch(key_mgmt)
11522 {
11523 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053011524 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011525#ifdef WLAN_FEATURE_VOWIFI_11R
11526 case WLAN_AKM_SUITE_FT_PSK:
11527#endif
11528 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070011529 __func__);
11530 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
11531 break;
11532
11533 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053011534 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011535#ifdef WLAN_FEATURE_VOWIFI_11R
11536 case WLAN_AKM_SUITE_FT_8021X:
11537#endif
11538 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011539 __func__);
11540 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11541 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011542#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011543#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
11544#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
11545 case WLAN_AKM_SUITE_CCKM:
11546 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
11547 __func__);
11548 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
11549 break;
11550#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070011551#ifndef WLAN_AKM_SUITE_OSEN
11552#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
11553 case WLAN_AKM_SUITE_OSEN:
11554 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
11555 __func__);
11556 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11557 break;
11558#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011559
11560 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011561 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011562 __func__, key_mgmt);
11563 return -EINVAL;
11564
11565 }
11566 return 0;
11567}
11568
11569/*
11570 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011571 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070011572 * (NONE/WEP40/WEP104/TKIP/CCMP).
11573 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011574static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
11575 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070011576 bool ucast
11577 )
11578{
11579 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011580 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011581 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11582
11583 ENTER();
11584
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011585 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011586 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053011587 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070011588 __func__, cipher);
11589 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11590 }
11591 else
11592 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011593
Jeff Johnson295189b2012-06-20 16:38:30 -070011594 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011595 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011596 {
11597 case IW_AUTH_CIPHER_NONE:
11598 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11599 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011600
Jeff Johnson295189b2012-06-20 16:38:30 -070011601 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011602 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070011603 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011604
Jeff Johnson295189b2012-06-20 16:38:30 -070011605 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011606 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070011607 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011608
Jeff Johnson295189b2012-06-20 16:38:30 -070011609 case WLAN_CIPHER_SUITE_TKIP:
11610 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
11611 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011612
Jeff Johnson295189b2012-06-20 16:38:30 -070011613 case WLAN_CIPHER_SUITE_CCMP:
11614 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11615 break;
11616#ifdef FEATURE_WLAN_WAPI
11617 case WLAN_CIPHER_SUITE_SMS4:
11618 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
11619 break;
11620#endif
11621
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011622#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011623 case WLAN_CIPHER_SUITE_KRK:
11624 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
11625 break;
11626#endif
11627 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011628 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011629 __func__, cipher);
11630 return -EOPNOTSUPP;
11631 }
11632 }
11633
11634 if (ucast)
11635 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011636 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011637 __func__, encryptionType);
11638 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11639 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011640 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011641 encryptionType;
11642 }
11643 else
11644 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011645 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011646 __func__, encryptionType);
11647 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
11648 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
11649 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
11650 }
11651
11652 return 0;
11653}
11654
11655
11656/*
11657 * FUNCTION: wlan_hdd_cfg80211_set_ie
11658 * This function is used to parse WPA/RSN IE's.
11659 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011660int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011661#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11662 const u8 *ie,
11663#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011664 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011665#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011666 size_t ie_len
11667 )
11668{
11669 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011670#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11671 const u8 *genie = ie;
11672#else
Jeff Johnson295189b2012-06-20 16:38:30 -070011673 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011674#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011675 v_U16_t remLen = ie_len;
11676#ifdef FEATURE_WLAN_WAPI
11677 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
11678 u16 *tmp;
11679 v_U16_t akmsuiteCount;
11680 int *akmlist;
11681#endif
11682 ENTER();
11683
11684 /* clear previous assocAddIE */
11685 pWextState->assocAddIE.length = 0;
11686 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011687 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011688
11689 while (remLen >= 2)
11690 {
11691 v_U16_t eLen = 0;
11692 v_U8_t elementId;
11693 elementId = *genie++;
11694 eLen = *genie++;
11695 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011696
Arif Hussain6d2a3322013-11-17 19:50:10 -080011697 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070011698 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011699
11700 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070011701 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011702 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011703 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 -070011704 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011705 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011706 "%s: Invalid WPA IE", __func__);
11707 return -EINVAL;
11708 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011709 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070011710 {
11711 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011712 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011713 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011714
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011715 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011716 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011717 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
11718 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011719 VOS_ASSERT(0);
11720 return -ENOMEM;
11721 }
11722 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11723 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11724 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011725
Jeff Johnson295189b2012-06-20 16:38:30 -070011726 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
11727 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11728 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11729 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011730 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
11731 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011732 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
11733 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11734 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
11735 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
11736 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
11737 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011738 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053011739 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070011740 {
11741 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011742 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011743 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011744
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011745 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011746 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011747 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11748 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011749 VOS_ASSERT(0);
11750 return -ENOMEM;
11751 }
11752 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11753 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11754 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011755
Jeff Johnson295189b2012-06-20 16:38:30 -070011756 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11757 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11758 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011759#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011760 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
11761 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011762 /*Consider WFD IE, only for P2P Client */
11763 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
11764 {
11765 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011766 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011767 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011768
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011769 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011770 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011771 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11772 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011773 VOS_ASSERT(0);
11774 return -ENOMEM;
11775 }
11776 // WFD IE is saved to Additional IE ; it should be accumulated to handle
11777 // WPS IE + P2P IE + WFD IE
11778 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11779 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011780
Jeff Johnson295189b2012-06-20 16:38:30 -070011781 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11782 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11783 }
11784#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011785 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011786 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011787 HS20_OUI_TYPE_SIZE)) )
11788 {
11789 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011790 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011791 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011792
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011793 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011794 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011795 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11796 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011797 VOS_ASSERT(0);
11798 return -ENOMEM;
11799 }
11800 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11801 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011802
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011803 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11804 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11805 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011806 /* Appending OSEN Information Element in Assiciation Request */
11807 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
11808 OSEN_OUI_TYPE_SIZE)) )
11809 {
11810 v_U16_t curAddIELen = pWextState->assocAddIE.length;
11811 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
11812 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011813
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011814 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011815 {
11816 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11817 "Need bigger buffer space");
11818 VOS_ASSERT(0);
11819 return -ENOMEM;
11820 }
11821 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11822 pWextState->assocAddIE.length += eLen + 2;
11823
11824 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
11825 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11826 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11827 }
11828
Abhishek Singh4322e622015-06-10 15:42:54 +053011829 /* Update only for WPA IE */
11830 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
11831 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011832
11833 /* populating as ADDIE in beacon frames */
11834 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011835 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011836 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
11837 {
11838 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11839 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
11840 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11841 {
11842 hddLog(LOGE,
11843 "Coldn't pass "
11844 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
11845 }
11846 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
11847 else
11848 hddLog(LOGE,
11849 "Could not pass on "
11850 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
11851
11852 /* IBSS mode doesn't contain params->proberesp_ies still
11853 beaconIE's need to be populated in probe response frames */
11854 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
11855 {
11856 u16 rem_probe_resp_ie_len = eLen + 2;
11857 u8 probe_rsp_ie_len[3] = {0};
11858 u8 counter = 0;
11859
11860 /* Check Probe Resp Length if it is greater then 255 then
11861 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
11862 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
11863 not able Store More then 255 bytes into One Variable */
11864
11865 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
11866 {
11867 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
11868 {
11869 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
11870 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
11871 }
11872 else
11873 {
11874 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
11875 rem_probe_resp_ie_len = 0;
11876 }
11877 }
11878
11879 rem_probe_resp_ie_len = 0;
11880
11881 if (probe_rsp_ie_len[0] > 0)
11882 {
11883 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11884 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
11885 (tANI_U8*)(genie - 2),
11886 probe_rsp_ie_len[0], NULL,
11887 eANI_BOOLEAN_FALSE)
11888 == eHAL_STATUS_FAILURE)
11889 {
11890 hddLog(LOGE,
11891 "Could not pass"
11892 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
11893 }
11894 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
11895 }
11896
11897 if (probe_rsp_ie_len[1] > 0)
11898 {
11899 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11900 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
11901 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11902 probe_rsp_ie_len[1], NULL,
11903 eANI_BOOLEAN_FALSE)
11904 == eHAL_STATUS_FAILURE)
11905 {
11906 hddLog(LOGE,
11907 "Could not pass"
11908 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
11909 }
11910 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
11911 }
11912
11913 if (probe_rsp_ie_len[2] > 0)
11914 {
11915 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11916 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
11917 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11918 probe_rsp_ie_len[2], NULL,
11919 eANI_BOOLEAN_FALSE)
11920 == eHAL_STATUS_FAILURE)
11921 {
11922 hddLog(LOGE,
11923 "Could not pass"
11924 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
11925 }
11926 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
11927 }
11928
11929 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11930 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
11931 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11932 {
11933 hddLog(LOGE,
11934 "Could not pass"
11935 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
11936 }
11937 }
11938 else
11939 {
11940 // Reset WNI_CFG_PROBE_RSP Flags
11941 wlan_hdd_reset_prob_rspies(pAdapter);
11942
11943 hddLog(VOS_TRACE_LEVEL_INFO,
11944 "%s: No Probe Response IE received in set beacon",
11945 __func__);
11946 }
11947 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070011948 break;
11949 case DOT11F_EID_RSN:
11950 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
11951 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11952 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
11953 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
11954 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
11955 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053011956
11957 /* Appending Extended Capabilities with Interworking bit set
11958 * in Assoc Req.
11959 *
11960 * In assoc req this EXT Cap will only be taken into account if
11961 * interworkingService bit is set to 1. Currently
11962 * driver is only interested in interworkingService capability
11963 * from supplicant. If in future any other EXT Cap info is
11964 * required from supplicat, it needs to be handled while
11965 * sending Assoc Req in LIM.
11966 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011967 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011968 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011969 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011970 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011971 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011972
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011973 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011974 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011975 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11976 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011977 VOS_ASSERT(0);
11978 return -ENOMEM;
11979 }
11980 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11981 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011982
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011983 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11984 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11985 break;
11986 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011987#ifdef FEATURE_WLAN_WAPI
11988 case WLAN_EID_WAPI:
11989 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011990 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070011991 pAdapter->wapi_info.nWapiMode);
11992 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011993 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070011994 akmsuiteCount = WPA_GET_LE16(tmp);
11995 tmp = tmp + 1;
11996 akmlist = (int *)(tmp);
11997 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
11998 {
11999 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
12000 }
12001 else
12002 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012003 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070012004 VOS_ASSERT(0);
12005 return -EINVAL;
12006 }
12007
12008 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
12009 {
12010 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012011 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012012 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012013 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012014 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012015 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012016 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012017 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012018 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
12019 }
12020 break;
12021#endif
12022 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012023 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012024 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012025 /* when Unknown IE is received we should break and continue
12026 * to the next IE in the buffer instead we were returning
12027 * so changing this to break */
12028 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012029 }
12030 genie += eLen;
12031 remLen -= eLen;
12032 }
12033 EXIT();
12034 return 0;
12035}
12036
12037/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053012038 * FUNCTION: hdd_isWPAIEPresent
12039 * Parse the received IE to find the WPA IE
12040 *
12041 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012042static bool hdd_isWPAIEPresent(
12043#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
12044 const u8 *ie,
12045#else
12046 u8 *ie,
12047#endif
12048 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053012049{
12050 v_U8_t eLen = 0;
12051 v_U16_t remLen = ie_len;
12052 v_U8_t elementId = 0;
12053
12054 while (remLen >= 2)
12055 {
12056 elementId = *ie++;
12057 eLen = *ie++;
12058 remLen -= 2;
12059 if (eLen > remLen)
12060 {
12061 hddLog(VOS_TRACE_LEVEL_ERROR,
12062 "%s: IE length is wrong %d", __func__, eLen);
12063 return FALSE;
12064 }
12065 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
12066 {
12067 /* OUI - 0x00 0X50 0XF2
12068 WPA Information Element - 0x01
12069 WPA version - 0x01*/
12070 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
12071 return TRUE;
12072 }
12073 ie += eLen;
12074 remLen -= eLen;
12075 }
12076 return FALSE;
12077}
12078
12079/*
Jeff Johnson295189b2012-06-20 16:38:30 -070012080 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012081 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012082 * parameters during connect operation.
12083 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012084int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012085 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012086 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012087{
12088 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012089 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012090 ENTER();
12091
12092 /*set wpa version*/
12093 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
12094
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012095 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070012096 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053012097 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070012098 {
12099 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12100 }
12101 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
12102 {
12103 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12104 }
12105 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012106
12107 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012108 pWextState->wpaVersion);
12109
12110 /*set authentication type*/
12111 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
12112
12113 if (0 > status)
12114 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012115 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012116 "%s: failed to set authentication type ", __func__);
12117 return status;
12118 }
12119
12120 /*set key mgmt type*/
12121 if (req->crypto.n_akm_suites)
12122 {
12123 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
12124 if (0 > status)
12125 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012126 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070012127 __func__);
12128 return status;
12129 }
12130 }
12131
12132 /*set pairwise cipher type*/
12133 if (req->crypto.n_ciphers_pairwise)
12134 {
12135 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
12136 req->crypto.ciphers_pairwise[0], true);
12137 if (0 > status)
12138 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012139 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012140 "%s: failed to set unicast cipher type", __func__);
12141 return status;
12142 }
12143 }
12144 else
12145 {
12146 /*Reset previous cipher suite to none*/
12147 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
12148 if (0 > status)
12149 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012150 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012151 "%s: failed to set unicast cipher type", __func__);
12152 return status;
12153 }
12154 }
12155
12156 /*set group cipher type*/
12157 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
12158 false);
12159
12160 if (0 > status)
12161 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012162 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070012163 __func__);
12164 return status;
12165 }
12166
Chet Lanctot186b5732013-03-18 10:26:30 -070012167#ifdef WLAN_FEATURE_11W
12168 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
12169#endif
12170
Jeff Johnson295189b2012-06-20 16:38:30 -070012171 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
12172 if (req->ie_len)
12173 {
12174 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
12175 if ( 0 > status)
12176 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012177 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012178 __func__);
12179 return status;
12180 }
12181 }
12182
12183 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012184 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012185 {
12186 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
12187 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
12188 )
12189 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012190 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070012191 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
12192 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012193 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012194 __func__);
12195 return -EOPNOTSUPP;
12196 }
12197 else
12198 {
12199 u8 key_len = req->key_len;
12200 u8 key_idx = req->key_idx;
12201
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012202 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012203 && (CSR_MAX_NUM_KEY > key_idx)
12204 )
12205 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012206 hddLog(VOS_TRACE_LEVEL_INFO,
12207 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012208 __func__, key_idx, key_len);
12209 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012210 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012211 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012212 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070012213 (u8)key_len;
12214 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
12215 }
12216 }
12217 }
12218 }
12219
12220 return status;
12221}
12222
12223/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012224 * FUNCTION: wlan_hdd_try_disconnect
12225 * This function is used to disconnect from previous
12226 * connection
12227 */
12228static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
12229{
12230 long ret = 0;
12231 hdd_station_ctx_t *pHddStaCtx;
12232 eMib_dot11DesiredBssType connectedBssType;
12233
12234 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12235
12236 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
12237
12238 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
12239 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
12240 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
12241 {
12242 /* Issue disconnect to CSR */
12243 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12244 if( eHAL_STATUS_SUCCESS ==
12245 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12246 pAdapter->sessionId,
12247 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
12248 {
12249 ret = wait_for_completion_interruptible_timeout(
12250 &pAdapter->disconnect_comp_var,
12251 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12252 if (0 >= ret)
12253 {
12254 hddLog(LOGE, FL("Failed to receive disconnect event"));
12255 return -EALREADY;
12256 }
12257 }
12258 }
12259 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
12260 {
12261 ret = wait_for_completion_interruptible_timeout(
12262 &pAdapter->disconnect_comp_var,
12263 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12264 if (0 >= ret)
12265 {
12266 hddLog(LOGE, FL("Failed to receive disconnect event"));
12267 return -EALREADY;
12268 }
12269 }
12270
12271 return 0;
12272}
12273
12274/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053012275 * FUNCTION: __wlan_hdd_cfg80211_connect
12276 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070012277 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012278static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012279 struct net_device *ndev,
12280 struct cfg80211_connect_params *req
12281 )
12282{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012283 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012284 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012285 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053012286 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012287
12288 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012289
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012290 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12291 TRACE_CODE_HDD_CFG80211_CONNECT,
12292 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012293 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012294 "%s: device_mode = %s (%d)", __func__,
12295 hdd_device_modetoString(pAdapter->device_mode),
12296 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012297
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012298 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012299 if (!pHddCtx)
12300 {
12301 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12302 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053012303 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012304 }
12305
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012306 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012307 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012308 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012309 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012310 }
12311
Agarwal Ashish51325b52014-06-16 16:50:49 +053012312 if (vos_max_concurrent_connections_reached()) {
12313 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12314 return -ECONNREFUSED;
12315 }
12316
Jeff Johnson295189b2012-06-20 16:38:30 -070012317#ifdef WLAN_BTAMP_FEATURE
12318 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012319 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070012320 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012321 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012322 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080012323 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012324 }
12325#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012326
12327 //If Device Mode is Station Concurrent Sessions Exit BMps
12328 //P2P Mode will be taken care in Open/close adapter
12329 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012330 (vos_concurrent_open_sessions_running())) {
12331 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
12332 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012333 }
12334
12335 /*Try disconnecting if already in connected state*/
12336 status = wlan_hdd_try_disconnect(pAdapter);
12337 if ( 0 > status)
12338 {
12339 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12340 " connection"));
12341 return -EALREADY;
12342 }
12343
Jeff Johnson295189b2012-06-20 16:38:30 -070012344 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012345 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070012346
12347 if ( 0 > status)
12348 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012349 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070012350 __func__);
12351 return status;
12352 }
Mohit Khanna765234a2012-09-11 15:08:35 -070012353 if ( req->channel )
12354 {
12355 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
12356 req->ssid_len, req->bssid,
12357 req->channel->hw_value);
12358 }
12359 else
12360 {
12361 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012362 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070012363 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012364
Sushant Kaushikd7083982015-03-18 14:33:24 +053012365 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012366 {
12367 //ReEnable BMPS if disabled
12368 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
12369 (NULL != pHddCtx))
12370 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012371 if (pHddCtx->hdd_wlan_suspended)
12372 {
12373 hdd_set_pwrparams(pHddCtx);
12374 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012375 //ReEnable Bmps and Imps back
12376 hdd_enable_bmps_imps(pHddCtx);
12377 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053012378 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012379 return status;
12380 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012381 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012382 EXIT();
12383 return status;
12384}
12385
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012386static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
12387 struct net_device *ndev,
12388 struct cfg80211_connect_params *req)
12389{
12390 int ret;
12391 vos_ssr_protect(__func__);
12392 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
12393 vos_ssr_unprotect(__func__);
12394
12395 return ret;
12396}
Jeff Johnson295189b2012-06-20 16:38:30 -070012397
12398/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012399 * FUNCTION: wlan_hdd_disconnect
12400 * This function is used to issue a disconnect request to SME
12401 */
12402int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
12403{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012404 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012405 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012406 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012407 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012408
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012409 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012410
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012411 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012412 if (0 != status)
12413 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012414 return status;
12415 }
12416
Sushant Kaushikb4834d22015-07-15 15:29:05 +053012417 if (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)
12418 {
12419 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
12420 pAdapter->sessionId);
12421 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012422 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012423
Agarwal Ashish47d18112014-08-04 19:55:07 +053012424 /* Need to apply spin lock before decreasing active sessions
12425 * as there can be chance for double decrement if context switch
12426 * Calls hdd_DisConnectHandler.
12427 */
12428
12429 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012430 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
12431 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012432 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
12433 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053012434 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
12435 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012436
Abhishek Singhf4669da2014-05-26 15:07:49 +053012437 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053012438 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
12439
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012440 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012441
Mihir Shete182a0b22014-08-18 16:08:48 +053012442 /*
12443 * stop tx queues before deleting STA/BSS context from the firmware.
12444 * tx has to be disabled because the firmware can get busy dropping
12445 * the tx frames after BSS/STA has been deleted and will not send
12446 * back a response resulting in WDI timeout
12447 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053012448 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053012449 netif_tx_disable(pAdapter->dev);
12450 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012451
Mihir Shete182a0b22014-08-18 16:08:48 +053012452 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012453 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12454 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012455 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
12456 {
12457 hddLog(VOS_TRACE_LEVEL_INFO,
12458 FL("status = %d, already disconnected"),
12459 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012460
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012461 }
12462 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012463 {
12464 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012465 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012466 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012467 result = -EINVAL;
12468 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012469 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012470 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012471 &pAdapter->disconnect_comp_var,
12472 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012473 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012474 {
12475 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012476 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012477 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012478 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012479 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012480 {
12481 hddLog(VOS_TRACE_LEVEL_ERROR,
12482 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012483 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012484 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012485disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012486 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12487 FL("Set HDD connState to eConnectionState_NotConnected"));
12488 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
12489
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012490 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012491 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012492}
12493
12494
12495/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012496 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070012497 * This function is used to issue a disconnect request to SME
12498 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012499static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012500 struct net_device *dev,
12501 u16 reason
12502 )
12503{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012504 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012505 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012506 tCsrRoamProfile *pRoamProfile;
12507 hdd_station_ctx_t *pHddStaCtx;
12508 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012509#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012510 tANI_U8 staIdx;
12511#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012512
Jeff Johnson295189b2012-06-20 16:38:30 -070012513 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012514
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012515 if (!pAdapter) {
12516 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
12517 return -EINVAL;
12518 }
12519
12520 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12521 if (!pHddStaCtx) {
12522 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
12523 return -EINVAL;
12524 }
12525
12526 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12527 status = wlan_hdd_validate_context(pHddCtx);
12528 if (0 != status)
12529 {
12530 return status;
12531 }
12532
12533 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
12534
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012535 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12536 TRACE_CODE_HDD_CFG80211_DISCONNECT,
12537 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012538 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
12539 __func__, hdd_device_modetoString(pAdapter->device_mode),
12540 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012541
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012542 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
12543 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070012544
Jeff Johnson295189b2012-06-20 16:38:30 -070012545 if (NULL != pRoamProfile)
12546 {
12547 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012548 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
12549 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070012550 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012551 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070012552 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012553 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012554 switch(reason)
12555 {
12556 case WLAN_REASON_MIC_FAILURE:
12557 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
12558 break;
12559
12560 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
12561 case WLAN_REASON_DISASSOC_AP_BUSY:
12562 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
12563 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
12564 break;
12565
12566 case WLAN_REASON_PREV_AUTH_NOT_VALID:
12567 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053012568 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070012569 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
12570 break;
12571
Jeff Johnson295189b2012-06-20 16:38:30 -070012572 default:
12573 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
12574 break;
12575 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012576 pScanInfo = &pHddCtx->scan_info;
12577 if (pScanInfo->mScanPending)
12578 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012579 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012580 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053012581 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012582 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012583 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053012584 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012585#ifdef FEATURE_WLAN_TDLS
12586 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012587 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012588 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012589 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
12590 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012591 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012592 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012593 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012595 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012596 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012597 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012598 status = sme_DeleteTdlsPeerSta(
12599 WLAN_HDD_GET_HAL_CTX(pAdapter),
12600 pAdapter->sessionId,
12601 mac);
12602 if (status != eHAL_STATUS_SUCCESS) {
12603 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
12604 return -EPERM;
12605 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012606 }
12607 }
12608#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012609 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012610 status = wlan_hdd_disconnect(pAdapter, reasonCode);
12611 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070012612 {
12613 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012614 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012615 __func__, (int)status );
12616 return -EINVAL;
12617 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012618 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012619 else
12620 {
12621 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
12622 "called while in %d state", __func__,
12623 pHddStaCtx->conn_info.connState);
12624 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 }
12626 else
12627 {
12628 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
12629 }
12630
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012631 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012632 return status;
12633}
12634
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012635static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
12636 struct net_device *dev,
12637 u16 reason
12638 )
12639{
12640 int ret;
12641 vos_ssr_protect(__func__);
12642 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
12643 vos_ssr_unprotect(__func__);
12644
12645 return ret;
12646}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012647
Jeff Johnson295189b2012-06-20 16:38:30 -070012648/*
12649 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012650 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012651 * settings in IBSS mode.
12652 */
12653static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012654 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012655 struct cfg80211_ibss_params *params
12656 )
12657{
12658 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012659 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012660 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
12661 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012662
Jeff Johnson295189b2012-06-20 16:38:30 -070012663 ENTER();
12664
12665 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070012666 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070012667
12668 if (params->ie_len && ( NULL != params->ie) )
12669 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012670 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12671 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012672 {
12673 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12674 encryptionType = eCSR_ENCRYPT_TYPE_AES;
12675 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012676 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012677 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012678 tDot11fIEWPA dot11WPAIE;
12679 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012680 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012681
Wilson Yang00256342013-10-10 23:13:38 -070012682 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012683 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12684 params->ie_len, DOT11F_EID_WPA);
12685 if ( NULL != ie )
12686 {
12687 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12688 // Unpack the WPA IE
12689 //Skip past the EID byte and length byte - and four byte WiFi OUI
12690 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
12691 &ie[2+4],
12692 ie[1] - 4,
12693 &dot11WPAIE);
12694 /*Extract the multicast cipher, the encType for unicast
12695 cipher for wpa-none is none*/
12696 encryptionType =
12697 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
12698 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012699 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012700
Jeff Johnson295189b2012-06-20 16:38:30 -070012701 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
12702
12703 if (0 > status)
12704 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012705 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012706 __func__);
12707 return status;
12708 }
12709 }
12710
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012711 pWextState->roamProfile.AuthType.authType[0] =
12712 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012713 eCSR_AUTH_TYPE_OPEN_SYSTEM;
12714
12715 if (params->privacy)
12716 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012717 /* Security enabled IBSS, At this time there is no information available
12718 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070012719 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012720 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070012721 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012722 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070012723 *enable privacy bit in beacons */
12724
12725 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
12726 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012727 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
12728 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012729 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
12730 pWextState->roamProfile.EncryptionType.numEntries = 1;
12731 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012732 return status;
12733}
12734
12735/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012736 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012737 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012738 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012739static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012740 struct net_device *dev,
12741 struct cfg80211_ibss_params *params
12742 )
12743{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012744 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012745 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12746 tCsrRoamProfile *pRoamProfile;
12747 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012748 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12749 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012750 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070012751
12752 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012753
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012754 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12755 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
12756 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012757 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012758 "%s: device_mode = %s (%d)", __func__,
12759 hdd_device_modetoString(pAdapter->device_mode),
12760 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012761
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012762 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012763 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012764 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012765 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012766 }
12767
12768 if (NULL == pWextState)
12769 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012770 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012771 __func__);
12772 return -EIO;
12773 }
12774
Agarwal Ashish51325b52014-06-16 16:50:49 +053012775 if (vos_max_concurrent_connections_reached()) {
12776 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12777 return -ECONNREFUSED;
12778 }
12779
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012780 /*Try disconnecting if already in connected state*/
12781 status = wlan_hdd_try_disconnect(pAdapter);
12782 if ( 0 > status)
12783 {
12784 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12785 " IBSS connection"));
12786 return -EALREADY;
12787 }
12788
Jeff Johnson295189b2012-06-20 16:38:30 -070012789 pRoamProfile = &pWextState->roamProfile;
12790
12791 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
12792 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012793 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012794 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012795 return -EINVAL;
12796 }
12797
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012798 /* BSSID is provided by upper layers hence no need to AUTO generate */
12799 if (NULL != params->bssid) {
12800 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12801 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
12802 hddLog (VOS_TRACE_LEVEL_ERROR,
12803 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12804 return -EIO;
12805 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012806 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012807 }
krunal sonie9002db2013-11-25 14:24:17 -080012808 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
12809 {
12810 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12811 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
12812 {
12813 hddLog (VOS_TRACE_LEVEL_ERROR,
12814 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12815 return -EIO;
12816 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012817
12818 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080012819 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012820 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080012821 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012822
Jeff Johnson295189b2012-06-20 16:38:30 -070012823 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070012824 if (NULL !=
12825#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12826 params->chandef.chan)
12827#else
12828 params->channel)
12829#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012830 {
12831 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012832 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12833 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
12834 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12835 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012836
12837 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012838 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070012839 ieee80211_frequency_to_channel(
12840#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12841 params->chandef.chan->center_freq);
12842#else
12843 params->channel->center_freq);
12844#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012845
12846 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
12847 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070012848 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012849 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
12850 __func__);
12851 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070012852 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012853
12854 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012855 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012856 if (channelNum == validChan[indx])
12857 {
12858 break;
12859 }
12860 }
12861 if (indx >= numChans)
12862 {
12863 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012864 __func__, channelNum);
12865 return -EINVAL;
12866 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012867 /* Set the Operational Channel */
12868 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
12869 channelNum);
12870 pRoamProfile->ChannelInfo.numOfChannels = 1;
12871 pHddStaCtx->conn_info.operationChannel = channelNum;
12872 pRoamProfile->ChannelInfo.ChannelList =
12873 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070012874 }
12875
12876 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012877 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070012878 if (status < 0)
12879 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012880 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070012881 __func__);
12882 return status;
12883 }
12884
12885 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012886 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012887 params->ssid_len, params->bssid,
12888 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070012889
12890 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012891 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012892
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012893 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012894 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012895}
12896
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012897static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
12898 struct net_device *dev,
12899 struct cfg80211_ibss_params *params
12900 )
12901{
12902 int ret = 0;
12903
12904 vos_ssr_protect(__func__);
12905 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
12906 vos_ssr_unprotect(__func__);
12907
12908 return ret;
12909}
12910
Jeff Johnson295189b2012-06-20 16:38:30 -070012911/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012912 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012913 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012914 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012915static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012916 struct net_device *dev
12917 )
12918{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012919 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012920 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12921 tCsrRoamProfile *pRoamProfile;
12922 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012923 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012924
12925 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012926
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012927 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12928 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
12929 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012930 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012931 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012932 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012933 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012934 }
12935
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012936 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
12937 hdd_device_modetoString(pAdapter->device_mode),
12938 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012939 if (NULL == pWextState)
12940 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012941 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012942 __func__);
12943 return -EIO;
12944 }
12945
12946 pRoamProfile = &pWextState->roamProfile;
12947
12948 /* Issue disconnect only if interface type is set to IBSS */
12949 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
12950 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012951 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070012952 __func__);
12953 return -EINVAL;
12954 }
12955
12956 /* Issue Disconnect request */
12957 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12958 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
12959 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
12960
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012961 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012962 return 0;
12963}
12964
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012965static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
12966 struct net_device *dev
12967 )
12968{
12969 int ret = 0;
12970
12971 vos_ssr_protect(__func__);
12972 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
12973 vos_ssr_unprotect(__func__);
12974
12975 return ret;
12976}
12977
Jeff Johnson295189b2012-06-20 16:38:30 -070012978/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012979 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070012980 * This function is used to set the phy parameters
12981 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
12982 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012983static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012984 u32 changed)
12985{
12986 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
12987 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012988 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012989
12990 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012991
12992 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012993 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
12994 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012995
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012996 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012997 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012998 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012999 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013000 }
13001
Jeff Johnson295189b2012-06-20 16:38:30 -070013002 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
13003 {
13004 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
13005 WNI_CFG_RTS_THRESHOLD_STAMAX :
13006 wiphy->rts_threshold;
13007
13008 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013009 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070013010 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013011 hddLog(VOS_TRACE_LEVEL_ERROR,
13012 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013013 __func__, rts_threshold);
13014 return -EINVAL;
13015 }
13016
13017 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
13018 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013019 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013020 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013021 hddLog(VOS_TRACE_LEVEL_ERROR,
13022 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013023 __func__, rts_threshold);
13024 return -EIO;
13025 }
13026
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013027 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013028 rts_threshold);
13029 }
13030
13031 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
13032 {
13033 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
13034 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
13035 wiphy->frag_threshold;
13036
13037 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013038 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013039 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013040 hddLog(VOS_TRACE_LEVEL_ERROR,
13041 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013042 frag_threshold);
13043 return -EINVAL;
13044 }
13045
13046 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
13047 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013048 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013049 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013050 hddLog(VOS_TRACE_LEVEL_ERROR,
13051 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013052 __func__, frag_threshold);
13053 return -EIO;
13054 }
13055
13056 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
13057 frag_threshold);
13058 }
13059
13060 if ((changed & WIPHY_PARAM_RETRY_SHORT)
13061 || (changed & WIPHY_PARAM_RETRY_LONG))
13062 {
13063 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
13064 wiphy->retry_short :
13065 wiphy->retry_long;
13066
13067 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
13068 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
13069 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013070 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013071 __func__, retry_value);
13072 return -EINVAL;
13073 }
13074
13075 if (changed & WIPHY_PARAM_RETRY_SHORT)
13076 {
13077 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
13078 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013079 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013080 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013081 hddLog(VOS_TRACE_LEVEL_ERROR,
13082 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013083 __func__, retry_value);
13084 return -EIO;
13085 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013086 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013087 __func__, retry_value);
13088 }
13089 else if (changed & WIPHY_PARAM_RETRY_SHORT)
13090 {
13091 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
13092 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013093 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013094 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013095 hddLog(VOS_TRACE_LEVEL_ERROR,
13096 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013097 __func__, retry_value);
13098 return -EIO;
13099 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013100 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013101 __func__, retry_value);
13102 }
13103 }
13104
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013105 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013106 return 0;
13107}
13108
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013109static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
13110 u32 changed)
13111{
13112 int ret;
13113
13114 vos_ssr_protect(__func__);
13115 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
13116 vos_ssr_unprotect(__func__);
13117
13118 return ret;
13119}
13120
Jeff Johnson295189b2012-06-20 16:38:30 -070013121/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013122 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013123 * This function is used to set the txpower
13124 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013125static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013126#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13127 struct wireless_dev *wdev,
13128#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013129#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013130 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013131#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013132 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013133#endif
13134 int dbm)
13135{
13136 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013137 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013138 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
13139 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013140 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013141
13142 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013143
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013144 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13145 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
13146 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013147 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013148 if (0 != status)
13149 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013150 return status;
13151 }
13152
13153 hHal = pHddCtx->hHal;
13154
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013155 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
13156 dbm, ccmCfgSetCallback,
13157 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013158 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013159 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013160 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
13161 return -EIO;
13162 }
13163
13164 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
13165 dbm);
13166
13167 switch(type)
13168 {
13169 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
13170 /* Fall through */
13171 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
13172 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
13173 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013174 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
13175 __func__);
13176 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070013177 }
13178 break;
13179 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013180 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070013181 __func__);
13182 return -EOPNOTSUPP;
13183 break;
13184 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013185 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
13186 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070013187 return -EIO;
13188 }
13189
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013190 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013191 return 0;
13192}
13193
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013194static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
13195#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13196 struct wireless_dev *wdev,
13197#endif
13198#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13199 enum tx_power_setting type,
13200#else
13201 enum nl80211_tx_power_setting type,
13202#endif
13203 int dbm)
13204{
13205 int ret;
13206 vos_ssr_protect(__func__);
13207 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
13208#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13209 wdev,
13210#endif
13211#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13212 type,
13213#else
13214 type,
13215#endif
13216 dbm);
13217 vos_ssr_unprotect(__func__);
13218
13219 return ret;
13220}
13221
Jeff Johnson295189b2012-06-20 16:38:30 -070013222/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013223 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013224 * This function is used to read the txpower
13225 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013226static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013227#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13228 struct wireless_dev *wdev,
13229#endif
13230 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070013231{
13232
13233 hdd_adapter_t *pAdapter;
13234 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013235 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013236
Jeff Johnsone7245742012-09-05 17:12:55 -070013237 ENTER();
13238
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013239 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013240 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013241 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013242 *dbm = 0;
13243 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013244 }
13245
Jeff Johnson295189b2012-06-20 16:38:30 -070013246 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
13247 if (NULL == pAdapter)
13248 {
13249 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
13250 return -ENOENT;
13251 }
13252
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053013253 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13254 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
13255 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070013256 wlan_hdd_get_classAstats(pAdapter);
13257 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
13258
Jeff Johnsone7245742012-09-05 17:12:55 -070013259 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013260 return 0;
13261}
13262
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013263static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
13264#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13265 struct wireless_dev *wdev,
13266#endif
13267 int *dbm)
13268{
13269 int ret;
13270
13271 vos_ssr_protect(__func__);
13272 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
13273#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13274 wdev,
13275#endif
13276 dbm);
13277 vos_ssr_unprotect(__func__);
13278
13279 return ret;
13280}
13281
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013282static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013283#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13284 const u8* mac,
13285#else
13286 u8* mac,
13287#endif
13288 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070013289{
13290 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13291 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13292 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053013293 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013294
13295 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
13296 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070013297
13298 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
13299 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
13300 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
13301 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
13302 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
13303 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
13304 tANI_U16 maxRate = 0;
13305 tANI_U16 myRate;
13306 tANI_U16 currentRate = 0;
13307 tANI_U8 maxSpeedMCS = 0;
13308 tANI_U8 maxMCSIdx = 0;
13309 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053013310 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013311 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013312 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013313
Leo Chang6f8870f2013-03-26 18:11:36 -070013314#ifdef WLAN_FEATURE_11AC
13315 tANI_U32 vht_mcs_map;
13316 eDataRate11ACMaxMcs vhtMaxMcs;
13317#endif /* WLAN_FEATURE_11AC */
13318
Jeff Johnsone7245742012-09-05 17:12:55 -070013319 ENTER();
13320
Jeff Johnson295189b2012-06-20 16:38:30 -070013321 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
13322 (0 == ssidlen))
13323 {
13324 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
13325 " Invalid ssidlen, %d", __func__, ssidlen);
13326 /*To keep GUI happy*/
13327 return 0;
13328 }
13329
Mukul Sharma811205f2014-07-09 21:07:30 +053013330 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
13331 {
13332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13333 "%s: Roaming in progress, so unable to proceed this request", __func__);
13334 return 0;
13335 }
13336
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013337 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013338 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013339 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013340 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013341 }
13342
Jeff Johnson295189b2012-06-20 16:38:30 -070013343
Kiet Lam3b17fc82013-09-27 05:24:08 +053013344 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
13345 sinfo->filled |= STATION_INFO_SIGNAL;
13346
c_hpothu09f19542014-05-30 21:53:31 +053013347 wlan_hdd_get_station_stats(pAdapter);
13348 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
13349
13350 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053013351 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
13352 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053013353 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053013354 {
13355 rate_flags = pAdapter->maxRateFlags;
13356 }
c_hpothu44ff4e02014-05-08 00:13:57 +053013357
Jeff Johnson295189b2012-06-20 16:38:30 -070013358 //convert to the UI units of 100kbps
13359 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
13360
13361#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070013362 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 -070013363 sinfo->signal,
13364 pCfg->reportMaxLinkSpeed,
13365 myRate,
13366 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013367 (int) pCfg->linkSpeedRssiMid,
13368 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070013369 (int) rate_flags,
13370 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013371#endif //LINKSPEED_DEBUG_ENABLED
13372
13373 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
13374 {
13375 // we do not want to necessarily report the current speed
13376 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
13377 {
13378 // report the max possible speed
13379 rssidx = 0;
13380 }
13381 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
13382 {
13383 // report the max possible speed with RSSI scaling
13384 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
13385 {
13386 // report the max possible speed
13387 rssidx = 0;
13388 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013389 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070013390 {
13391 // report middle speed
13392 rssidx = 1;
13393 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013394 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
13395 {
13396 // report middle speed
13397 rssidx = 2;
13398 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013399 else
13400 {
13401 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013402 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070013403 }
13404 }
13405 else
13406 {
13407 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
13408 hddLog(VOS_TRACE_LEVEL_ERROR,
13409 "%s: Invalid value for reportMaxLinkSpeed: %u",
13410 __func__, pCfg->reportMaxLinkSpeed);
13411 rssidx = 0;
13412 }
13413
13414 maxRate = 0;
13415
13416 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013417 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
13418 OperationalRates, &ORLeng))
13419 {
13420 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13421 /*To keep GUI happy*/
13422 return 0;
13423 }
13424
Jeff Johnson295189b2012-06-20 16:38:30 -070013425 for (i = 0; i < ORLeng; i++)
13426 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013427 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013428 {
13429 /* Validate Rate Set */
13430 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
13431 {
13432 currentRate = supported_data_rate[j].supported_rate[rssidx];
13433 break;
13434 }
13435 }
13436 /* Update MAX rate */
13437 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13438 }
13439
13440 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013441 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
13442 ExtendedRates, &ERLeng))
13443 {
13444 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13445 /*To keep GUI happy*/
13446 return 0;
13447 }
13448
Jeff Johnson295189b2012-06-20 16:38:30 -070013449 for (i = 0; i < ERLeng; i++)
13450 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013451 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013452 {
13453 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
13454 {
13455 currentRate = supported_data_rate[j].supported_rate[rssidx];
13456 break;
13457 }
13458 }
13459 /* Update MAX rate */
13460 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13461 }
c_hpothu79aab322014-07-14 21:11:01 +053013462
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013463 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053013464 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013465 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053013466 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070013467 {
c_hpothu79aab322014-07-14 21:11:01 +053013468 if (rate_flags & eHAL_TX_RATE_VHT80)
13469 mode = 2;
13470 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
13471 mode = 1;
13472 else
13473 mode = 0;
13474
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013475 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
13476 MCSRates, &MCSLeng))
13477 {
13478 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13479 /*To keep GUI happy*/
13480 return 0;
13481 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013482 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070013483#ifdef WLAN_FEATURE_11AC
13484 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013485 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070013486 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013487 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013488 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070013489 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070013490 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013491 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013493 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070013494 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013495 maxMCSIdx = 7;
13496 }
13497 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
13498 {
13499 maxMCSIdx = 8;
13500 }
13501 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
13502 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013503 //VHT20 is supporting 0~8
13504 if (rate_flags & eHAL_TX_RATE_VHT20)
13505 maxMCSIdx = 8;
13506 else
13507 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070013508 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013509
c_hpothu79aab322014-07-14 21:11:01 +053013510 if (0 != rssidx)/*check for scaled */
13511 {
13512 //get middle rate MCS index if rssi=1/2
13513 for (i=0; i <= maxMCSIdx; i++)
13514 {
13515 if (sinfo->signal <= rssiMcsTbl[mode][i])
13516 {
13517 maxMCSIdx = i;
13518 break;
13519 }
13520 }
13521 }
13522
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013523 if (rate_flags & eHAL_TX_RATE_VHT80)
13524 {
13525 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
13526 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
13527 }
13528 else if (rate_flags & eHAL_TX_RATE_VHT40)
13529 {
13530 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
13531 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
13532 }
13533 else if (rate_flags & eHAL_TX_RATE_VHT20)
13534 {
13535 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
13536 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
13537 }
13538
Leo Chang6f8870f2013-03-26 18:11:36 -070013539 maxSpeedMCS = 1;
13540 if (currentRate > maxRate)
13541 {
13542 maxRate = currentRate;
13543 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013544
Leo Chang6f8870f2013-03-26 18:11:36 -070013545 }
13546 else
13547#endif /* WLAN_FEATURE_11AC */
13548 {
13549 if (rate_flags & eHAL_TX_RATE_HT40)
13550 {
13551 rateFlag |= 1;
13552 }
13553 if (rate_flags & eHAL_TX_RATE_SGI)
13554 {
13555 rateFlag |= 2;
13556 }
13557
Girish Gowli01abcee2014-07-31 20:18:55 +053013558 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053013559 if (rssidx == 1 || rssidx == 2)
13560 {
13561 //get middle rate MCS index if rssi=1/2
13562 for (i=0; i <= 7; i++)
13563 {
13564 if (sinfo->signal <= rssiMcsTbl[mode][i])
13565 {
13566 temp = i+1;
13567 break;
13568 }
13569 }
13570 }
c_hpothu79aab322014-07-14 21:11:01 +053013571
13572 for (i = 0; i < MCSLeng; i++)
13573 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013574 for (j = 0; j < temp; j++)
13575 {
13576 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
13577 {
13578 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013579 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013580 break;
13581 }
13582 }
13583 if ((j < temp) && (currentRate > maxRate))
13584 {
13585 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070013586 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013587 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013588 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013589 }
13590 }
13591
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013592 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
13593 {
13594 maxRate = myRate;
13595 maxSpeedMCS = 1;
13596 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13597 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013598 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053013599 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070013600 {
13601 maxRate = myRate;
13602 if (rate_flags & eHAL_TX_RATE_LEGACY)
13603 {
13604 maxSpeedMCS = 0;
13605 }
13606 else
13607 {
13608 maxSpeedMCS = 1;
13609 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13610 }
13611 }
13612
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013613 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070013614 {
13615 sinfo->txrate.legacy = maxRate;
13616#ifdef LINKSPEED_DEBUG_ENABLED
13617 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
13618#endif //LINKSPEED_DEBUG_ENABLED
13619 }
13620 else
13621 {
13622 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070013623#ifdef WLAN_FEATURE_11AC
13624 sinfo->txrate.nss = 1;
13625 if (rate_flags & eHAL_TX_RATE_VHT80)
13626 {
13627 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013628 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070013629 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013630 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070013631 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013632 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13633 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13634 }
13635 else if (rate_flags & eHAL_TX_RATE_VHT20)
13636 {
13637 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13638 }
13639#endif /* WLAN_FEATURE_11AC */
13640 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
13641 {
13642 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13643 if (rate_flags & eHAL_TX_RATE_HT40)
13644 {
13645 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13646 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013647 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 if (rate_flags & eHAL_TX_RATE_SGI)
13649 {
13650 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13651 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013652
Jeff Johnson295189b2012-06-20 16:38:30 -070013653#ifdef LINKSPEED_DEBUG_ENABLED
13654 pr_info("Reporting MCS rate %d flags %x\n",
13655 sinfo->txrate.mcs,
13656 sinfo->txrate.flags );
13657#endif //LINKSPEED_DEBUG_ENABLED
13658 }
13659 }
13660 else
13661 {
13662 // report current rate instead of max rate
13663
13664 if (rate_flags & eHAL_TX_RATE_LEGACY)
13665 {
13666 //provide to the UI in units of 100kbps
13667 sinfo->txrate.legacy = myRate;
13668#ifdef LINKSPEED_DEBUG_ENABLED
13669 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
13670#endif //LINKSPEED_DEBUG_ENABLED
13671 }
13672 else
13673 {
13674 //must be MCS
13675 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013676#ifdef WLAN_FEATURE_11AC
13677 sinfo->txrate.nss = 1;
13678 if (rate_flags & eHAL_TX_RATE_VHT80)
13679 {
13680 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13681 }
13682 else
13683#endif /* WLAN_FEATURE_11AC */
13684 {
13685 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13686 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 if (rate_flags & eHAL_TX_RATE_SGI)
13688 {
13689 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13690 }
13691 if (rate_flags & eHAL_TX_RATE_HT40)
13692 {
13693 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13694 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013695#ifdef WLAN_FEATURE_11AC
13696 else if (rate_flags & eHAL_TX_RATE_VHT80)
13697 {
13698 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
13699 }
13700#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070013701#ifdef LINKSPEED_DEBUG_ENABLED
13702 pr_info("Reporting actual MCS rate %d flags %x\n",
13703 sinfo->txrate.mcs,
13704 sinfo->txrate.flags );
13705#endif //LINKSPEED_DEBUG_ENABLED
13706 }
13707 }
13708 sinfo->filled |= STATION_INFO_TX_BITRATE;
13709
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013710 sinfo->tx_packets =
13711 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
13712 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
13713 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
13714 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
13715
13716 sinfo->tx_retries =
13717 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
13718 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
13719 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
13720 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
13721
13722 sinfo->tx_failed =
13723 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
13724 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
13725 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
13726 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
13727
13728 sinfo->filled |=
13729 STATION_INFO_TX_PACKETS |
13730 STATION_INFO_TX_RETRIES |
13731 STATION_INFO_TX_FAILED;
13732
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013733 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13734 TRACE_CODE_HDD_CFG80211_GET_STA,
13735 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013736 EXIT();
13737 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013738}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013739#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
13740static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13741 const u8* mac, struct station_info *sinfo)
13742#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013743static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13744 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013745#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013746{
13747 int ret;
13748
13749 vos_ssr_protect(__func__);
13750 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
13751 vos_ssr_unprotect(__func__);
13752
13753 return ret;
13754}
13755
13756static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070013757 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070013758{
13759 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013760 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013761 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013762 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013763
Jeff Johnsone7245742012-09-05 17:12:55 -070013764 ENTER();
13765
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 if (NULL == pAdapter)
13767 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013768 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013769 return -ENODEV;
13770 }
13771
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013772 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13773 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
13774 pAdapter->sessionId, timeout));
13775
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013776 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013777 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013778 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013779 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013780 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013781 }
13782
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013783 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
13784 (TRUE == pHddCtx->hdd_wlan_suspended) &&
13785 (pHddCtx->cfg_ini->fhostArpOffload) &&
13786 (eConnectionState_Associated ==
13787 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13788 {
Amar Singhald53568e2013-09-26 11:03:45 -070013789
13790 hddLog(VOS_TRACE_LEVEL_INFO,
13791 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053013792 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013793 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13794 {
13795 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013796 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013797 __func__, vos_status);
13798 }
13799 }
13800
Jeff Johnson295189b2012-06-20 16:38:30 -070013801 /**The get power cmd from the supplicant gets updated by the nl only
13802 *on successful execution of the function call
13803 *we are oppositely mapped w.r.t mode in the driver
13804 **/
13805 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
13806
13807 if (VOS_STATUS_E_FAILURE == vos_status)
13808 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013809 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13810 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013811 return -EINVAL;
13812 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013813 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013814 return 0;
13815}
13816
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013817static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
13818 struct net_device *dev, bool mode, int timeout)
13819{
13820 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013821
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013822 vos_ssr_protect(__func__);
13823 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
13824 vos_ssr_unprotect(__func__);
13825
13826 return ret;
13827}
Jeff Johnson295189b2012-06-20 16:38:30 -070013828#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013829static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
13830 struct net_device *netdev,
13831 u8 key_index)
13832{
13833 ENTER();
13834 return 0;
13835}
13836
Jeff Johnson295189b2012-06-20 16:38:30 -070013837static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013838 struct net_device *netdev,
13839 u8 key_index)
13840{
13841 int ret;
13842 vos_ssr_protect(__func__);
13843 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
13844 vos_ssr_unprotect(__func__);
13845 return ret;
13846}
13847#endif //LINUX_VERSION_CODE
13848
13849#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13850static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13851 struct net_device *dev,
13852 struct ieee80211_txq_params *params)
13853{
13854 ENTER();
13855 return 0;
13856}
13857#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13858static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13859 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013860{
Jeff Johnsone7245742012-09-05 17:12:55 -070013861 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070013862 return 0;
13863}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013864#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070013865
13866#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13867static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013868 struct net_device *dev,
13869 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013870{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013871 int ret;
13872
13873 vos_ssr_protect(__func__);
13874 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
13875 vos_ssr_unprotect(__func__);
13876 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013877}
13878#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13879static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
13880 struct ieee80211_txq_params *params)
13881{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013882 int ret;
13883
13884 vos_ssr_protect(__func__);
13885 ret = __wlan_hdd_set_txq_params(wiphy, params);
13886 vos_ssr_unprotect(__func__);
13887 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013888}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013889#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013890
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013891static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013892 struct net_device *dev,
13893 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070013894{
13895 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013896 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013897 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013898 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013899 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013900 v_CONTEXT_t pVosContext = NULL;
13901 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013902
Jeff Johnsone7245742012-09-05 17:12:55 -070013903 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013904
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013905 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070013906 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013907 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013908 return -EINVAL;
13909 }
13910
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013911 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13912 TRACE_CODE_HDD_CFG80211_DEL_STA,
13913 pAdapter->sessionId, pAdapter->device_mode));
13914
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013915 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13916 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013917 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013918 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013919 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013920 }
13921
Jeff Johnson295189b2012-06-20 16:38:30 -070013922 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013923 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013924 )
13925 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013926 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13927 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13928 if(pSapCtx == NULL){
13929 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13930 FL("psapCtx is NULL"));
13931 return -ENOENT;
13932 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013933 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070013934 {
13935 v_U16_t i;
13936 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
13937 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013938 if ((pSapCtx->aStaInfo[i].isUsed) &&
13939 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070013940 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013941 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013942 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013943 ETHER_ADDR_LEN);
13944
Jeff Johnson295189b2012-06-20 16:38:30 -070013945 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013946 "%s: Delete STA with MAC::"
13947 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013948 __func__,
13949 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
13950 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070013951 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013952 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013953 }
13954 }
13955 }
13956 else
13957 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013958
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013959 vos_status = hdd_softap_GetStaId(pAdapter,
13960 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013961 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13962 {
13963 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013964 "%s: Skip this DEL STA as this is not used::"
13965 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013966 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013967 return -ENOENT;
13968 }
13969
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013970 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013971 {
13972 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013973 "%s: Skip this DEL STA as deauth is in progress::"
13974 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013975 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013976 return -ENOENT;
13977 }
13978
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013979 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013980
Jeff Johnson295189b2012-06-20 16:38:30 -070013981 hddLog(VOS_TRACE_LEVEL_INFO,
13982 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013983 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013984 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013985 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013986
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013987 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013988 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13989 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013990 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013991 hddLog(VOS_TRACE_LEVEL_INFO,
13992 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013993 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013994 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013995 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013996 return -ENOENT;
13997 }
13998
Jeff Johnson295189b2012-06-20 16:38:30 -070013999 }
14000 }
14001
14002 EXIT();
14003
14004 return 0;
14005}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014006
14007#ifdef CFG80211_DEL_STA_V2
14008static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14009 struct net_device *dev,
14010 struct station_del_parameters *param)
14011#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014012#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
14013static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14014 struct net_device *dev, const u8 *mac)
14015#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014016static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14017 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014018#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014019#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014020{
14021 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014022 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070014023
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014024 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014025
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014026#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014027 if (NULL == param) {
14028 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014029 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014030 return -EINVAL;
14031 }
14032
14033 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
14034 param->subtype, &delStaParams);
14035
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014036#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053014037 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014038 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014039#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014040 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
14041
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014042 vos_ssr_unprotect(__func__);
14043
14044 return ret;
14045}
14046
14047static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014048 struct net_device *dev,
14049#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14050 const u8 *mac,
14051#else
14052 u8 *mac,
14053#endif
14054 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014055{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014056 hdd_adapter_t *pAdapter;
14057 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014058 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014059#ifdef FEATURE_WLAN_TDLS
14060 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014061
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014062 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014063
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014064 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14065 if (NULL == pAdapter)
14066 {
14067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14068 "%s: Adapter is NULL",__func__);
14069 return -EINVAL;
14070 }
14071 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14072 status = wlan_hdd_validate_context(pHddCtx);
14073 if (0 != status)
14074 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014075 return status;
14076 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014077
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014078 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14079 TRACE_CODE_HDD_CFG80211_ADD_STA,
14080 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014081 mask = params->sta_flags_mask;
14082
14083 set = params->sta_flags_set;
14084
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014085 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014086 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
14087 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014088
14089 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
14090 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080014091 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014092 }
14093 }
14094#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014095 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014096 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014097}
14098
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014099#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
14100static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
14101 struct net_device *dev, const u8 *mac,
14102 struct station_parameters *params)
14103#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014104static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
14105 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014106#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014107{
14108 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014109
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014110 vos_ssr_protect(__func__);
14111 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
14112 vos_ssr_unprotect(__func__);
14113
14114 return ret;
14115}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014116#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070014117
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014118static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070014119 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014120{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014121 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14122 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014123 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014124 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014125 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014126 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070014127
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014128 ENTER();
14129
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014130 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014131 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014132 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014133 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014134 return -EINVAL;
14135 }
14136
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014137 if (!pmksa) {
14138 hddLog(LOGE, FL("pmksa is NULL"));
14139 return -EINVAL;
14140 }
14141
14142 if (!pmksa->bssid || !pmksa->pmkid) {
14143 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
14144 pmksa->bssid, pmksa->pmkid);
14145 return -EINVAL;
14146 }
14147
14148 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
14149 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14150
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014151 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14152 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014153 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014154 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014155 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014156 }
14157
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014158 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014159 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14160
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014161 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
14162 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014163
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014164 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014165 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014166 &pmk_id, 1, FALSE);
14167
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014168 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14169 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
14170 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014171
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014172 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014173 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014174}
14175
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014176static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
14177 struct cfg80211_pmksa *pmksa)
14178{
14179 int ret;
14180
14181 vos_ssr_protect(__func__);
14182 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
14183 vos_ssr_unprotect(__func__);
14184
14185 return ret;
14186}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014187
Wilson Yang6507c4e2013-10-01 20:11:19 -070014188
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014189static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070014190 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014191{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014192 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14193 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014194 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014195 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014196
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014197 ENTER();
14198
Wilson Yang6507c4e2013-10-01 20:11:19 -070014199 /* Validate pAdapter */
14200 if (NULL == pAdapter)
14201 {
14202 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
14203 return -EINVAL;
14204 }
14205
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014206 if (!pmksa) {
14207 hddLog(LOGE, FL("pmksa is NULL"));
14208 return -EINVAL;
14209 }
14210
14211 if (!pmksa->bssid) {
14212 hddLog(LOGE, FL("pmksa->bssid is NULL"));
14213 return -EINVAL;
14214 }
14215
Kiet Lam98c46a12014-10-31 15:34:57 -070014216 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
14217 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14218
Wilson Yang6507c4e2013-10-01 20:11:19 -070014219 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14220 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014221 if (0 != status)
14222 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014223 return status;
14224 }
14225
14226 /*Retrieve halHandle*/
14227 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14228
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014229 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14230 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
14231 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014232 /* Delete the PMKID CSR cache */
14233 if (eHAL_STATUS_SUCCESS !=
14234 sme_RoamDelPMKIDfromCache(halHandle,
14235 pAdapter->sessionId, pmksa->bssid, FALSE)) {
14236 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
14237 MAC_ADDR_ARRAY(pmksa->bssid));
14238 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014239 }
14240
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014241 EXIT();
14242 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014243}
14244
Wilson Yang6507c4e2013-10-01 20:11:19 -070014245
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014246static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
14247 struct cfg80211_pmksa *pmksa)
14248{
14249 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014250
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014251 vos_ssr_protect(__func__);
14252 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
14253 vos_ssr_unprotect(__func__);
14254
14255 return ret;
14256
14257}
14258
14259static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014260{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014261 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14262 tHalHandle halHandle;
14263 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014264 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014265
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014266 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070014267
14268 /* Validate pAdapter */
14269 if (NULL == pAdapter)
14270 {
14271 hddLog(VOS_TRACE_LEVEL_ERROR,
14272 "%s: Invalid Adapter" ,__func__);
14273 return -EINVAL;
14274 }
14275
14276 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14277 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014278 if (0 != status)
14279 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014280 return status;
14281 }
14282
14283 /*Retrieve halHandle*/
14284 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14285
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014286 /* Flush the PMKID cache in CSR */
14287 if (eHAL_STATUS_SUCCESS !=
14288 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
14289 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
14290 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014291 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014292 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080014293 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014294}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014295
14296static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
14297{
14298 int ret;
14299
14300 vos_ssr_protect(__func__);
14301 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
14302 vos_ssr_unprotect(__func__);
14303
14304 return ret;
14305}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014306#endif
14307
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014308#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014309static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14310 struct net_device *dev,
14311 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014312{
14313 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14314 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014315 hdd_context_t *pHddCtx;
14316 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014317
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014318 ENTER();
14319
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014320 if (NULL == pAdapter)
14321 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014322 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014323 return -ENODEV;
14324 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014325 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14326 ret = wlan_hdd_validate_context(pHddCtx);
14327 if (0 != ret)
14328 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014329 return ret;
14330 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014331 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014332 if (NULL == pHddStaCtx)
14333 {
14334 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
14335 return -EINVAL;
14336 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014337
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014338 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14339 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
14340 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014341 // Added for debug on reception of Re-assoc Req.
14342 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
14343 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014344 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014345 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080014346 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014347 }
14348
14349#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080014350 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014351 ftie->ie_len);
14352#endif
14353
14354 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014355 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14356 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014357 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014358
14359 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014360 return 0;
14361}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014362
14363static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14364 struct net_device *dev,
14365 struct cfg80211_update_ft_ies_params *ftie)
14366{
14367 int ret;
14368
14369 vos_ssr_protect(__func__);
14370 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
14371 vos_ssr_unprotect(__func__);
14372
14373 return ret;
14374}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014375#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014376
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014377#ifdef FEATURE_WLAN_SCAN_PNO
14378
14379void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
14380 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
14381{
14382 int ret;
14383 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
14384 hdd_context_t *pHddCtx;
14385
Nirav Shah80830bf2013-12-31 16:35:12 +053014386 ENTER();
14387
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014388 if (NULL == pAdapter)
14389 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014390 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014391 "%s: HDD adapter is Null", __func__);
14392 return ;
14393 }
14394
14395 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14396 if (NULL == pHddCtx)
14397 {
14398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14399 "%s: HDD context is Null!!!", __func__);
14400 return ;
14401 }
14402
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014403 spin_lock(&pHddCtx->schedScan_lock);
14404 if (TRUE == pHddCtx->isWiphySuspended)
14405 {
14406 pHddCtx->isSchedScanUpdatePending = TRUE;
14407 spin_unlock(&pHddCtx->schedScan_lock);
14408 hddLog(VOS_TRACE_LEVEL_INFO,
14409 "%s: Update cfg80211 scan database after it resume", __func__);
14410 return ;
14411 }
14412 spin_unlock(&pHddCtx->schedScan_lock);
14413
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014414 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
14415
14416 if (0 > ret)
14417 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
14418
14419 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14421 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014422}
14423
14424/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014425 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014426 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014427 */
14428static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
14429{
14430 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
14431 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014432 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014433 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14434 int status = 0;
14435 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
14436
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014437 /* The current firmware design does not allow PNO during any
14438 * active sessions. Hence, determine the active sessions
14439 * and return a failure.
14440 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014441 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
14442 {
14443 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014444 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014445
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014446 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
14447 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
14448 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
14449 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
14450 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053014451 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014452 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014453 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014454 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014455 }
14456 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14457 pAdapterNode = pNext;
14458 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014459 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014460}
14461
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014462void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
14463{
14464 hdd_adapter_t *pAdapter = callbackContext;
14465 hdd_context_t *pHddCtx;
14466
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014467 ENTER();
14468
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014469 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
14470 {
14471 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14472 FL("Invalid adapter or adapter has invalid magic"));
14473 return;
14474 }
14475
14476 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14477 if (0 != wlan_hdd_validate_context(pHddCtx))
14478 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014479 return;
14480 }
14481
c_hpothub53c45d2014-08-18 16:53:14 +053014482 if (VOS_STATUS_SUCCESS != status)
14483 {
14484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014485 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053014486 pHddCtx->isPnoEnable = FALSE;
14487 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014488
14489 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
14490 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014491 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014492}
14493
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014494/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014495 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
14496 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014497 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014498static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014499 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14500{
14501 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014502 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014503 hdd_context_t *pHddCtx;
14504 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014505 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053014506 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
14507 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014508 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14509 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014510 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014511 hdd_config_t *pConfig = NULL;
14512 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014513
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014514 ENTER();
14515
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014516 if (NULL == pAdapter)
14517 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014519 "%s: HDD adapter is Null", __func__);
14520 return -ENODEV;
14521 }
14522
14523 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014524 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014525
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014526 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014527 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014528 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014529 }
14530
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014531 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014532 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14533 if (NULL == hHal)
14534 {
14535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14536 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014537 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014538 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014539 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14540 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
14541 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053014542 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014543 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053014544 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014545 {
14546 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14547 "%s: aborting the existing scan is unsuccessfull", __func__);
14548 return -EBUSY;
14549 }
14550
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014551 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014552 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014554 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014555 return -EBUSY;
14556 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014557
c_hpothu37f21312014-04-09 21:49:54 +053014558 if (TRUE == pHddCtx->isPnoEnable)
14559 {
14560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14561 FL("already PNO is enabled"));
14562 return -EBUSY;
14563 }
c_hpothu225aa7c2014-10-22 17:45:13 +053014564
14565 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
14566 {
14567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14568 "%s: abort ROC failed ", __func__);
14569 return -EBUSY;
14570 }
14571
c_hpothu37f21312014-04-09 21:49:54 +053014572 pHddCtx->isPnoEnable = TRUE;
14573
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014574 pnoRequest.enable = 1; /*Enable PNO */
14575 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014576
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014577 if (( !pnoRequest.ucNetworksCount ) ||
14578 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014579 {
14580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014581 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014582 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014583 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014584 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014585 goto error;
14586 }
14587
14588 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
14589 {
14590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014591 "%s: Incorrect number of channels %d",
14592 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014593 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014594 goto error;
14595 }
14596
14597 /* Framework provides one set of channels(all)
14598 * common for all saved profile */
14599 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14600 channels_allowed, &num_channels_allowed))
14601 {
14602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14603 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014604 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014605 goto error;
14606 }
14607 /* Checking each channel against allowed channel list */
14608 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053014609 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014610 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014611 char chList [(request->n_channels*5)+1];
14612 int len;
14613 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014614 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014615 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014616 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014617 if (request->channels[i]->hw_value == channels_allowed[indx])
14618 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014619 if ((!pConfig->enableDFSPnoChnlScan) &&
14620 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
14621 {
14622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14623 "%s : Dropping DFS channel : %d",
14624 __func__,channels_allowed[indx]);
14625 num_ignore_dfs_ch++;
14626 break;
14627 }
14628
Nirav Shah80830bf2013-12-31 16:35:12 +053014629 valid_ch[num_ch++] = request->channels[i]->hw_value;
14630 len += snprintf(chList+len, 5, "%d ",
14631 request->channels[i]->hw_value);
14632 break ;
14633 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014634 }
14635 }
Nirav Shah80830bf2013-12-31 16:35:12 +053014636 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014637
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014638 /*If all channels are DFS and dropped, then ignore the PNO request*/
14639 if (num_ignore_dfs_ch == request->n_channels)
14640 {
14641 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14642 "%s : All requested channels are DFS channels", __func__);
14643 ret = -EINVAL;
14644 goto error;
14645 }
14646 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014647
14648 pnoRequest.aNetworks =
14649 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14650 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014651 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014652 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14653 FL("failed to allocate memory aNetworks %u"),
14654 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14655 goto error;
14656 }
14657 vos_mem_zero(pnoRequest.aNetworks,
14658 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14659
14660 /* Filling per profile params */
14661 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
14662 {
14663 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014664 request->match_sets[i].ssid.ssid_len;
14665
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014666 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
14667 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014668 {
14669 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014670 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014671 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014672 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014673 goto error;
14674 }
14675
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014676 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014677 request->match_sets[i].ssid.ssid,
14678 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14680 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014681 i, pnoRequest.aNetworks[i].ssId.ssId);
14682 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
14683 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
14684 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014685
14686 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014687 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
14688 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014689
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014690 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014691 }
14692
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014693 for (i = 0; i < request->n_ssids; i++)
14694 {
14695 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014696 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014697 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014698 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014699 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014700 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014701 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014702 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014703 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014704 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014705 break;
14706 }
14707 j++;
14708 }
14709 }
14710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14711 "Number of hidden networks being Configured = %d",
14712 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014713 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080014714 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014715
14716 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14717 if (pnoRequest.p24GProbeTemplate == NULL)
14718 {
14719 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14720 FL("failed to allocate memory p24GProbeTemplate %u"),
14721 SIR_PNO_MAX_PB_REQ_SIZE);
14722 goto error;
14723 }
14724
14725 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14726 if (pnoRequest.p5GProbeTemplate == NULL)
14727 {
14728 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14729 FL("failed to allocate memory p5GProbeTemplate %u"),
14730 SIR_PNO_MAX_PB_REQ_SIZE);
14731 goto error;
14732 }
14733
14734 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14735 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14736
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053014737 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
14738 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014739 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014740 pnoRequest.us24GProbeTemplateLen = request->ie_len;
14741 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
14742 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014743
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014744 pnoRequest.us5GProbeTemplateLen = request->ie_len;
14745 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
14746 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014747 }
14748
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014749 /* Driver gets only one time interval which is hardcoded in
14750 * supplicant for 10000ms. Taking power consumption into account 6 timers
14751 * will be used, Timervalue is increased exponentially i.e 10,20,40,
14752 * 80,160,320 secs. And number of scan cycle for each timer
14753 * is configurable through INI param gPNOScanTimerRepeatValue.
14754 * If it is set to 0 only one timer will be used and PNO scan cycle
14755 * will be repeated after each interval specified by supplicant
14756 * till PNO is disabled.
14757 */
14758 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014759 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014760 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014761 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014762 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
14763
14764 tempInterval = (request->interval)/1000;
14765 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14766 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
14767 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014768 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014769 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014770 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014771 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014772 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014773 tempInterval *= 2;
14774 }
14775 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014776 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014777
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014778 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014779
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014780 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014781 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
14782 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014783 pAdapter->pno_req_status = 0;
14784
Nirav Shah80830bf2013-12-31 16:35:12 +053014785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14786 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014787 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
14788 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053014789
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014790 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014791 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014792 hdd_cfg80211_sched_scan_done_callback, pAdapter);
14793 if (eHAL_STATUS_SUCCESS != status)
14794 {
14795 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014796 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014797 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014798 goto error;
14799 }
14800
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014801 ret = wait_for_completion_timeout(
14802 &pAdapter->pno_comp_var,
14803 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
14804 if (0 >= ret)
14805 {
14806 // Did not receive the response for PNO enable in time.
14807 // Assuming the PNO enable was success.
14808 // Returning error from here, because we timeout, results
14809 // in side effect of Wifi (Wifi Setting) not to work.
14810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14811 FL("Timed out waiting for PNO to be Enabled"));
14812 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014813 }
14814
14815 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053014816 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014817
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014818error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14820 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053014821 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014822 if (pnoRequest.aNetworks)
14823 vos_mem_free(pnoRequest.aNetworks);
14824 if (pnoRequest.p24GProbeTemplate)
14825 vos_mem_free(pnoRequest.p24GProbeTemplate);
14826 if (pnoRequest.p5GProbeTemplate)
14827 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014828
14829 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014830 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014831}
14832
14833/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014834 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
14835 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014836 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014837static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
14838 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14839{
14840 int ret;
14841
14842 vos_ssr_protect(__func__);
14843 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
14844 vos_ssr_unprotect(__func__);
14845
14846 return ret;
14847}
14848
14849/*
14850 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
14851 * Function to disable PNO
14852 */
14853static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014854 struct net_device *dev)
14855{
14856 eHalStatus status = eHAL_STATUS_FAILURE;
14857 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14858 hdd_context_t *pHddCtx;
14859 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014860 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014861 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014862
14863 ENTER();
14864
14865 if (NULL == pAdapter)
14866 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014868 "%s: HDD adapter is Null", __func__);
14869 return -ENODEV;
14870 }
14871
14872 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014873
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014874 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014875 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014876 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014877 "%s: HDD context is Null", __func__);
14878 return -ENODEV;
14879 }
14880
14881 /* The return 0 is intentional when isLogpInProgress and
14882 * isLoadUnloadInProgress. We did observe a crash due to a return of
14883 * failure in sched_scan_stop , especially for a case where the unload
14884 * of the happens at the same time. The function __cfg80211_stop_sched_scan
14885 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
14886 * success. If it returns a failure , then its next invocation due to the
14887 * clean up of the second interface will have the dev pointer corresponding
14888 * to the first one leading to a crash.
14889 */
14890 if (pHddCtx->isLogpInProgress)
14891 {
14892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14893 "%s: LOGP in Progress. Ignore!!!", __func__);
14894 return ret;
14895 }
14896
Mihir Shete18156292014-03-11 15:38:30 +053014897 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014898 {
14899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14900 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14901 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014902 }
14903
14904 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14905 if (NULL == hHal)
14906 {
14907 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14908 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014909 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014910 }
14911
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014912 pnoRequest.enable = 0; /* Disable PNO */
14913 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014914
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014915 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14916 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
14917 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014918 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014919 pAdapter->sessionId,
14920 NULL, pAdapter);
14921 if (eHAL_STATUS_SUCCESS != status)
14922 {
14923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14924 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014925 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014926 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014927 }
c_hpothu37f21312014-04-09 21:49:54 +053014928 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014929
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014930error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014931 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014932 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014933
14934 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014935 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014936}
14937
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014938/*
14939 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
14940 * NL interface to disable PNO
14941 */
14942static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
14943 struct net_device *dev)
14944{
14945 int ret;
14946
14947 vos_ssr_protect(__func__);
14948 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
14949 vos_ssr_unprotect(__func__);
14950
14951 return ret;
14952}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014953#endif /*FEATURE_WLAN_SCAN_PNO*/
14954
14955
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014956#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014957#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053014958static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
14959 struct net_device *dev,
14960 u8 *peer, u8 action_code,
14961 u8 dialog_token,
14962 u16 status_code, u32 peer_capability,
14963 const u8 *buf, size_t len)
14964#else /* TDLS_MGMT_VERSION2 */
14965#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
14966static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
14967 struct net_device *dev,
14968 const u8 *peer, u8 action_code,
14969 u8 dialog_token, u16 status_code,
14970 u32 peer_capability, bool initiator,
14971 const u8 *buf, size_t len)
14972#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
14973static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
14974 struct net_device *dev,
14975 const u8 *peer, u8 action_code,
14976 u8 dialog_token, u16 status_code,
14977 u32 peer_capability, const u8 *buf,
14978 size_t len)
14979#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
14980static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
14981 struct net_device *dev,
14982 u8 *peer, u8 action_code,
14983 u8 dialog_token,
14984 u16 status_code, u32 peer_capability,
14985 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014986#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053014987static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
14988 struct net_device *dev,
14989 u8 *peer, u8 action_code,
14990 u8 dialog_token,
14991 u16 status_code, const u8 *buf,
14992 size_t len)
14993#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014994#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014995{
14996
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014997 hdd_adapter_t *pAdapter;
14998 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014999 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070015000 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080015001 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070015002 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015003 int ret;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015004#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015005 u32 peer_capability = 0;
15006#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015007 tANI_U16 numCurrTdlsPeers;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015008
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015009 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15010 if (NULL == pAdapter)
15011 {
15012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15013 "%s: Adapter is NULL",__func__);
15014 return -EINVAL;
15015 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015016 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15017 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
15018 pAdapter->sessionId, action_code));
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015019 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015020 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015021 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015022 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015023 "Invalid arguments");
15024 return -EINVAL;
15025 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015026 if (pHddCtx->isLogpInProgress)
15027 {
15028 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15029 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053015030 wlan_hdd_tdls_set_link_status(pAdapter,
15031 peer,
15032 eTDLS_LINK_IDLE,
15033 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015034 return -EBUSY;
15035 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015036 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
15037 {
15038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15039 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
15040 return -EAGAIN;
15041 }
Hoonki Lee27511902013-03-14 18:19:06 -070015042 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015043 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015044 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070015045 "%s: TDLS mode is disabled OR not enabled in FW."
15046 MAC_ADDRESS_STR " action %d declined.",
15047 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015048 return -ENOTSUPP;
15049 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015050
Hoonki Lee27511902013-03-14 18:19:06 -070015051 /* other than teardown frame, other mgmt frames are not sent if disabled */
15052 if (SIR_MAC_TDLS_TEARDOWN != action_code)
15053 {
15054 /* if tdls_mode is disabled to respond to peer's request */
15055 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
15056 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015057 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070015058 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015059 " TDLS mode is disabled. action %d declined.",
15060 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070015061
15062 return -ENOTSUPP;
15063 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053015064
15065 if (vos_max_concurrent_connections_reached())
15066 {
15067 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15068 return -EINVAL;
15069 }
Hoonki Lee27511902013-03-14 18:19:06 -070015070 }
15071
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015072 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
15073 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053015074 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015075 {
15076 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015077 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015078 " TDLS setup is ongoing. action %d declined.",
15079 __func__, MAC_ADDR_ARRAY(peer), action_code);
15080 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015081 }
15082 }
15083
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015084 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
15085 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080015086 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015087 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15088 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080015089 {
15090 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
15091 we return error code at 'add_station()'. Hence we have this
15092 check again in addtion to add_station().
15093 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015094 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080015095 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015096 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15097 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015098 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
15099 __func__, MAC_ADDR_ARRAY(peer), action_code,
15100 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053015101 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080015102 }
15103 else
15104 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015105 /* maximum reached. tweak to send error code to peer and return
15106 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080015107 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015108 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15109 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015110 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
15111 __func__, MAC_ADDR_ARRAY(peer), status_code,
15112 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070015113 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015114 /* fall through to send setup resp with failure status
15115 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080015116 }
15117 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015118 else
15119 {
15120 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053015121 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015122 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015123 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015124 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015125 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
15126 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015127 return -EPERM;
15128 }
15129 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015130 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015131
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015132 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053015133 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015134 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
15135 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015136
Hoonki Leea34dd892013-02-05 22:56:02 -080015137 /*Except teardown responder will not be used so just make 0*/
15138 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015139 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080015140 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015141
15142 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015143 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015144
15145 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
15146 responder = pTdlsPeer->is_responder;
15147 else
Hoonki Leea34dd892013-02-05 22:56:02 -080015148 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015149 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053015150 "%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 -070015151 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
15152 dialog_token, status_code, len);
15153 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080015154 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015155 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015156
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015157 /* For explicit trigger of DIS_REQ come out of BMPS for
15158 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070015159 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015160 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
15161 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070015162 {
15163 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
15164 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015165 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015166 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015167 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
15168 if (status != VOS_STATUS_SUCCESS) {
15169 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
15170 }
Hoonki Lee14621352013-04-16 17:51:19 -070015171 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015172 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015173 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015174 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
15175 }
15176 }
Hoonki Lee14621352013-04-16 17:51:19 -070015177 }
15178
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015179 /* make sure doesn't call send_mgmt() while it is pending */
15180 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
15181 {
15182 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015183 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015184 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015185 ret = -EBUSY;
15186 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015187 }
15188
15189 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015190 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
15191
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015192 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015193 peer, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015194
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015195 if (VOS_STATUS_SUCCESS != status)
15196 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15198 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015199 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015200 ret = -EINVAL;
15201 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015202 }
15203
Hoonki Leed37cbb32013-04-20 00:31:14 -070015204 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
15205 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
15206
15207 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015208 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070015209 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070015210 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070015211 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015212 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080015213
15214 if (pHddCtx->isLogpInProgress)
15215 {
15216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15217 "%s: LOGP in Progress. Ignore!!!", __func__);
15218 return -EAGAIN;
15219 }
15220
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015221 ret = -EINVAL;
15222 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015223 }
15224
Gopichand Nakkala05922802013-03-14 12:23:19 -070015225 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070015226 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015227 ret = max_sta_failed;
15228 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070015229 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015230
Hoonki Leea34dd892013-02-05 22:56:02 -080015231 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
15232 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015233 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015234 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15235 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015236 }
15237 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
15238 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015239 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015240 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15241 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015242 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015243
15244 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015245
15246tx_failed:
15247 /* add_station will be called before sending TDLS_SETUP_REQ and
15248 * TDLS_SETUP_RSP and as part of add_station driver will enable
15249 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
15250 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
15251 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
15252 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
15253 */
15254
15255 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
15256 (SIR_MAC_TDLS_SETUP_RSP == action_code))
15257 wlan_hdd_tdls_check_bmps(pAdapter);
15258 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015259}
15260
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015261#if TDLS_MGMT_VERSION2
15262static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15263 u8 *peer, u8 action_code, u8 dialog_token,
15264 u16 status_code, u32 peer_capability,
15265 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015266#else /* TDLS_MGMT_VERSION2 */
15267#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
15268static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15269 struct net_device *dev,
15270 const u8 *peer, u8 action_code,
15271 u8 dialog_token, u16 status_code,
15272 u32 peer_capability, bool initiator,
15273 const u8 *buf, size_t len)
15274#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
15275static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15276 struct net_device *dev,
15277 const u8 *peer, u8 action_code,
15278 u8 dialog_token, u16 status_code,
15279 u32 peer_capability, const u8 *buf,
15280 size_t len)
15281#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
15282static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15283 struct net_device *dev,
15284 u8 *peer, u8 action_code,
15285 u8 dialog_token,
15286 u16 status_code, u32 peer_capability,
15287 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015288#else
15289static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15290 u8 *peer, u8 action_code, u8 dialog_token,
15291 u16 status_code, const u8 *buf, size_t len)
15292#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015293#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015294{
15295 int ret;
15296
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015297 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015298#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015299 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15300 dialog_token, status_code,
15301 peer_capability, buf, len);
15302#else /* TDLS_MGMT_VERSION2 */
15303#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
15304 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15305 dialog_token, status_code,
15306 peer_capability, initiator,
15307 buf, len);
15308#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
15309 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15310 dialog_token, status_code,
15311 peer_capability, buf, len);
15312#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
15313 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15314 dialog_token, status_code,
15315 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015316#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015317 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15318 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015319#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015320#endif
15321 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015322
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015323 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015324}
Atul Mittal115287b2014-07-08 13:26:33 +053015325
15326int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015327#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15328 const u8 *peer,
15329#else
Atul Mittal115287b2014-07-08 13:26:33 +053015330 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015331#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015332 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053015333 cfg80211_exttdls_callback callback)
15334{
15335
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015336 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053015337 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015338 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053015339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15340 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
15341 __func__, MAC_ADDR_ARRAY(peer));
15342
15343 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15344 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15345
15346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015347 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15348 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15349 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015350 return -ENOTSUPP;
15351 }
15352
15353 /* To cater the requirement of establishing the TDLS link
15354 * irrespective of the data traffic , get an entry of TDLS peer.
15355 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015356 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015357 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
15358 if (pTdlsPeer == NULL) {
15359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15360 "%s: peer " MAC_ADDRESS_STR " not existing",
15361 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015362 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015363 return -EINVAL;
15364 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015365 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015366
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015367 /* check FW TDLS Off Channel capability */
15368 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015369 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015370 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015371 {
15372 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
15373 pTdlsPeer->peerParams.global_operating_class =
15374 tdls_peer_params->global_operating_class;
15375 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
15376 pTdlsPeer->peerParams.min_bandwidth_kbps =
15377 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015378 /* check configured channel is valid, non dfs and
15379 * not current operating channel */
15380 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
15381 tdls_peer_params->channel)) &&
15382 (pHddStaCtx) &&
15383 (tdls_peer_params->channel !=
15384 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015385 {
15386 pTdlsPeer->isOffChannelConfigured = TRUE;
15387 }
15388 else
15389 {
15390 pTdlsPeer->isOffChannelConfigured = FALSE;
15391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15392 "%s: Configured Tdls Off Channel is not valid", __func__);
15393
15394 }
15395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015396 "%s: tdls_off_channel %d isOffChannelConfigured %d "
15397 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015398 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015399 pTdlsPeer->isOffChannelConfigured,
15400 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015401 }
15402 else
15403 {
15404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015405 "%s: TDLS off channel FW capability %d, "
15406 "host capab %d or Invalid TDLS Peer Params", __func__,
15407 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
15408 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015409 }
15410
Atul Mittal115287b2014-07-08 13:26:33 +053015411 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
15412
15413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15414 " %s TDLS Add Force Peer Failed",
15415 __func__);
15416 return -EINVAL;
15417 }
15418 /*EXT TDLS*/
15419
15420 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
15421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15422 " %s TDLS set callback Failed",
15423 __func__);
15424 return -EINVAL;
15425 }
15426
15427 return(0);
15428
15429}
15430
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015431int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
15432#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15433 const u8 *peer
15434#else
15435 u8 *peer
15436#endif
15437)
Atul Mittal115287b2014-07-08 13:26:33 +053015438{
15439
15440 hddTdlsPeer_t *pTdlsPeer;
15441 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15442 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15443 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
15444 __func__, MAC_ADDR_ARRAY(peer));
15445
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015446 if (0 != wlan_hdd_validate_context(pHddCtx)) {
15447 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
15448 return -EINVAL;
15449 }
15450
Atul Mittal115287b2014-07-08 13:26:33 +053015451 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15452 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15453
15454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015455 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15456 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15457 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015458 return -ENOTSUPP;
15459 }
15460
15461
15462 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15463
15464 if ( NULL == pTdlsPeer ) {
15465 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015466 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053015467 __func__, MAC_ADDR_ARRAY(peer));
15468 return -EINVAL;
15469 }
15470 else {
15471 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
15472 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015473 /* if channel switch is configured, reset
15474 the channel for this peer */
15475 if (TRUE == pTdlsPeer->isOffChannelConfigured)
15476 {
15477 pTdlsPeer->peerParams.channel = 0;
15478 pTdlsPeer->isOffChannelConfigured = FALSE;
15479 }
Atul Mittal115287b2014-07-08 13:26:33 +053015480 }
15481
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015482 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
15483 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053015484 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015485 }
Atul Mittal115287b2014-07-08 13:26:33 +053015486
15487 /*EXT TDLS*/
15488
15489 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
15490
15491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15492 " %s TDLS set callback Failed",
15493 __func__);
15494 return -EINVAL;
15495 }
15496 return(0);
15497
15498}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015499static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015500#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15501 const u8 *peer,
15502#else
15503 u8 *peer,
15504#endif
15505 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015506{
15507 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15508 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015509 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015510 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015511
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015512 ENTER();
15513
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015514 if (!pAdapter) {
15515 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15516 return -EINVAL;
15517 }
15518
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015519 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15520 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
15521 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015522 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015523 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015524 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070015525 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015526 return -EINVAL;
15527 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015528
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015529 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015530 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015531 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015532 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015533 }
15534
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015535
15536 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015537 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015538 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015539 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015540 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
15541 "Cannot process TDLS commands",
15542 pHddCtx->cfg_ini->fEnableTDLSSupport,
15543 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015544 return -ENOTSUPP;
15545 }
15546
15547 switch (oper) {
15548 case NL80211_TDLS_ENABLE_LINK:
15549 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015550 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015551 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015552 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053015553 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015554 tANI_U16 numCurrTdlsPeers = 0;
15555 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015556 tANI_U8 suppChannelLen = 0;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015557
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015558 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15559 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
15560 __func__, MAC_ADDR_ARRAY(peer));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015561 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015562 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015563 if ( NULL == pTdlsPeer ) {
15564 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15565 " (oper %d) not exsting. ignored",
15566 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15567 return -EINVAL;
15568 }
15569
15570 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15571 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15572 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15573 "NL80211_TDLS_ENABLE_LINK");
15574
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070015575 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
15576 {
15577 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
15578 MAC_ADDRESS_STR " failed",
15579 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
15580 return -EINVAL;
15581 }
15582
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015583 /* before starting tdls connection, set tdls
15584 * off channel established status to default value */
15585 pTdlsPeer->isOffChannelEstablished = FALSE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015586 /* TDLS Off Channel, Disable tdls channel switch,
15587 when there are more than one tdls link */
15588 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053015589 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015590 {
15591 /* get connected peer and send disable tdls off chan */
15592 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015593 if ((connPeer) &&
15594 (connPeer->isOffChannelSupported == TRUE) &&
15595 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015596 {
15597 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15598 "%s: More then one peer connected, Disable "
15599 "TDLS channel switch", __func__);
15600
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015601 connPeer->isOffChannelEstablished = FALSE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015602 ret = sme_SendTdlsChanSwitchReq(
15603 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015604 pAdapter->sessionId,
15605 connPeer->peerMac,
15606 connPeer->peerParams.channel,
15607 TDLS_OFF_CHANNEL_BW_OFFSET,
15608 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015609 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015610 hddLog(VOS_TRACE_LEVEL_ERROR,
15611 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015612 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015613 }
15614 else
15615 {
15616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15617 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015618 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015619 "isOffChannelConfigured %d",
15620 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015621 (connPeer ? (connPeer->isOffChannelSupported)
15622 : -1),
15623 (connPeer ? (connPeer->isOffChannelConfigured)
15624 : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015625 }
15626 }
15627
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015628 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015629 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015630 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053015631
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015632 if (0 != wlan_hdd_tdls_get_link_establish_params(
15633 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015634 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015635 return -EINVAL;
15636 }
15637 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015638
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015639 ret = sme_SendTdlsLinkEstablishParams(
15640 WLAN_HDD_GET_HAL_CTX(pAdapter),
15641 pAdapter->sessionId, peer,
15642 &tdlsLinkEstablishParams);
15643 if (ret != VOS_STATUS_SUCCESS) {
15644 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
15645 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015646 /* Send TDLS peer UAPSD capabilities to the firmware and
15647 * register with the TL on after the response for this operation
15648 * is received .
15649 */
15650 ret = wait_for_completion_interruptible_timeout(
15651 &pAdapter->tdls_link_establish_req_comp,
15652 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
15653 if (ret <= 0)
15654 {
15655 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015656 FL("Link Establish Request Failed Status %ld"),
15657 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015658 return -EINVAL;
15659 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015660 }
Atul Mittal115287b2014-07-08 13:26:33 +053015661 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15662 eTDLS_LINK_CONNECTED,
15663 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015664 staDesc.ucSTAId = pTdlsPeer->staId;
15665 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015666 ret = WLANTL_UpdateTdlsSTAClient(
15667 pHddCtx->pvosContext,
15668 &staDesc);
15669 if (ret != VOS_STATUS_SUCCESS) {
15670 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
15671 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053015672
Gopichand Nakkala471708b2013-06-04 20:03:01 +053015673 /* Mark TDLS client Authenticated .*/
15674 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
15675 pTdlsPeer->staId,
15676 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015677 if (VOS_STATUS_SUCCESS == status)
15678 {
Hoonki Lee14621352013-04-16 17:51:19 -070015679 if (pTdlsPeer->is_responder == 0)
15680 {
15681 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
15682
15683 wlan_hdd_tdls_timer_restart(pAdapter,
15684 &pTdlsPeer->initiatorWaitTimeoutTimer,
15685 WAIT_TIME_TDLS_INITIATOR);
15686 /* suspend initiator TX until it receives direct packet from the
15687 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015688 ret = WLANTL_SuspendDataTx(
15689 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15690 &staId, NULL);
15691 if (ret != VOS_STATUS_SUCCESS) {
15692 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
15693 }
Hoonki Lee14621352013-04-16 17:51:19 -070015694 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015695
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015696 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015697 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015698 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015699 suppChannelLen =
15700 tdlsLinkEstablishParams.supportedChannelsLen;
15701
15702 if ((suppChannelLen > 0) &&
15703 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
15704 {
15705 tANI_U8 suppPeerChannel = 0;
15706 int i = 0;
15707 for (i = 0U; i < suppChannelLen; i++)
15708 {
15709 suppPeerChannel =
15710 tdlsLinkEstablishParams.supportedChannels[i];
15711
15712 pTdlsPeer->isOffChannelSupported = FALSE;
15713 if (suppPeerChannel ==
15714 pTdlsPeer->peerParams.channel)
15715 {
15716 pTdlsPeer->isOffChannelSupported = TRUE;
15717 break;
15718 }
15719 }
15720 }
15721 else
15722 {
15723 pTdlsPeer->isOffChannelSupported = FALSE;
15724 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015725 }
15726 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15727 "%s: TDLS channel switch request for channel "
15728 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015729 "%d isOffChannelSupported %d", __func__,
15730 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015731 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015732 suppChannelLen,
15733 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015734
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015735 /* TDLS Off Channel, Enable tdls channel switch,
15736 when their is only one tdls link and it supports */
15737 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15738 if ((numCurrTdlsPeers == 1) &&
15739 (TRUE == pTdlsPeer->isOffChannelSupported) &&
15740 (TRUE == pTdlsPeer->isOffChannelConfigured))
15741 {
15742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15743 "%s: Send TDLS channel switch request for channel %d",
15744 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015745
15746 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015747 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
15748 pAdapter->sessionId,
15749 pTdlsPeer->peerMac,
15750 pTdlsPeer->peerParams.channel,
15751 TDLS_OFF_CHANNEL_BW_OFFSET,
15752 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015753 if (ret != VOS_STATUS_SUCCESS) {
15754 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
15755 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015756 }
15757 else
15758 {
15759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15760 "%s: TDLS channel switch request not sent"
15761 " numCurrTdlsPeers %d "
15762 "isOffChannelSupported %d "
15763 "isOffChannelConfigured %d",
15764 __func__, numCurrTdlsPeers,
15765 pTdlsPeer->isOffChannelSupported,
15766 pTdlsPeer->isOffChannelConfigured);
15767 }
15768
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015769 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015770 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015771
15772 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015773 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
15774 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015775 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015776 int ac;
15777 uint8 ucAc[4] = { WLANTL_AC_VO,
15778 WLANTL_AC_VI,
15779 WLANTL_AC_BK,
15780 WLANTL_AC_BE };
15781 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
15782 for(ac=0; ac < 4; ac++)
15783 {
15784 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15785 pTdlsPeer->staId, ucAc[ac],
15786 tlTid[ac], tlTid[ac], 0, 0,
15787 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015788 if (status != VOS_STATUS_SUCCESS) {
15789 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
15790 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015791 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015792 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015793 }
15794
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015795 }
15796 break;
15797 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080015798 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015799 tANI_U16 numCurrTdlsPeers = 0;
15800 hddTdlsPeer_t *connPeer = NULL;
15801
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15803 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
15804 __func__, MAC_ADDR_ARRAY(peer));
15805
Sunil Dutt41de4e22013-11-14 18:09:02 +053015806 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15807
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015808
Sunil Dutt41de4e22013-11-14 18:09:02 +053015809 if ( NULL == pTdlsPeer ) {
15810 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15811 " (oper %d) not exsting. ignored",
15812 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15813 return -EINVAL;
15814 }
15815
15816 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15817 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15818 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15819 "NL80211_TDLS_DISABLE_LINK");
15820
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015821 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080015822 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015823 long status;
15824
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015825 /* set tdls off channel status to false for this peer */
15826 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053015827 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15828 eTDLS_LINK_TEARING,
15829 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
15830 eTDLS_LINK_UNSPECIFIED:
15831 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015832 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
15833
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015834 status = sme_DeleteTdlsPeerSta(
15835 WLAN_HDD_GET_HAL_CTX(pAdapter),
15836 pAdapter->sessionId, peer );
15837 if (status != VOS_STATUS_SUCCESS) {
15838 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15839 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015840
15841 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
15842 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053015843 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053015844 eTDLS_LINK_IDLE,
15845 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015846 if (status <= 0)
15847 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15849 "%s: Del station failed status %ld",
15850 __func__, status);
15851 return -EPERM;
15852 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015853
15854 /* TDLS Off Channel, Enable tdls channel switch,
15855 when their is only one tdls link and it supports */
15856 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15857 if (numCurrTdlsPeers == 1)
15858 {
15859 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15860 if ((connPeer) &&
15861 (connPeer->isOffChannelSupported == TRUE) &&
15862 (connPeer->isOffChannelConfigured == TRUE))
15863 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015864 connPeer->isOffChannelEstablished = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015865 status = sme_SendTdlsChanSwitchReq(
15866 WLAN_HDD_GET_HAL_CTX(pAdapter),
15867 pAdapter->sessionId,
15868 connPeer->peerMac,
15869 connPeer->peerParams.channel,
15870 TDLS_OFF_CHANNEL_BW_OFFSET,
15871 TDLS_CHANNEL_SWITCH_ENABLE);
15872 if (status != VOS_STATUS_SUCCESS) {
15873 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
15874 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015875 }
15876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15877 "%s: TDLS channel switch "
15878 "isOffChannelSupported %d "
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015879 "isOffChannelConfigured %d "
15880 "isOffChannelEstablished %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015881 __func__,
15882 (connPeer ? connPeer->isOffChannelSupported : -1),
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015883 (connPeer ? connPeer->isOffChannelConfigured : -1),
15884 (connPeer ? connPeer->isOffChannelEstablished : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015885 }
15886 else
15887 {
15888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15889 "%s: TDLS channel switch request not sent "
15890 "numCurrTdlsPeers %d ",
15891 __func__, numCurrTdlsPeers);
15892 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015893 }
15894 else
15895 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15897 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080015898 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015899 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015900 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015901 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015902 {
Atul Mittal115287b2014-07-08 13:26:33 +053015903 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015904
Atul Mittal115287b2014-07-08 13:26:33 +053015905 if (0 != status)
15906 {
15907 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015908 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053015909 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015910 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053015911 break;
15912 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015913 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015914 {
Atul Mittal115287b2014-07-08 13:26:33 +053015915 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
15916 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015917 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053015918 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015919
Atul Mittal115287b2014-07-08 13:26:33 +053015920 if (0 != status)
15921 {
15922 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015923 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053015924 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053015925 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053015926 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015927 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015928 case NL80211_TDLS_DISCOVERY_REQ:
15929 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015931 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015932 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015933 return -ENOTSUPP;
15934 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15936 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015937 return -ENOTSUPP;
15938 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015939
15940 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015941 return 0;
15942}
Chilam NG571c65a2013-01-19 12:27:36 +053015943
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015944static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015945#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15946 const u8 *peer,
15947#else
15948 u8 *peer,
15949#endif
15950 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015951{
15952 int ret;
15953
15954 vos_ssr_protect(__func__);
15955 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
15956 vos_ssr_unprotect(__func__);
15957
15958 return ret;
15959}
15960
Chilam NG571c65a2013-01-19 12:27:36 +053015961int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
15962 struct net_device *dev, u8 *peer)
15963{
Arif Hussaina7c8e412013-11-20 11:06:42 -080015964 hddLog(VOS_TRACE_LEVEL_INFO,
15965 "tdls send discover req: "MAC_ADDRESS_STR,
15966 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053015967
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015968#if TDLS_MGMT_VERSION2
15969 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15970 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
15971#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015972#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
15973 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15974 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
15975#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
15976 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15977 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
15978#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
15979 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15980 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
15981#else
Chilam NG571c65a2013-01-19 12:27:36 +053015982 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15983 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015984#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015985#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053015986}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015987#endif
15988
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015989#ifdef WLAN_FEATURE_GTK_OFFLOAD
15990/*
15991 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
15992 * Callback rountine called upon receiving response for
15993 * get offload info
15994 */
15995void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
15996 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
15997{
15998
15999 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016000 tANI_U8 tempReplayCounter[8];
16001 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016002
16003 ENTER();
16004
16005 if (NULL == pAdapter)
16006 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053016007 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016008 "%s: HDD adapter is Null", __func__);
16009 return ;
16010 }
16011
16012 if (NULL == pGtkOffloadGetInfoRsp)
16013 {
16014 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16015 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
16016 return ;
16017 }
16018
16019 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
16020 {
16021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16022 "%s: wlan Failed to get replay counter value",
16023 __func__);
16024 return ;
16025 }
16026
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016027 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16028 /* Update replay counter */
16029 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
16030 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
16031
16032 {
16033 /* changing from little to big endian since supplicant
16034 * works on big endian format
16035 */
16036 int i;
16037 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
16038
16039 for (i = 0; i < 8; i++)
16040 {
16041 tempReplayCounter[7-i] = (tANI_U8)p[i];
16042 }
16043 }
16044
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016045 /* Update replay counter to NL */
16046 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016047 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016048}
16049
16050/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016051 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016052 * This function is used to offload GTK rekeying job to the firmware.
16053 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016054int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016055 struct cfg80211_gtk_rekey_data *data)
16056{
16057 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16058 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16059 hdd_station_ctx_t *pHddStaCtx;
16060 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016061 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016062 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016063 eHalStatus status = eHAL_STATUS_FAILURE;
16064
16065 ENTER();
16066
16067 if (NULL == pAdapter)
16068 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016069 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016070 "%s: HDD adapter is Null", __func__);
16071 return -ENODEV;
16072 }
16073
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016074 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16075 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
16076 pAdapter->sessionId, pAdapter->device_mode));
16077
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016078 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016079 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016080 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016081 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016082 }
16083
16084 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16085 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
16086 if (NULL == hHal)
16087 {
16088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16089 "%s: HAL context is Null!!!", __func__);
16090 return -EAGAIN;
16091 }
16092
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016093 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
16094 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
16095 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
16096 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016097 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016098 {
16099 /* changing from big to little endian since driver
16100 * works on little endian format
16101 */
16102 tANI_U8 *p =
16103 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
16104 int i;
16105
16106 for (i = 0; i < 8; i++)
16107 {
16108 p[7-i] = data->replay_ctr[i];
16109 }
16110 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016111
16112 if (TRUE == pHddCtx->hdd_wlan_suspended)
16113 {
16114 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016115 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
16116 sizeof (tSirGtkOffloadParams));
16117 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016118 pAdapter->sessionId);
16119
16120 if (eHAL_STATUS_SUCCESS != status)
16121 {
16122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16123 "%s: sme_SetGTKOffload failed, returned %d",
16124 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053016125
16126 /* Need to clear any trace of key value in the memory.
16127 * Thus zero out the memory even though it is local
16128 * variable.
16129 */
16130 vos_mem_zero(&hddGtkOffloadReqParams,
16131 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016132 return status;
16133 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16135 "%s: sme_SetGTKOffload successfull", __func__);
16136 }
16137 else
16138 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16140 "%s: wlan not suspended GTKOffload request is stored",
16141 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016142 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016143
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053016144 /* Need to clear any trace of key value in the memory.
16145 * Thus zero out the memory even though it is local
16146 * variable.
16147 */
16148 vos_mem_zero(&hddGtkOffloadReqParams,
16149 sizeof(hddGtkOffloadReqParams));
16150
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016151 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016152 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016153}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016154
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016155int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
16156 struct cfg80211_gtk_rekey_data *data)
16157{
16158 int ret;
16159
16160 vos_ssr_protect(__func__);
16161 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
16162 vos_ssr_unprotect(__func__);
16163
16164 return ret;
16165}
16166#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016167/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016168 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016169 * This function is used to set access control policy
16170 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016171static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16172 struct net_device *dev,
16173 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016174{
16175 int i;
16176 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16177 hdd_hostapd_state_t *pHostapdState;
16178 tsap_Config_t *pConfig;
16179 v_CONTEXT_t pVosContext = NULL;
16180 hdd_context_t *pHddCtx;
16181 int status;
16182
16183 ENTER();
16184
16185 if (NULL == pAdapter)
16186 {
16187 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16188 "%s: HDD adapter is Null", __func__);
16189 return -ENODEV;
16190 }
16191
16192 if (NULL == params)
16193 {
16194 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16195 "%s: params is Null", __func__);
16196 return -EINVAL;
16197 }
16198
16199 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16200 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016201 if (0 != status)
16202 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016203 return status;
16204 }
16205
16206 pVosContext = pHddCtx->pvosContext;
16207 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
16208
16209 if (NULL == pHostapdState)
16210 {
16211 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16212 "%s: pHostapdState is Null", __func__);
16213 return -EINVAL;
16214 }
16215
16216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
16217 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016218 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16219 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
16220 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016221
16222 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
16223 {
16224 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
16225
16226 /* default value */
16227 pConfig->num_accept_mac = 0;
16228 pConfig->num_deny_mac = 0;
16229
16230 /**
16231 * access control policy
16232 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
16233 * listed in hostapd.deny file.
16234 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
16235 * listed in hostapd.accept file.
16236 */
16237 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
16238 {
16239 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
16240 }
16241 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
16242 {
16243 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
16244 }
16245 else
16246 {
16247 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16248 "%s:Acl Policy : %d is not supported",
16249 __func__, params->acl_policy);
16250 return -ENOTSUPP;
16251 }
16252
16253 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
16254 {
16255 pConfig->num_accept_mac = params->n_acl_entries;
16256 for (i = 0; i < params->n_acl_entries; i++)
16257 {
16258 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16259 "** Add ACL MAC entry %i in WhiletList :"
16260 MAC_ADDRESS_STR, i,
16261 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16262
16263 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
16264 sizeof(qcmacaddr));
16265 }
16266 }
16267 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
16268 {
16269 pConfig->num_deny_mac = params->n_acl_entries;
16270 for (i = 0; i < params->n_acl_entries; i++)
16271 {
16272 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16273 "** Add ACL MAC entry %i in BlackList :"
16274 MAC_ADDRESS_STR, i,
16275 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16276
16277 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
16278 sizeof(qcmacaddr));
16279 }
16280 }
16281
16282 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
16283 {
16284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16285 "%s: SAP Set Mac Acl fail", __func__);
16286 return -EINVAL;
16287 }
16288 }
16289 else
16290 {
16291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053016292 "%s: Invalid device_mode = %s (%d)",
16293 __func__, hdd_device_modetoString(pAdapter->device_mode),
16294 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016295 return -EINVAL;
16296 }
16297
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016298 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016299 return 0;
16300}
16301
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016302static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16303 struct net_device *dev,
16304 const struct cfg80211_acl_data *params)
16305{
16306 int ret;
16307 vos_ssr_protect(__func__);
16308 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
16309 vos_ssr_unprotect(__func__);
16310
16311 return ret;
16312}
16313
Leo Chang9056f462013-08-01 19:21:11 -070016314#ifdef WLAN_NL80211_TESTMODE
16315#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070016316void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070016317(
16318 void *pAdapter,
16319 void *indCont
16320)
16321{
Leo Changd9df8aa2013-09-26 13:32:26 -070016322 tSirLPHBInd *lphbInd;
16323 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053016324 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070016325
16326 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016327 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070016328
c_hpothu73f35e62014-04-18 13:40:08 +053016329 if (pAdapter == NULL)
16330 {
16331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16332 "%s: pAdapter is NULL\n",__func__);
16333 return;
16334 }
16335
Leo Chang9056f462013-08-01 19:21:11 -070016336 if (NULL == indCont)
16337 {
16338 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016339 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070016340 return;
16341 }
16342
c_hpothu73f35e62014-04-18 13:40:08 +053016343 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070016344 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070016345 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053016346 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070016347 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070016348 GFP_ATOMIC);
16349 if (!skb)
16350 {
16351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16352 "LPHB timeout, NL buffer alloc fail");
16353 return;
16354 }
16355
Leo Changac3ba772013-10-07 09:47:04 -070016356 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070016357 {
16358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16359 "WLAN_HDD_TM_ATTR_CMD put fail");
16360 goto nla_put_failure;
16361 }
Leo Changac3ba772013-10-07 09:47:04 -070016362 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070016363 {
16364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16365 "WLAN_HDD_TM_ATTR_TYPE put fail");
16366 goto nla_put_failure;
16367 }
Leo Changac3ba772013-10-07 09:47:04 -070016368 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070016369 sizeof(tSirLPHBInd), lphbInd))
16370 {
16371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16372 "WLAN_HDD_TM_ATTR_DATA put fail");
16373 goto nla_put_failure;
16374 }
Leo Chang9056f462013-08-01 19:21:11 -070016375 cfg80211_testmode_event(skb, GFP_ATOMIC);
16376 return;
16377
16378nla_put_failure:
16379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16380 "NLA Put fail");
16381 kfree_skb(skb);
16382
16383 return;
16384}
16385#endif /* FEATURE_WLAN_LPHB */
16386
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016387static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070016388{
16389 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
16390 int err = 0;
16391#ifdef FEATURE_WLAN_LPHB
16392 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070016393 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016394
16395 ENTER();
16396
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016397 err = wlan_hdd_validate_context(pHddCtx);
16398 if (0 != err)
16399 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016400 return err;
16401 }
Leo Chang9056f462013-08-01 19:21:11 -070016402#endif /* FEATURE_WLAN_LPHB */
16403
16404 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
16405 if (err)
16406 {
16407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16408 "%s Testmode INV ATTR", __func__);
16409 return err;
16410 }
16411
16412 if (!tb[WLAN_HDD_TM_ATTR_CMD])
16413 {
16414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16415 "%s Testmode INV CMD", __func__);
16416 return -EINVAL;
16417 }
16418
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016419 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16420 TRACE_CODE_HDD_CFG80211_TESTMODE,
16421 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070016422 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
16423 {
16424#ifdef FEATURE_WLAN_LPHB
16425 /* Low Power Heartbeat configuration request */
16426 case WLAN_HDD_TM_CMD_WLAN_HB:
16427 {
16428 int buf_len;
16429 void *buf;
16430 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080016431 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070016432
16433 if (!tb[WLAN_HDD_TM_ATTR_DATA])
16434 {
16435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16436 "%s Testmode INV DATA", __func__);
16437 return -EINVAL;
16438 }
16439
16440 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
16441 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080016442
16443 hb_params_temp =(tSirLPHBReq *)buf;
16444 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
16445 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
16446 return -EINVAL;
16447
Leo Chang9056f462013-08-01 19:21:11 -070016448 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
16449 if (NULL == hb_params)
16450 {
16451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16452 "%s Request Buffer Alloc Fail", __func__);
16453 return -EINVAL;
16454 }
16455
16456 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070016457 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
16458 hb_params,
16459 wlan_hdd_cfg80211_lphb_ind_handler);
16460 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070016461 {
Leo Changd9df8aa2013-09-26 13:32:26 -070016462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16463 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070016464 vos_mem_free(hb_params);
16465 }
Leo Chang9056f462013-08-01 19:21:11 -070016466 return 0;
16467 }
16468#endif /* FEATURE_WLAN_LPHB */
16469 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16471 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070016472 return -EOPNOTSUPP;
16473 }
16474
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016475 EXIT();
16476 return err;
Leo Chang9056f462013-08-01 19:21:11 -070016477}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016478
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053016479static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
16480#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
16481 struct wireless_dev *wdev,
16482#endif
16483 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016484{
16485 int ret;
16486
16487 vos_ssr_protect(__func__);
16488 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
16489 vos_ssr_unprotect(__func__);
16490
16491 return ret;
16492}
Leo Chang9056f462013-08-01 19:21:11 -070016493#endif /* CONFIG_NL80211_TESTMODE */
16494
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016495static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016496 struct net_device *dev,
16497 int idx, struct survey_info *survey)
16498{
16499 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16500 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053016501 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016502 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053016503 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016504 v_S7_t snr,rssi;
16505 int status, i, j, filled = 0;
16506
16507 ENTER();
16508
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016509 if (NULL == pAdapter)
16510 {
16511 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16512 "%s: HDD adapter is Null", __func__);
16513 return -ENODEV;
16514 }
16515
16516 if (NULL == wiphy)
16517 {
16518 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16519 "%s: wiphy is Null", __func__);
16520 return -ENODEV;
16521 }
16522
16523 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16524 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016525 if (0 != status)
16526 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016527 return status;
16528 }
16529
Mihir Sheted9072e02013-08-21 17:02:29 +053016530 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16531
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016532 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053016533 0 != pAdapter->survey_idx ||
16534 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016535 {
16536 /* The survey dump ops when implemented completely is expected to
16537 * return a survey of all channels and the ops is called by the
16538 * kernel with incremental values of the argument 'idx' till it
16539 * returns -ENONET. But we can only support the survey for the
16540 * operating channel for now. survey_idx is used to track
16541 * that the ops is called only once and then return -ENONET for
16542 * the next iteration
16543 */
16544 pAdapter->survey_idx = 0;
16545 return -ENONET;
16546 }
16547
Mukul Sharma9d5233b2015-06-11 20:28:20 +053016548 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
16549 {
16550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16551 "%s: Roaming in progress, hence return ", __func__);
16552 return -ENONET;
16553 }
16554
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016555 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16556
16557 wlan_hdd_get_snr(pAdapter, &snr);
16558 wlan_hdd_get_rssi(pAdapter, &rssi);
16559
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016560 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16561 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
16562 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016563 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
16564 hdd_wlan_get_freq(channel, &freq);
16565
16566
16567 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
16568 {
16569 if (NULL == wiphy->bands[i])
16570 {
16571 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
16572 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
16573 continue;
16574 }
16575
16576 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
16577 {
16578 struct ieee80211_supported_band *band = wiphy->bands[i];
16579
16580 if (band->channels[j].center_freq == (v_U16_t)freq)
16581 {
16582 survey->channel = &band->channels[j];
16583 /* The Rx BDs contain SNR values in dB for the received frames
16584 * while the supplicant expects noise. So we calculate and
16585 * return the value of noise (dBm)
16586 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
16587 */
16588 survey->noise = rssi - snr;
16589 survey->filled = SURVEY_INFO_NOISE_DBM;
16590 filled = 1;
16591 }
16592 }
16593 }
16594
16595 if (filled)
16596 pAdapter->survey_idx = 1;
16597 else
16598 {
16599 pAdapter->survey_idx = 0;
16600 return -ENONET;
16601 }
16602
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016603 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016604 return 0;
16605}
16606
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016607static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
16608 struct net_device *dev,
16609 int idx, struct survey_info *survey)
16610{
16611 int ret;
16612
16613 vos_ssr_protect(__func__);
16614 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
16615 vos_ssr_unprotect(__func__);
16616
16617 return ret;
16618}
16619
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016620/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016621 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016622 * this is called when cfg80211 driver resume
16623 * driver updates latest sched_scan scan result(if any) to cfg80211 database
16624 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016625int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016626{
16627 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16628 hdd_adapter_t *pAdapter;
16629 hdd_adapter_list_node_t *pAdapterNode, *pNext;
16630 VOS_STATUS status = VOS_STATUS_SUCCESS;
16631
16632 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016633
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016634 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016635 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016636 return 0;
16637 }
16638
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016639 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
16640 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016641 spin_lock(&pHddCtx->schedScan_lock);
16642 pHddCtx->isWiphySuspended = FALSE;
16643 if (TRUE != pHddCtx->isSchedScanUpdatePending)
16644 {
16645 spin_unlock(&pHddCtx->schedScan_lock);
16646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16647 "%s: Return resume is not due to PNO indication", __func__);
16648 return 0;
16649 }
16650 // Reset flag to avoid updatating cfg80211 data old results again
16651 pHddCtx->isSchedScanUpdatePending = FALSE;
16652 spin_unlock(&pHddCtx->schedScan_lock);
16653
16654 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
16655
16656 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
16657 {
16658 pAdapter = pAdapterNode->pAdapter;
16659 if ( (NULL != pAdapter) &&
16660 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
16661 {
16662 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016663 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16665 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016666 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016667 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016668 {
16669 /* Acquire wakelock to handle the case where APP's tries to
16670 * suspend immediately after updating the scan results. Whis
16671 * results in app's is in suspended state and not able to
16672 * process the connect request to AP
16673 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053016674 hdd_prevent_suspend_timeout(2000,
16675 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016676 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016677 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016678
16679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16680 "%s : cfg80211 scan result database updated", __func__);
16681
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016682 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016683 return 0;
16684
16685 }
16686 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16687 pAdapterNode = pNext;
16688 }
16689
16690 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16691 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016692 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016693 return 0;
16694}
16695
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016696int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
16697{
16698 int ret;
16699
16700 vos_ssr_protect(__func__);
16701 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
16702 vos_ssr_unprotect(__func__);
16703
16704 return ret;
16705}
16706
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016707/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016708 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016709 * this is called when cfg80211 driver suspends
16710 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016711int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016712 struct cfg80211_wowlan *wow)
16713{
16714 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016715 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016716
16717 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016718
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016719 ret = wlan_hdd_validate_context(pHddCtx);
16720 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016721 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016722 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016723 }
16724
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016725
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016726 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16727 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
16728 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016729 pHddCtx->isWiphySuspended = TRUE;
16730
16731 EXIT();
16732
16733 return 0;
16734}
16735
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016736int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
16737 struct cfg80211_wowlan *wow)
16738{
16739 int ret;
16740
16741 vos_ssr_protect(__func__);
16742 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
16743 vos_ssr_unprotect(__func__);
16744
16745 return ret;
16746}
Jeff Johnson295189b2012-06-20 16:38:30 -070016747/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016748static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070016749{
16750 .add_virtual_intf = wlan_hdd_add_virtual_intf,
16751 .del_virtual_intf = wlan_hdd_del_virtual_intf,
16752 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
16753 .change_station = wlan_hdd_change_station,
16754#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
16755 .add_beacon = wlan_hdd_cfg80211_add_beacon,
16756 .del_beacon = wlan_hdd_cfg80211_del_beacon,
16757 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016758#else
16759 .start_ap = wlan_hdd_cfg80211_start_ap,
16760 .change_beacon = wlan_hdd_cfg80211_change_beacon,
16761 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070016762#endif
16763 .change_bss = wlan_hdd_cfg80211_change_bss,
16764 .add_key = wlan_hdd_cfg80211_add_key,
16765 .get_key = wlan_hdd_cfg80211_get_key,
16766 .del_key = wlan_hdd_cfg80211_del_key,
16767 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016768#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070016769 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016770#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016771 .scan = wlan_hdd_cfg80211_scan,
16772 .connect = wlan_hdd_cfg80211_connect,
16773 .disconnect = wlan_hdd_cfg80211_disconnect,
16774 .join_ibss = wlan_hdd_cfg80211_join_ibss,
16775 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
16776 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
16777 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
16778 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070016779 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
16780 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053016781 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070016782#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16783 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
16784 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
16785 .set_txq_params = wlan_hdd_set_txq_params,
16786#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016787 .get_station = wlan_hdd_cfg80211_get_station,
16788 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
16789 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016790 .add_station = wlan_hdd_cfg80211_add_station,
16791#ifdef FEATURE_WLAN_LFR
16792 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
16793 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
16794 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
16795#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016796#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
16797 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
16798#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016799#ifdef FEATURE_WLAN_TDLS
16800 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
16801 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
16802#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016803#ifdef WLAN_FEATURE_GTK_OFFLOAD
16804 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
16805#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016806#ifdef FEATURE_WLAN_SCAN_PNO
16807 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
16808 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
16809#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016810 .resume = wlan_hdd_cfg80211_resume_wlan,
16811 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016812 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070016813#ifdef WLAN_NL80211_TESTMODE
16814 .testmode_cmd = wlan_hdd_cfg80211_testmode,
16815#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016816 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070016817};
16818