blob: f618282a610f5c779daddb0a5d3f6b6941f64d67 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +053026 *
Kiet Lamaa8e15a2014-02-11 23:30:06 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Kiet Lama7f454d2014-07-24 12:04:06 -070030
31
Jeff Johnson295189b2012-06-20 16:38:30 -070032/**========================================================================
33
34 \file wlan_hdd_cfg80211.c
35
36 \brief WLAN Host Device Driver implementation
37
Jeff Johnson295189b2012-06-20 16:38:30 -070038 ========================================================================*/
39
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070040/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070041
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070042 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070043
44
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070045 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070047
48
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070049 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070050
51
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070052 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070053 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070054 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070055
56 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070057 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070058 ==========================================================================*/
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060
61#include <linux/version.h>
62#include <linux/module.h>
63#include <linux/kernel.h>
64#include <linux/init.h>
65#include <linux/wireless.h>
66#include <wlan_hdd_includes.h>
67#include <net/arp.h>
68#include <net/cfg80211.h>
69#include <linux/wireless.h>
70#include <wlan_hdd_wowl.h>
71#include <aniGlobal.h>
72#include "ccmApi.h"
73#include "sirParams.h"
74#include "dot11f.h"
75#include "wlan_hdd_assoc.h"
76#include "wlan_hdd_wext.h"
77#include "sme_Api.h"
78#include "wlan_hdd_p2p.h"
79#include "wlan_hdd_cfg80211.h"
80#include "wlan_hdd_hostapd.h"
81#include "sapInternal.h"
82#include "wlan_hdd_softap_tx_rx.h"
83#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053084#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053085#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053086#include "wlan_hdd_trace.h"
87#include "vos_types.h"
88#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070089#ifdef WLAN_BTAMP_FEATURE
90#include "bap_hdd_misc.h"
91#endif
92#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080093#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053094#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053095#include "wlan_qct_wda.h"
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053096#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070097#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070098
99#define g_mode_rates_size (12)
100#define a_mode_rates_size (8)
101#define FREQ_BASE_80211G (2407)
102#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700103#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530104#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800106 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
108#define HDD2GHZCHAN(freq, chan, flag) { \
109 .band = IEEE80211_BAND_2GHZ, \
110 .center_freq = (freq), \
111 .hw_value = (chan),\
112 .flags = (flag), \
113 .max_antenna_gain = 0 ,\
114 .max_power = 30, \
115}
116
117#define HDD5GHZCHAN(freq, chan, flag) { \
118 .band = IEEE80211_BAND_5GHZ, \
119 .center_freq = (freq), \
120 .hw_value = (chan),\
121 .flags = (flag), \
122 .max_antenna_gain = 0 ,\
123 .max_power = 30, \
124}
125
126#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
127{\
128 .bitrate = rate, \
129 .hw_value = rate_id, \
130 .flags = flag, \
131}
132
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530133#ifdef WLAN_FEATURE_VOWIFI_11R
134#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
135#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
136#endif
137
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530138#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530139#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530140
Sunil Duttc69bccb2014-05-26 21:30:20 +0530141#ifdef WLAN_FEATURE_LINK_LAYER_STATS
142/*
143 * Used to allocate the size of 4096 for the link layer stats.
144 * The size of 4096 is considered assuming that all data per
145 * respective event fit with in the limit.Please take a call
146 * on the limit based on the data requirements on link layer
147 * statistics.
148 */
149#define LL_STATS_EVENT_BUF_SIZE 4096
150#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530151#ifdef WLAN_FEATURE_EXTSCAN
152/*
153 * Used to allocate the size of 4096 for the EXTScan NL data.
154 * The size of 4096 is considered assuming that all data per
155 * respective event fit with in the limit.Please take a call
156 * on the limit based on the data requirements.
157 */
158
159#define EXTSCAN_EVENT_BUF_SIZE 4096
160#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
161#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530162
Atul Mittal115287b2014-07-08 13:26:33 +0530163/*EXT TDLS*/
164/*
165 * Used to allocate the size of 4096 for the TDLS.
166 * The size of 4096 is considered assuming that all data per
167 * respective event fit with in the limit.Please take a call
168 * on the limit based on the data requirements on link layer
169 * statistics.
170 */
171#define EXTTDLS_EVENT_BUF_SIZE 4096
172
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530173static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700174{
175 WLAN_CIPHER_SUITE_WEP40,
176 WLAN_CIPHER_SUITE_WEP104,
177 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800178#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700179#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
180 WLAN_CIPHER_SUITE_KRK,
181 WLAN_CIPHER_SUITE_CCMP,
182#else
183 WLAN_CIPHER_SUITE_CCMP,
184#endif
185#ifdef FEATURE_WLAN_WAPI
186 WLAN_CIPHER_SUITE_SMS4,
187#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700188#ifdef WLAN_FEATURE_11W
189 WLAN_CIPHER_SUITE_AES_CMAC,
190#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700191};
192
193static inline int is_broadcast_ether_addr(const u8 *addr)
194{
195 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
196 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
197}
198
199static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530200{
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 HDD2GHZCHAN(2412, 1, 0) ,
202 HDD2GHZCHAN(2417, 2, 0) ,
203 HDD2GHZCHAN(2422, 3, 0) ,
204 HDD2GHZCHAN(2427, 4, 0) ,
205 HDD2GHZCHAN(2432, 5, 0) ,
206 HDD2GHZCHAN(2437, 6, 0) ,
207 HDD2GHZCHAN(2442, 7, 0) ,
208 HDD2GHZCHAN(2447, 8, 0) ,
209 HDD2GHZCHAN(2452, 9, 0) ,
210 HDD2GHZCHAN(2457, 10, 0) ,
211 HDD2GHZCHAN(2462, 11, 0) ,
212 HDD2GHZCHAN(2467, 12, 0) ,
213 HDD2GHZCHAN(2472, 13, 0) ,
214 HDD2GHZCHAN(2484, 14, 0) ,
215};
216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
218{
219 HDD2GHZCHAN(2412, 1, 0) ,
220 HDD2GHZCHAN(2437, 6, 0) ,
221 HDD2GHZCHAN(2462, 11, 0) ,
222};
Jeff Johnson295189b2012-06-20 16:38:30 -0700223
224static struct ieee80211_channel hdd_channels_5_GHZ[] =
225{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700226 HDD5GHZCHAN(4920, 240, 0) ,
227 HDD5GHZCHAN(4940, 244, 0) ,
228 HDD5GHZCHAN(4960, 248, 0) ,
229 HDD5GHZCHAN(4980, 252, 0) ,
230 HDD5GHZCHAN(5040, 208, 0) ,
231 HDD5GHZCHAN(5060, 212, 0) ,
232 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 HDD5GHZCHAN(5180, 36, 0) ,
234 HDD5GHZCHAN(5200, 40, 0) ,
235 HDD5GHZCHAN(5220, 44, 0) ,
236 HDD5GHZCHAN(5240, 48, 0) ,
237 HDD5GHZCHAN(5260, 52, 0) ,
238 HDD5GHZCHAN(5280, 56, 0) ,
239 HDD5GHZCHAN(5300, 60, 0) ,
240 HDD5GHZCHAN(5320, 64, 0) ,
241 HDD5GHZCHAN(5500,100, 0) ,
242 HDD5GHZCHAN(5520,104, 0) ,
243 HDD5GHZCHAN(5540,108, 0) ,
244 HDD5GHZCHAN(5560,112, 0) ,
245 HDD5GHZCHAN(5580,116, 0) ,
246 HDD5GHZCHAN(5600,120, 0) ,
247 HDD5GHZCHAN(5620,124, 0) ,
248 HDD5GHZCHAN(5640,128, 0) ,
249 HDD5GHZCHAN(5660,132, 0) ,
250 HDD5GHZCHAN(5680,136, 0) ,
251 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800252#ifdef FEATURE_WLAN_CH144
253 HDD5GHZCHAN(5720,144, 0) ,
254#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 HDD5GHZCHAN(5745,149, 0) ,
256 HDD5GHZCHAN(5765,153, 0) ,
257 HDD5GHZCHAN(5785,157, 0) ,
258 HDD5GHZCHAN(5805,161, 0) ,
259 HDD5GHZCHAN(5825,165, 0) ,
260};
261
262static struct ieee80211_rate g_mode_rates[] =
263{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530264 HDD_G_MODE_RATETAB(10, 0x1, 0),
265 HDD_G_MODE_RATETAB(20, 0x2, 0),
266 HDD_G_MODE_RATETAB(55, 0x4, 0),
267 HDD_G_MODE_RATETAB(110, 0x8, 0),
268 HDD_G_MODE_RATETAB(60, 0x10, 0),
269 HDD_G_MODE_RATETAB(90, 0x20, 0),
270 HDD_G_MODE_RATETAB(120, 0x40, 0),
271 HDD_G_MODE_RATETAB(180, 0x80, 0),
272 HDD_G_MODE_RATETAB(240, 0x100, 0),
273 HDD_G_MODE_RATETAB(360, 0x200, 0),
274 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530276};
Jeff Johnson295189b2012-06-20 16:38:30 -0700277
278static struct ieee80211_rate a_mode_rates[] =
279{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530280 HDD_G_MODE_RATETAB(60, 0x10, 0),
281 HDD_G_MODE_RATETAB(90, 0x20, 0),
282 HDD_G_MODE_RATETAB(120, 0x40, 0),
283 HDD_G_MODE_RATETAB(180, 0x80, 0),
284 HDD_G_MODE_RATETAB(240, 0x100, 0),
285 HDD_G_MODE_RATETAB(360, 0x200, 0),
286 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 HDD_G_MODE_RATETAB(540, 0x800, 0),
288};
289
290static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
291{
292 .channels = hdd_channels_2_4_GHZ,
293 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
294 .band = IEEE80211_BAND_2GHZ,
295 .bitrates = g_mode_rates,
296 .n_bitrates = g_mode_rates_size,
297 .ht_cap.ht_supported = 1,
298 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
299 | IEEE80211_HT_CAP_GRN_FLD
300 | IEEE80211_HT_CAP_DSSSCCK40
301 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
302 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
303 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
304 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
305 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
306 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
307};
308
Jeff Johnson295189b2012-06-20 16:38:30 -0700309static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
310{
311 .channels = hdd_social_channels_2_4_GHZ,
312 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
313 .band = IEEE80211_BAND_2GHZ,
314 .bitrates = g_mode_rates,
315 .n_bitrates = g_mode_rates_size,
316 .ht_cap.ht_supported = 1,
317 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
318 | IEEE80211_HT_CAP_GRN_FLD
319 | IEEE80211_HT_CAP_DSSSCCK40
320 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
321 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
322 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
323 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
324 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
325 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
326};
Jeff Johnson295189b2012-06-20 16:38:30 -0700327
328static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
329{
330 .channels = hdd_channels_5_GHZ,
331 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
332 .band = IEEE80211_BAND_5GHZ,
333 .bitrates = a_mode_rates,
334 .n_bitrates = a_mode_rates_size,
335 .ht_cap.ht_supported = 1,
336 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
337 | IEEE80211_HT_CAP_GRN_FLD
338 | IEEE80211_HT_CAP_DSSSCCK40
339 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
340 | IEEE80211_HT_CAP_SGI_40
341 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
342 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
343 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
344 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
345 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
346 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
347};
348
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530349/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700350 TX/RX direction for each kind of interface */
351static const struct ieee80211_txrx_stypes
352wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
353 [NL80211_IFTYPE_STATION] = {
354 .tx = 0xffff,
355 .rx = BIT(SIR_MAC_MGMT_ACTION) |
356 BIT(SIR_MAC_MGMT_PROBE_REQ),
357 },
358 [NL80211_IFTYPE_AP] = {
359 .tx = 0xffff,
360 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
361 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
362 BIT(SIR_MAC_MGMT_PROBE_REQ) |
363 BIT(SIR_MAC_MGMT_DISASSOC) |
364 BIT(SIR_MAC_MGMT_AUTH) |
365 BIT(SIR_MAC_MGMT_DEAUTH) |
366 BIT(SIR_MAC_MGMT_ACTION),
367 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700368 [NL80211_IFTYPE_ADHOC] = {
369 .tx = 0xffff,
370 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
371 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
372 BIT(SIR_MAC_MGMT_PROBE_REQ) |
373 BIT(SIR_MAC_MGMT_DISASSOC) |
374 BIT(SIR_MAC_MGMT_AUTH) |
375 BIT(SIR_MAC_MGMT_DEAUTH) |
376 BIT(SIR_MAC_MGMT_ACTION),
377 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 [NL80211_IFTYPE_P2P_CLIENT] = {
379 .tx = 0xffff,
380 .rx = BIT(SIR_MAC_MGMT_ACTION) |
381 BIT(SIR_MAC_MGMT_PROBE_REQ),
382 },
383 [NL80211_IFTYPE_P2P_GO] = {
384 /* This is also same as for SoftAP */
385 .tx = 0xffff,
386 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
387 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
388 BIT(SIR_MAC_MGMT_PROBE_REQ) |
389 BIT(SIR_MAC_MGMT_DISASSOC) |
390 BIT(SIR_MAC_MGMT_AUTH) |
391 BIT(SIR_MAC_MGMT_DEAUTH) |
392 BIT(SIR_MAC_MGMT_ACTION),
393 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700394};
395
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800396#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800397static const struct ieee80211_iface_limit
398wlan_hdd_iface_limit[] = {
399 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800400 /* max = 3 ; Our driver create two interfaces during driver init
401 * wlan0 and p2p0 interfaces. p2p0 is considered as station
402 * interface until a group is formed. In JB architecture, once the
403 * group is formed, interface type of p2p0 is changed to P2P GO or
404 * Client.
405 * When supplicant remove the group, it first issue a set interface
406 * cmd to change the mode back to Station. In JB this works fine as
407 * we advertize two station type interface during driver init.
408 * Some vendors create separate interface for P2P GO/Client,
409 * after group formation(Third one). But while group remove
410 * supplicant first tries to change the mode(3rd interface) to STATION
411 * But as we advertized only two sta type interfaces nl80211 was
412 * returning error for the third one which was leading to failure in
413 * delete interface. Ideally while removing the group, supplicant
414 * should not try to change the 3rd interface mode to Station type.
415 * Till we get a fix in wpa_supplicant, we advertize max STA
416 * interface type to 3
417 */
418 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800419 .types = BIT(NL80211_IFTYPE_STATION),
420 },
421 {
422 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700423 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800424 },
425 {
426 .max = 1,
427 .types = BIT(NL80211_IFTYPE_P2P_GO) |
428 BIT(NL80211_IFTYPE_P2P_CLIENT),
429 },
430};
431
432/* By default, only single channel concurrency is allowed */
433static struct ieee80211_iface_combination
434wlan_hdd_iface_combination = {
435 .limits = wlan_hdd_iface_limit,
436 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800437 /*
438 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
439 * and p2p0 interfaces during driver init
440 * Some vendors create separate interface for P2P operations.
441 * wlan0: STA interface
442 * p2p0: P2P Device interface, action frames goes
443 * through this interface.
444 * p2p-xx: P2P interface, After GO negotiation this interface is
445 * created for p2p operations(GO/CLIENT interface).
446 */
447 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800448 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
449 .beacon_int_infra_match = false,
450};
451#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800452
Jeff Johnson295189b2012-06-20 16:38:30 -0700453static struct cfg80211_ops wlan_hdd_cfg80211_ops;
454
455/* Data rate 100KBPS based on IE Index */
456struct index_data_rate_type
457{
458 v_U8_t beacon_rate_index;
459 v_U16_t supported_rate[4];
460};
461
462/* 11B, 11G Rate table include Basic rate and Extended rate
463 The IDX field is the rate index
464 The HI field is the rate when RSSI is strong or being ignored
465 (in this case we report actual rate)
466 The MID field is the rate when RSSI is moderate
467 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
468 The LO field is the rate when RSSI is low
469 (in this case we don't report rates, actual current rate used)
470 */
471static const struct
472{
473 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700474 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700475} supported_data_rate[] =
476{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700477/* IDX HI HM LM LO (RSSI-based index */
478 {2, { 10, 10, 10, 0}},
479 {4, { 20, 20, 10, 0}},
480 {11, { 55, 20, 10, 0}},
481 {12, { 60, 55, 20, 0}},
482 {18, { 90, 55, 20, 0}},
483 {22, {110, 55, 20, 0}},
484 {24, {120, 90, 60, 0}},
485 {36, {180, 120, 60, 0}},
486 {44, {220, 180, 60, 0}},
487 {48, {240, 180, 90, 0}},
488 {66, {330, 180, 90, 0}},
489 {72, {360, 240, 90, 0}},
490 {96, {480, 240, 120, 0}},
491 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700492};
493
494/* MCS Based rate table */
495static struct index_data_rate_type supported_mcs_rate[] =
496{
497/* MCS L20 L40 S20 S40 */
498 {0, {65, 135, 72, 150}},
499 {1, {130, 270, 144, 300}},
500 {2, {195, 405, 217, 450}},
501 {3, {260, 540, 289, 600}},
502 {4, {390, 810, 433, 900}},
503 {5, {520, 1080, 578, 1200}},
504 {6, {585, 1215, 650, 1350}},
505 {7, {650, 1350, 722, 1500}}
506};
507
Leo Chang6f8870f2013-03-26 18:11:36 -0700508#ifdef WLAN_FEATURE_11AC
509
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530510#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700511
512struct index_vht_data_rate_type
513{
514 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530515 v_U16_t supported_VHT80_rate[2];
516 v_U16_t supported_VHT40_rate[2];
517 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700518};
519
520typedef enum
521{
522 DATA_RATE_11AC_MAX_MCS_7,
523 DATA_RATE_11AC_MAX_MCS_8,
524 DATA_RATE_11AC_MAX_MCS_9,
525 DATA_RATE_11AC_MAX_MCS_NA
526} eDataRate11ACMaxMcs;
527
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530528/* SSID broadcast type */
529typedef enum eSSIDBcastType
530{
531 eBCAST_UNKNOWN = 0,
532 eBCAST_NORMAL = 1,
533 eBCAST_HIDDEN = 2,
534} tSSIDBcastType;
535
Leo Chang6f8870f2013-03-26 18:11:36 -0700536/* MCS Based VHT rate table */
537static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
538{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530539/* MCS L80 S80 L40 S40 L20 S40*/
540 {0, {293, 325}, {135, 150}, {65, 72}},
541 {1, {585, 650}, {270, 300}, {130, 144}},
542 {2, {878, 975}, {405, 450}, {195, 217}},
543 {3, {1170, 1300}, {540, 600}, {260, 289}},
544 {4, {1755, 1950}, {810, 900}, {390, 433}},
545 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
546 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
547 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
548 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
549 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700550};
551#endif /* WLAN_FEATURE_11AC */
552
c_hpothu79aab322014-07-14 21:11:01 +0530553/*array index points to MCS and array value points respective rssi*/
554static int rssiMcsTbl[][10] =
555{
556/*MCS 0 1 2 3 4 5 6 7 8 9*/
557 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
558 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
559 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
560};
561
Jeff Johnson295189b2012-06-20 16:38:30 -0700562extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530563#ifdef FEATURE_WLAN_SCAN_PNO
564static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
565#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700566
Leo Chang9056f462013-08-01 19:21:11 -0700567#ifdef WLAN_NL80211_TESTMODE
568enum wlan_hdd_tm_attr
569{
570 WLAN_HDD_TM_ATTR_INVALID = 0,
571 WLAN_HDD_TM_ATTR_CMD = 1,
572 WLAN_HDD_TM_ATTR_DATA = 2,
573 WLAN_HDD_TM_ATTR_TYPE = 3,
574 /* keep last */
575 WLAN_HDD_TM_ATTR_AFTER_LAST,
576 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
577};
578
579enum wlan_hdd_tm_cmd
580{
581 WLAN_HDD_TM_CMD_WLAN_HB = 1,
582};
583
584#define WLAN_HDD_TM_DATA_MAX_LEN 5000
585
586static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
587{
588 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
589 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
590 .len = WLAN_HDD_TM_DATA_MAX_LEN },
591};
592#endif /* WLAN_NL80211_TESTMODE */
593
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800594#ifdef FEATURE_WLAN_CH_AVOID
595/*
596 * FUNCTION: wlan_hdd_send_avoid_freq_event
597 * This is called when wlan driver needs to send vendor specific
598 * avoid frequency range event to userspace
599 */
600int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
601 tHddAvoidFreqList *pAvoidFreqList)
602{
603 struct sk_buff *vendor_event;
604
605 ENTER();
606
607 if (!pHddCtx)
608 {
609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
610 "%s: HDD context is null", __func__);
611 return -1;
612 }
613
614 if (!pAvoidFreqList)
615 {
616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
617 "%s: pAvoidFreqList is null", __func__);
618 return -1;
619 }
620
621 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530622#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
623 NULL,
624#endif
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800625 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530626 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800627 GFP_KERNEL);
628 if (!vendor_event)
629 {
630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
631 "%s: cfg80211_vendor_event_alloc failed", __func__);
632 return -1;
633 }
634
635 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
636 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
637
638 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
639
640 EXIT();
641 return 0;
642}
643#endif /* FEATURE_WLAN_CH_AVOID */
644
Srinivas Dasari030bad32015-02-18 23:23:54 +0530645/*
646 * FUNCTION: __wlan_hdd_cfg80211_nan_request
647 * This is called when wlan driver needs to send vendor specific
648 * nan request event.
649 */
650static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
651 struct wireless_dev *wdev,
652 const void *data, int data_len)
653{
654 tNanRequestReq nan_req;
655 VOS_STATUS status;
656 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530657 struct net_device *dev = wdev->netdev;
658 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
659 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530660 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
661
662 if (0 == data_len)
663 {
664 hddLog(VOS_TRACE_LEVEL_ERROR,
665 FL("NAN - Invalid Request, length = 0"));
666 return ret_val;
667 }
668
669 if (NULL == data)
670 {
671 hddLog(VOS_TRACE_LEVEL_ERROR,
672 FL("NAN - Invalid Request, data is NULL"));
673 return ret_val;
674 }
675
676 status = wlan_hdd_validate_context(pHddCtx);
677 if (0 != status)
678 {
679 hddLog(VOS_TRACE_LEVEL_ERROR,
680 FL("HDD context is not valid"));
681 return -EINVAL;
682 }
683
684 hddLog(LOG1, FL("Received NAN command"));
685 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
686 (tANI_U8 *)data, data_len);
687
688 /* check the NAN Capability */
689 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
690 {
691 hddLog(VOS_TRACE_LEVEL_ERROR,
692 FL("NAN is not supported by Firmware"));
693 return -EINVAL;
694 }
695
696 nan_req.request_data_len = data_len;
697 nan_req.request_data = data;
698
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530699 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530700 if (VOS_STATUS_SUCCESS == status)
701 {
702 ret_val = 0;
703 }
704 return ret_val;
705}
706
707/*
708 * FUNCTION: wlan_hdd_cfg80211_nan_request
709 * Wrapper to protect the nan vendor command from ssr
710 */
711static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
712 struct wireless_dev *wdev,
713 const void *data, int data_len)
714{
715 int ret;
716
717 vos_ssr_protect(__func__);
718 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
719 vos_ssr_unprotect(__func__);
720
721 return ret;
722}
723
724/*
725 * FUNCTION: wlan_hdd_cfg80211_nan_callback
726 * This is a callback function and it gets called
727 * when we need to report nan response event to
728 * upper layers.
729 */
730static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
731{
732 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
733 struct sk_buff *vendor_event;
734 int status;
735 tSirNanEvent *data;
736
737 ENTER();
738 if (NULL == msg)
739 {
740 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
741 FL(" msg received here is null"));
742 return;
743 }
744 data = msg;
745
746 status = wlan_hdd_validate_context(pHddCtx);
747
748 if (0 != status)
749 {
750 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
751 FL("HDD context is not valid"));
752 return;
753 }
754
755 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530756#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
757 NULL,
758#endif
Srinivas Dasari030bad32015-02-18 23:23:54 +0530759 data->event_data_len +
760 NLMSG_HDRLEN,
761 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
762 GFP_KERNEL);
763
764 if (!vendor_event)
765 {
766 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
767 FL("cfg80211_vendor_event_alloc failed"));
768 return;
769 }
770 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
771 data->event_data_len, data->event_data))
772 {
773 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
774 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
775 kfree_skb(vendor_event);
776 return;
777 }
778 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
779 EXIT();
780}
781
782/*
783 * FUNCTION: wlan_hdd_cfg80211_nan_init
784 * This function is called to register the callback to sme layer
785 */
786inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
787{
788 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
789}
790
791
Sunil Duttc69bccb2014-05-26 21:30:20 +0530792#ifdef WLAN_FEATURE_LINK_LAYER_STATS
793
794static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
795 struct sk_buff *vendor_event)
796{
797 if (nla_put_u8(vendor_event,
798 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
799 stats->rate.preamble) ||
800 nla_put_u8(vendor_event,
801 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
802 stats->rate.nss) ||
803 nla_put_u8(vendor_event,
804 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
805 stats->rate.bw) ||
806 nla_put_u8(vendor_event,
807 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
808 stats->rate.rateMcsIdx) ||
809 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
810 stats->rate.bitrate ) ||
811 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
812 stats->txMpdu ) ||
813 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
814 stats->rxMpdu ) ||
815 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
816 stats->mpduLost ) ||
817 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
818 stats->retries) ||
819 nla_put_u32(vendor_event,
820 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
821 stats->retriesShort ) ||
822 nla_put_u32(vendor_event,
823 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
824 stats->retriesLong))
825 {
826 hddLog(VOS_TRACE_LEVEL_ERROR,
827 FL("QCA_WLAN_VENDOR_ATTR put fail"));
828 return FALSE;
829 }
830 return TRUE;
831}
832
833static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
834 struct sk_buff *vendor_event)
835{
836 u32 i = 0;
837 struct nlattr *rateInfo;
838 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
839 stats->type) ||
840 nla_put(vendor_event,
841 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
842 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
843 nla_put_u32(vendor_event,
844 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
845 stats->capabilities) ||
846 nla_put_u32(vendor_event,
847 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
848 stats->numRate))
849 {
850 hddLog(VOS_TRACE_LEVEL_ERROR,
851 FL("QCA_WLAN_VENDOR_ATTR put fail"));
852 goto error;
853 }
854
855 rateInfo = nla_nest_start(vendor_event,
856 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530857 if(!rateInfo)
858 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530859 for (i = 0; i < stats->numRate; i++)
860 {
861 struct nlattr *rates;
862 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
863 stats->rateStats +
864 (i * sizeof(tSirWifiRateStat)));
865 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530866 if(!rates)
867 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530868
869 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
870 {
871 hddLog(VOS_TRACE_LEVEL_ERROR,
872 FL("QCA_WLAN_VENDOR_ATTR put fail"));
873 return FALSE;
874 }
875 nla_nest_end(vendor_event, rates);
876 }
877 nla_nest_end(vendor_event, rateInfo);
878
879 return TRUE;
880error:
881 return FALSE;
882}
883
884static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
885 struct sk_buff *vendor_event)
886{
887 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
888 stats->ac ) ||
889 nla_put_u32(vendor_event,
890 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
891 stats->txMpdu ) ||
892 nla_put_u32(vendor_event,
893 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
894 stats->rxMpdu ) ||
895 nla_put_u32(vendor_event,
896 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
897 stats->txMcast ) ||
898 nla_put_u32(vendor_event,
899 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
900 stats->rxMcast ) ||
901 nla_put_u32(vendor_event,
902 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
903 stats->rxAmpdu ) ||
904 nla_put_u32(vendor_event,
905 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
906 stats->txAmpdu ) ||
907 nla_put_u32(vendor_event,
908 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
909 stats->mpduLost )||
910 nla_put_u32(vendor_event,
911 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
912 stats->retries ) ||
913 nla_put_u32(vendor_event,
914 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
915 stats->retriesShort ) ||
916 nla_put_u32(vendor_event,
917 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
918 stats->retriesLong ) ||
919 nla_put_u32(vendor_event,
920 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
921 stats->contentionTimeMin ) ||
922 nla_put_u32(vendor_event,
923 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
924 stats->contentionTimeMax ) ||
925 nla_put_u32(vendor_event,
926 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
927 stats->contentionTimeAvg ) ||
928 nla_put_u32(vendor_event,
929 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
930 stats->contentionNumSamples ))
931 {
932 hddLog(VOS_TRACE_LEVEL_ERROR,
933 FL("QCA_WLAN_VENDOR_ATTR put fail") );
934 return FALSE;
935 }
936 return TRUE;
937}
938
939static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
940 struct sk_buff *vendor_event)
941{
Dino Myclec8f3f332014-07-21 16:48:27 +0530942 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530943 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
944 nla_put(vendor_event,
945 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
946 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
947 nla_put_u32(vendor_event,
948 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
949 stats->state ) ||
950 nla_put_u32(vendor_event,
951 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
952 stats->roaming ) ||
953 nla_put_u32(vendor_event,
954 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
955 stats->capabilities ) ||
956 nla_put(vendor_event,
957 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
958 strlen(stats->ssid), stats->ssid) ||
959 nla_put(vendor_event,
960 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
961 WNI_CFG_BSSID_LEN, stats->bssid) ||
962 nla_put(vendor_event,
963 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
964 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
965 nla_put(vendor_event,
966 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
967 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
968 )
969 {
970 hddLog(VOS_TRACE_LEVEL_ERROR,
971 FL("QCA_WLAN_VENDOR_ATTR put fail") );
972 return FALSE;
973 }
974 return TRUE;
975}
976
Dino Mycle3b9536d2014-07-09 22:05:24 +0530977static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
978 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530979 struct sk_buff *vendor_event)
980{
981 int i = 0;
982 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530983 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
984 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530985 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530986
Sunil Duttc69bccb2014-05-26 21:30:20 +0530987 if (FALSE == put_wifi_interface_info(
988 &pWifiIfaceStat->info,
989 vendor_event))
990 {
991 hddLog(VOS_TRACE_LEVEL_ERROR,
992 FL("QCA_WLAN_VENDOR_ATTR put fail") );
993 return FALSE;
994
995 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530996 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
997 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
998 if (NULL == pWifiIfaceStatTL)
999 {
1000 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
1001 return FALSE;
1002 }
1003
Srinivas Dasaria8a304f2014-11-15 16:13:37 +05301004 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
1005 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
1006 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
1007 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1008
1009 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1010 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1011 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1012 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301013
1014 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1015 {
1016 if (VOS_STATUS_SUCCESS ==
1017 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1018 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1019 {
1020 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1021 * obtained from TL structure
1022 */
1023
1024 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1025 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301026 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1027
Srinivas Dasari98947432014-11-07 19:41:24 +05301028 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1029 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1030 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1031 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1032 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1033 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1034 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1035 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301036
Srinivas Dasari98947432014-11-07 19:41:24 +05301037 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1038 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1039 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1040 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1041 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1042 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1043 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1044 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301045
Srinivas Dasari98947432014-11-07 19:41:24 +05301046 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1047 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1048 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1049 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1050 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1051 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1052 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1053 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301054 }
1055 else
1056 {
1057 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1058 }
1059
Dino Mycle3b9536d2014-07-09 22:05:24 +05301060 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1061 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1062 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1063 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1064 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1065 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1066 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1067 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1068 }
1069 else
1070 {
1071 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1072 }
1073
1074
Sunil Duttc69bccb2014-05-26 21:30:20 +05301075
1076 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301077 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1078 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_IFACE) ||
1079 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301080 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1081 pWifiIfaceStat->beaconRx) ||
1082 nla_put_u32(vendor_event,
1083 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1084 pWifiIfaceStat->mgmtRx) ||
1085 nla_put_u32(vendor_event,
1086 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1087 pWifiIfaceStat->mgmtActionRx) ||
1088 nla_put_u32(vendor_event,
1089 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1090 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301091 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301092 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1093 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301094 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301095 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1096 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301097 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301098 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1099 pWifiIfaceStat->rssiAck))
1100 {
1101 hddLog(VOS_TRACE_LEVEL_ERROR,
1102 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301103 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301104 return FALSE;
1105 }
1106
1107 wmmInfo = nla_nest_start(vendor_event,
1108 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301109 if(!wmmInfo)
1110 {
1111 vos_mem_free(pWifiIfaceStatTL);
1112 return FALSE;
1113 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301114 for (i = 0; i < WIFI_AC_MAX; i++)
1115 {
1116 struct nlattr *wmmStats;
1117 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301118 if(!wmmStats)
1119 {
1120 vos_mem_free(pWifiIfaceStatTL);
1121 return FALSE;
1122 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301123 if (FALSE == put_wifi_wmm_ac_stat(
1124 &pWifiIfaceStat->AccessclassStats[i],
1125 vendor_event))
1126 {
1127 hddLog(VOS_TRACE_LEVEL_ERROR,
1128 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301129 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301130 return FALSE;
1131 }
1132
1133 nla_nest_end(vendor_event, wmmStats);
1134 }
1135 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301136 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301137 return TRUE;
1138}
1139
1140static tSirWifiInterfaceMode
1141 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1142{
1143 switch (deviceMode)
1144 {
1145 case WLAN_HDD_INFRA_STATION:
1146 return WIFI_INTERFACE_STA;
1147 case WLAN_HDD_SOFTAP:
1148 return WIFI_INTERFACE_SOFTAP;
1149 case WLAN_HDD_P2P_CLIENT:
1150 return WIFI_INTERFACE_P2P_CLIENT;
1151 case WLAN_HDD_P2P_GO:
1152 return WIFI_INTERFACE_P2P_GO;
1153 case WLAN_HDD_IBSS:
1154 return WIFI_INTERFACE_IBSS;
1155 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301156 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301157 }
1158}
1159
1160static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1161 tpSirWifiInterfaceInfo pInfo)
1162{
1163 v_U8_t *staMac = NULL;
1164 hdd_station_ctx_t *pHddStaCtx;
1165 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1166 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1167
1168 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1169
1170 vos_mem_copy(pInfo->macAddr,
1171 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1172
1173 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1174 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1175 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1176 {
1177 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1178 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1179 {
1180 pInfo->state = WIFI_DISCONNECTED;
1181 }
1182 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1183 {
1184 hddLog(VOS_TRACE_LEVEL_ERROR,
1185 "%s: Session ID %d, Connection is in progress", __func__,
1186 pAdapter->sessionId);
1187 pInfo->state = WIFI_ASSOCIATING;
1188 }
1189 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1190 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1191 {
1192 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1193 hddLog(VOS_TRACE_LEVEL_ERROR,
1194 "%s: client " MAC_ADDRESS_STR
1195 " is in the middle of WPS/EAPOL exchange.", __func__,
1196 MAC_ADDR_ARRAY(staMac));
1197 pInfo->state = WIFI_AUTHENTICATING;
1198 }
1199 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1200 {
1201 pInfo->state = WIFI_ASSOCIATED;
1202 vos_mem_copy(pInfo->bssid,
1203 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1204 vos_mem_copy(pInfo->ssid,
1205 pHddStaCtx->conn_info.SSID.SSID.ssId,
1206 pHddStaCtx->conn_info.SSID.SSID.length);
1207 //NULL Terminate the string.
1208 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1209 }
1210 }
1211 vos_mem_copy(pInfo->countryStr,
1212 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1213
1214 vos_mem_copy(pInfo->apCountryStr,
1215 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1216
1217 return TRUE;
1218}
1219
1220/*
1221 * hdd_link_layer_process_peer_stats () - This function is called after
1222 * receiving Link Layer Peer statistics from FW.This function converts
1223 * the firmware data to the NL data and sends the same to the kernel/upper
1224 * layers.
1225 */
1226static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1227 v_VOID_t *pData)
1228{
1229 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1230 tpSirWifiRateStat pWifiRateStat;
1231 tpSirWifiPeerStat pWifiPeerStat;
1232 tpSirWifiPeerInfo pWifiPeerInfo;
1233 struct nlattr *peerInfo;
1234 struct sk_buff *vendor_event;
1235 int status, i;
1236
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301237 ENTER();
1238
Sunil Duttc69bccb2014-05-26 21:30:20 +05301239 status = wlan_hdd_validate_context(pHddCtx);
1240 if (0 != status)
1241 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301242 return;
1243 }
1244
1245 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1246
1247 hddLog(VOS_TRACE_LEVEL_INFO,
1248 "LL_STATS_PEER_ALL : numPeers %u",
1249 pWifiPeerStat->numPeers);
1250 {
1251 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1252 {
1253 pWifiPeerInfo = (tpSirWifiPeerInfo)
1254 ((uint8 *)pWifiPeerStat->peerInfo +
1255 ( i * sizeof(tSirWifiPeerInfo)));
1256
Dasari Srinivas1be0c4e2014-10-19 13:03:41 +05301257 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) {
1258 pWifiPeerInfo->type = WIFI_PEER_AP;
1259 }
1260 if (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) {
1261 pWifiPeerInfo->type = WIFI_PEER_P2P_GO;
1262 }
1263
Sunil Duttc69bccb2014-05-26 21:30:20 +05301264 hddLog(VOS_TRACE_LEVEL_INFO,
1265 " %d) LL_STATS Channel Stats "
1266 " Peer Type %u "
1267 " peerMacAddress %pM "
1268 " capabilities 0x%x "
1269 " numRate %u ",
1270 i,
1271 pWifiPeerInfo->type,
1272 pWifiPeerInfo->peerMacAddress,
1273 pWifiPeerInfo->capabilities,
1274 pWifiPeerInfo->numRate);
1275 {
1276 int j;
1277 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1278 {
1279 pWifiRateStat = (tpSirWifiRateStat)
1280 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1281 ( j * sizeof(tSirWifiRateStat)));
1282
1283 hddLog(VOS_TRACE_LEVEL_INFO,
1284 " peer Rate Stats "
1285 " preamble %u "
1286 " nss %u "
1287 " bw %u "
1288 " rateMcsIdx %u "
1289 " reserved %u "
1290 " bitrate %u "
1291 " txMpdu %u "
1292 " rxMpdu %u "
1293 " mpduLost %u "
1294 " retries %u "
1295 " retriesShort %u "
1296 " retriesLong %u",
1297 pWifiRateStat->rate.preamble,
1298 pWifiRateStat->rate.nss,
1299 pWifiRateStat->rate.bw,
1300 pWifiRateStat->rate.rateMcsIdx,
1301 pWifiRateStat->rate.reserved,
1302 pWifiRateStat->rate.bitrate,
1303 pWifiRateStat->txMpdu,
1304 pWifiRateStat->rxMpdu,
1305 pWifiRateStat->mpduLost,
1306 pWifiRateStat->retries,
1307 pWifiRateStat->retriesShort,
1308 pWifiRateStat->retriesLong);
1309 }
1310 }
1311 }
1312 }
1313
1314 /*
1315 * Allocate a size of 4096 for the peer stats comprising
1316 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1317 * sizeof (tSirWifiRateStat).Each field is put with an
1318 * NL attribute.The size of 4096 is considered assuming
1319 * that number of rates shall not exceed beyond 50 with
1320 * the sizeof (tSirWifiRateStat) being 32.
1321 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301322 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1323 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301324 if (!vendor_event)
1325 {
1326 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301327 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301328 __func__);
1329 return;
1330 }
1331 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301332 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1333 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_PEER) ||
1334 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301335 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1336 pWifiPeerStat->numPeers))
1337 {
1338 hddLog(VOS_TRACE_LEVEL_ERROR,
1339 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1340 kfree_skb(vendor_event);
1341 return;
1342 }
1343
1344 peerInfo = nla_nest_start(vendor_event,
1345 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301346 if(!peerInfo)
1347 {
1348 hddLog(VOS_TRACE_LEVEL_ERROR,
1349 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1350 __func__);
1351 kfree_skb(vendor_event);
1352 return;
1353 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301354
1355 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1356 pWifiPeerStat->peerInfo);
1357
1358 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1359 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301360 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301361 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301362
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301363 if(!peers)
1364 {
1365 hddLog(VOS_TRACE_LEVEL_ERROR,
1366 "%s: peer stats put fail",
1367 __func__);
1368 kfree_skb(vendor_event);
1369 return;
1370 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301371 if (FALSE == put_wifi_peer_info(
1372 pWifiPeerInfo, vendor_event))
1373 {
1374 hddLog(VOS_TRACE_LEVEL_ERROR,
1375 "%s: put_wifi_peer_info put fail", __func__);
1376 kfree_skb(vendor_event);
1377 return;
1378 }
1379
1380 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1381 pWifiPeerStat->peerInfo +
1382 (i * sizeof(tSirWifiPeerInfo)) +
1383 (numRate * sizeof (tSirWifiRateStat)));
1384 nla_nest_end(vendor_event, peers);
1385 }
1386 nla_nest_end(vendor_event, peerInfo);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301387 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301388 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301389}
1390
1391/*
1392 * hdd_link_layer_process_iface_stats () - This function is called after
1393 * receiving Link Layer Interface statistics from FW.This function converts
1394 * the firmware data to the NL data and sends the same to the kernel/upper
1395 * layers.
1396 */
1397static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1398 v_VOID_t *pData)
1399{
1400 tpSirWifiIfaceStat pWifiIfaceStat;
1401 struct sk_buff *vendor_event;
1402 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1403 int status;
1404
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301405 ENTER();
1406
Sunil Duttc69bccb2014-05-26 21:30:20 +05301407 status = wlan_hdd_validate_context(pHddCtx);
1408 if (0 != status)
1409 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301410 return;
1411 }
1412 /*
1413 * Allocate a size of 4096 for the interface stats comprising
1414 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1415 * assuming that all these fit with in the limit.Please take
1416 * a call on the limit based on the data requirements on
1417 * interface statistics.
1418 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301419 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1420 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301421 if (!vendor_event)
1422 {
1423 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301424 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301425 return;
1426 }
1427
1428 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1429
Dino Mycle3b9536d2014-07-09 22:05:24 +05301430
1431 if (FALSE == hdd_get_interface_info( pAdapter,
1432 &pWifiIfaceStat->info))
1433 {
1434 hddLog(VOS_TRACE_LEVEL_ERROR,
1435 FL("hdd_get_interface_info get fail") );
1436 kfree_skb(vendor_event);
1437 return;
1438 }
1439
1440 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1441 vendor_event))
1442 {
1443 hddLog(VOS_TRACE_LEVEL_ERROR,
1444 FL("put_wifi_iface_stats fail") );
1445 kfree_skb(vendor_event);
1446 return;
1447 }
1448
Sunil Duttc69bccb2014-05-26 21:30:20 +05301449 hddLog(VOS_TRACE_LEVEL_INFO,
1450 "WMI_LINK_STATS_IFACE Data");
1451
1452 hddLog(VOS_TRACE_LEVEL_INFO,
1453 "LL_STATS_IFACE: "
1454 " Mode %u "
1455 " MAC %pM "
1456 " State %u "
1457 " Roaming %u "
1458 " capabilities 0x%x "
1459 " SSID %s "
1460 " BSSID %pM",
1461 pWifiIfaceStat->info.mode,
1462 pWifiIfaceStat->info.macAddr,
1463 pWifiIfaceStat->info.state,
1464 pWifiIfaceStat->info.roaming,
1465 pWifiIfaceStat->info.capabilities,
1466 pWifiIfaceStat->info.ssid,
1467 pWifiIfaceStat->info.bssid);
1468
1469 hddLog(VOS_TRACE_LEVEL_INFO,
1470 " AP country str: %c%c%c",
1471 pWifiIfaceStat->info.apCountryStr[0],
1472 pWifiIfaceStat->info.apCountryStr[1],
1473 pWifiIfaceStat->info.apCountryStr[2]);
1474
1475
1476 hddLog(VOS_TRACE_LEVEL_INFO,
1477 " Country Str Association: %c%c%c",
1478 pWifiIfaceStat->info.countryStr[0],
1479 pWifiIfaceStat->info.countryStr[1],
1480 pWifiIfaceStat->info.countryStr[2]);
1481
1482 hddLog(VOS_TRACE_LEVEL_INFO,
1483 " beaconRx %u "
1484 " mgmtRx %u "
1485 " mgmtActionRx %u "
1486 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301487 " rssiMgmt %d "
1488 " rssiData %d "
1489 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301490 pWifiIfaceStat->beaconRx,
1491 pWifiIfaceStat->mgmtRx,
1492 pWifiIfaceStat->mgmtActionRx,
1493 pWifiIfaceStat->mgmtActionTx,
1494 pWifiIfaceStat->rssiMgmt,
1495 pWifiIfaceStat->rssiData,
1496 pWifiIfaceStat->rssiAck );
1497
1498
1499 {
1500 int i;
1501 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1502 {
1503 hddLog(VOS_TRACE_LEVEL_INFO,
1504
1505 " %d) LL_STATS IFACE: "
1506 " ac: %u txMpdu: %u "
1507 " rxMpdu: %u txMcast: %u "
1508 " rxMcast: %u rxAmpdu: %u "
1509 " txAmpdu: %u mpduLost: %u "
1510 " retries: %u retriesShort: %u "
1511 " retriesLong: %u contentionTimeMin: %u "
1512 " contentionTimeMax: %u contentionTimeAvg: %u "
1513 " contentionNumSamples: %u",
1514 i,
1515 pWifiIfaceStat->AccessclassStats[i].ac,
1516 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1517 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1518 pWifiIfaceStat->AccessclassStats[i].txMcast,
1519 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1520 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1521 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1522 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1523 pWifiIfaceStat->AccessclassStats[i].retries,
1524 pWifiIfaceStat->
1525 AccessclassStats[i].retriesShort,
1526 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1527 pWifiIfaceStat->
1528 AccessclassStats[i].contentionTimeMin,
1529 pWifiIfaceStat->
1530 AccessclassStats[i].contentionTimeMax,
1531 pWifiIfaceStat->
1532 AccessclassStats[i].contentionTimeAvg,
1533 pWifiIfaceStat->
1534 AccessclassStats[i].contentionNumSamples);
1535
1536 }
1537 }
1538
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301539 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301540
1541 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301542}
1543
1544/*
1545 * hdd_link_layer_process_radio_stats () - This function is called after
1546 * receiving Link Layer Radio statistics from FW.This function converts
1547 * the firmware data to the NL data and sends the same to the kernel/upper
1548 * layers.
1549 */
1550static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1551 v_VOID_t *pData)
1552{
1553 int status, i;
1554 tpSirWifiRadioStat pWifiRadioStat;
1555 tpSirWifiChannelStats pWifiChannelStats;
1556 struct sk_buff *vendor_event;
1557 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1558 struct nlattr *chList;
1559
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301560 ENTER();
1561
Sunil Duttc69bccb2014-05-26 21:30:20 +05301562 status = wlan_hdd_validate_context(pHddCtx);
1563 if (0 != status)
1564 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301565 return;
1566 }
1567 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1568
1569 hddLog(VOS_TRACE_LEVEL_INFO,
1570 "LL_STATS_RADIO"
1571 " radio is %d onTime is %u "
1572 " txTime is %u rxTime is %u "
1573 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301574 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301575 " onTimePnoScan is %u onTimeHs20 is %u "
1576 " numChannels is %u",
1577 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1578 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1579 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301580 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301581 pWifiRadioStat->onTimeRoamScan,
1582 pWifiRadioStat->onTimePnoScan,
1583 pWifiRadioStat->onTimeHs20,
1584 pWifiRadioStat->numChannels);
1585 /*
1586 * Allocate a size of 4096 for the Radio stats comprising
1587 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1588 * (tSirWifiChannelStats).Each channel data is put with an
1589 * NL attribute.The size of 4096 is considered assuming that
1590 * number of channels shall not exceed beyond 60 with the
1591 * sizeof (tSirWifiChannelStats) being 24 bytes.
1592 */
1593
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301594 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1595 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301596 if (!vendor_event)
1597 {
1598 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301599 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301600 return;
1601 }
1602
1603 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301604 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1605 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_RADIO) ||
1606 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301607 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1608 pWifiRadioStat->radio) ||
1609 nla_put_u32(vendor_event,
1610 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1611 pWifiRadioStat->onTime) ||
1612 nla_put_u32(vendor_event,
1613 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1614 pWifiRadioStat->txTime) ||
1615 nla_put_u32(vendor_event,
1616 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1617 pWifiRadioStat->rxTime) ||
1618 nla_put_u32(vendor_event,
1619 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1620 pWifiRadioStat->onTimeScan) ||
1621 nla_put_u32(vendor_event,
1622 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1623 pWifiRadioStat->onTimeNbd) ||
1624 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301625 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1626 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301627 nla_put_u32(vendor_event,
1628 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1629 pWifiRadioStat->onTimeRoamScan) ||
1630 nla_put_u32(vendor_event,
1631 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1632 pWifiRadioStat->onTimePnoScan) ||
1633 nla_put_u32(vendor_event,
1634 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1635 pWifiRadioStat->onTimeHs20) ||
1636 nla_put_u32(vendor_event,
1637 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1638 pWifiRadioStat->numChannels))
1639 {
1640 hddLog(VOS_TRACE_LEVEL_ERROR,
1641 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1642 kfree_skb(vendor_event);
1643 return ;
1644 }
1645
1646 chList = nla_nest_start(vendor_event,
1647 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301648 if(!chList)
1649 {
1650 hddLog(VOS_TRACE_LEVEL_ERROR,
1651 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1652 __func__);
1653 kfree_skb(vendor_event);
1654 return;
1655 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301656 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1657 {
1658 struct nlattr *chInfo;
1659
1660 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1661 pWifiRadioStat->channels +
1662 (i * sizeof(tSirWifiChannelStats)));
1663
1664 hddLog(VOS_TRACE_LEVEL_INFO,
1665 " %d) Channel Info"
1666 " width is %u "
1667 " CenterFreq %u "
1668 " CenterFreq0 %u "
1669 " CenterFreq1 %u "
1670 " onTime %u "
1671 " ccaBusyTime %u",
1672 i,
1673 pWifiChannelStats->channel.width,
1674 pWifiChannelStats->channel.centerFreq,
1675 pWifiChannelStats->channel.centerFreq0,
1676 pWifiChannelStats->channel.centerFreq1,
1677 pWifiChannelStats->onTime,
1678 pWifiChannelStats->ccaBusyTime);
1679
1680
1681 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301682 if(!chInfo)
1683 {
1684 hddLog(VOS_TRACE_LEVEL_ERROR,
1685 "%s: failed to put chInfo",
1686 __func__);
1687 kfree_skb(vendor_event);
1688 return;
1689 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301690
1691 if (nla_put_u32(vendor_event,
1692 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1693 pWifiChannelStats->channel.width) ||
1694 nla_put_u32(vendor_event,
1695 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1696 pWifiChannelStats->channel.centerFreq) ||
1697 nla_put_u32(vendor_event,
1698 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1699 pWifiChannelStats->channel.centerFreq0) ||
1700 nla_put_u32(vendor_event,
1701 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1702 pWifiChannelStats->channel.centerFreq1) ||
1703 nla_put_u32(vendor_event,
1704 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1705 pWifiChannelStats->onTime) ||
1706 nla_put_u32(vendor_event,
1707 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1708 pWifiChannelStats->ccaBusyTime))
1709 {
1710 hddLog(VOS_TRACE_LEVEL_ERROR,
1711 FL("cfg80211_vendor_event_alloc failed") );
1712 kfree_skb(vendor_event);
1713 return ;
1714 }
1715 nla_nest_end(vendor_event, chInfo);
1716 }
1717 nla_nest_end(vendor_event, chList);
1718
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301719 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301720
1721 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301722 return;
1723}
1724
1725/*
1726 * hdd_link_layer_stats_ind_callback () - This function is called after
1727 * receiving Link Layer indications from FW.This callback converts the firmware
1728 * data to the NL data and send the same to the kernel/upper layers.
1729 */
1730static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1731 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301732 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301733{
Dino Mycled3d50022014-07-07 12:58:25 +05301734 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1735 hdd_adapter_t *pAdapter = NULL;
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301736 struct hdd_ll_stats_context *context;
Dino Mycled3d50022014-07-07 12:58:25 +05301737 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301738 int status;
1739
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301740 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301741
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301742 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301743 if (0 != status)
1744 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301745 return;
1746 }
1747
Dino Mycled3d50022014-07-07 12:58:25 +05301748 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1749 if (NULL == pAdapter)
1750 {
1751 hddLog(VOS_TRACE_LEVEL_ERROR,
1752 FL(" MAC address %pM does not exist with host"),
1753 macAddr);
1754 return;
1755 }
1756
Sunil Duttc69bccb2014-05-26 21:30:20 +05301757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301758 "%s: Interface: %s LLStats indType: %d", __func__,
1759 pAdapter->dev->name, indType);
1760
Sunil Duttc69bccb2014-05-26 21:30:20 +05301761 switch (indType)
1762 {
1763 case SIR_HAL_LL_STATS_RESULTS_RSP:
1764 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301765 hddLog(VOS_TRACE_LEVEL_INFO,
1766 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1767 hddLog(VOS_TRACE_LEVEL_INFO,
1768 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1769 linkLayerStatsResults->paramId);
1770 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301771 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1772 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301773 hddLog(VOS_TRACE_LEVEL_INFO,
1774 "LL_STATS RESULTS RESPONSE respId = %u",
1775 linkLayerStatsResults->respId);
1776 hddLog(VOS_TRACE_LEVEL_INFO,
1777 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1778 linkLayerStatsResults->moreResultToFollow);
1779 hddLog(VOS_TRACE_LEVEL_INFO,
1780 "LL_STATS RESULTS RESPONSE result = %p",
1781 linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301782 spin_lock(&hdd_context_lock);
1783 context = &pHddCtx->ll_stats_context;
1784 /* validate response received from target */
1785 if ((context->request_id != linkLayerStatsResults->respId) ||
1786 !(context->request_bitmap & linkLayerStatsResults->paramId))
1787 {
1788 spin_unlock(&hdd_context_lock);
1789 hddLog(LOGE,
1790 FL("Error : Request id %d response id %d request bitmap 0x%x"
1791 "response bitmap 0x%x"),
1792 context->request_id, linkLayerStatsResults->respId,
1793 context->request_bitmap, linkLayerStatsResults->paramId);
1794 return;
1795 }
1796 spin_unlock(&hdd_context_lock);
1797
Sunil Duttc69bccb2014-05-26 21:30:20 +05301798 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1799 {
1800 hdd_link_layer_process_radio_stats(pAdapter,
1801 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301802 spin_lock(&hdd_context_lock);
1803 context->request_bitmap &= ~(WMI_LINK_STATS_RADIO);
1804 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301805 }
1806 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1807 {
1808 hdd_link_layer_process_iface_stats(pAdapter,
1809 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301810 spin_lock(&hdd_context_lock);
1811 context->request_bitmap &= ~(WMI_LINK_STATS_IFACE);
1812 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301813 }
1814 else if ( linkLayerStatsResults->paramId &
1815 WMI_LINK_STATS_ALL_PEER )
1816 {
1817 hdd_link_layer_process_peer_stats(pAdapter,
1818 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301819 spin_lock(&hdd_context_lock);
1820 context->request_bitmap &= ~(WMI_LINK_STATS_ALL_PEER);
1821 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301822 } /* WMI_LINK_STATS_ALL_PEER */
1823 else
1824 {
1825 hddLog(VOS_TRACE_LEVEL_ERROR,
1826 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1827 }
1828
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301829 spin_lock(&hdd_context_lock);
1830 /* complete response event if all requests are completed */
1831 if (0 == context->request_bitmap)
1832 complete(&context->response_event);
1833 spin_unlock(&hdd_context_lock);
1834
Sunil Duttc69bccb2014-05-26 21:30:20 +05301835 break;
1836 }
1837 default:
1838 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1839 break;
1840 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301841
1842 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301843 return;
1844}
1845
1846const struct
1847nla_policy
1848qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1849{
1850 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1851 { .type = NLA_U32 },
1852 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1853 { .type = NLA_U32 },
1854};
1855
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301856static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1857 struct wireless_dev *wdev,
1858 const void *data,
1859 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301860{
1861 int status;
1862 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301863 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301864 struct net_device *dev = wdev->netdev;
1865 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1866 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1867
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301868 ENTER();
1869
Sunil Duttc69bccb2014-05-26 21:30:20 +05301870 status = wlan_hdd_validate_context(pHddCtx);
1871 if (0 != status)
1872 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301873 return -EINVAL;
1874 }
1875
1876 if (NULL == pAdapter)
1877 {
1878 hddLog(VOS_TRACE_LEVEL_ERROR,
1879 FL("HDD adapter is Null"));
1880 return -ENODEV;
1881 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301882 /* check the LLStats Capability */
1883 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1884 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1885 {
1886 hddLog(VOS_TRACE_LEVEL_ERROR,
1887 FL("Link Layer Statistics not supported by Firmware"));
1888 return -EINVAL;
1889 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301890
1891 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1892 (struct nlattr *)data,
1893 data_len, qca_wlan_vendor_ll_set_policy))
1894 {
1895 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1896 return -EINVAL;
1897 }
1898 if (!tb_vendor
1899 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1900 {
1901 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1902 return -EINVAL;
1903 }
1904 if (!tb_vendor[
1905 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1906 {
1907 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1908 return -EINVAL;
1909 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301910 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301911 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301912
Dino Mycledf0a5d92014-07-04 09:41:55 +05301913 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301914 nla_get_u32(
1915 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1916
Dino Mycledf0a5d92014-07-04 09:41:55 +05301917 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301918 nla_get_u32(
1919 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1920
Dino Mycled3d50022014-07-07 12:58:25 +05301921 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1922 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301923
1924
1925 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301926 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301927 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301928 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301929 hddLog(VOS_TRACE_LEVEL_INFO,
1930 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301931 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301932 hddLog(VOS_TRACE_LEVEL_INFO,
1933 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301934 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301935
1936 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1937 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301938 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301939 {
1940 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1941 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301942 return -EINVAL;
1943
1944 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301945
Sunil Duttc69bccb2014-05-26 21:30:20 +05301946 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301947 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301948 {
1949 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1950 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301951 return -EINVAL;
1952 }
1953
1954 pAdapter->isLinkLayerStatsSet = 1;
1955
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301956 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301957 return 0;
1958}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301959static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1960 struct wireless_dev *wdev,
1961 const void *data,
1962 int data_len)
1963{
1964 int ret = 0;
1965
1966 vos_ssr_protect(__func__);
1967 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1968 vos_ssr_unprotect(__func__);
1969
1970 return ret;
1971}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301972
1973const struct
1974nla_policy
1975qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1976{
1977 /* Unsigned 32bit value provided by the caller issuing the GET stats
1978 * command. When reporting
1979 * the stats results, the driver uses the same value to indicate
1980 * which GET request the results
1981 * correspond to.
1982 */
1983 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1984
1985 /* Unsigned 32bit value . bit mask to identify what statistics are
1986 requested for retrieval */
1987 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1988};
1989
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301990static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1991 struct wireless_dev *wdev,
1992 const void *data,
1993 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301994{
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301995 unsigned long rc;
1996 struct hdd_ll_stats_context *context;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301997 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1998 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301999 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302000 struct net_device *dev = wdev->netdev;
2001 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mukul Sharma10313ba2015-07-29 19:14:39 +05302002 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302003 int status;
2004
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302005 ENTER();
2006
Sunil Duttc69bccb2014-05-26 21:30:20 +05302007 status = wlan_hdd_validate_context(pHddCtx);
2008 if (0 != status)
2009 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302010 return -EINVAL ;
2011 }
2012
2013 if (NULL == pAdapter)
2014 {
2015 hddLog(VOS_TRACE_LEVEL_FATAL,
2016 "%s: HDD adapter is Null", __func__);
2017 return -ENODEV;
2018 }
Mukul Sharma10313ba2015-07-29 19:14:39 +05302019
2020 if (pHddStaCtx == NULL)
2021 {
2022 hddLog(VOS_TRACE_LEVEL_FATAL,
2023 "%s: HddStaCtx is Null", __func__);
2024 return -ENODEV;
2025 }
2026
Dino Mycledf0a5d92014-07-04 09:41:55 +05302027 /* check the LLStats Capability */
2028 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2029 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2030 {
2031 hddLog(VOS_TRACE_LEVEL_ERROR,
2032 FL("Link Layer Statistics not supported by Firmware"));
2033 return -EINVAL;
2034 }
2035
Sunil Duttc69bccb2014-05-26 21:30:20 +05302036
2037 if (!pAdapter->isLinkLayerStatsSet)
2038 {
2039 hddLog(VOS_TRACE_LEVEL_FATAL,
2040 "%s: isLinkLayerStatsSet : %d",
2041 __func__, pAdapter->isLinkLayerStatsSet);
2042 return -EINVAL;
2043 }
2044
Mukul Sharma10313ba2015-07-29 19:14:39 +05302045 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
2046 {
2047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2048 "%s: Roaming in progress, so unable to proceed this request", __func__);
2049 return -EBUSY;
2050 }
2051
Sunil Duttc69bccb2014-05-26 21:30:20 +05302052 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2053 (struct nlattr *)data,
2054 data_len, qca_wlan_vendor_ll_get_policy))
2055 {
2056 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2057 return -EINVAL;
2058 }
2059
2060 if (!tb_vendor
2061 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2062 {
2063 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2064 return -EINVAL;
2065 }
2066
2067 if (!tb_vendor
2068 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2069 {
2070 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
2071 return -EINVAL;
2072 }
2073
Sunil Duttc69bccb2014-05-26 21:30:20 +05302074
Dino Mycledf0a5d92014-07-04 09:41:55 +05302075 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302076 nla_get_u32( tb_vendor[
2077 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05302078 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302079 nla_get_u32( tb_vendor[
2080 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
2081
Dino Mycled3d50022014-07-07 12:58:25 +05302082 vos_mem_copy(linkLayerStatsGetReq.macAddr,
2083 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302084
2085 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302086 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302087 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302088 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302089 hddLog(VOS_TRACE_LEVEL_INFO,
2090 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302091 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302092
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302093 spin_lock(&hdd_context_lock);
2094 context = &pHddCtx->ll_stats_context;
2095 context->request_id = linkLayerStatsGetReq.reqId;
2096 context->request_bitmap = linkLayerStatsGetReq.paramIdMask;
2097 INIT_COMPLETION(context->response_event);
2098 spin_unlock(&hdd_context_lock);
2099
Sunil Duttc69bccb2014-05-26 21:30:20 +05302100 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302101 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302102 {
2103 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2104 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302105 return -EINVAL;
2106 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302107
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302108 rc = wait_for_completion_timeout(&context->response_event,
2109 msecs_to_jiffies(WLAN_WAIT_TIME_LL_STATS));
2110 if (!rc)
2111 {
2112 hddLog(LOGE,
2113 FL("Target response timed out request id %d request bitmap 0x%x"),
2114 context->request_id, context->request_bitmap);
2115 return -ETIMEDOUT;
2116 }
2117
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302118 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302119 return 0;
2120}
2121
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302122static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2123 struct wireless_dev *wdev,
2124 const void *data,
2125 int data_len)
2126{
2127 int ret = 0;
2128
2129 vos_ssr_protect(__func__);
2130 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
2131 vos_ssr_unprotect(__func__);
2132
2133 return ret;
2134}
2135
Sunil Duttc69bccb2014-05-26 21:30:20 +05302136const struct
2137nla_policy
2138qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
2139{
2140 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
2141 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
2142 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
2143 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
2144};
2145
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302146static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2147 struct wireless_dev *wdev,
2148 const void *data,
2149 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302150{
2151 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2152 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302153 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302154 struct net_device *dev = wdev->netdev;
2155 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2156 u32 statsClearReqMask;
2157 u8 stopReq;
2158 int status;
2159
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302160 ENTER();
2161
Sunil Duttc69bccb2014-05-26 21:30:20 +05302162 status = wlan_hdd_validate_context(pHddCtx);
2163 if (0 != status)
2164 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302165 return -EINVAL;
2166 }
2167
2168 if (NULL == pAdapter)
2169 {
2170 hddLog(VOS_TRACE_LEVEL_FATAL,
2171 "%s: HDD adapter is Null", __func__);
2172 return -ENODEV;
2173 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302174 /* check the LLStats Capability */
2175 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2176 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2177 {
2178 hddLog(VOS_TRACE_LEVEL_ERROR,
2179 FL("Enable LLStats Capability"));
2180 return -EINVAL;
2181 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302182
2183 if (!pAdapter->isLinkLayerStatsSet)
2184 {
2185 hddLog(VOS_TRACE_LEVEL_FATAL,
2186 "%s: isLinkLayerStatsSet : %d",
2187 __func__, pAdapter->isLinkLayerStatsSet);
2188 return -EINVAL;
2189 }
2190
2191 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2192 (struct nlattr *)data,
2193 data_len, qca_wlan_vendor_ll_clr_policy))
2194 {
2195 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2196 return -EINVAL;
2197 }
2198
2199 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2200
2201 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2202 {
2203 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2204 return -EINVAL;
2205
2206 }
2207
Sunil Duttc69bccb2014-05-26 21:30:20 +05302208
Dino Mycledf0a5d92014-07-04 09:41:55 +05302209 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302210 nla_get_u32(
2211 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2212
Dino Mycledf0a5d92014-07-04 09:41:55 +05302213 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302214 nla_get_u8(
2215 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2216
2217 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302218 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302219
Dino Mycled3d50022014-07-07 12:58:25 +05302220 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2221 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302222
2223 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302224 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302225 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302226 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302227 hddLog(VOS_TRACE_LEVEL_INFO,
2228 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302229 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302230 hddLog(VOS_TRACE_LEVEL_INFO,
2231 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302232 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302233
2234 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302235 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302236 {
2237 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302238 hdd_station_ctx_t *pHddStaCtx;
2239
2240 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2241 if (VOS_STATUS_SUCCESS !=
2242 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2243 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2244 {
2245 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2246 "WLANTL_ClearInterfaceStats Failed", __func__);
2247 return -EINVAL;
2248 }
2249 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2250 (statsClearReqMask & WIFI_STATS_IFACE)) {
2251 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2252 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2253 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2254 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2255 }
2256
Sunil Duttc69bccb2014-05-26 21:30:20 +05302257 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2258 2 * sizeof(u32) +
2259 NLMSG_HDRLEN);
2260
2261 if (temp_skbuff != NULL)
2262 {
2263
2264 if (nla_put_u32(temp_skbuff,
2265 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2266 statsClearReqMask) ||
2267 nla_put_u32(temp_skbuff,
2268 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2269 stopReq))
2270 {
2271 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2272 kfree_skb(temp_skbuff);
2273 return -EINVAL;
2274 }
2275 /* If the ask is to stop the stats collection as part of clear
2276 * (stopReq = 1) , ensure that no further requests of get
2277 * go to the firmware by having isLinkLayerStatsSet set to 0.
2278 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302279 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302280 * case the firmware is just asked to clear the statistics.
2281 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302282 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302283 pAdapter->isLinkLayerStatsSet = 0;
2284 return cfg80211_vendor_cmd_reply(temp_skbuff);
2285 }
2286 return -ENOMEM;
2287 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302288
2289 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302290 return -EINVAL;
2291}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302292static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2293 struct wireless_dev *wdev,
2294 const void *data,
2295 int data_len)
2296{
2297 int ret = 0;
2298
2299 vos_ssr_protect(__func__);
2300 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2301 vos_ssr_unprotect(__func__);
2302
2303 return ret;
2304
2305
2306}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302307#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2308
Dino Mycle6fb96c12014-06-10 11:52:40 +05302309#ifdef WLAN_FEATURE_EXTSCAN
2310static const struct nla_policy
2311wlan_hdd_extscan_config_policy
2312 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2313{
2314 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2315 { .type = NLA_U32 },
2316 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2317 { .type = NLA_U32 },
2318 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2319 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2320 { .type = NLA_U32 },
2321 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2322 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2323
2324 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2325 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2326 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2327 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2328 { .type = NLA_U8 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302329 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD] =
2330 { .type = NLA_U32 },
2331 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT] =
2332 { .type = NLA_U32 },
2333 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT] =
2334 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05302335 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2336 { .type = NLA_U32 },
2337 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2338 { .type = NLA_U32 },
2339 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2340 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302341 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT] =
2342 { .type = NLA_U8 },
2343 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05302344 { .type = NLA_U8 },
2345 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2346 { .type = NLA_U8 },
2347 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2348 { .type = NLA_U8 },
2349
2350 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2351 { .type = NLA_U32 },
2352 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2353 { .type = NLA_UNSPEC },
2354 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2355 { .type = NLA_S32 },
2356 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2357 { .type = NLA_S32 },
2358 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2359 { .type = NLA_U32 },
2360 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2361 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302362 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE] =
2363 { .type = NLA_U32 },
2364 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID] =
2365 { .type = NLA_BINARY,
2366 .len = IEEE80211_MAX_SSID_LEN + 1 },
2367 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05302368 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302369 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID] =
2370 { .type = NLA_U32 },
2371 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND] =
2372 { .type = NLA_U8 },
2373 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW] =
2374 { .type = NLA_S32 },
2375 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH] =
2376 { .type = NLA_S32 },
2377 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS] =
2378 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05302379};
2380
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302381/**
2382 * wlan_hdd_cfg80211_extscan_get_capabilities_rsp() - response from target
2383 * @ctx: hdd global context
2384 * @data: capabilities data
2385 *
2386 * Return: none
2387 */
2388static void
2389wlan_hdd_cfg80211_extscan_get_capabilities_rsp(void *ctx, void *pMsg)
Dino Mycle6fb96c12014-06-10 11:52:40 +05302390{
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302391 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302392 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302393 tSirEXTScanCapabilitiesEvent *data =
2394 (tSirEXTScanCapabilitiesEvent *) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302395
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302396 ENTER();
2397
2398 if (wlan_hdd_validate_context(pHddCtx))
2399 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302400 return;
2401 }
2402
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302403 if (!pMsg)
2404 {
2405 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2406 return;
2407 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302408
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302409 vos_spin_lock_acquire(&hdd_context_lock);
2410
2411 context = &pHddCtx->ext_scan_context;
2412 /* validate response received from target*/
2413 if (context->request_id != data->requestId)
2414 {
2415 vos_spin_lock_release(&hdd_context_lock);
2416 hddLog(LOGE,
2417 FL("Target response id did not match: request_id %d resposne_id %d"),
2418 context->request_id, data->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302419 return;
2420 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302421 else
2422 {
2423 context->capability_response = *data;
2424 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302425 }
2426
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302427 vos_spin_lock_release(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302428
Dino Mycle6fb96c12014-06-10 11:52:40 +05302429 return;
2430}
2431
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302432/*
2433 * define short names for the global vendor params
2434 * used by wlan_hdd_send_ext_scan_capability()
2435 */
2436#define PARAM_REQUEST_ID \
2437 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
2438#define PARAM_STATUS \
2439 QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS
2440#define MAX_SCAN_CACHE_SIZE \
2441 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE
2442#define MAX_SCAN_BUCKETS \
2443 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS
2444#define MAX_AP_CACHE_PER_SCAN \
2445 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN
2446#define MAX_RSSI_SAMPLE_SIZE \
2447 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE
2448#define MAX_SCAN_RPT_THRHOLD \
2449 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD
2450#define MAX_HOTLIST_BSSIDS \
2451 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_BSSIDS
2452#define MAX_BSSID_HISTORY_ENTRIES \
2453 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES
2454#define MAX_HOTLIST_SSIDS \
2455 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_SSIDS
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302456#define MAX_SIGNIFICANT_WIFI_CHANGE_APS \
2457 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302458
2459static int wlan_hdd_send_ext_scan_capability(void *ctx)
2460{
2461 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2462 struct sk_buff *skb = NULL;
2463 int ret;
2464 tSirEXTScanCapabilitiesEvent *data;
2465 tANI_U32 nl_buf_len;
2466
2467 ret = wlan_hdd_validate_context(pHddCtx);
2468 if (0 != ret)
2469 {
2470 return ret;
2471 }
2472
2473 data = &(pHddCtx->ext_scan_context.capability_response);
2474
2475 nl_buf_len = NLMSG_HDRLEN;
2476 nl_buf_len += (sizeof(data->requestId) + NLA_HDRLEN) +
2477 (sizeof(data->status) + NLA_HDRLEN) +
2478 (sizeof(data->scanCacheSize) + NLA_HDRLEN) +
2479 (sizeof(data->scanBuckets) + NLA_HDRLEN) +
2480 (sizeof(data->maxApPerScan) + NLA_HDRLEN) +
2481 (sizeof(data->maxRssiSampleSize) + NLA_HDRLEN) +
2482 (sizeof(data->maxScanReportingThreshold) + NLA_HDRLEN) +
2483 (sizeof(data->maxHotlistAPs) + NLA_HDRLEN) +
2484 (sizeof(data->maxBsidHistoryEntries) + NLA_HDRLEN) +
2485 (sizeof(data->maxHotlistSSIDs) + NLA_HDRLEN);
2486
2487 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy, nl_buf_len);
2488
2489 if (!skb)
2490 {
2491 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
2492 return -ENOMEM;
2493 }
2494
2495 hddLog(LOG1, "Req Id (%u) Status (%u)", data->requestId, data->status);
2496 hddLog(LOG1, "Scan cache size (%u) Scan buckets (%u) Max AP per scan (%u)",
2497 data->scanCacheSize, data->scanBuckets, data->maxApPerScan);
2498 hddLog(LOG1, "max_rssi_sample_size (%u) max_scan_reporting_threshold (%u)",
2499 data->maxRssiSampleSize, data->maxScanReportingThreshold);
2500 hddLog(LOG1, "max_hotlist_bssids (%u) max_bssid_history_entries (%u)"
2501 "max_hotlist_ssids (%u)", data->maxHotlistAPs,
2502 data->maxBsidHistoryEntries, data->maxHotlistSSIDs);
2503
2504 if (nla_put_u32(skb, PARAM_REQUEST_ID, data->requestId) ||
2505 nla_put_u32(skb, PARAM_STATUS, data->status) ||
2506 nla_put_u32(skb, MAX_SCAN_CACHE_SIZE, data->scanCacheSize) ||
2507 nla_put_u32(skb, MAX_SCAN_BUCKETS, data->scanBuckets) ||
2508 nla_put_u32(skb, MAX_AP_CACHE_PER_SCAN,
2509 data->maxApPerScan) ||
2510 nla_put_u32(skb, MAX_RSSI_SAMPLE_SIZE,
2511 data->maxRssiSampleSize) ||
2512 nla_put_u32(skb, MAX_SCAN_RPT_THRHOLD,
2513 data->maxScanReportingThreshold) ||
2514 nla_put_u32(skb, MAX_HOTLIST_BSSIDS, data->maxHotlistAPs) ||
2515 nla_put_u32(skb, MAX_BSSID_HISTORY_ENTRIES,
2516 data->maxBsidHistoryEntries) ||
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302517 nla_put_u32(skb, MAX_HOTLIST_SSIDS, data->maxHotlistSSIDs) ||
2518 nla_put_u32(skb, MAX_SIGNIFICANT_WIFI_CHANGE_APS, 0))
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302519 {
2520 hddLog(LOGE, FL("nla put fail"));
2521 goto nla_put_failure;
2522 }
2523
2524 cfg80211_vendor_cmd_reply(skb);
2525 return 0;
2526
2527nla_put_failure:
2528 kfree_skb(skb);
2529 return -EINVAL;;
2530}
2531
2532/*
2533 * done with short names for the global vendor params
2534 * used by wlan_hdd_send_ext_scan_capability()
2535 */
2536#undef PARAM_REQUEST_ID
2537#undef PARAM_STATUS
2538#undef MAX_SCAN_CACHE_SIZE
2539#undef MAX_SCAN_BUCKETS
2540#undef MAX_AP_CACHE_PER_SCAN
2541#undef MAX_RSSI_SAMPLE_SIZE
2542#undef MAX_SCAN_RPT_THRHOLD
2543#undef MAX_HOTLIST_BSSIDS
2544#undef MAX_SIGNIFICANT_WIFI_CHANGE_APS
2545#undef MAX_BSSID_HISTORY_ENTRIES
2546#undef MAX_HOTLIST_SSIDS
Dino Mycle6fb96c12014-06-10 11:52:40 +05302547
2548static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2549{
2550 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2551 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302552 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302553 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302554
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302555 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302556
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302557 if (wlan_hdd_validate_context(pHddCtx))
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302558 return;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302559
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302560 if (!pMsg)
2561 {
2562 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302563 return;
2564 }
2565
Dino Mycle6fb96c12014-06-10 11:52:40 +05302566 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2567 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2568
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302569 context = &pHddCtx->ext_scan_context;
2570 spin_lock(&hdd_context_lock);
2571 if (context->request_id == pData->requestId) {
2572 context->response_status = pData->status ? -EINVAL : 0;
2573 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302574 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302575 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302576
2577 /*
2578 * Store the Request ID for comparing with the requestID obtained
2579 * in other requests.HDD shall return a failure is the extscan_stop
2580 * request is issued with a different requestId as that of the
2581 * extscan_start request. Also, This requestId shall be used while
2582 * indicating the full scan results to the upper layers.
2583 * The requestId is stored with the assumption that the firmware
2584 * shall return the ext scan start request's requestId in ext scan
2585 * start response.
2586 */
2587 if (pData->status == 0)
2588 pMac->sme.extScanStartReqId = pData->requestId;
2589
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302590 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302591 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302592}
2593
2594
2595static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2596{
2597 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2598 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2599 struct sk_buff *skb = NULL;
2600
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302601 ENTER();
2602
2603 if (wlan_hdd_validate_context(pHddCtx)){
2604 return;
2605 }
2606 if (!pMsg)
2607 {
2608 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302609 return;
2610 }
2611
2612 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302613#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2614 NULL,
2615#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302616 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2617 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2618 GFP_KERNEL);
2619
2620 if (!skb) {
2621 hddLog(VOS_TRACE_LEVEL_ERROR,
2622 FL("cfg80211_vendor_event_alloc failed"));
2623 return;
2624 }
2625 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2626 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2627
2628 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2629 pData->requestId) ||
2630 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2631 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2632 goto nla_put_failure;
2633 }
2634
2635 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302636 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302637 return;
2638
2639nla_put_failure:
2640 kfree_skb(skb);
2641 return;
2642}
2643
2644
2645static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2646 void *pMsg)
2647{
2648 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2649 struct sk_buff *skb = NULL;
2650 tpSirEXTScanSetBssidHotListRspParams pData =
2651 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2652
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302653 ENTER();
2654
2655 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302656 return;
2657 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302658 if (!pMsg)
2659 {
2660 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2661 return;
2662 }
2663
Dino Mycle6fb96c12014-06-10 11:52:40 +05302664 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302665#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2666 NULL,
2667#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302668 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2669 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2670 GFP_KERNEL);
2671
2672 if (!skb) {
2673 hddLog(VOS_TRACE_LEVEL_ERROR,
2674 FL("cfg80211_vendor_event_alloc failed"));
2675 return;
2676 }
2677 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2678 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2679 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2680
2681 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2682 pData->requestId) ||
2683 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2684 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2685 goto nla_put_failure;
2686 }
2687
2688 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302689 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302690 return;
2691
2692nla_put_failure:
2693 kfree_skb(skb);
2694 return;
2695}
2696
2697static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2698 void *pMsg)
2699{
2700 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2701 struct sk_buff *skb = NULL;
2702 tpSirEXTScanResetBssidHotlistRspParams pData =
2703 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2704
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302705 ENTER();
2706
2707 if (wlan_hdd_validate_context(pHddCtx)) {
2708 return;
2709 }
2710 if (!pMsg)
2711 {
2712 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302713 return;
2714 }
2715
2716 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302717#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2718 NULL,
2719#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302720 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2721 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2722 GFP_KERNEL);
2723
2724 if (!skb) {
2725 hddLog(VOS_TRACE_LEVEL_ERROR,
2726 FL("cfg80211_vendor_event_alloc failed"));
2727 return;
2728 }
2729 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2730 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2731
2732 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2733 pData->requestId) ||
2734 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2735 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2736 goto nla_put_failure;
2737 }
2738
2739 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302740 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302741 return;
2742
2743nla_put_failure:
2744 kfree_skb(skb);
2745 return;
2746}
2747
2748
2749static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2750 void *pMsg)
2751{
2752 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2753 struct sk_buff *skb = NULL;
2754 tpSirEXTScanSetSignificantChangeRspParams pData =
2755 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2756
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302757 ENTER();
2758
2759 if (wlan_hdd_validate_context(pHddCtx)) {
2760 return;
2761 }
2762 if (!pMsg)
2763 {
2764 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302765 return;
2766 }
2767
2768 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302769#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2770 NULL,
2771#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302772 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2773 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2774 GFP_KERNEL);
2775
2776 if (!skb) {
2777 hddLog(VOS_TRACE_LEVEL_ERROR,
2778 FL("cfg80211_vendor_event_alloc failed"));
2779 return;
2780 }
2781 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2782 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2783 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2784
2785 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2786 pData->requestId) ||
2787 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2788 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2789 goto nla_put_failure;
2790 }
2791
2792 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302793 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302794 return;
2795
2796nla_put_failure:
2797 kfree_skb(skb);
2798 return;
2799}
2800
2801
2802static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2803 void *pMsg)
2804{
2805 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2806 struct sk_buff *skb = NULL;
2807 tpSirEXTScanResetSignificantChangeRspParams pData =
2808 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2809
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302810 ENTER();
2811
2812 if (wlan_hdd_validate_context(pHddCtx)) {
2813 return;
2814 }
2815 if (!pMsg)
2816 {
2817 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302818 return;
2819 }
2820
2821 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302822#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2823 NULL,
2824#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302825 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2826 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2827 GFP_KERNEL);
2828
2829 if (!skb) {
2830 hddLog(VOS_TRACE_LEVEL_ERROR,
2831 FL("cfg80211_vendor_event_alloc failed"));
2832 return;
2833 }
2834 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2835 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2836 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2837
2838 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2839 pData->requestId) ||
2840 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2841 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2842 goto nla_put_failure;
2843 }
2844
2845 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302846 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302847 return;
2848
2849nla_put_failure:
2850 kfree_skb(skb);
2851 return;
2852}
2853
2854static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2855 void *pMsg)
2856{
2857 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2858 struct sk_buff *skb = NULL;
2859 tANI_U32 i = 0, j, resultsPerEvent;
2860 tANI_S32 totalResults;
2861 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2862 tpSirWifiScanResult pSirWifiScanResult;
2863
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302864 ENTER();
2865
2866 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302867 return;
2868 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302869 if (!pMsg)
2870 {
2871 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2872 return;
2873 }
2874
Dino Mycle6fb96c12014-06-10 11:52:40 +05302875 totalResults = pData->numOfAps;
2876 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2877 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2878 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2879
2880 do{
2881 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2882 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2883 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2884
2885 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302886#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2887 NULL,
2888#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302889 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2890 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2891 GFP_KERNEL);
2892
2893 if (!skb) {
2894 hddLog(VOS_TRACE_LEVEL_ERROR,
2895 FL("cfg80211_vendor_event_alloc failed"));
2896 return;
2897 }
2898
2899 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2900
2901 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2902 pData->requestId) ||
2903 nla_put_u32(skb,
2904 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2905 resultsPerEvent)) {
2906 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2907 goto fail;
2908 }
2909 if (nla_put_u8(skb,
2910 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2911 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2912 {
2913 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2914 goto fail;
2915 }
2916
2917 if (resultsPerEvent) {
2918 struct nlattr *aps;
2919
2920 aps = nla_nest_start(skb,
2921 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2922 if (!aps)
2923 {
2924 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2925 goto fail;
2926 }
2927
2928 for (j = 0; j < resultsPerEvent; j++, i++) {
2929 struct nlattr *ap;
2930 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2931 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2932
2933 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2934 "Ssid (%s)"
2935 "Bssid: %pM "
2936 "Channel (%u)"
2937 "Rssi (%d)"
2938 "RTT (%u)"
2939 "RTT_SD (%u)",
2940 i,
2941 pSirWifiScanResult->ts,
2942 pSirWifiScanResult->ssid,
2943 pSirWifiScanResult->bssid,
2944 pSirWifiScanResult->channel,
2945 pSirWifiScanResult->rssi,
2946 pSirWifiScanResult->rtt,
2947 pSirWifiScanResult->rtt_sd);
2948
2949 ap = nla_nest_start(skb, j + 1);
2950 if (!ap)
2951 {
2952 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2953 goto fail;
2954 }
2955
2956 if (nla_put_u64(skb,
2957 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2958 pSirWifiScanResult->ts) )
2959 {
2960 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2961 goto fail;
2962 }
2963 if (nla_put(skb,
2964 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2965 sizeof(pSirWifiScanResult->ssid),
2966 pSirWifiScanResult->ssid) )
2967 {
2968 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2969 goto fail;
2970 }
2971 if (nla_put(skb,
2972 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2973 sizeof(pSirWifiScanResult->bssid),
2974 pSirWifiScanResult->bssid) )
2975 {
2976 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2977 goto fail;
2978 }
2979 if (nla_put_u32(skb,
2980 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2981 pSirWifiScanResult->channel) )
2982 {
2983 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2984 goto fail;
2985 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302986 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302987 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2988 pSirWifiScanResult->rssi) )
2989 {
2990 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2991 goto fail;
2992 }
2993 if (nla_put_u32(skb,
2994 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2995 pSirWifiScanResult->rtt) )
2996 {
2997 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2998 goto fail;
2999 }
3000 if (nla_put_u32(skb,
3001 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3002 pSirWifiScanResult->rtt_sd))
3003 {
3004 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3005 goto fail;
3006 }
3007
3008 nla_nest_end(skb, ap);
3009 }
3010 nla_nest_end(skb, aps);
3011
3012 }
3013 cfg80211_vendor_event(skb, GFP_KERNEL);
3014 } while (totalResults > 0);
3015
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303016 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303017 return;
3018fail:
3019 kfree_skb(skb);
3020 return;
3021}
3022
3023static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
3024 void *pMsg)
3025{
3026 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
3027 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3028 struct sk_buff *skb = NULL;
3029 tANI_U32 i;
3030
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303031 ENTER();
3032
3033 if (wlan_hdd_validate_context(pHddCtx)) {
3034 return;
3035 }
3036 if (!pMsg)
3037 {
3038 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303039 return;
3040 }
3041
3042 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303043#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3044 NULL,
3045#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303046 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3047 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
3048 GFP_KERNEL);
3049
3050 if (!skb) {
3051 hddLog(VOS_TRACE_LEVEL_ERROR,
3052 FL("cfg80211_vendor_event_alloc failed"));
3053 return;
3054 }
3055 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3056 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3057 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
3058 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
3059
3060 for (i = 0; i < pData->numOfAps; i++) {
3061 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
3062 "Ssid (%s) "
3063 "Bssid (" MAC_ADDRESS_STR ") "
3064 "Channel (%u) "
3065 "Rssi (%d) "
3066 "RTT (%u) "
3067 "RTT_SD (%u) ",
3068 i,
3069 pData->ap[i].ts,
3070 pData->ap[i].ssid,
3071 MAC_ADDR_ARRAY(pData->ap[i].bssid),
3072 pData->ap[i].channel,
3073 pData->ap[i].rssi,
3074 pData->ap[i].rtt,
3075 pData->ap[i].rtt_sd);
3076 }
3077
3078 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3079 pData->requestId) ||
3080 nla_put_u32(skb,
3081 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3082 pData->numOfAps)) {
3083 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3084 goto fail;
3085 }
3086 if (pData->numOfAps) {
3087 struct nlattr *aps;
3088
3089 aps = nla_nest_start(skb,
3090 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3091 if (!aps)
3092 goto fail;
3093
3094 for (i = 0; i < pData->numOfAps; i++) {
3095 struct nlattr *ap;
3096
3097 ap = nla_nest_start(skb, i + 1);
3098 if (!ap)
3099 goto fail;
3100
3101 if (nla_put_u64(skb,
3102 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3103 pData->ap[i].ts) ||
3104 nla_put(skb,
3105 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3106 sizeof(pData->ap[i].ssid),
3107 pData->ap[i].ssid) ||
3108 nla_put(skb,
3109 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3110 sizeof(pData->ap[i].bssid),
3111 pData->ap[i].bssid) ||
3112 nla_put_u32(skb,
3113 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3114 pData->ap[i].channel) ||
3115 nla_put_s32(skb,
3116 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
3117 pData->ap[i].rssi) ||
3118 nla_put_u32(skb,
3119 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3120 pData->ap[i].rtt) ||
3121 nla_put_u32(skb,
3122 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3123 pData->ap[i].rtt_sd))
3124 goto fail;
3125
3126 nla_nest_end(skb, ap);
3127 }
3128 nla_nest_end(skb, aps);
3129
3130 if (nla_put_u8(skb,
3131 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3132 pData->moreData))
3133 goto fail;
3134 }
3135
3136 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303137 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303138 return;
3139
3140fail:
3141 kfree_skb(skb);
3142 return;
3143
3144}
3145static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
3146 void *pMsg)
3147{
3148 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3149 struct sk_buff *skb = NULL;
3150 tANI_U32 i, j;
3151 tpSirWifiSignificantChangeEvent pData =
3152 (tpSirWifiSignificantChangeEvent) pMsg;
3153
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303154 ENTER();
3155
3156 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303157 return;
3158 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303159 if (!pMsg)
3160 {
3161 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3162 return;
3163 }
3164
Dino Mycle6fb96c12014-06-10 11:52:40 +05303165 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303166#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3167 NULL,
3168#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303169 EXTSCAN_EVENT_BUF_SIZE,
3170 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
3171 GFP_KERNEL);
3172
3173 if (!skb) {
3174 hddLog(VOS_TRACE_LEVEL_ERROR,
3175 FL("cfg80211_vendor_event_alloc failed"));
3176 return;
3177 }
3178 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3179 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3180 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
3181 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
3182 pData->numSigRssiBss);
3183 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
3184
3185 for (i = 0; i < pData->numSigRssiBss; i++) {
3186 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
3187 " num RSSI %u ",
3188 i, pData->sigRssiResult[i].bssid,
3189 pData->sigRssiResult[i].channel,
3190 pData->sigRssiResult[i].numRssi);
3191
3192 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
3193
3194 hddLog(VOS_TRACE_LEVEL_INFO,
3195 " [%d]",
Dino Myclec8f3f332014-07-21 16:48:27 +05303196 pData->sigRssiResult[i].rssi[j]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303197
3198 }
3199 }
3200
3201
3202 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3203 pData->requestId) ||
3204 nla_put_u32(skb,
3205 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3206 pData->numSigRssiBss)) {
3207 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3208 goto fail;
3209 }
3210
3211 if (pData->numSigRssiBss) {
3212 struct nlattr *aps;
3213 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3214 if (!aps)
3215 goto fail;
3216 for (i = 0; i < pData->numSigRssiBss; i++) {
3217 struct nlattr *ap;
3218
3219 ap = nla_nest_start(skb, i);
3220 if (!ap)
3221 goto fail;
3222 if (nla_put(skb,
3223 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
3224 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
3225 nla_put_u32(skb,
3226 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
3227 pData->sigRssiResult[i].channel) ||
3228 nla_put_u32(skb,
3229 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
3230 pData->sigRssiResult[i].numRssi) ||
3231 nla_put(skb,
3232 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
3233 sizeof(s32) * pData->sigRssiResult[i].numRssi,
3234 pData->sigRssiResult[i].rssi))
3235 goto fail;
3236 nla_nest_end(skb, ap);
3237 }
3238 nla_nest_end(skb, aps);
3239 if (nla_put_u8(skb,
3240 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3241 pData->moreData))
3242 goto fail;
3243 }
3244 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303245 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303246 return;
3247fail:
3248 kfree_skb(skb);
3249 return;
3250}
3251
3252static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3253 void *pMsg)
3254{
3255 struct sk_buff *skb;
3256 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3257 tpSirWifiFullScanResultEvent pData =
3258 (tpSirWifiFullScanResultEvent) (pMsg);
3259
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303260 ENTER();
3261
3262 if (wlan_hdd_validate_context(pHddCtx)) {
3263 return;
3264 }
3265 if (!pMsg)
3266 {
3267 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303268 return;
3269 }
3270
3271 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303272#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3273 NULL,
3274#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303275 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3276 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3277 GFP_KERNEL);
3278
3279 if (!skb) {
3280 hddLog(VOS_TRACE_LEVEL_ERROR,
3281 FL("cfg80211_vendor_event_alloc failed"));
3282 return;
3283 }
3284
3285 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3286 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3287 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3288 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3289 "Ssid (%s)"
3290 "Bssid (" MAC_ADDRESS_STR ")"
3291 "Channel (%u)"
3292 "Rssi (%d)"
3293 "RTT (%u)"
3294 "RTT_SD (%u)"),
3295 pData->ap.ts,
3296 pData->ap.ssid,
3297 MAC_ADDR_ARRAY(pData->ap.bssid),
3298 pData->ap.channel,
3299 pData->ap.rssi,
3300 pData->ap.rtt,
3301 pData->ap.rtt_sd);
3302 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3303 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3304 pData->requestId) ||
3305 nla_put_u64(skb,
3306 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3307 pData->ap.ts) ||
3308 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3309 sizeof(pData->ap.ssid),
3310 pData->ap.ssid) ||
3311 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3312 WNI_CFG_BSSID_LEN,
3313 pData->ap.bssid) ||
3314 nla_put_u32(skb,
3315 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3316 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303317 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303318 pData->ap.rssi) ||
3319 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3320 pData->ap.rtt) ||
3321 nla_put_u32(skb,
3322 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3323 pData->ap.rtt_sd) ||
3324 nla_put_u16(skb,
3325 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3326 pData->ap.beaconPeriod) ||
3327 nla_put_u16(skb,
3328 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3329 pData->ap.capability) ||
3330 nla_put_u32(skb,
3331 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3332 pData->ieLength))
3333 {
3334 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3335 goto nla_put_failure;
3336 }
3337 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3338 pData->ieLength,
3339 pData->ie))
3340 {
3341 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3342 goto nla_put_failure;
3343 }
3344
3345 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303346 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303347 return;
3348
3349nla_put_failure:
3350 kfree_skb(skb);
3351 return;
3352}
3353
3354static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3355 void *pMsg)
3356{
3357 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3358 struct sk_buff *skb = NULL;
3359 tpSirEXTScanResultsAvailableIndParams pData =
3360 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3361
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303362 ENTER();
3363
3364 if (wlan_hdd_validate_context(pHddCtx)){
3365 return;
3366 }
3367 if (!pMsg)
3368 {
3369 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303370 return;
3371 }
3372
3373 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303374#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3375 NULL,
3376#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303377 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3378 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3379 GFP_KERNEL);
3380
3381 if (!skb) {
3382 hddLog(VOS_TRACE_LEVEL_ERROR,
3383 FL("cfg80211_vendor_event_alloc failed"));
3384 return;
3385 }
3386
3387 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3388 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3389 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3390 pData->numResultsAvailable);
3391 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3392 pData->requestId) ||
3393 nla_put_u32(skb,
3394 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3395 pData->numResultsAvailable)) {
3396 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3397 goto nla_put_failure;
3398 }
3399
3400 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303401 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303402 return;
3403
3404nla_put_failure:
3405 kfree_skb(skb);
3406 return;
3407}
3408
3409static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3410{
3411 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3412 struct sk_buff *skb = NULL;
3413 tpSirEXTScanProgressIndParams pData =
3414 (tpSirEXTScanProgressIndParams) pMsg;
3415
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303416 ENTER();
3417
3418 if (wlan_hdd_validate_context(pHddCtx)){
3419 return;
3420 }
3421 if (!pMsg)
3422 {
3423 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303424 return;
3425 }
3426
3427 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303428#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3429 NULL,
3430#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303431 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3432 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3433 GFP_KERNEL);
3434
3435 if (!skb) {
3436 hddLog(VOS_TRACE_LEVEL_ERROR,
3437 FL("cfg80211_vendor_event_alloc failed"));
3438 return;
3439 }
3440 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3441 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3442 pData->extScanEventType);
3443 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3444 pData->status);
3445
3446 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3447 pData->extScanEventType) ||
3448 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303449 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3450 pData->requestId) ||
3451 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303452 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3453 pData->status)) {
3454 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3455 goto nla_put_failure;
3456 }
3457
3458 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303459 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303460 return;
3461
3462nla_put_failure:
3463 kfree_skb(skb);
3464 return;
3465}
3466
3467void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3468 void *pMsg)
3469{
3470 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3471
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303472 ENTER();
3473
Dino Mycle6fb96c12014-06-10 11:52:40 +05303474 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303475 return;
3476 }
3477
3478 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3479
3480
3481 switch(evType) {
3482 case SIR_HAL_EXTSCAN_START_RSP:
3483 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3484 break;
3485
3486 case SIR_HAL_EXTSCAN_STOP_RSP:
3487 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3488 break;
3489 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3490 /* There is no need to send this response to upper layer
3491 Just log the message */
3492 hddLog(VOS_TRACE_LEVEL_INFO,
3493 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3494 break;
3495 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3496 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3497 break;
3498
3499 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3500 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3501 break;
3502
3503 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
3504 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
3505 break;
3506
3507 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
3508 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
3509 break;
3510 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303511 wlan_hdd_cfg80211_extscan_get_capabilities_rsp(ctx, pMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303512 break;
3513 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3514 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3515 break;
3516 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3517 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3518 break;
3519 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3520 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3521 break;
3522 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3523 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3524 break;
3525 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
3526 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
3527 break;
3528 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3529 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3530 break;
3531 default:
3532 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3533 break;
3534 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303535 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303536}
3537
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303538static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3539 struct wireless_dev *wdev,
3540 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303541{
Dino Myclee8843b32014-07-04 14:21:45 +05303542 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303543 struct net_device *dev = wdev->netdev;
3544 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3545 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3546 struct nlattr
3547 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3548 eHalStatus status;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303549 struct hdd_ext_scan_context *context;
3550 unsigned long rc;
3551 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303552
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303553 ENTER();
3554
Dino Mycle6fb96c12014-06-10 11:52:40 +05303555 status = wlan_hdd_validate_context(pHddCtx);
3556 if (0 != status)
3557 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303558 return -EINVAL;
3559 }
Dino Myclee8843b32014-07-04 14:21:45 +05303560 /* check the EXTScan Capability */
3561 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3562 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3563 {
3564 hddLog(VOS_TRACE_LEVEL_ERROR,
3565 FL("EXTScan not enabled/supported by Firmware"));
3566 return -EINVAL;
3567 }
3568
Dino Mycle6fb96c12014-06-10 11:52:40 +05303569 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3570 data, dataLen,
3571 wlan_hdd_extscan_config_policy)) {
3572 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3573 return -EINVAL;
3574 }
3575
3576 /* Parse and fetch request Id */
3577 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3578 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3579 return -EINVAL;
3580 }
3581
Dino Myclee8843b32014-07-04 14:21:45 +05303582 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303583 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303584 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303585
Dino Myclee8843b32014-07-04 14:21:45 +05303586 reqMsg.sessionId = pAdapter->sessionId;
3587 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303588
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303589 vos_spin_lock_acquire(&hdd_context_lock);
3590 context = &pHddCtx->ext_scan_context;
3591 context->request_id = reqMsg.requestId;
3592 INIT_COMPLETION(context->response_event);
3593 vos_spin_lock_release(&hdd_context_lock);
3594
Dino Myclee8843b32014-07-04 14:21:45 +05303595 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303596 if (!HAL_STATUS_SUCCESS(status)) {
3597 hddLog(VOS_TRACE_LEVEL_ERROR,
3598 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303599 return -EINVAL;
3600 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303601
3602 rc = wait_for_completion_timeout(&context->response_event,
3603 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3604 if (!rc) {
3605 hddLog(LOGE, FL("Target response timed out"));
3606 return -ETIMEDOUT;
3607 }
3608
3609 ret = wlan_hdd_send_ext_scan_capability(pHddCtx);
3610 if (ret)
3611 hddLog(LOGE, FL("Failed to send ext scan capability to user space"));
3612
3613 return ret;
3614
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303615 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303616 return 0;
3617}
3618
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303619static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3620 struct wireless_dev *wdev,
3621 const void *data, int dataLen)
3622{
3623 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303624
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303625 vos_ssr_protect(__func__);
3626 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3627 vos_ssr_unprotect(__func__);
3628
3629 return ret;
3630}
3631
3632static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3633 struct wireless_dev *wdev,
3634 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303635{
Dino Myclee8843b32014-07-04 14:21:45 +05303636 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303637 struct net_device *dev = wdev->netdev;
3638 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3639 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3640 struct nlattr
3641 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3642 eHalStatus status;
3643
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303644 ENTER();
3645
Dino Mycle6fb96c12014-06-10 11:52:40 +05303646 status = wlan_hdd_validate_context(pHddCtx);
3647 if (0 != status)
3648 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303649 return -EINVAL;
3650 }
Dino Myclee8843b32014-07-04 14:21:45 +05303651 /* check the EXTScan Capability */
3652 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3653 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3654 {
3655 hddLog(VOS_TRACE_LEVEL_ERROR,
3656 FL("EXTScan not enabled/supported by Firmware"));
3657 return -EINVAL;
3658 }
3659
Dino Mycle6fb96c12014-06-10 11:52:40 +05303660 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3661 data, dataLen,
3662 wlan_hdd_extscan_config_policy)) {
3663 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3664 return -EINVAL;
3665 }
3666 /* Parse and fetch request Id */
3667 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3668 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3669 return -EINVAL;
3670 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303671
Dino Myclee8843b32014-07-04 14:21:45 +05303672 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303673 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3674
Dino Myclee8843b32014-07-04 14:21:45 +05303675 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303676
Dino Myclee8843b32014-07-04 14:21:45 +05303677 reqMsg.sessionId = pAdapter->sessionId;
3678 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303679
3680 /* Parse and fetch flush parameter */
3681 if (!tb
3682 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3683 {
3684 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3685 goto failed;
3686 }
Dino Myclee8843b32014-07-04 14:21:45 +05303687 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303688 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3689
Dino Myclee8843b32014-07-04 14:21:45 +05303690 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303691
Dino Myclee8843b32014-07-04 14:21:45 +05303692 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303693 if (!HAL_STATUS_SUCCESS(status)) {
3694 hddLog(VOS_TRACE_LEVEL_ERROR,
3695 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303696 return -EINVAL;
3697 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303698 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303699 return 0;
3700
3701failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303702 return -EINVAL;
3703}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303704static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3705 struct wireless_dev *wdev,
3706 const void *data, int dataLen)
3707{
3708 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303709
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303710 vos_ssr_protect(__func__);
3711 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3712 vos_ssr_unprotect(__func__);
3713
3714 return ret;
3715}
3716
3717static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303718 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303719 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303720{
3721 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3722 struct net_device *dev = wdev->netdev;
3723 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3724 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3725 struct nlattr
3726 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3727 struct nlattr
3728 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3729 struct nlattr *apTh;
3730 eHalStatus status;
3731 tANI_U8 i = 0;
3732 int rem;
3733
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303734 ENTER();
3735
Dino Mycle6fb96c12014-06-10 11:52:40 +05303736 status = wlan_hdd_validate_context(pHddCtx);
3737 if (0 != status)
3738 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303739 return -EINVAL;
3740 }
Dino Myclee8843b32014-07-04 14:21:45 +05303741 /* check the EXTScan Capability */
3742 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3743 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3744 {
3745 hddLog(VOS_TRACE_LEVEL_ERROR,
3746 FL("EXTScan not enabled/supported by Firmware"));
3747 return -EINVAL;
3748 }
3749
Dino Mycle6fb96c12014-06-10 11:52:40 +05303750 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3751 data, dataLen,
3752 wlan_hdd_extscan_config_policy)) {
3753 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3754 return -EINVAL;
3755 }
3756
3757 /* Parse and fetch request Id */
3758 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3759 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3760 return -EINVAL;
3761 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303762 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3763 vos_mem_malloc(sizeof(*pReqMsg));
3764 if (!pReqMsg) {
3765 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3766 return -ENOMEM;
3767 }
3768
Dino Myclee8843b32014-07-04 14:21:45 +05303769
Dino Mycle6fb96c12014-06-10 11:52:40 +05303770 pReqMsg->requestId = nla_get_u32(
3771 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3772 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3773
3774 /* Parse and fetch number of APs */
3775 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3776 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3777 goto fail;
3778 }
3779
3780 pReqMsg->sessionId = pAdapter->sessionId;
3781 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3782
3783 pReqMsg->numAp = nla_get_u32(
3784 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3785 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3786
3787 nla_for_each_nested(apTh,
3788 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3789 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3790 nla_data(apTh), nla_len(apTh),
3791 NULL)) {
3792 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3793 goto fail;
3794 }
3795
3796 /* Parse and fetch MAC address */
3797 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3798 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3799 goto fail;
3800 }
3801 memcpy(pReqMsg->ap[i].bssid, nla_data(
3802 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3803 sizeof(tSirMacAddr));
3804 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3805
3806 /* Parse and fetch low RSSI */
3807 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3808 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3809 goto fail;
3810 }
3811 pReqMsg->ap[i].low = nla_get_s32(
3812 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3813 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3814
3815 /* Parse and fetch high RSSI */
3816 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3817 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3818 goto fail;
3819 }
3820 pReqMsg->ap[i].high = nla_get_s32(
3821 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3822 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3823 pReqMsg->ap[i].high);
3824
3825 /* Parse and fetch channel */
3826 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3827 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3828 goto fail;
3829 }
3830 pReqMsg->ap[i].channel = nla_get_u32(
3831 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3832 hddLog(VOS_TRACE_LEVEL_INFO,
3833 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3834 i++;
3835 }
3836 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3837 if (!HAL_STATUS_SUCCESS(status)) {
3838 hddLog(VOS_TRACE_LEVEL_ERROR,
3839 FL("sme_SetBssHotlist failed(err=%d)"), status);
3840 vos_mem_free(pReqMsg);
3841 return -EINVAL;
3842 }
3843
Dino Myclee8843b32014-07-04 14:21:45 +05303844 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303845 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303846 return 0;
3847
3848fail:
3849 vos_mem_free(pReqMsg);
3850 return -EINVAL;
3851}
3852
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303853static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3854 struct wireless_dev *wdev,
3855 const void *data, int dataLen)
3856{
3857 int ret = 0;
3858
3859 vos_ssr_protect(__func__);
3860 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3861 dataLen);
3862 vos_ssr_unprotect(__func__);
3863
3864 return ret;
3865}
3866
3867static int __wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303868 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303869 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303870{
3871 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3872 struct net_device *dev = wdev->netdev;
3873 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3874 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3875 struct nlattr
3876 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3877 struct nlattr
3878 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3879 struct nlattr *apTh;
3880 eHalStatus status;
3881 int i = 0;
3882 int rem;
3883
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303884 ENTER();
3885
Dino Mycle6fb96c12014-06-10 11:52:40 +05303886 status = wlan_hdd_validate_context(pHddCtx);
3887 if (0 != status)
3888 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303889 return -EINVAL;
3890 }
Dino Myclee8843b32014-07-04 14:21:45 +05303891 /* check the EXTScan Capability */
3892 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3893 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3894 {
3895 hddLog(VOS_TRACE_LEVEL_ERROR,
3896 FL("EXTScan not enabled/supported by Firmware"));
3897 return -EINVAL;
3898 }
3899
Dino Mycle6fb96c12014-06-10 11:52:40 +05303900 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3901 data, dataLen,
3902 wlan_hdd_extscan_config_policy)) {
3903 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3904 return -EINVAL;
3905 }
3906
3907 /* Parse and fetch request Id */
3908 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3909 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3910 return -EINVAL;
3911 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303912 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303913 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303914 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303915 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3916 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303917 }
3918
Dino Myclee8843b32014-07-04 14:21:45 +05303919
3920
Dino Mycle6fb96c12014-06-10 11:52:40 +05303921 pReqMsg->requestId = nla_get_u32(
3922 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3923 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3924
3925 /* Parse and fetch RSSI sample size */
3926 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3927 {
3928 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3929 goto fail;
3930 }
3931 pReqMsg->rssiSampleSize = nla_get_u32(
3932 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3933 hddLog(VOS_TRACE_LEVEL_INFO,
3934 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3935
3936 /* Parse and fetch lost AP sample size */
3937 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3938 {
3939 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3940 goto fail;
3941 }
3942 pReqMsg->lostApSampleSize = nla_get_u32(
3943 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3944 hddLog(VOS_TRACE_LEVEL_INFO,
3945 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3946 /* Parse and fetch minimum Breaching */
3947 if (!tb
3948 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3949 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3950 goto fail;
3951 }
3952 pReqMsg->minBreaching = nla_get_u32(
3953 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3954 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3955
3956 /* Parse and fetch number of APs */
3957 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3958 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3959 goto fail;
3960 }
3961 pReqMsg->numAp = nla_get_u32(
3962 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3963 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3964
3965 pReqMsg->sessionId = pAdapter->sessionId;
3966 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3967
3968 nla_for_each_nested(apTh,
3969 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3970 if(nla_parse(tb2,
3971 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3972 nla_data(apTh), nla_len(apTh),
3973 NULL)) {
3974 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3975 goto fail;
3976 }
3977
3978 /* Parse and fetch MAC address */
3979 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3980 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3981 goto fail;
3982 }
3983 memcpy(pReqMsg->ap[i].bssid, nla_data(
3984 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3985 sizeof(tSirMacAddr));
3986
3987 /* Parse and fetch low RSSI */
3988 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3989 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3990 goto fail;
3991 }
3992 pReqMsg->ap[i].low = nla_get_s32(
3993 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3994 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3995
3996 /* Parse and fetch high RSSI */
3997 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3998 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3999 goto fail;
4000 }
4001 pReqMsg->ap[i].high = nla_get_s32(
4002 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
4003 hddLog(VOS_TRACE_LEVEL_INFO,
4004 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
4005
4006 /* Parse and fetch channel */
4007 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
4008 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4009 goto fail;
4010 }
4011 pReqMsg->ap[i].channel = nla_get_u32(
4012 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
4013 hddLog(VOS_TRACE_LEVEL_INFO,
4014 FL("Channel (%u)"), pReqMsg->ap[i].channel);
4015 i++;
4016 }
4017
4018 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
4019 if (!HAL_STATUS_SUCCESS(status)) {
4020 hddLog(VOS_TRACE_LEVEL_ERROR,
4021 FL("sme_SetSignificantChange failed(err=%d)"), status);
4022 vos_mem_free(pReqMsg);
4023 return -EINVAL;
4024 }
Dino Myclee8843b32014-07-04 14:21:45 +05304025 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304026 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304027 return 0;
4028
4029fail:
4030 vos_mem_free(pReqMsg);
4031 return -EINVAL;
4032}
4033
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304034static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
4035 struct wireless_dev *wdev,
4036 const void *data, int dataLen)
4037{
4038 int ret = 0;
4039
4040 vos_ssr_protect(__func__);
4041 ret = __wlan_hdd_cfg80211_extscan_set_significant_change(wiphy, wdev, data,
4042 dataLen);
4043 vos_ssr_unprotect(__func__);
4044
4045 return ret;
4046}
4047
4048static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304049 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304050 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304051{
4052 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4053 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4054 tANI_U8 numChannels = 0;
4055 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304056 tANI_U32 requestId, maxChannels;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304057 tWifiBand wifiBand;
4058 eHalStatus status;
4059 struct sk_buff *replySkb;
4060 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304061 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304062
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304063 ENTER();
4064
Dino Mycle6fb96c12014-06-10 11:52:40 +05304065 status = wlan_hdd_validate_context(pHddCtx);
4066 if (0 != status)
4067 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304068 return -EINVAL;
4069 }
Dino Myclee8843b32014-07-04 14:21:45 +05304070
Dino Mycle6fb96c12014-06-10 11:52:40 +05304071 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4072 data, dataLen,
4073 wlan_hdd_extscan_config_policy)) {
4074 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4075 return -EINVAL;
4076 }
4077
4078 /* Parse and fetch request Id */
4079 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4080 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4081 return -EINVAL;
4082 }
4083 requestId = nla_get_u32(
4084 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4085 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
4086
4087 /* Parse and fetch wifi band */
4088 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
4089 {
4090 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4091 return -EINVAL;
4092 }
4093 wifiBand = nla_get_u32(
4094 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
4095 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
4096
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304097 /* Parse and fetch max channels */
4098 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS])
4099 {
4100 hddLog(LOGE, FL("attr max channels failed"));
4101 return -EINVAL;
4102 }
4103 maxChannels = nla_get_u32(
4104 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS]);
4105 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max channels %d"), maxChannels);
4106
Dino Mycle6fb96c12014-06-10 11:52:40 +05304107 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
4108 wifiBand, ChannelList,
4109 &numChannels);
4110 if (eHAL_STATUS_SUCCESS != status) {
4111 hddLog(VOS_TRACE_LEVEL_ERROR,
4112 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
4113 return -EINVAL;
4114 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304115
4116 numChannels = VOS_MIN(numChannels, maxChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304117 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304118
Dino Mycle6fb96c12014-06-10 11:52:40 +05304119 for (i = 0; i < numChannels; i++)
4120 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
4121
4122 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
4123 sizeof(u32) * numChannels +
4124 NLMSG_HDRLEN);
4125
4126 if (!replySkb) {
4127 hddLog(VOS_TRACE_LEVEL_ERROR,
4128 FL("valid channels: buffer alloc fail"));
4129 return -EINVAL;
4130 }
4131 if (nla_put_u32(replySkb,
4132 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
4133 numChannels) ||
4134 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
4135 sizeof(u32) * numChannels, ChannelList)) {
4136
4137 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4138 kfree_skb(replySkb);
4139 return -EINVAL;
4140 }
4141
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304142 ret = cfg80211_vendor_cmd_reply(replySkb);
4143
4144 EXIT();
4145 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304146}
4147
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304148static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
4149 struct wireless_dev *wdev,
4150 const void *data, int dataLen)
4151{
4152 int ret = 0;
4153
4154 vos_ssr_protect(__func__);
4155 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
4156 dataLen);
4157 vos_ssr_unprotect(__func__);
4158
4159 return ret;
4160}
4161
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304162static int hdd_extscan_start_fill_bucket_channel_spec(
4163 hdd_context_t *pHddCtx,
4164 tpSirEXTScanStartReqParams pReqMsg,
4165 struct nlattr **tb)
4166{
4167 struct nlattr *bucket[
4168 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4169 struct nlattr *channel[
4170 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4171 struct nlattr *buckets;
4172 struct nlattr *channels;
4173 int rem1, rem2;
4174 eHalStatus status;
4175 tANI_U8 bktIndex, j, numChannels;
4176 tANI_U32 chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
4177 tANI_U32 passive_max_chn_time, active_max_chn_time;
4178
4179 bktIndex = 0;
4180
4181 nla_for_each_nested(buckets,
4182 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4183 if (nla_parse(bucket,
4184 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4185 nla_data(buckets), nla_len(buckets), NULL)) {
4186 hddLog(LOGE, FL("nla_parse failed"));
4187 return -EINVAL;
4188 }
4189
4190 /* Parse and fetch bucket spec */
4191 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4192 hddLog(LOGE, FL("attr bucket index failed"));
4193 return -EINVAL;
4194 }
4195 pReqMsg->buckets[bktIndex].bucket = nla_get_u8(
4196 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4197 hddLog(LOG1, FL("Bucket spec Index %d"),
4198 pReqMsg->buckets[bktIndex].bucket);
4199
4200 /* Parse and fetch wifi band */
4201 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4202 hddLog(LOGE, FL("attr wifi band failed"));
4203 return -EINVAL;
4204 }
4205 pReqMsg->buckets[bktIndex].band = nla_get_u8(
4206 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4207 hddLog(LOG1, FL("Wifi band %d"),
4208 pReqMsg->buckets[bktIndex].band);
4209
4210 /* Parse and fetch period */
4211 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4212 hddLog(LOGE, FL("attr period failed"));
4213 return -EINVAL;
4214 }
4215 pReqMsg->buckets[bktIndex].period = nla_get_u32(
4216 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4217 hddLog(LOG1, FL("period %d"),
4218 pReqMsg->buckets[bktIndex].period);
4219
4220 /* Parse and fetch report events */
4221 if (!bucket[
4222 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4223 hddLog(LOGE, FL("attr report events failed"));
4224 return -EINVAL;
4225 }
4226 pReqMsg->buckets[bktIndex].reportEvents = nla_get_u8(
4227 bucket[
4228 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4229 hddLog(LOG1, FL("report events %d"),
4230 pReqMsg->buckets[bktIndex].reportEvents);
4231
4232 /* Parse and fetch max period */
4233 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]) {
4234 hddLog(LOGE, FL("attr max period failed"));
4235 return -EINVAL;
4236 }
4237 pReqMsg->buckets[bktIndex].max_period = nla_get_u32(
4238 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]);
4239 hddLog(LOG1, FL("max period %u"),
4240 pReqMsg->buckets[bktIndex].max_period);
4241
4242 /* Parse and fetch exponent */
4243 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]) {
4244 hddLog(LOGE, FL("attr exponent failed"));
4245 return -EINVAL;
4246 }
4247 pReqMsg->buckets[bktIndex].exponent = nla_get_u32(
4248 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]);
4249 hddLog(LOG1, FL("exponent %u"),
4250 pReqMsg->buckets[bktIndex].exponent);
4251
4252 /* Parse and fetch step count */
4253 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]) {
4254 hddLog(LOGE, FL("attr step count failed"));
4255 return -EINVAL;
4256 }
4257 pReqMsg->buckets[bktIndex].step_count = nla_get_u32(
4258 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]);
4259 hddLog(LOG1, FL("Step count %u"),
4260 pReqMsg->buckets[bktIndex].step_count);
4261
4262 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &passive_max_chn_time);
4263 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &active_max_chn_time);
4264
4265 /* Framework shall pass the channel list if the input WiFi band is
4266 * WIFI_BAND_UNSPECIFIED.
4267 * If the input WiFi band is specified (any value other than
4268 * WIFI_BAND_UNSPECIFIED) then driver populates the channel list
4269 */
4270 if (pReqMsg->buckets[bktIndex].band != WIFI_BAND_UNSPECIFIED) {
4271 numChannels = 0;
4272 hddLog(LOG1, "WiFi band is specified, driver to fill channel list");
4273 status = sme_GetValidChannelsByBand(pHddCtx->hHal,
4274 pReqMsg->buckets[bktIndex].band,
4275 chanList, &numChannels);
4276 if (!HAL_STATUS_SUCCESS(status)) {
4277 hddLog(LOGE,
4278 FL("sme_GetValidChannelsByBand failed (err=%d)"),
4279 status);
4280 return -EINVAL;
4281 }
4282
4283 pReqMsg->buckets[bktIndex].numChannels =
4284 VOS_MIN(numChannels, WLAN_EXTSCAN_MAX_CHANNELS);
4285 hddLog(LOG1, FL("Num channels %d"),
4286 pReqMsg->buckets[bktIndex].numChannels);
4287
4288 for (j = 0; j < pReqMsg->buckets[bktIndex].numChannels;
4289 j++) {
4290 pReqMsg->buckets[bktIndex].channels[j].channel =
4291 chanList[j];
4292 pReqMsg->buckets[bktIndex].channels[j].
4293 chnlClass = 0;
4294 if (CSR_IS_CHANNEL_DFS(
4295 vos_freq_to_chan(chanList[j]))) {
4296 pReqMsg->buckets[bktIndex].channels[j].
4297 passive = 1;
4298 pReqMsg->buckets[bktIndex].channels[j].
4299 dwellTimeMs = passive_max_chn_time;
4300 } else {
4301 pReqMsg->buckets[bktIndex].channels[j].
4302 passive = 0;
4303 pReqMsg->buckets[bktIndex].channels[j].
4304 dwellTimeMs = active_max_chn_time;
4305 }
4306
4307 hddLog(LOG1,
4308 "Channel %u Passive %u Dwell time %u ms",
4309 pReqMsg->buckets[bktIndex].channels[j].channel,
4310 pReqMsg->buckets[bktIndex].channels[j].passive,
4311 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4312 }
4313
4314 bktIndex++;
4315 continue;
4316 }
4317
4318 /* Parse and fetch number of channels */
4319 if (!bucket[
4320 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]) {
4321 hddLog(LOGE, FL("attr num channels failed"));
4322 return -EINVAL;
4323 }
4324
4325 pReqMsg->buckets[bktIndex].numChannels =
4326 nla_get_u32(bucket[
4327 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4328 hddLog(LOG1, FL("num channels %d"),
4329 pReqMsg->buckets[bktIndex].numChannels);
4330
4331 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4332 hddLog(LOGE, FL("attr channel spec failed"));
4333 return -EINVAL;
4334 }
4335
4336 j = 0;
4337 nla_for_each_nested(channels,
4338 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4339 if (nla_parse(channel,
4340 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4341 nla_data(channels), nla_len(channels),
4342 wlan_hdd_extscan_config_policy)) {
4343 hddLog(LOGE, FL("nla_parse failed"));
4344 return -EINVAL;
4345 }
4346
4347 /* Parse and fetch channel */
4348 if (!channel[
4349 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4350 hddLog(LOGE, FL("attr channel failed"));
4351 return -EINVAL;
4352 }
4353 pReqMsg->buckets[bktIndex].channels[j].channel =
4354 nla_get_u32(channel[
4355 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4356 hddLog(LOG1, FL("channel %u"),
4357 pReqMsg->buckets[bktIndex].channels[j].channel);
4358
4359 /* Parse and fetch dwell time */
4360 if (!channel[
4361 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4362 hddLog(LOGE, FL("attr dwelltime failed"));
4363 return -EINVAL;
4364 }
4365 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs =
4366 nla_get_u32(channel[
4367 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4368
4369 hddLog(LOG1, FL("Dwell time (%u ms)"),
4370 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
4371
4372
4373 /* Parse and fetch channel spec passive */
4374 if (!channel[
4375 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4376 hddLog(LOGE,
4377 FL("attr channel spec passive failed"));
4378 return -EINVAL;
4379 }
4380 pReqMsg->buckets[bktIndex].channels[j].passive =
4381 nla_get_u8(channel[
4382 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4383 hddLog(LOG1, FL("Chnl spec passive %u"),
4384 pReqMsg->buckets[bktIndex].channels[j].passive);
4385
4386 j++;
4387 }
4388
4389 bktIndex++;
4390 }
4391
4392 return 0;
4393}
4394
4395
4396/*
4397 * define short names for the global vendor params
4398 * used by wlan_hdd_cfg80211_extscan_start()
4399 */
4400#define PARAM_MAX \
4401QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
4402#define PARAM_REQUEST_ID \
4403QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
4404#define PARAM_BASE_PERIOD \
4405QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD
4406#define PARAM_MAX_AP_PER_SCAN \
4407QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN
4408#define PARAM_RPT_THRHLD_PERCENT \
4409QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT
4410#define PARAM_RPT_THRHLD_NUM_SCANS \
4411QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS
4412#define PARAM_NUM_BUCKETS \
4413QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
4414
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304415static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304416 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304417 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304418{
Dino Myclee8843b32014-07-04 14:21:45 +05304419 tpSirEXTScanStartReqParams pReqMsg = NULL;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304420 struct net_device *dev = wdev->netdev;
4421 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4422 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4423 struct nlattr *tb[PARAM_MAX + 1];
4424 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304425 eHalStatus status;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304426 tANI_U32 request_id;
4427 struct hdd_ext_scan_context *context;
4428 unsigned long rc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304429
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304430 ENTER();
4431
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304432 if (VOS_FTM_MODE == hdd_get_conparam()) {
4433 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4434 return -EINVAL;
4435 }
4436
Dino Mycle6fb96c12014-06-10 11:52:40 +05304437 status = wlan_hdd_validate_context(pHddCtx);
4438 if (0 != status)
4439 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304440 return -EINVAL;
4441 }
Dino Myclee8843b32014-07-04 14:21:45 +05304442 /* check the EXTScan Capability */
4443 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4444 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4445 {
4446 hddLog(VOS_TRACE_LEVEL_ERROR,
4447 FL("EXTScan not enabled/supported by Firmware"));
4448 return -EINVAL;
4449 }
4450
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304451 if (nla_parse(tb, PARAM_MAX,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304452 data, dataLen,
4453 wlan_hdd_extscan_config_policy)) {
4454 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4455 return -EINVAL;
4456 }
4457
4458 /* Parse and fetch request Id */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304459 if (!tb[PARAM_REQUEST_ID]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304460 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4461 return -EINVAL;
4462 }
4463
Dino Myclee8843b32014-07-04 14:21:45 +05304464 pReqMsg = (tpSirEXTScanStartReqParams)
4465 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304466 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304467 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4468 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304469 }
4470
4471 pReqMsg->requestId = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304472 tb[PARAM_REQUEST_ID]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304473 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4474
4475 pReqMsg->sessionId = pAdapter->sessionId;
4476 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4477
4478 /* Parse and fetch base period */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304479 if (!tb[PARAM_BASE_PERIOD]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304480 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4481 goto fail;
4482 }
4483 pReqMsg->basePeriod = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304484 tb[PARAM_BASE_PERIOD]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304485 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4486 pReqMsg->basePeriod);
4487
4488 /* Parse and fetch max AP per scan */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304489 if (!tb[PARAM_MAX_AP_PER_SCAN]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304490 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4491 goto fail;
4492 }
4493 pReqMsg->maxAPperScan = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304494 tb[PARAM_MAX_AP_PER_SCAN]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304495 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4496 pReqMsg->maxAPperScan);
4497
4498 /* Parse and fetch report threshold */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304499 if (!tb[PARAM_RPT_THRHLD_PERCENT]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304500 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4501 goto fail;
4502 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304503 pReqMsg->reportThresholdPercent = nla_get_u8(
4504 tb[PARAM_RPT_THRHLD_PERCENT]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304505 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304506 pReqMsg->reportThresholdPercent);
4507
4508 /* Parse and fetch report threshold num scans */
4509 if (!tb[PARAM_RPT_THRHLD_NUM_SCANS]) {
4510 hddLog(LOGE, FL("attr report_threshold num scans failed"));
4511 goto fail;
4512 }
4513 pReqMsg->reportThresholdNumScans = nla_get_u8(
4514 tb[PARAM_RPT_THRHLD_NUM_SCANS]);
4515 hddLog(LOG1, FL("Report Threshold num scans %d"),
4516 pReqMsg->reportThresholdNumScans);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304517
4518 /* Parse and fetch number of buckets */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304519 if (!tb[PARAM_NUM_BUCKETS]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304520 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4521 goto fail;
4522 }
4523 pReqMsg->numBuckets = nla_get_u8(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304524 tb[PARAM_NUM_BUCKETS]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304525 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4526 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4527 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4528 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4529 }
4530 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4531 pReqMsg->numBuckets);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304532
Dino Mycle6fb96c12014-06-10 11:52:40 +05304533 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4534 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4535 goto fail;
4536 }
4537
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304538 pReqMsg->homeAwayTime = pHddCtx->cfg_ini->nRestTimeConc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304539
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304540 if (hdd_extscan_start_fill_bucket_channel_spec(pHddCtx, pReqMsg, tb))
4541 goto fail;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304542
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304543 context = &pHddCtx->ext_scan_context;
4544 spin_lock(&hdd_context_lock);
4545 INIT_COMPLETION(context->response_event);
4546 context->request_id = request_id = pReqMsg->requestId;
4547 spin_unlock(&hdd_context_lock);
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304548
Dino Mycle6fb96c12014-06-10 11:52:40 +05304549 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4550 if (!HAL_STATUS_SUCCESS(status)) {
4551 hddLog(VOS_TRACE_LEVEL_ERROR,
4552 FL("sme_EXTScanStart failed(err=%d)"), status);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304553 goto fail;
4554 }
4555
4556 /* request was sent -- wait for the response */
4557 rc = wait_for_completion_timeout(&context->response_event,
4558 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4559
4560 if (!rc) {
4561 hddLog(LOGE, FL("sme_ExtScanStart timed out"));
4562 retval = -ETIMEDOUT;
4563 } else {
4564 spin_lock(&hdd_context_lock);
4565 if (context->request_id == request_id)
4566 retval = context->response_status;
4567 else
4568 retval = -EINVAL;
4569 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304570 }
4571
Dino Myclee8843b32014-07-04 14:21:45 +05304572 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304573 EXIT();
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304574 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304575
4576fail:
4577 vos_mem_free(pReqMsg);
4578 return -EINVAL;
4579}
4580
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304581/*
4582 * done with short names for the global vendor params
4583 * used by wlan_hdd_cfg80211_extscan_start()
4584 */
4585#undef PARAM_MAX
4586#undef PARAM_REQUEST_ID
4587#undef PARAM_BASE_PERIOD
4588#undef PARAMS_MAX_AP_PER_SCAN
4589#undef PARAMS_RPT_THRHLD_PERCENT
4590#undef PARAMS_RPT_THRHLD_NUM_SCANS
4591#undef PARAMS_NUM_BUCKETS
4592
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304593static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4594 struct wireless_dev *wdev,
4595 const void *data, int dataLen)
4596{
4597 int ret = 0;
4598
4599 vos_ssr_protect(__func__);
4600 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4601 vos_ssr_unprotect(__func__);
4602
4603 return ret;
4604}
4605
4606static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304607 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304608 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304609{
Dino Myclee8843b32014-07-04 14:21:45 +05304610 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304611 struct net_device *dev = wdev->netdev;
4612 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4613 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4614 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4615 eHalStatus status;
4616
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304617 ENTER();
4618
Dino Mycle6fb96c12014-06-10 11:52:40 +05304619 status = wlan_hdd_validate_context(pHddCtx);
4620 if (0 != status)
4621 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304622 return -EINVAL;
4623 }
Dino Myclee8843b32014-07-04 14:21:45 +05304624 /* check the EXTScan Capability */
4625 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4626 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4627 {
4628 hddLog(VOS_TRACE_LEVEL_ERROR,
4629 FL("EXTScan not enabled/supported by Firmware"));
4630 return -EINVAL;
4631 }
4632
Dino Mycle6fb96c12014-06-10 11:52:40 +05304633 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4634 data, dataLen,
4635 wlan_hdd_extscan_config_policy)) {
4636 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4637 return -EINVAL;
4638 }
4639
4640 /* Parse and fetch request Id */
4641 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4642 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4643 return -EINVAL;
4644 }
4645
Dino Myclee8843b32014-07-04 14:21:45 +05304646 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304647 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304648 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304649
Dino Myclee8843b32014-07-04 14:21:45 +05304650 reqMsg.sessionId = pAdapter->sessionId;
4651 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304652
Dino Myclee8843b32014-07-04 14:21:45 +05304653 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304654 if (!HAL_STATUS_SUCCESS(status)) {
4655 hddLog(VOS_TRACE_LEVEL_ERROR,
4656 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304657 return -EINVAL;
4658 }
4659
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304660 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304661 return 0;
4662}
4663
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304664static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4665 struct wireless_dev *wdev,
4666 const void *data, int dataLen)
4667{
4668 int ret = 0;
4669
4670 vos_ssr_protect(__func__);
4671 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4672 vos_ssr_unprotect(__func__);
4673
4674 return ret;
4675}
4676
4677static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304678 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304679 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304680{
Dino Myclee8843b32014-07-04 14:21:45 +05304681 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304682 struct net_device *dev = wdev->netdev;
4683 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4684 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4685 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4686 eHalStatus status;
4687
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304688 ENTER();
4689
Dino Mycle6fb96c12014-06-10 11:52:40 +05304690 status = wlan_hdd_validate_context(pHddCtx);
4691 if (0 != status)
4692 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304693 return -EINVAL;
4694 }
Dino Myclee8843b32014-07-04 14:21:45 +05304695 /* check the EXTScan Capability */
4696 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4697 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4698 {
4699 hddLog(VOS_TRACE_LEVEL_ERROR,
4700 FL("EXTScan not enabled/supported by Firmware"));
4701 return -EINVAL;
4702 }
4703
Dino Mycle6fb96c12014-06-10 11:52:40 +05304704 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4705 data, dataLen,
4706 wlan_hdd_extscan_config_policy)) {
4707 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4708 return -EINVAL;
4709 }
4710
4711 /* Parse and fetch request Id */
4712 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4713 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4714 return -EINVAL;
4715 }
4716
Dino Myclee8843b32014-07-04 14:21:45 +05304717 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304718 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304719 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304720
Dino Myclee8843b32014-07-04 14:21:45 +05304721 reqMsg.sessionId = pAdapter->sessionId;
4722 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304723
Dino Myclee8843b32014-07-04 14:21:45 +05304724 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304725 if (!HAL_STATUS_SUCCESS(status)) {
4726 hddLog(VOS_TRACE_LEVEL_ERROR,
4727 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304728 return -EINVAL;
4729 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304730 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304731 return 0;
4732}
4733
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304734static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4735 struct wireless_dev *wdev,
4736 const void *data, int dataLen)
4737{
4738 int ret = 0;
4739
4740 vos_ssr_protect(__func__);
4741 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4742 vos_ssr_unprotect(__func__);
4743
4744 return ret;
4745}
4746
4747static int __wlan_hdd_cfg80211_extscan_reset_significant_change(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304748 struct wiphy *wiphy,
4749 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304750 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304751{
Dino Myclee8843b32014-07-04 14:21:45 +05304752 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304753 struct net_device *dev = wdev->netdev;
4754 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4755 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4756 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4757 eHalStatus status;
4758
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304759 ENTER();
4760
Dino Mycle6fb96c12014-06-10 11:52:40 +05304761 status = wlan_hdd_validate_context(pHddCtx);
4762 if (0 != status)
4763 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304764 return -EINVAL;
4765 }
Dino Myclee8843b32014-07-04 14:21:45 +05304766 /* check the EXTScan Capability */
4767 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4768 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4769 {
4770 hddLog(VOS_TRACE_LEVEL_ERROR,
4771 FL("EXTScan not enabled/supported by Firmware"));
4772 return -EINVAL;
4773 }
4774
Dino Mycle6fb96c12014-06-10 11:52:40 +05304775 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4776 data, dataLen,
4777 wlan_hdd_extscan_config_policy)) {
4778 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4779 return -EINVAL;
4780 }
4781
4782 /* Parse and fetch request Id */
4783 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4784 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4785 return -EINVAL;
4786 }
4787
Dino Mycle6fb96c12014-06-10 11:52:40 +05304788
Dino Myclee8843b32014-07-04 14:21:45 +05304789 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304790 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304791 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304792
Dino Myclee8843b32014-07-04 14:21:45 +05304793 reqMsg.sessionId = pAdapter->sessionId;
4794 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304795
Dino Myclee8843b32014-07-04 14:21:45 +05304796 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304797 if (!HAL_STATUS_SUCCESS(status)) {
4798 hddLog(VOS_TRACE_LEVEL_ERROR,
4799 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304800 return -EINVAL;
4801 }
4802
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304803 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304804 return 0;
4805}
4806
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304807static int wlan_hdd_cfg80211_extscan_reset_significant_change(
4808 struct wiphy *wiphy,
4809 struct wireless_dev *wdev,
4810 const void *data, int dataLen)
4811{
4812 int ret = 0;
4813
4814 vos_ssr_protect(__func__);
4815 ret = __wlan_hdd_cfg80211_extscan_reset_significant_change(wiphy,
4816 wdev, data,
4817 dataLen);
4818 vos_ssr_unprotect(__func__);
4819
4820 return ret;
4821}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304822#endif /* WLAN_FEATURE_EXTSCAN */
4823
Atul Mittal115287b2014-07-08 13:26:33 +05304824/*EXT TDLS*/
4825static const struct nla_policy
4826wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4827{
4828 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4829 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4830 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4831 {.type = NLA_S32 },
4832 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4833 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4834
4835};
4836
4837static const struct nla_policy
4838wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4839{
4840 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4841
4842};
4843
4844static const struct nla_policy
4845wlan_hdd_tdls_config_state_change_policy[
4846 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4847{
4848 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4849 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4850 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304851 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4852 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4853 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304854
4855};
4856
4857static const struct nla_policy
4858wlan_hdd_tdls_config_get_status_policy[
4859 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4860{
4861 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4862 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4863 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304864 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4865 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4866 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304867
4868};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304869
4870static const struct nla_policy
4871wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4872{
4873 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4874};
4875
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304876static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304877 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304878 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304879 int data_len)
4880{
4881
4882 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4883 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4884
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304885 ENTER();
4886
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304887 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304888 return -EINVAL;
4889 }
4890 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05304891 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304892 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304893 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304894 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05304895 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304896 return -ENOTSUPP;
4897 }
4898
4899 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4900 data, data_len, wlan_hdd_mac_config)) {
4901 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4902 return -EINVAL;
4903 }
4904
4905 /* Parse and fetch mac address */
4906 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4907 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4908 return -EINVAL;
4909 }
4910
4911 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4912 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4913 VOS_MAC_ADDR_LAST_3_BYTES);
4914
Siddharth Bhal76972212014-10-15 16:22:51 +05304915 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4916
4917 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304918 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4919 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304920 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4921 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4922 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4923 {
4924 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4925 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4926 VOS_MAC_ADDRESS_LEN);
4927 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304928 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304929
Siddharth Bhal76972212014-10-15 16:22:51 +05304930 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
4931 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304932 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4933 }
4934
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304935 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304936 return 0;
4937}
4938
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304939static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4940 struct wireless_dev *wdev,
4941 const void *data,
4942 int data_len)
4943{
4944 int ret = 0;
4945
4946 vos_ssr_protect(__func__);
4947 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
4948 vos_ssr_unprotect(__func__);
4949
4950 return ret;
4951}
4952
4953static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304954 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304955 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304956 int data_len)
4957{
4958 u8 peer[6] = {0};
4959 struct net_device *dev = wdev->netdev;
4960 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4961 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4962 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4963 eHalStatus ret;
4964 tANI_S32 state;
4965 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304966 tANI_S32 global_operating_class = 0;
4967 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304968 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304969 int retVal;
4970
4971 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304972
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304973 if (!pAdapter) {
4974 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4975 return -EINVAL;
4976 }
4977
Atul Mittal115287b2014-07-08 13:26:33 +05304978 ret = wlan_hdd_validate_context(pHddCtx);
4979 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304980 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304981 return -EINVAL;
4982 }
4983 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304984 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304985 return -ENOTSUPP;
4986 }
4987 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4988 data, data_len,
4989 wlan_hdd_tdls_config_get_status_policy)) {
4990 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4991 return -EINVAL;
4992 }
4993
4994 /* Parse and fetch mac address */
4995 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4996 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4997 return -EINVAL;
4998 }
4999
5000 memcpy(peer, nla_data(
5001 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
5002 sizeof(peer));
5003 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5004
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05305005 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05305006
Atul Mittal115287b2014-07-08 13:26:33 +05305007 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305008 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05305009 NLMSG_HDRLEN);
5010
5011 if (!skb) {
5012 hddLog(VOS_TRACE_LEVEL_ERROR,
5013 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5014 return -EINVAL;
5015 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305016 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 +05305017 reason,
5018 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305019 global_operating_class,
5020 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05305021 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305022 if (nla_put_s32(skb,
5023 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
5024 state) ||
5025 nla_put_s32(skb,
5026 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
5027 reason) ||
5028 nla_put_s32(skb,
5029 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
5030 global_operating_class) ||
5031 nla_put_s32(skb,
5032 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
5033 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05305034
5035 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5036 goto nla_put_failure;
5037 }
5038
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305039 retVal = cfg80211_vendor_cmd_reply(skb);
5040 EXIT();
5041 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05305042
5043nla_put_failure:
5044 kfree_skb(skb);
5045 return -EINVAL;
5046}
5047
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305048static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
5049 struct wireless_dev *wdev,
5050 const void *data,
5051 int data_len)
5052{
5053 int ret = 0;
5054
5055 vos_ssr_protect(__func__);
5056 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
5057 vos_ssr_unprotect(__func__);
5058
5059 return ret;
5060}
5061
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05305062static int wlan_hdd_cfg80211_exttdls_callback(
5063#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
5064 const tANI_U8* mac,
5065#else
5066 tANI_U8* mac,
5067#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305068 tANI_S32 state,
5069 tANI_S32 reason,
5070 void *ctx)
5071{
5072 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05305073 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305074 tANI_S32 global_operating_class = 0;
5075 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305076 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05305077
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305078 ENTER();
5079
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305080 if (!pAdapter) {
5081 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5082 return -EINVAL;
5083 }
5084
5085 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05305086 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305087 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305088 return -EINVAL;
5089 }
5090
5091 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305092 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305093 return -ENOTSUPP;
5094 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05305095 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
5096#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
5097 NULL,
5098#endif
Atul Mittal115287b2014-07-08 13:26:33 +05305099 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
5100 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
5101 GFP_KERNEL);
5102
5103 if (!skb) {
5104 hddLog(VOS_TRACE_LEVEL_ERROR,
5105 FL("cfg80211_vendor_event_alloc failed"));
5106 return -EINVAL;
5107 }
5108 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305109 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
5110 reason,
5111 state,
5112 global_operating_class,
5113 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05305114 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
5115 MAC_ADDR_ARRAY(mac));
5116
Atul Mittal0a9f68d2014-10-16 15:26:38 +05305117 if (nla_put(skb,
5118 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
5119 VOS_MAC_ADDR_SIZE, mac) ||
5120 nla_put_s32(skb,
5121 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
5122 state) ||
5123 nla_put_s32(skb,
5124 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
5125 reason) ||
5126 nla_put_s32(skb,
5127 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
5128 channel) ||
5129 nla_put_s32(skb,
5130 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
5131 global_operating_class)
5132 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05305133 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
5134 goto nla_put_failure;
5135 }
5136
5137 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305138 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05305139 return (0);
5140
5141nla_put_failure:
5142 kfree_skb(skb);
5143 return -EINVAL;
5144}
5145
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305146static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305147 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305148 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305149 int data_len)
5150{
5151 u8 peer[6] = {0};
5152 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305153 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5154 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
5155 eHalStatus status;
5156 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305157 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305158 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305159
5160 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305161
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305162 if (!dev) {
5163 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5164 return -EINVAL;
5165 }
5166
5167 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5168 if (!pAdapter) {
5169 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
5170 return -EINVAL;
5171 }
5172
Atul Mittal115287b2014-07-08 13:26:33 +05305173 status = wlan_hdd_validate_context(pHddCtx);
5174 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305175 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305176 return -EINVAL;
5177 }
5178 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305179 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305180 return -ENOTSUPP;
5181 }
5182 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
5183 data, data_len,
5184 wlan_hdd_tdls_config_enable_policy)) {
5185 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5186 return -EINVAL;
5187 }
5188
5189 /* Parse and fetch mac address */
5190 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
5191 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5192 return -EINVAL;
5193 }
5194
5195 memcpy(peer, nla_data(
5196 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
5197 sizeof(peer));
5198 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5199
5200 /* Parse and fetch channel */
5201 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
5202 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
5203 return -EINVAL;
5204 }
5205 pReqMsg.channel = nla_get_s32(
5206 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
5207 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
5208
5209 /* Parse and fetch global operating class */
5210 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
5211 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
5212 return -EINVAL;
5213 }
5214 pReqMsg.global_operating_class = nla_get_s32(
5215 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
5216 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
5217 pReqMsg.global_operating_class);
5218
5219 /* Parse and fetch latency ms */
5220 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
5221 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
5222 return -EINVAL;
5223 }
5224 pReqMsg.max_latency_ms = nla_get_s32(
5225 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
5226 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
5227 pReqMsg.max_latency_ms);
5228
5229 /* Parse and fetch required bandwidth kbps */
5230 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
5231 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
5232 return -EINVAL;
5233 }
5234
5235 pReqMsg.min_bandwidth_kbps = nla_get_s32(
5236 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
5237 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
5238 pReqMsg.min_bandwidth_kbps);
5239
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305240 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05305241 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05305242 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305243 wlan_hdd_cfg80211_exttdls_callback);
5244
5245 EXIT();
5246 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305247}
5248
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305249static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
5250 struct wireless_dev *wdev,
5251 const void *data,
5252 int data_len)
5253{
5254 int ret = 0;
5255
5256 vos_ssr_protect(__func__);
5257 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
5258 vos_ssr_unprotect(__func__);
5259
5260 return ret;
5261}
5262
5263static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05305264 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305265 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05305266 int data_len)
5267{
5268 u8 peer[6] = {0};
5269 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05305270 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5271 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
5272 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305273 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305274 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305275
5276 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05305277
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05305278 if (!dev) {
5279 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
5280 return -EINVAL;
5281 }
5282
5283 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5284 if (!pAdapter) {
5285 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
5286 return -EINVAL;
5287 }
5288
Atul Mittal115287b2014-07-08 13:26:33 +05305289 status = wlan_hdd_validate_context(pHddCtx);
5290 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305291 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305292 return -EINVAL;
5293 }
5294 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305295 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305296 return -ENOTSUPP;
5297 }
5298 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
5299 data, data_len,
5300 wlan_hdd_tdls_config_disable_policy)) {
5301 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5302 return -EINVAL;
5303 }
5304 /* Parse and fetch mac address */
5305 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
5306 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5307 return -EINVAL;
5308 }
5309
5310 memcpy(peer, nla_data(
5311 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
5312 sizeof(peer));
5313 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5314
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305315 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
5316
5317 EXIT();
5318 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305319}
5320
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305321static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
5322 struct wireless_dev *wdev,
5323 const void *data,
5324 int data_len)
5325{
5326 int ret = 0;
5327
5328 vos_ssr_protect(__func__);
5329 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
5330 vos_ssr_unprotect(__func__);
5331
5332 return ret;
5333}
5334
Dasari Srinivas7875a302014-09-26 17:50:57 +05305335static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305336__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05305337 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305338 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05305339{
5340 struct net_device *dev = wdev->netdev;
5341 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5342 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5343 struct sk_buff *skb = NULL;
5344 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305345 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305346
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305347 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305348
5349 ret = wlan_hdd_validate_context(pHddCtx);
5350 if (0 != ret)
5351 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305352 return ret;
5353 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305354 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
5355 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
5356 fset |= WIFI_FEATURE_INFRA;
5357 }
5358
5359 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
5360 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
5361 fset |= WIFI_FEATURE_INFRA_5G;
5362 }
5363
5364#ifdef WLAN_FEATURE_P2P
5365 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
5366 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
5367 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
5368 fset |= WIFI_FEATURE_P2P;
5369 }
5370#endif
5371
5372 /* Soft-AP is supported currently by default */
5373 fset |= WIFI_FEATURE_SOFT_AP;
5374
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05305375 /* HOTSPOT is a supplicant feature, enable it by default */
5376 fset |= WIFI_FEATURE_HOTSPOT;
5377
Dasari Srinivas7875a302014-09-26 17:50:57 +05305378#ifdef WLAN_FEATURE_EXTSCAN
5379 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
5380 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
5381 hddLog(LOG1, FL("EXTScan is supported by firmware"));
5382 fset |= WIFI_FEATURE_EXTSCAN;
5383 }
5384#endif
5385
Dasari Srinivas7875a302014-09-26 17:50:57 +05305386 if (sme_IsFeatureSupportedByFW(NAN)) {
5387 hddLog(LOG1, FL("NAN is supported by firmware"));
5388 fset |= WIFI_FEATURE_NAN;
5389 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305390
5391 /* D2D RTT is not supported currently by default */
5392 if (sme_IsFeatureSupportedByFW(RTT)) {
5393 hddLog(LOG1, FL("RTT is supported by firmware"));
5394 fset |= WIFI_FEATURE_D2AP_RTT;
5395 }
5396
5397#ifdef FEATURE_WLAN_BATCH_SCAN
5398 if (fset & WIFI_FEATURE_EXTSCAN) {
5399 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5400 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5401 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5402 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5403 fset |= WIFI_FEATURE_BATCH_SCAN;
5404 }
5405#endif
5406
5407#ifdef FEATURE_WLAN_SCAN_PNO
5408 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5409 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5410 hddLog(LOG1, FL("PNO is supported by firmware"));
5411 fset |= WIFI_FEATURE_PNO;
5412 }
5413#endif
5414
5415 /* STA+STA is supported currently by default */
5416 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5417
5418#ifdef FEATURE_WLAN_TDLS
5419 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5420 sme_IsFeatureSupportedByFW(TDLS)) {
5421 hddLog(LOG1, FL("TDLS is supported by firmware"));
5422 fset |= WIFI_FEATURE_TDLS;
5423 }
5424
5425 /* TDLS_OFFCHANNEL is not supported currently by default */
5426#endif
5427
5428#ifdef WLAN_AP_STA_CONCURRENCY
5429 /* AP+STA concurrency is supported currently by default */
5430 fset |= WIFI_FEATURE_AP_STA;
5431#endif
5432
Mukul Sharma5add0532015-08-17 15:57:47 +05305433#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5434 fset |= WIFI_FEATURE_LINK_LAYER_STATS;
5435 hddLog(LOG1, FL("Link layer stats is supported by driver"));
5436#endif
5437
Dasari Srinivas7875a302014-09-26 17:50:57 +05305438 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5439 NLMSG_HDRLEN);
5440
5441 if (!skb) {
5442 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5443 return -EINVAL;
5444 }
5445 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5446
5447 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5448 hddLog(LOGE, FL("nla put fail"));
5449 goto nla_put_failure;
5450 }
5451
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305452 ret = cfg80211_vendor_cmd_reply(skb);
5453 EXIT();
5454 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305455
5456nla_put_failure:
5457 kfree_skb(skb);
5458 return -EINVAL;
5459}
5460
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305461static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305462wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5463 struct wireless_dev *wdev,
5464 const void *data, int data_len)
5465{
5466 int ret = 0;
5467
5468 vos_ssr_protect(__func__);
5469 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5470 vos_ssr_unprotect(__func__);
5471
5472 return ret;
5473}
5474
5475static int
5476__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305477 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305478 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305479{
5480 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5481 uint8_t i, feature_sets, max_feature_sets;
5482 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5483 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305484 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5485 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305486
5487 ENTER();
5488
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305489 ret = wlan_hdd_validate_context(pHddCtx);
5490 if (0 != ret)
5491 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305492 return ret;
5493 }
5494
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305495 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5496 data, data_len, NULL)) {
5497 hddLog(LOGE, FL("Invalid ATTR"));
5498 return -EINVAL;
5499 }
5500
5501 /* Parse and fetch max feature set */
5502 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5503 hddLog(LOGE, FL("Attr max feature set size failed"));
5504 return -EINVAL;
5505 }
5506 max_feature_sets = nla_get_u32(
5507 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5508 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5509
5510 /* Fill feature combination matrix */
5511 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305512 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5513 WIFI_FEATURE_P2P;
5514
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305515 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5516 WIFI_FEATURE_SOFT_AP;
5517
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305518 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5519 WIFI_FEATURE_SOFT_AP;
5520
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305521 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5522 WIFI_FEATURE_SOFT_AP |
5523 WIFI_FEATURE_P2P;
5524
5525 /* Add more feature combinations here */
5526
5527 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5528 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5529 hddLog(LOG1, "Feature set matrix");
5530 for (i = 0; i < feature_sets; i++)
5531 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5532
5533 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5534 sizeof(u32) * feature_sets +
5535 NLMSG_HDRLEN);
5536
5537 if (reply_skb) {
5538 if (nla_put_u32(reply_skb,
5539 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5540 feature_sets) ||
5541 nla_put(reply_skb,
5542 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5543 sizeof(u32) * feature_sets, feature_set_matrix)) {
5544 hddLog(LOGE, FL("nla put fail"));
5545 kfree_skb(reply_skb);
5546 return -EINVAL;
5547 }
5548
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305549 ret = cfg80211_vendor_cmd_reply(reply_skb);
5550 EXIT();
5551 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305552 }
5553 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5554 return -ENOMEM;
5555
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305556}
5557
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305558static int
5559wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5560 struct wireless_dev *wdev,
5561 const void *data, int data_len)
5562{
5563 int ret = 0;
5564
5565 vos_ssr_protect(__func__);
5566 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5567 data_len);
5568 vos_ssr_unprotect(__func__);
5569
5570 return ret;
5571}
5572
Agarwal Ashish738843c2014-09-25 12:27:56 +05305573static const struct nla_policy
5574wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5575 +1] =
5576{
5577 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5578};
5579
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305580static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305581 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305582 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305583 int data_len)
5584{
5585 struct net_device *dev = wdev->netdev;
5586 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5587 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5588 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5589 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5590 eHalStatus status;
5591 u32 dfsFlag = 0;
5592
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305593 ENTER();
5594
Agarwal Ashish738843c2014-09-25 12:27:56 +05305595 status = wlan_hdd_validate_context(pHddCtx);
5596 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305597 return -EINVAL;
5598 }
5599 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5600 data, data_len,
5601 wlan_hdd_set_no_dfs_flag_config_policy)) {
5602 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5603 return -EINVAL;
5604 }
5605
5606 /* Parse and fetch required bandwidth kbps */
5607 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5608 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5609 return -EINVAL;
5610 }
5611
5612 dfsFlag = nla_get_u32(
5613 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5614 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
5615 dfsFlag);
5616
5617 pHddCtx->disable_dfs_flag = dfsFlag;
5618
5619 sme_disable_dfs_channel(hHal, dfsFlag);
5620 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305621
5622 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05305623 return 0;
5624}
Atul Mittal115287b2014-07-08 13:26:33 +05305625
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305626static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
5627 struct wireless_dev *wdev,
5628 const void *data,
5629 int data_len)
5630{
5631 int ret = 0;
5632
5633 vos_ssr_protect(__func__);
5634 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
5635 vos_ssr_unprotect(__func__);
5636
5637 return ret;
5638
5639}
5640
Mukul Sharma2a271632014-10-13 14:59:01 +05305641const struct
5642nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
5643{
5644 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
5645 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
5646};
5647
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305648static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05305649 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05305650{
5651
5652 u8 bssid[6] = {0};
5653 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5654 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5655 eHalStatus status = eHAL_STATUS_SUCCESS;
5656 v_U32_t isFwrRoamEnabled = FALSE;
5657 int ret;
5658
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305659 ENTER();
5660
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305661 ret = wlan_hdd_validate_context(pHddCtx);
5662 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305663 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05305664 }
5665
5666 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
5667 data, data_len,
5668 qca_wlan_vendor_attr);
5669 if (ret){
5670 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5671 return -EINVAL;
5672 }
5673
5674 /* Parse and fetch Enable flag */
5675 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
5676 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
5677 return -EINVAL;
5678 }
5679
5680 isFwrRoamEnabled = nla_get_u32(
5681 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
5682
5683 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
5684
5685 /* Parse and fetch bssid */
5686 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
5687 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
5688 return -EINVAL;
5689 }
5690
5691 memcpy(bssid, nla_data(
5692 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
5693 sizeof(bssid));
5694 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
5695
5696 //Update roaming
5697 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305698 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05305699 return status;
5700}
5701
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305702static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
5703 struct wireless_dev *wdev, const void *data, int data_len)
5704{
5705 int ret = 0;
5706
5707 vos_ssr_protect(__func__);
5708 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
5709 vos_ssr_unprotect(__func__);
5710
5711 return ret;
5712}
5713
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305714/**
5715 * __wlan_hdd_cfg80211_setband() - set band
5716 * @wiphy: Pointer to wireless phy
5717 * @wdev: Pointer to wireless device
5718 * @data: Pointer to data
5719 * @data_len: Data length
5720 *
5721 * Return: 0 on success, negative errno on failure
5722 */
5723static int
5724__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5725 struct wireless_dev *wdev,
5726 const void *data,
5727 int data_len)
5728{
5729 struct net_device *dev = wdev->netdev;
5730 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5731 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5732 int ret;
5733 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
5734 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
5735
5736 ENTER();
5737
5738 ret = wlan_hdd_validate_context(hdd_ctx);
5739 if (0 != ret) {
5740 hddLog(LOGE, FL("HDD context is not valid"));
5741 return ret;
5742 }
5743
5744 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
5745 policy)) {
5746 hddLog(LOGE, FL("Invalid ATTR"));
5747 return -EINVAL;
5748 }
5749
5750 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
5751 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
5752 return -EINVAL;
5753 }
5754
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05305755 hdd_ctx->isSetBandByNL = TRUE;
5756 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305757 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05305758 hdd_ctx->isSetBandByNL = FALSE;
5759
5760 EXIT();
5761 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305762}
5763
5764/**
5765 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
5766 * @wiphy: wiphy structure pointer
5767 * @wdev: Wireless device structure pointer
5768 * @data: Pointer to the data received
5769 * @data_len: Length of @data
5770 *
5771 * Return: 0 on success; errno on failure
5772 */
5773static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5774 struct wireless_dev *wdev,
5775 const void *data,
5776 int data_len)
5777{
5778 int ret = 0;
5779
5780 vos_ssr_protect(__func__);
5781 ret = __wlan_hdd_cfg80211_setband(wiphy,
5782 wdev, data, data_len);
5783 vos_ssr_unprotect(__func__);
5784
5785 return ret;
5786}
5787
Sunil Duttc69bccb2014-05-26 21:30:20 +05305788const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
5789{
Mukul Sharma2a271632014-10-13 14:59:01 +05305790 {
5791 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5792 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
5793 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5794 WIPHY_VENDOR_CMD_NEED_NETDEV |
5795 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305796 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05305797 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305798
5799 {
5800 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5801 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
5802 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5803 WIPHY_VENDOR_CMD_NEED_NETDEV |
5804 WIPHY_VENDOR_CMD_NEED_RUNNING,
5805 .doit = wlan_hdd_cfg80211_nan_request
5806 },
5807
Sunil Duttc69bccb2014-05-26 21:30:20 +05305808#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5809 {
5810 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5811 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
5812 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5813 WIPHY_VENDOR_CMD_NEED_NETDEV |
5814 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305815 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05305816 },
5817
5818 {
5819 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5820 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
5821 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5822 WIPHY_VENDOR_CMD_NEED_NETDEV |
5823 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305824 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05305825 },
5826
5827 {
5828 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5829 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
5830 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5831 WIPHY_VENDOR_CMD_NEED_NETDEV |
5832 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305833 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05305834 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305835#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305836#ifdef WLAN_FEATURE_EXTSCAN
5837 {
5838 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5839 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
5840 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5841 WIPHY_VENDOR_CMD_NEED_NETDEV |
5842 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305843 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05305844 },
5845 {
5846 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5847 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
5848 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5849 WIPHY_VENDOR_CMD_NEED_NETDEV |
5850 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305851 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05305852 },
5853 {
5854 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5855 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
5856 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5857 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305858 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05305859 },
5860 {
5861 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5862 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
5863 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5864 WIPHY_VENDOR_CMD_NEED_NETDEV |
5865 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305866 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05305867 },
5868 {
5869 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5870 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
5871 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5872 WIPHY_VENDOR_CMD_NEED_NETDEV |
5873 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305874 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05305875 },
5876 {
5877 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5878 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
5879 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5880 WIPHY_VENDOR_CMD_NEED_NETDEV |
5881 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305882 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305883 },
5884 {
5885 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5886 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
5887 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5888 WIPHY_VENDOR_CMD_NEED_NETDEV |
5889 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305890 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305891 },
5892 {
5893 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5894 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
5895 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5896 WIPHY_VENDOR_CMD_NEED_NETDEV |
5897 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305898 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305899 },
5900 {
5901 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5902 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
5903 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5904 WIPHY_VENDOR_CMD_NEED_NETDEV |
5905 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305906 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305907 },
5908#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305909/*EXT TDLS*/
5910 {
5911 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5912 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
5913 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5914 WIPHY_VENDOR_CMD_NEED_NETDEV |
5915 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305916 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05305917 },
5918 {
5919 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5920 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
5921 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5922 WIPHY_VENDOR_CMD_NEED_NETDEV |
5923 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305924 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05305925 },
5926 {
5927 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5928 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
5929 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5930 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305931 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05305932 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05305933 {
5934 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5935 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
5936 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5937 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305938 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05305939 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05305940 {
5941 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5942 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
5943 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5944 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305945 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05305946 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305947 {
5948 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5949 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
5950 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5951 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305952 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305953 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305954 {
5955 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5956 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
5957 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5958 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305959 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305960 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305961 {
5962 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5963 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
5964 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5965 WIPHY_VENDOR_CMD_NEED_NETDEV |
5966 WIPHY_VENDOR_CMD_NEED_RUNNING,
5967 .doit = wlan_hdd_cfg80211_setband
5968 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05305969};
5970
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005971/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05305972static const
5973struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005974{
5975#ifdef FEATURE_WLAN_CH_AVOID
5976 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05305977 .vendor_id = QCA_NL80211_VENDOR_ID,
5978 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005979 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305980#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
5981#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5982 {
5983 /* Index = 1*/
5984 .vendor_id = QCA_NL80211_VENDOR_ID,
5985 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
5986 },
5987 {
5988 /* Index = 2*/
5989 .vendor_id = QCA_NL80211_VENDOR_ID,
5990 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
5991 },
5992 {
5993 /* Index = 3*/
5994 .vendor_id = QCA_NL80211_VENDOR_ID,
5995 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
5996 },
5997 {
5998 /* Index = 4*/
5999 .vendor_id = QCA_NL80211_VENDOR_ID,
6000 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
6001 },
6002 {
6003 /* Index = 5*/
6004 .vendor_id = QCA_NL80211_VENDOR_ID,
6005 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
6006 },
6007 {
6008 /* Index = 6*/
6009 .vendor_id = QCA_NL80211_VENDOR_ID,
6010 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
6011 },
6012#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05306013#ifdef WLAN_FEATURE_EXTSCAN
6014 {
6015 .vendor_id = QCA_NL80211_VENDOR_ID,
6016 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
6017 },
6018 {
6019 .vendor_id = QCA_NL80211_VENDOR_ID,
6020 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
6021 },
6022 {
6023 .vendor_id = QCA_NL80211_VENDOR_ID,
6024 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
6025 },
6026 {
6027 .vendor_id = QCA_NL80211_VENDOR_ID,
6028 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
6029 },
6030 {
6031 .vendor_id = QCA_NL80211_VENDOR_ID,
6032 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
6033 },
6034 {
6035 .vendor_id = QCA_NL80211_VENDOR_ID,
6036 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
6037 },
6038 {
6039 .vendor_id = QCA_NL80211_VENDOR_ID,
6040 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
6041 },
6042 {
6043 .vendor_id = QCA_NL80211_VENDOR_ID,
6044 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
6045 },
6046 {
6047 .vendor_id = QCA_NL80211_VENDOR_ID,
6048 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
6049 },
6050 {
6051 .vendor_id = QCA_NL80211_VENDOR_ID,
6052 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
6053 },
6054 {
6055 .vendor_id = QCA_NL80211_VENDOR_ID,
6056 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
6057 },
6058 {
6059 .vendor_id = QCA_NL80211_VENDOR_ID,
6060 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
6061 },
6062 {
6063 .vendor_id = QCA_NL80211_VENDOR_ID,
6064 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
6065 },
6066#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05306067/*EXT TDLS*/
6068 {
6069 .vendor_id = QCA_NL80211_VENDOR_ID,
6070 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
6071 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05306072
6073 {
6074 .vendor_id = QCA_NL80211_VENDOR_ID,
6075 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
6076 },
6077
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08006078};
6079
Jeff Johnson295189b2012-06-20 16:38:30 -07006080/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306081 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306082 * This function is called by hdd_wlan_startup()
6083 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306084 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07006085 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306086struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07006087{
6088 struct wiphy *wiphy;
6089 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306090 /*
6091 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07006092 */
6093 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
6094
6095 if (!wiphy)
6096 {
6097 /* Print error and jump into err label and free the memory */
6098 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
6099 return NULL;
6100 }
6101
Sunil Duttc69bccb2014-05-26 21:30:20 +05306102
Jeff Johnson295189b2012-06-20 16:38:30 -07006103 return wiphy;
6104}
6105
6106/*
6107 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306108 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07006109 * private ioctl to change the band value
6110 */
6111int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
6112{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306113 int i, j;
6114 eNVChannelEnabledType channelEnabledState;
6115
Jeff Johnsone7245742012-09-05 17:12:55 -07006116 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306117
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306118 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006119 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306120
6121 if (NULL == wiphy->bands[i])
6122 {
6123 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
6124 __func__, i);
6125 continue;
6126 }
6127
6128 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
6129 {
6130 struct ieee80211_supported_band *band = wiphy->bands[i];
6131
6132 channelEnabledState = vos_nv_getChannelEnabledState(
6133 band->channels[j].hw_value);
6134
6135 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
6136 {
Abhishek Singh678227a2014-11-04 10:52:38 +05306137 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306138 continue;
6139 }
6140 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
6141 {
6142 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
6143 continue;
6144 }
6145
6146 if (NV_CHANNEL_DISABLE == channelEnabledState ||
6147 NV_CHANNEL_INVALID == channelEnabledState)
6148 {
6149 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
6150 }
6151 else if (NV_CHANNEL_DFS == channelEnabledState)
6152 {
6153 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
6154 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
6155 }
6156 else
6157 {
6158 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
6159 |IEEE80211_CHAN_RADAR);
6160 }
6161 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006162 }
6163 return 0;
6164}
6165/*
6166 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306167 * This function is called by hdd_wlan_startup()
6168 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07006169 * This function is used to initialize and register wiphy structure.
6170 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306171int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07006172 struct wiphy *wiphy,
6173 hdd_config_t *pCfg
6174 )
6175{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306176 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05306177 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6178
Jeff Johnsone7245742012-09-05 17:12:55 -07006179 ENTER();
6180
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 /* Now bind the underlying wlan device with wiphy */
6182 set_wiphy_dev(wiphy, dev);
6183
6184 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07006185
Kiet Lam6c583332013-10-14 05:37:09 +05306186#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07006187 /* the flag for the other case would be initialzed in
6188 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07006189 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05306190#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07006191
Amar Singhalfddc28c2013-09-05 13:03:40 -07006192 /* This will disable updating of NL channels from passive to
6193 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306194#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
6195 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
6196#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07006197 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306198#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07006199
Amar Singhala49cbc52013-10-08 18:37:44 -07006200
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006201#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07006202 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
6203 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
6204 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07006205 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306206#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
6207 wiphy->regulatory_flags = REGULATORY_COUNTRY_IE_IGNORE;
6208#else
6209 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
6210#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006211#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07006212
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006213#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07006214 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08006215#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07006216 || pCfg->isFastRoamIniFeatureEnabled
6217#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006218#ifdef FEATURE_WLAN_ESE
6219 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07006220#endif
6221 )
6222 {
6223 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
6224 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08006225#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006226#ifdef FEATURE_WLAN_TDLS
6227 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
6228 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
6229#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05306230#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05306231 if (pCfg->configPNOScanSupport)
6232 {
6233 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
6234 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
6235 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
6236 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
6237 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05306238#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006239
Abhishek Singh10d85972015-04-17 10:27:23 +05306240#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
6241 wiphy->features |= NL80211_FEATURE_HT_IBSS;
6242#endif
6243
Amar Singhalfddc28c2013-09-05 13:03:40 -07006244#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07006245 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
6246 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07006247 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07006248 driver need to determine what to do with both
6249 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07006250
6251 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07006252#else
6253 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07006254#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006255
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306256 wiphy->max_scan_ssids = MAX_SCAN_SSID;
6257
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05306258 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07006259
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05306260 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
6261
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05306263 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
6264 | BIT(NL80211_IFTYPE_ADHOC)
6265 | BIT(NL80211_IFTYPE_P2P_CLIENT)
6266 | BIT(NL80211_IFTYPE_P2P_GO)
6267 | BIT(NL80211_IFTYPE_AP);
6268
6269 if (VOS_MONITOR_MODE == hdd_get_conparam())
6270 {
6271 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
6272 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006273
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05306274 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08006275 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05306276#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
6277 if( pCfg->enableMCC )
6278 {
6279 /* Currently, supports up to two channels */
6280 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08006281
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05306282 if( !pCfg->allowMCCGODiffBI )
6283 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08006284
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05306285 }
6286 wiphy->iface_combinations = &wlan_hdd_iface_combination;
6287 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08006288#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05306289 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08006290
Jeff Johnson295189b2012-06-20 16:38:30 -07006291 /* Before registering we need to update the ht capabilitied based
6292 * on ini values*/
6293 if( !pCfg->ShortGI20MhzEnable )
6294 {
6295 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
6296 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
6297 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
6298 }
6299
6300 if( !pCfg->ShortGI40MhzEnable )
6301 {
6302 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
6303 }
6304
6305 if( !pCfg->nChannelBondingMode5GHz )
6306 {
6307 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
6308 }
6309
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306310 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05306311 if (true == hdd_is_5g_supported(pHddCtx))
6312 {
6313 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
6314 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306315
6316 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
6317 {
6318
6319 if (NULL == wiphy->bands[i])
6320 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05306321 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306322 __func__, i);
6323 continue;
6324 }
6325
6326 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
6327 {
6328 struct ieee80211_supported_band *band = wiphy->bands[i];
6329
6330 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
6331 {
6332 // Enable social channels for P2P
6333 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
6334 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
6335 else
6336 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
6337 continue;
6338 }
6339 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
6340 {
6341 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
6342 continue;
6343 }
6344 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006345 }
6346 /*Initialise the supported cipher suite details*/
6347 wiphy->cipher_suites = hdd_cipher_suites;
6348 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
6349
6350 /*signal strength in mBm (100*dBm) */
6351 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
6352
6353#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05306354 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07006355#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006356
Sunil Duttc69bccb2014-05-26 21:30:20 +05306357 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
6358 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08006359 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
6360 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
6361
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306362 EXIT();
6363 return 0;
6364}
6365
6366/* In this function we are registering wiphy. */
6367int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
6368{
6369 ENTER();
6370 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 if (0 > wiphy_register(wiphy))
6372 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306373 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
6375 return -EIO;
6376 }
6377
6378 EXIT();
6379 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306380}
Jeff Johnson295189b2012-06-20 16:38:30 -07006381
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306382/* In this function we are updating channel list when,
6383 regulatory domain is FCC and country code is US.
6384 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
6385 As per FCC smart phone is not a indoor device.
6386 GO should not opeate on indoor channels */
6387void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
6388{
6389 int j;
6390 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6391 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
6392 //Default counrtycode from NV at the time of wiphy initialization.
6393 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
6394 &defaultCountryCode[0]))
6395 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006396 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306397 }
6398 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
6399 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306400 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
6401 {
6402 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
6403 return;
6404 }
6405 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
6406 {
6407 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
6408 // Mark UNII -1 band channel as passive
6409 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
6410 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
6411 }
6412 }
6413}
6414
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05306415/* This function registers for all frame which supplicant is interested in */
6416void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07006417{
Jeff Johnson295189b2012-06-20 16:38:30 -07006418 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6419 /* Register for all P2P action, public action etc frames */
6420 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
6421
Jeff Johnsone7245742012-09-05 17:12:55 -07006422 ENTER();
6423
Jeff Johnson295189b2012-06-20 16:38:30 -07006424 /* Right now we are registering these frame when driver is getting
6425 initialized. Once we will move to 2.6.37 kernel, in which we have
6426 frame register ops, we will move this code as a part of that */
6427 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306428 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006429 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6430
6431 /* GAS Initial Response */
6432 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6433 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306434
Jeff Johnson295189b2012-06-20 16:38:30 -07006435 /* GAS Comeback Request */
6436 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6437 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6438
6439 /* GAS Comeback Response */
6440 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6441 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6442
6443 /* P2P Public Action */
6444 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306445 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006446 P2P_PUBLIC_ACTION_FRAME_SIZE );
6447
6448 /* P2P Action */
6449 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6450 (v_U8_t*)P2P_ACTION_FRAME,
6451 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07006452
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05306453 /* WNM BSS Transition Request frame */
6454 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6455 (v_U8_t*)WNM_BSS_ACTION_FRAME,
6456 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006457
6458 /* WNM-Notification */
6459 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6460 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6461 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006462}
6463
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05306464void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07006465{
Jeff Johnson295189b2012-06-20 16:38:30 -07006466 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6467 /* Register for all P2P action, public action etc frames */
6468 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
6469
Jeff Johnsone7245742012-09-05 17:12:55 -07006470 ENTER();
6471
Jeff Johnson295189b2012-06-20 16:38:30 -07006472 /* Right now we are registering these frame when driver is getting
6473 initialized. Once we will move to 2.6.37 kernel, in which we have
6474 frame register ops, we will move this code as a part of that */
6475 /* GAS Initial Request */
6476
6477 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6478 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6479
6480 /* GAS Initial Response */
6481 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6482 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306483
Jeff Johnson295189b2012-06-20 16:38:30 -07006484 /* GAS Comeback Request */
6485 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6486 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6487
6488 /* GAS Comeback Response */
6489 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6490 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6491
6492 /* P2P Public Action */
6493 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306494 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006495 P2P_PUBLIC_ACTION_FRAME_SIZE );
6496
6497 /* P2P Action */
6498 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6499 (v_U8_t*)P2P_ACTION_FRAME,
6500 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006501 /* WNM-Notification */
6502 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6503 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6504 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006505}
6506
6507#ifdef FEATURE_WLAN_WAPI
6508void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05306509 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006510{
6511 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6512 tCsrRoamSetKey setKey;
6513 v_BOOL_t isConnected = TRUE;
6514 int status = 0;
6515 v_U32_t roamId= 0xFF;
6516 tANI_U8 *pKeyPtr = NULL;
6517 int n = 0;
6518
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306519 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
6520 __func__, hdd_device_modetoString(pAdapter->device_mode),
6521 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006522
Gopichand Nakkalae7480202013-02-11 15:24:22 +05306523 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006524 setKey.keyId = key_index; // Store Key ID
6525 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
6526 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
6527 setKey.paeRole = 0 ; // the PAE role
6528 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
6529 {
6530 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
6531 }
6532 else
6533 {
6534 isConnected = hdd_connIsConnected(pHddStaCtx);
6535 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
6536 }
6537 setKey.keyLength = key_Len;
6538 pKeyPtr = setKey.Key;
6539 memcpy( pKeyPtr, key, key_Len);
6540
Arif Hussain6d2a3322013-11-17 19:50:10 -08006541 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006542 __func__, key_Len);
6543 for (n = 0 ; n < key_Len; n++)
6544 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
6545 __func__,n,setKey.Key[n]);
6546
6547 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6548 if ( isConnected )
6549 {
6550 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
6551 pAdapter->sessionId, &setKey, &roamId );
6552 }
6553 if ( status != 0 )
6554 {
6555 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6556 "[%4d] sme_RoamSetKey returned ERROR status= %d",
6557 __LINE__, status );
6558 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6559 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05306560 /* Need to clear any trace of key value in the memory.
6561 * Thus zero out the memory even though it is local
6562 * variable.
6563 */
6564 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006565}
6566#endif /* FEATURE_WLAN_WAPI*/
6567
6568#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306569int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006570 beacon_data_t **ppBeacon,
6571 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006572#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306573int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006574 beacon_data_t **ppBeacon,
6575 struct cfg80211_beacon_data *params,
6576 int dtim_period)
6577#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306578{
Jeff Johnson295189b2012-06-20 16:38:30 -07006579 int size;
6580 beacon_data_t *beacon = NULL;
6581 beacon_data_t *old = NULL;
6582 int head_len,tail_len;
6583
Jeff Johnsone7245742012-09-05 17:12:55 -07006584 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006585 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306586 {
6587 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6588 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006589 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006591
6592 old = pAdapter->sessionCtx.ap.beacon;
6593
6594 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306595 {
6596 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6597 FL("session(%d) old and new heads points to NULL"),
6598 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306600 }
6601
6602 if (params->tail && !params->tail_len)
6603 {
6604 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6605 FL("tail_len is zero but tail is not NULL"));
6606 return -EINVAL;
6607 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006608
Jeff Johnson295189b2012-06-20 16:38:30 -07006609#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
6610 /* Kernel 3.0 is not updating dtim_period for set beacon */
6611 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306612 {
6613 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6614 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006615 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006617#endif
6618
6619 if(params->head)
6620 head_len = params->head_len;
6621 else
6622 head_len = old->head_len;
6623
6624 if(params->tail || !old)
6625 tail_len = params->tail_len;
6626 else
6627 tail_len = old->tail_len;
6628
6629 size = sizeof(beacon_data_t) + head_len + tail_len;
6630
6631 beacon = kzalloc(size, GFP_KERNEL);
6632
6633 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306634 {
6635 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6636 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006637 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006639
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006640#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006641 if(params->dtim_period || !old )
6642 beacon->dtim_period = params->dtim_period;
6643 else
6644 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006645#else
6646 if(dtim_period || !old )
6647 beacon->dtim_period = dtim_period;
6648 else
6649 beacon->dtim_period = old->dtim_period;
6650#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306651
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
6653 beacon->tail = beacon->head + head_len;
6654 beacon->head_len = head_len;
6655 beacon->tail_len = tail_len;
6656
6657 if(params->head) {
6658 memcpy (beacon->head,params->head,beacon->head_len);
6659 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306660 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07006661 if(old)
6662 memcpy (beacon->head,old->head,beacon->head_len);
6663 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306664
Jeff Johnson295189b2012-06-20 16:38:30 -07006665 if(params->tail) {
6666 memcpy (beacon->tail,params->tail,beacon->tail_len);
6667 }
6668 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306669 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07006670 memcpy (beacon->tail,old->tail,beacon->tail_len);
6671 }
6672
6673 *ppBeacon = beacon;
6674
6675 kfree(old);
6676
6677 return 0;
6678
6679}
Jeff Johnson295189b2012-06-20 16:38:30 -07006680
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05306681v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
6682#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
6683 const v_U8_t *pIes,
6684#else
6685 v_U8_t *pIes,
6686#endif
6687 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006688{
6689 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05306690 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07006691 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306692
Jeff Johnson295189b2012-06-20 16:38:30 -07006693 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306694 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006695 elem_id = ptr[0];
6696 elem_len = ptr[1];
6697 left -= 2;
6698 if(elem_len > left)
6699 {
6700 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006701 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006702 eid,elem_len,left);
6703 return NULL;
6704 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306705 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006706 {
6707 return ptr;
6708 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306709
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 left -= elem_len;
6711 ptr += (elem_len + 2);
6712 }
6713 return NULL;
6714}
6715
Jeff Johnson295189b2012-06-20 16:38:30 -07006716/* Check if rate is 11g rate or not */
6717static int wlan_hdd_rate_is_11g(u8 rate)
6718{
Sanjay Devnani28322e22013-06-21 16:13:40 -07006719 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006720 u8 i;
6721 for (i = 0; i < 8; i++)
6722 {
6723 if(rate == gRateArray[i])
6724 return TRUE;
6725 }
6726 return FALSE;
6727}
6728
6729/* Check for 11g rate and set proper 11g only mode */
6730static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
6731 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
6732{
6733 u8 i, num_rates = pIe[0];
6734
6735 pIe += 1;
6736 for ( i = 0; i < num_rates; i++)
6737 {
6738 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
6739 {
6740 /* If rate set have 11g rate than change the mode to 11G */
6741 *pSapHw_mode = eSAP_DOT11_MODE_11g;
6742 if (pIe[i] & BASIC_RATE_MASK)
6743 {
6744 /* If we have 11g rate as basic rate, it means mode
6745 is 11g only mode.
6746 */
6747 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
6748 *pCheckRatesfor11g = FALSE;
6749 }
6750 }
6751 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
6752 {
6753 *require_ht = TRUE;
6754 }
6755 }
6756 return;
6757}
6758
6759static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
6760{
6761 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6762 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6763 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6764 u8 checkRatesfor11g = TRUE;
6765 u8 require_ht = FALSE;
6766 u8 *pIe=NULL;
6767
6768 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
6769
6770 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
6771 pBeacon->head_len, WLAN_EID_SUPP_RATES);
6772 if (pIe != NULL)
6773 {
6774 pIe += 1;
6775 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6776 &pConfig->SapHw_mode);
6777 }
6778
6779 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6780 WLAN_EID_EXT_SUPP_RATES);
6781 if (pIe != NULL)
6782 {
6783
6784 pIe += 1;
6785 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6786 &pConfig->SapHw_mode);
6787 }
6788
6789 if( pConfig->channel > 14 )
6790 {
6791 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
6792 }
6793
6794 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6795 WLAN_EID_HT_CAPABILITY);
6796
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306797 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006798 {
6799 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
6800 if(require_ht)
6801 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
6802 }
6803}
6804
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306805static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
6806 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
6807{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006808 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306809 v_U8_t *pIe = NULL;
6810 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6811
6812 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
6813 pBeacon->tail, pBeacon->tail_len);
6814
6815 if (pIe)
6816 {
6817 ielen = pIe[1] + 2;
6818 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6819 {
6820 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
6821 }
6822 else
6823 {
6824 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
6825 return -EINVAL;
6826 }
6827 *total_ielen += ielen;
6828 }
6829 return 0;
6830}
6831
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006832static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
6833 v_U8_t *genie, v_U8_t *total_ielen)
6834{
6835 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6836 int left = pBeacon->tail_len;
6837 v_U8_t *ptr = pBeacon->tail;
6838 v_U8_t elem_id, elem_len;
6839 v_U16_t ielen = 0;
6840
6841 if ( NULL == ptr || 0 == left )
6842 return;
6843
6844 while (left >= 2)
6845 {
6846 elem_id = ptr[0];
6847 elem_len = ptr[1];
6848 left -= 2;
6849 if (elem_len > left)
6850 {
6851 hddLog( VOS_TRACE_LEVEL_ERROR,
6852 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
6853 elem_id, elem_len, left);
6854 return;
6855 }
6856 if (IE_EID_VENDOR == elem_id)
6857 {
6858 /* skipping the VSIE's which we don't want to include or
6859 * it will be included by existing code
6860 */
6861 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
6862#ifdef WLAN_FEATURE_WFD
6863 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
6864#endif
6865 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6866 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6867 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
6868 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6869 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
6870 {
6871 ielen = ptr[1] + 2;
6872 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6873 {
6874 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
6875 *total_ielen += ielen;
6876 }
6877 else
6878 {
6879 hddLog( VOS_TRACE_LEVEL_ERROR,
6880 "IE Length is too big "
6881 "IEs eid=%d elem_len=%d total_ie_lent=%d",
6882 elem_id, elem_len, *total_ielen);
6883 }
6884 }
6885 }
6886
6887 left -= elem_len;
6888 ptr += (elem_len + 2);
6889 }
6890 return;
6891}
6892
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006893#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006894static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6895 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006896#else
6897static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6898 struct cfg80211_beacon_data *params)
6899#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006900{
6901 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306902 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07006904 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006905
6906 genie = vos_mem_malloc(MAX_GENIE_LEN);
6907
6908 if(genie == NULL) {
6909
6910 return -ENOMEM;
6911 }
6912
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306913 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6914 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006915 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306916 hddLog(LOGE,
6917 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306918 ret = -EINVAL;
6919 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006920 }
6921
6922#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306923 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6924 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
6925 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306926 hddLog(LOGE,
6927 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306928 ret = -EINVAL;
6929 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006930 }
6931#endif
6932
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306933 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6934 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306936 hddLog(LOGE,
6937 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306938 ret = -EINVAL;
6939 goto done;
6940 }
6941
6942 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
6943 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006944 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006945 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006946
6947 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6948 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
6949 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6950 {
6951 hddLog(LOGE,
6952 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006953 ret = -EINVAL;
6954 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006955 }
6956
6957 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6958 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6959 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6960 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6961 ==eHAL_STATUS_FAILURE)
6962 {
6963 hddLog(LOGE,
6964 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006965 ret = -EINVAL;
6966 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006967 }
6968
6969 // Added for ProResp IE
6970 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
6971 {
6972 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
6973 u8 probe_rsp_ie_len[3] = {0};
6974 u8 counter = 0;
6975 /* Check Probe Resp Length if it is greater then 255 then Store
6976 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
6977 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
6978 Store More then 255 bytes into One Variable.
6979 */
6980 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6981 {
6982 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6983 {
6984 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6985 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6986 }
6987 else
6988 {
6989 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6990 rem_probe_resp_ie_len = 0;
6991 }
6992 }
6993
6994 rem_probe_resp_ie_len = 0;
6995
6996 if (probe_rsp_ie_len[0] > 0)
6997 {
6998 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6999 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
7000 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
7001 probe_rsp_ie_len[0], NULL,
7002 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
7003 {
7004 hddLog(LOGE,
7005 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07007006 ret = -EINVAL;
7007 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07007008 }
7009 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
7010 }
7011
7012 if (probe_rsp_ie_len[1] > 0)
7013 {
7014 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
7015 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
7016 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
7017 probe_rsp_ie_len[1], NULL,
7018 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
7019 {
7020 hddLog(LOGE,
7021 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07007022 ret = -EINVAL;
7023 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07007024 }
7025 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
7026 }
7027
7028 if (probe_rsp_ie_len[2] > 0)
7029 {
7030 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
7031 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
7032 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
7033 probe_rsp_ie_len[2], NULL,
7034 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
7035 {
7036 hddLog(LOGE,
7037 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07007038 ret = -EINVAL;
7039 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07007040 }
7041 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
7042 }
7043
7044 if (probe_rsp_ie_len[1] == 0 )
7045 {
7046 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
7047 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
7048 eANI_BOOLEAN_FALSE) )
7049 {
7050 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007051 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007052 }
7053 }
7054
7055 if (probe_rsp_ie_len[2] == 0 )
7056 {
7057 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
7058 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
7059 eANI_BOOLEAN_FALSE) )
7060 {
7061 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007062 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007063 }
7064 }
7065
7066 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
7067 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
7068 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
7069 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
7070 == eHAL_STATUS_FAILURE)
7071 {
7072 hddLog(LOGE,
7073 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07007074 ret = -EINVAL;
7075 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07007076 }
7077 }
7078 else
7079 {
7080 // Reset WNI_CFG_PROBE_RSP Flags
7081 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
7082
7083 hddLog(VOS_TRACE_LEVEL_INFO,
7084 "%s: No Probe Response IE received in set beacon",
7085 __func__);
7086 }
7087
7088 // Added for AssocResp IE
7089 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
7090 {
7091 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
7092 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
7093 params->assocresp_ies_len, NULL,
7094 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
7095 {
7096 hddLog(LOGE,
7097 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07007098 ret = -EINVAL;
7099 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07007100 }
7101
7102 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
7103 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
7104 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
7105 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
7106 == eHAL_STATUS_FAILURE)
7107 {
7108 hddLog(LOGE,
7109 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07007110 ret = -EINVAL;
7111 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07007112 }
7113 }
7114 else
7115 {
7116 hddLog(VOS_TRACE_LEVEL_INFO,
7117 "%s: No Assoc Response IE received in set beacon",
7118 __func__);
7119
7120 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
7121 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7122 eANI_BOOLEAN_FALSE) )
7123 {
7124 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007125 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007126 }
7127 }
7128
Jeff Johnsone7245742012-09-05 17:12:55 -07007129done:
Jeff Johnson295189b2012-06-20 16:38:30 -07007130 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05307131 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007132}
Jeff Johnson295189b2012-06-20 16:38:30 -07007133
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307134/*
Jeff Johnson295189b2012-06-20 16:38:30 -07007135 * FUNCTION: wlan_hdd_validate_operation_channel
7136 * called by wlan_hdd_cfg80211_start_bss() and
7137 * wlan_hdd_cfg80211_set_channel()
7138 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307139 * channel list.
7140 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07007141VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07007142{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307143
Jeff Johnson295189b2012-06-20 16:38:30 -07007144 v_U32_t num_ch = 0;
7145 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7146 u32 indx = 0;
7147 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05307148 v_U8_t fValidChannel = FALSE, count = 0;
7149 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307150
Jeff Johnson295189b2012-06-20 16:38:30 -07007151 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7152
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05307153 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07007154 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05307155 /* Validate the channel */
7156 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007157 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05307158 if ( channel == rfChannels[count].channelNum )
7159 {
7160 fValidChannel = TRUE;
7161 break;
7162 }
7163 }
7164 if (fValidChannel != TRUE)
7165 {
7166 hddLog(VOS_TRACE_LEVEL_ERROR,
7167 "%s: Invalid Channel [%d]", __func__, channel);
7168 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007169 }
7170 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05307171 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007172 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05307173 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
7174 valid_ch, &num_ch))
7175 {
7176 hddLog(VOS_TRACE_LEVEL_ERROR,
7177 "%s: failed to get valid channel list", __func__);
7178 return VOS_STATUS_E_FAILURE;
7179 }
7180 for (indx = 0; indx < num_ch; indx++)
7181 {
7182 if (channel == valid_ch[indx])
7183 {
7184 break;
7185 }
7186 }
7187
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05307188 if (indx >= num_ch)
7189 {
7190 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
7191 {
7192 eCsrBand band;
7193 unsigned int freq;
7194
7195 sme_GetFreqBand(hHal, &band);
7196
7197 if (eCSR_BAND_5G == band)
7198 {
7199#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
7200 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
7201 {
7202 freq = ieee80211_channel_to_frequency(channel,
7203 IEEE80211_BAND_2GHZ);
7204 }
7205 else
7206 {
7207 freq = ieee80211_channel_to_frequency(channel,
7208 IEEE80211_BAND_5GHZ);
7209 }
7210#else
7211 freq = ieee80211_channel_to_frequency(channel);
7212#endif
7213 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
7214 return VOS_STATUS_SUCCESS;
7215 }
7216 }
7217
7218 hddLog(VOS_TRACE_LEVEL_ERROR,
7219 "%s: Invalid Channel [%d]", __func__, channel);
7220 return VOS_STATUS_E_FAILURE;
7221 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007222 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05307223
Jeff Johnson295189b2012-06-20 16:38:30 -07007224 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307225
Jeff Johnson295189b2012-06-20 16:38:30 -07007226}
7227
Viral Modi3a32cc52013-02-08 11:14:52 -08007228/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05307229 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08007230 * This function is used to set the channel number
7231 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05307232static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08007233 struct ieee80211_channel *chan,
7234 enum nl80211_channel_type channel_type
7235 )
7236{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307237 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08007238 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07007239 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08007240 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307241 hdd_context_t *pHddCtx;
7242 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08007243
7244 ENTER();
7245
7246 if( NULL == dev )
7247 {
7248 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007249 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08007250 return -ENODEV;
7251 }
7252 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307253
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307254 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7255 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
7256 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08007257 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307258 "%s: device_mode = %s (%d) freq = %d", __func__,
7259 hdd_device_modetoString(pAdapter->device_mode),
7260 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307261
7262 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7263 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307264 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08007265 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307266 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08007267 }
7268
7269 /*
7270 * Do freq to chan conversion
7271 * TODO: for 11a
7272 */
7273
7274 channel = ieee80211_frequency_to_channel(freq);
7275
7276 /* Check freq range */
7277 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
7278 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
7279 {
7280 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007281 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08007282 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
7283 WNI_CFG_CURRENT_CHANNEL_STAMAX);
7284 return -EINVAL;
7285 }
7286
7287 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7288
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05307289 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
7290 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08007291 {
7292 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
7293 {
7294 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007295 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08007296 return -EINVAL;
7297 }
7298 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7299 "%s: set channel to [%d] for device mode =%d",
7300 __func__, channel,pAdapter->device_mode);
7301 }
7302 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08007303 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08007304 )
7305 {
7306 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7307 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
7308 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7309
7310 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
7311 {
7312 /* Link is up then return cant set channel*/
7313 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007314 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08007315 return -EINVAL;
7316 }
7317
7318 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
7319 pHddStaCtx->conn_info.operationChannel = channel;
7320 pRoamProfile->ChannelInfo.ChannelList =
7321 &pHddStaCtx->conn_info.operationChannel;
7322 }
7323 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08007324 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08007325 )
7326 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307327 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
7328 {
7329 if(VOS_STATUS_SUCCESS !=
7330 wlan_hdd_validate_operation_channel(pAdapter,channel))
7331 {
7332 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007333 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307334 return -EINVAL;
7335 }
7336 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
7337 }
7338 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08007339 {
7340 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
7341
7342 /* If auto channel selection is configured as enable/ 1 then ignore
7343 channel set by supplicant
7344 */
7345 if ( cfg_param->apAutoChannelSelection )
7346 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307347 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
7348 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08007349 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307350 "%s: set channel to auto channel (0) for device mode =%s (%d)",
7351 __func__, hdd_device_modetoString(pAdapter->device_mode),
7352 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08007353 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307354 else
7355 {
7356 if(VOS_STATUS_SUCCESS !=
7357 wlan_hdd_validate_operation_channel(pAdapter,channel))
7358 {
7359 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007360 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307361 return -EINVAL;
7362 }
7363 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
7364 }
Viral Modi3a32cc52013-02-08 11:14:52 -08007365 }
7366 }
7367 else
7368 {
7369 hddLog(VOS_TRACE_LEVEL_FATAL,
7370 "%s: Invalid device mode failed to set valid channel", __func__);
7371 return -EINVAL;
7372 }
7373 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307374 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08007375}
7376
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05307377static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
7378 struct net_device *dev,
7379 struct ieee80211_channel *chan,
7380 enum nl80211_channel_type channel_type
7381 )
7382{
7383 int ret;
7384
7385 vos_ssr_protect(__func__);
7386 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
7387 vos_ssr_unprotect(__func__);
7388
7389 return ret;
7390}
7391
Jeff Johnson295189b2012-06-20 16:38:30 -07007392#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7393static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
7394 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007395#else
7396static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
7397 struct cfg80211_beacon_data *params,
7398 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307399 enum nl80211_hidden_ssid hidden_ssid,
7400 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007401#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007402{
7403 tsap_Config_t *pConfig;
7404 beacon_data_t *pBeacon = NULL;
7405 struct ieee80211_mgmt *pMgmt_frame;
7406 v_U8_t *pIe=NULL;
7407 v_U16_t capab_info;
7408 eCsrAuthType RSNAuthType;
7409 eCsrEncryptionType RSNEncryptType;
7410 eCsrEncryptionType mcRSNEncryptType;
7411 int status = VOS_STATUS_SUCCESS;
7412 tpWLAN_SAPEventCB pSapEventCallback;
7413 hdd_hostapd_state_t *pHostapdState;
7414 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
7415 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307416 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007417 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307418 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07007419 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08007420 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05307421 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07007422 v_BOOL_t MFPCapable = VOS_FALSE;
7423 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307424 v_BOOL_t sapEnable11AC =
7425 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07007426 ENTER();
7427
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307428 iniConfig = pHddCtx->cfg_ini;
7429
Jeff Johnson295189b2012-06-20 16:38:30 -07007430 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
7431
7432 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
7433
7434 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
7435
7436 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
7437
7438 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
7439
7440 //channel is already set in the set_channel Call back
7441 //pConfig->channel = pCommitConfig->channel;
7442
7443 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307444 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07007445 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
7446
7447 pConfig->dtim_period = pBeacon->dtim_period;
7448
Arif Hussain6d2a3322013-11-17 19:50:10 -08007449 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07007450 pConfig->dtim_period);
7451
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08007452 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07007453 {
7454 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007455 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05307456 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
7457 {
7458 tANI_BOOLEAN restartNeeded;
7459 pConfig->ieee80211d = 1;
7460 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
7461 sme_setRegInfo(hHal, pConfig->countryCode);
7462 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
7463 }
7464 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07007465 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07007466 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007467 pConfig->ieee80211d = 1;
7468 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
7469 sme_setRegInfo(hHal, pConfig->countryCode);
7470 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07007471 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007472 else
7473 {
7474 pConfig->ieee80211d = 0;
7475 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307476 /*
7477 * If auto channel is configured i.e. channel is 0,
7478 * so skip channel validation.
7479 */
7480 if( AUTO_CHANNEL_SELECT != pConfig->channel )
7481 {
7482 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
7483 {
7484 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007485 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307486 return -EINVAL;
7487 }
7488 }
7489 else
7490 {
7491 if(1 != pHddCtx->is_dynamic_channel_range_set)
7492 {
7493 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
7494 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
7495 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
7496 }
7497 pHddCtx->is_dynamic_channel_range_set = 0;
7498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007499 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007500 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 {
7502 pConfig->ieee80211d = 0;
7503 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307504
7505#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7506 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7507 pConfig->authType = eSAP_OPEN_SYSTEM;
7508 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7509 pConfig->authType = eSAP_SHARED_KEY;
7510 else
7511 pConfig->authType = eSAP_AUTO_SWITCH;
7512#else
7513 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7514 pConfig->authType = eSAP_OPEN_SYSTEM;
7515 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7516 pConfig->authType = eSAP_SHARED_KEY;
7517 else
7518 pConfig->authType = eSAP_AUTO_SWITCH;
7519#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007520
7521 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307522
7523 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07007524 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
7525
7526 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
7527
7528 /*Set wps station to configured*/
7529 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
7530
7531 if(pIe)
7532 {
7533 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
7534 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007535 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07007536 return -EINVAL;
7537 }
7538 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
7539 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007540 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07007541 /* Check 15 bit of WPS IE as it contain information for wps state
7542 * WPS state
7543 */
7544 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
7545 {
7546 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
7547 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
7548 {
7549 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
7550 }
7551 }
7552 }
7553 else
7554 {
7555 pConfig->wps_state = SAP_WPS_DISABLED;
7556 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307557 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07007558
c_hpothufe599e92014-06-16 11:38:55 +05307559 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7560 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7561 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
7562 eCSR_ENCRYPT_TYPE_NONE;
7563
Jeff Johnson295189b2012-06-20 16:38:30 -07007564 pConfig->RSNWPAReqIELength = 0;
7565 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307566 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007567 WLAN_EID_RSN);
7568 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307569 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007570 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7571 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7572 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307573 /* The actual processing may eventually be more extensive than
7574 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07007575 * by the app.
7576 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307577 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007578 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7579 &RSNEncryptType,
7580 &mcRSNEncryptType,
7581 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007582 &MFPCapable,
7583 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007584 pConfig->pRSNWPAReqIE[1]+2,
7585 pConfig->pRSNWPAReqIE );
7586
7587 if( VOS_STATUS_SUCCESS == status )
7588 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307589 /* Now copy over all the security attributes you have
7590 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007591 * */
7592 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7593 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7594 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7595 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307596 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007597 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007598 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7599 }
7600 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307601
Jeff Johnson295189b2012-06-20 16:38:30 -07007602 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7603 pBeacon->tail, pBeacon->tail_len);
7604
7605 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
7606 {
7607 if (pConfig->pRSNWPAReqIE)
7608 {
7609 /*Mixed mode WPA/WPA2*/
7610 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
7611 pConfig->RSNWPAReqIELength += pIe[1] + 2;
7612 }
7613 else
7614 {
7615 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7616 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7617 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307618 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007619 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7620 &RSNEncryptType,
7621 &mcRSNEncryptType,
7622 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007623 &MFPCapable,
7624 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007625 pConfig->pRSNWPAReqIE[1]+2,
7626 pConfig->pRSNWPAReqIE );
7627
7628 if( VOS_STATUS_SUCCESS == status )
7629 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307630 /* Now copy over all the security attributes you have
7631 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007632 * */
7633 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7634 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7635 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7636 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307637 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007638 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007639 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7640 }
7641 }
7642 }
7643
Jeff Johnson4416a782013-03-25 14:17:50 -07007644 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
7645 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
7646 return -EINVAL;
7647 }
7648
Jeff Johnson295189b2012-06-20 16:38:30 -07007649 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
7650
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007651#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007652 if (params->ssid != NULL)
7653 {
7654 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
7655 pConfig->SSIDinfo.ssid.length = params->ssid_len;
7656 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7657 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7658 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007659#else
7660 if (ssid != NULL)
7661 {
7662 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
7663 pConfig->SSIDinfo.ssid.length = ssid_len;
7664 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7665 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7666 }
7667#endif
7668
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307669 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07007670 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307671
Jeff Johnson295189b2012-06-20 16:38:30 -07007672 /* default value */
7673 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
7674 pConfig->num_accept_mac = 0;
7675 pConfig->num_deny_mac = 0;
7676
7677 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7678 pBeacon->tail, pBeacon->tail_len);
7679
7680 /* pIe for black list is following form:
7681 type : 1 byte
7682 length : 1 byte
7683 OUI : 4 bytes
7684 acl type : 1 byte
7685 no of mac addr in black list: 1 byte
7686 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307687 */
7688 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007689 {
7690 pConfig->SapMacaddr_acl = pIe[6];
7691 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007692 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007693 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307694 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
7695 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007696 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7697 for (i = 0; i < pConfig->num_deny_mac; i++)
7698 {
7699 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7700 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007702 }
7703 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7704 pBeacon->tail, pBeacon->tail_len);
7705
7706 /* pIe for white list is following form:
7707 type : 1 byte
7708 length : 1 byte
7709 OUI : 4 bytes
7710 acl type : 1 byte
7711 no of mac addr in white list: 1 byte
7712 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307713 */
7714 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007715 {
7716 pConfig->SapMacaddr_acl = pIe[6];
7717 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007718 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007719 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307720 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
7721 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007722 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7723 for (i = 0; i < pConfig->num_accept_mac; i++)
7724 {
7725 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7726 acl_entry++;
7727 }
7728 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307729
Jeff Johnson295189b2012-06-20 16:38:30 -07007730 wlan_hdd_set_sapHwmode(pHostapdAdapter);
7731
Jeff Johnsone7245742012-09-05 17:12:55 -07007732#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007733 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307734 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
7735 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05307736 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
7737 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007738 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
7739 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307740 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
7741 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07007742 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307743 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007744 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307745 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007746
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307747 /* If ACS disable and selected channel <= 14
7748 * OR
7749 * ACS enabled and ACS operating band is choosen as 2.4
7750 * AND
7751 * VHT in 2.4G Disabled
7752 * THEN
7753 * Fallback to 11N mode
7754 */
7755 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
7756 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05307757 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307758 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007759 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307760 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
7761 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007762 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
7763 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007764 }
7765#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307766
Jeff Johnson295189b2012-06-20 16:38:30 -07007767 // ht_capab is not what the name conveys,this is used for protection bitmap
7768 pConfig->ht_capab =
7769 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
7770
7771 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
7772 {
7773 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
7774 return -EINVAL;
7775 }
7776
7777 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307778 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07007779 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
7780 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307781 pConfig->obssProtEnabled =
7782 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07007783
Chet Lanctot8cecea22014-02-11 19:09:36 -08007784#ifdef WLAN_FEATURE_11W
7785 pConfig->mfpCapable = MFPCapable;
7786 pConfig->mfpRequired = MFPRequired;
7787 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
7788 pConfig->mfpCapable, pConfig->mfpRequired);
7789#endif
7790
Arif Hussain6d2a3322013-11-17 19:50:10 -08007791 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07007792 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007793 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
7794 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
7795 (int)pConfig->channel);
7796 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
7797 pConfig->SapHw_mode, pConfig->privacy,
7798 pConfig->authType);
7799 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
7800 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
7801 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
7802 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07007803
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307804 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007805 {
7806 //Bss already started. just return.
7807 //TODO Probably it should update some beacon params.
7808 hddLog( LOGE, "Bss Already started...Ignore the request");
7809 EXIT();
7810 return 0;
7811 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307812
Agarwal Ashish51325b52014-06-16 16:50:49 +05307813 if (vos_max_concurrent_connections_reached()) {
7814 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7815 return -EINVAL;
7816 }
7817
Jeff Johnson295189b2012-06-20 16:38:30 -07007818 pConfig->persona = pHostapdAdapter->device_mode;
7819
Peng Xu2446a892014-09-05 17:21:18 +05307820 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
7821 if ( NULL != psmeConfig)
7822 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307823 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05307824 sme_GetConfigParam(hHal, psmeConfig);
7825 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307826#ifdef WLAN_FEATURE_AP_HT40_24G
7827 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
7828 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
7829 && pHddCtx->cfg_ini->apHT40_24GEnabled)
7830 {
7831 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
7832 sme_UpdateConfig (hHal, psmeConfig);
7833 }
7834#endif
Peng Xu2446a892014-09-05 17:21:18 +05307835 vos_mem_free(psmeConfig);
7836 }
Peng Xuafc34e32014-09-25 13:23:55 +05307837 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05307838
Jeff Johnson295189b2012-06-20 16:38:30 -07007839 pSapEventCallback = hdd_hostapd_SAPEventCB;
7840 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
7841 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
7842 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007843 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007844 return -EINVAL;
7845 }
7846
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307847 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07007848 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
7849
7850 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307851
Jeff Johnson295189b2012-06-20 16:38:30 -07007852 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307853 {
7854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007855 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07007856 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007857 VOS_ASSERT(0);
7858 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307859
Jeff Johnson295189b2012-06-20 16:38:30 -07007860 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05307861 /* Initialize WMM configuation */
7862 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307863 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007864
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007865#ifdef WLAN_FEATURE_P2P_DEBUG
7866 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
7867 {
7868 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
7869 {
7870 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7871 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007872 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007873 }
7874 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
7875 {
7876 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7877 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007878 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007879 }
7880 }
7881#endif
7882
Jeff Johnson295189b2012-06-20 16:38:30 -07007883 pHostapdState->bCommit = TRUE;
7884 EXIT();
7885
7886 return 0;
7887}
7888
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007889#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307890static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307891 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007892 struct beacon_parameters *params)
7893{
7894 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307895 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307896 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007897
7898 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307899
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307900 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7901 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
7902 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307903 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
7904 hdd_device_modetoString(pAdapter->device_mode),
7905 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007906
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307907 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7908 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307909 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007910 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307911 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007912 }
7913
Agarwal Ashish51325b52014-06-16 16:50:49 +05307914 if (vos_max_concurrent_connections_reached()) {
7915 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7916 return -EINVAL;
7917 }
7918
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307919 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007920 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007921 )
7922 {
7923 beacon_data_t *old,*new;
7924
7925 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307926
Jeff Johnson295189b2012-06-20 16:38:30 -07007927 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307928 {
7929 hddLog(VOS_TRACE_LEVEL_WARN,
7930 FL("already beacon info added to session(%d)"),
7931 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007932 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007934
7935 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7936
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307937 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07007938 {
7939 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007940 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007941 return -EINVAL;
7942 }
7943
7944 pAdapter->sessionCtx.ap.beacon = new;
7945
7946 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7947 }
7948
7949 EXIT();
7950 return status;
7951}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307952
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307953static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
7954 struct net_device *dev,
7955 struct beacon_parameters *params)
7956{
7957 int ret;
7958
7959 vos_ssr_protect(__func__);
7960 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
7961 vos_ssr_unprotect(__func__);
7962
7963 return ret;
7964}
7965
7966static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007967 struct net_device *dev,
7968 struct beacon_parameters *params)
7969{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307970 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307971 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7972 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307973 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007974
7975 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307976
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307977 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7978 TRACE_CODE_HDD_CFG80211_SET_BEACON,
7979 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
7980 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7981 __func__, hdd_device_modetoString(pAdapter->device_mode),
7982 pAdapter->device_mode);
7983
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307984 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7985 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307986 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007987 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307988 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007989 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307990
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307991 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007992 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307993 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007994 {
7995 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307996
Jeff Johnson295189b2012-06-20 16:38:30 -07007997 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307998
Jeff Johnson295189b2012-06-20 16:38:30 -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) old and new heads points to NULL"),
8003 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008004 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308005 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008006
8007 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
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 Johnson295189b2012-06-20 16:38:30 -07008012 return -EINVAL;
8013 }
8014
8015 pAdapter->sessionCtx.ap.beacon = new;
8016
8017 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
8018 }
8019
8020 EXIT();
8021 return status;
8022}
8023
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308024static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
8025 struct net_device *dev,
8026 struct beacon_parameters *params)
8027{
8028 int ret;
8029
8030 vos_ssr_protect(__func__);
8031 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
8032 vos_ssr_unprotect(__func__);
8033
8034 return ret;
8035}
8036
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008037#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
8038
8039#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308040static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008042#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308043static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008044 struct net_device *dev)
8045#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008046{
8047 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07008048 hdd_context_t *pHddCtx = NULL;
8049 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308050 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05308051 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008052
8053 ENTER();
8054
8055 if (NULL == pAdapter)
8056 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308057 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07008058 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008059 return -ENODEV;
8060 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008061
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308062 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8063 TRACE_CODE_HDD_CFG80211_STOP_AP,
8064 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308065 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8066 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308067 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008068 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308069 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07008070 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008071
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008072 pScanInfo = &pHddCtx->scan_info;
8073
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308074 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8075 __func__, hdd_device_modetoString(pAdapter->device_mode),
8076 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008077
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05308078 ret = wlan_hdd_scan_abort(pAdapter);
8079
Girish Gowli4bf7a632014-06-12 13:42:11 +05308080 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07008081 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05308082 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8083 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308084
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05308085 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07008086 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05308087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8088 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08008089
Jeff Johnsone7245742012-09-05 17:12:55 -07008090 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05308091 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07008092 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05308093 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07008094 }
8095
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05308096 /* Delete all associated STAs before stopping AP/P2P GO */
8097 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05308098 hdd_hostapd_stop(dev);
8099
Jeff Johnson295189b2012-06-20 16:38:30 -07008100 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008101 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07008102 )
8103 {
8104 beacon_data_t *old;
8105
8106 old = pAdapter->sessionCtx.ap.beacon;
8107
8108 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308109 {
8110 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8111 FL("session(%d) beacon data points to NULL"),
8112 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008113 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008115
Jeff Johnson295189b2012-06-20 16:38:30 -07008116 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008117
8118 mutex_lock(&pHddCtx->sap_lock);
8119 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
8120 {
Jeff Johnson4416a782013-03-25 14:17:50 -07008121 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008122 {
8123 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8124
8125 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
8126
8127 if (!VOS_IS_STATUS_SUCCESS(status))
8128 {
8129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008130 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008131 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308132 }
8133 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008134 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05308135 /* BSS stopped, clear the active sessions for this device mode */
8136 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008137 }
8138 mutex_unlock(&pHddCtx->sap_lock);
8139
8140 if(status != VOS_STATUS_SUCCESS)
8141 {
8142 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008143 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008144 return -EINVAL;
8145 }
8146
Jeff Johnson4416a782013-03-25 14:17:50 -07008147 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07008148 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
8149 ==eHAL_STATUS_FAILURE)
8150 {
8151 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008152 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008153 }
8154
Jeff Johnson4416a782013-03-25 14:17:50 -07008155 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07008156 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
8157 eANI_BOOLEAN_FALSE) )
8158 {
8159 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008160 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07008161 }
8162
8163 // Reset WNI_CFG_PROBE_RSP Flags
8164 wlan_hdd_reset_prob_rspies(pAdapter);
8165
8166 pAdapter->sessionCtx.ap.beacon = NULL;
8167 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07008168#ifdef WLAN_FEATURE_P2P_DEBUG
8169 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
8170 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
8171 {
8172 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
8173 "GO got removed");
8174 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
8175 }
8176#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008177 }
8178 EXIT();
8179 return status;
8180}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008181
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308182#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
8183static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
8184 struct net_device *dev)
8185{
8186 int ret;
8187
8188 vos_ssr_protect(__func__);
8189 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
8190 vos_ssr_unprotect(__func__);
8191
8192 return ret;
8193}
8194#else
8195static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
8196 struct net_device *dev)
8197{
8198 int ret;
8199
8200 vos_ssr_protect(__func__);
8201 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
8202 vos_ssr_unprotect(__func__);
8203
8204 return ret;
8205}
8206#endif
8207
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008208#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
8209
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308210static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05308211 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008212 struct cfg80211_ap_settings *params)
8213{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05308214 hdd_adapter_t *pAdapter;
8215 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308216 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008217
8218 ENTER();
8219
Girish Gowlib143d7a2015-02-18 19:39:55 +05308220 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07008221 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308222 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05308223 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05308224 return -ENODEV;
8225 }
8226
8227 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8228 if (NULL == pAdapter)
8229 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308230 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05308231 "%s: HDD adapter is Null", __func__);
8232 return -ENODEV;
8233 }
8234
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308235 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8236 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
8237 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05308238 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
8239 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308240 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05308241 "%s: HDD adapter magic is invalid", __func__);
8242 return -ENODEV;
8243 }
8244
8245 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308246 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308247 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05308248 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308249 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05308250 }
8251
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308252 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
8253 __func__, hdd_device_modetoString(pAdapter->device_mode),
8254 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05308255
8256 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008257 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008258 )
8259 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05308260 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008261
8262 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05308263
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008264 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308265 {
8266 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8267 FL("already beacon info added to session(%d)"),
8268 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008269 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308270 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008271
Girish Gowlib143d7a2015-02-18 19:39:55 +05308272#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
8273 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
8274 &new,
8275 &params->beacon);
8276#else
8277 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
8278 &new,
8279 &params->beacon,
8280 params->dtim_period);
8281#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008282
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05308283 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008284 {
8285 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05308286 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008287 return -EINVAL;
8288 }
8289 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08008290#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07008291 wlan_hdd_cfg80211_set_channel(wiphy, dev,
8292#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
8293 params->channel, params->channel_type);
8294#else
8295 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
8296#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08008297#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008298 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05308299 params->ssid_len, params->hidden_ssid,
8300 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008301 }
8302
8303 EXIT();
8304 return status;
8305}
8306
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308307static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
8308 struct net_device *dev,
8309 struct cfg80211_ap_settings *params)
8310{
8311 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008312
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308313 vos_ssr_protect(__func__);
8314 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
8315 vos_ssr_unprotect(__func__);
8316
8317 return ret;
8318}
8319
8320static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008321 struct net_device *dev,
8322 struct cfg80211_beacon_data *params)
8323{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308324 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308325 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308326 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008327
8328 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308329
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308330 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8331 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
8332 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08008333 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008334 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308335
8336 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8337 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308338 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07008339 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308340 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07008341 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008342
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308343 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008344 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308345 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008346 {
8347 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308348
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008349 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308350
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008351 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308352 {
8353 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8354 FL("session(%d) beacon data points to NULL"),
8355 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008356 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308357 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008358
8359 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
8360
8361 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308362 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008363 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008364 return -EINVAL;
8365 }
8366
8367 pAdapter->sessionCtx.ap.beacon = new;
8368
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05308369 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
8370 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008371 }
8372
8373 EXIT();
8374 return status;
8375}
8376
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308377static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
8378 struct net_device *dev,
8379 struct cfg80211_beacon_data *params)
8380{
8381 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008382
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308383 vos_ssr_protect(__func__);
8384 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
8385 vos_ssr_unprotect(__func__);
8386
8387 return ret;
8388}
8389
8390#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008391
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308392static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008393 struct net_device *dev,
8394 struct bss_parameters *params)
8395{
8396 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308397 hdd_context_t *pHddCtx;
8398 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008399
8400 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308401
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308402 if (NULL == pAdapter)
8403 {
8404 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8405 "%s: HDD adapter is Null", __func__);
8406 return -ENODEV;
8407 }
8408 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308409 ret = wlan_hdd_validate_context(pHddCtx);
8410 if (0 != ret)
8411 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308412 return ret;
8413 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308414 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8415 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
8416 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308417 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8418 __func__, hdd_device_modetoString(pAdapter->device_mode),
8419 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008420
8421 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008422 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308423 )
Jeff Johnson295189b2012-06-20 16:38:30 -07008424 {
8425 /* ap_isolate == -1 means that in change bss, upper layer doesn't
8426 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308427 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07008428 {
8429 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308430 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008431 }
8432
8433 EXIT();
8434 return 0;
8435}
8436
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308437static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
8438 struct net_device *dev,
8439 struct bss_parameters *params)
8440{
8441 int ret;
8442
8443 vos_ssr_protect(__func__);
8444 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
8445 vos_ssr_unprotect(__func__);
8446
8447 return ret;
8448}
Kiet Lam10841362013-11-01 11:36:50 +05308449/* FUNCTION: wlan_hdd_change_country_code_cd
8450* to wait for contry code completion
8451*/
8452void* wlan_hdd_change_country_code_cb(void *pAdapter)
8453{
8454 hdd_adapter_t *call_back_pAdapter = pAdapter;
8455 complete(&call_back_pAdapter->change_country_code);
8456 return NULL;
8457}
8458
Jeff Johnson295189b2012-06-20 16:38:30 -07008459/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308460 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07008461 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
8462 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308463int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008464 struct net_device *ndev,
8465 enum nl80211_iftype type,
8466 u32 *flags,
8467 struct vif_params *params
8468 )
8469{
8470 struct wireless_dev *wdev;
8471 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008472 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07008473 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008474 tCsrRoamProfile *pRoamProfile = NULL;
8475 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308476 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008477 eMib_dot11DesiredBssType connectedBssType;
8478 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308479 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008480
8481 ENTER();
8482
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308483 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008484 {
8485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8486 "%s: Adapter context is null", __func__);
8487 return VOS_STATUS_E_FAILURE;
8488 }
8489
8490 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8491 if (!pHddCtx)
8492 {
8493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8494 "%s: HDD context is null", __func__);
8495 return VOS_STATUS_E_FAILURE;
8496 }
8497
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308498 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8499 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
8500 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308501 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308502 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07008503 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308504 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008505 }
8506
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308507 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8508 __func__, hdd_device_modetoString(pAdapter->device_mode),
8509 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008510
Agarwal Ashish51325b52014-06-16 16:50:49 +05308511 if (vos_max_concurrent_connections_reached()) {
8512 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
8513 return -EINVAL;
8514 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308515 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07008516 wdev = ndev->ieee80211_ptr;
8517
8518#ifdef WLAN_BTAMP_FEATURE
8519 if((NL80211_IFTYPE_P2P_CLIENT == type)||
8520 (NL80211_IFTYPE_ADHOC == type)||
8521 (NL80211_IFTYPE_AP == type)||
8522 (NL80211_IFTYPE_P2P_GO == type))
8523 {
8524 pHddCtx->isAmpAllowed = VOS_FALSE;
8525 // stop AMP traffic
8526 status = WLANBAP_StopAmp();
8527 if(VOS_STATUS_SUCCESS != status )
8528 {
8529 pHddCtx->isAmpAllowed = VOS_TRUE;
8530 hddLog(VOS_TRACE_LEVEL_FATAL,
8531 "%s: Failed to stop AMP", __func__);
8532 return -EINVAL;
8533 }
8534 }
8535#endif //WLAN_BTAMP_FEATURE
8536 /* Reset the current device mode bit mask*/
8537 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
8538
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05308539 if ((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
8540 ((type == NL80211_IFTYPE_P2P_CLIENT) ||
8541 (type == NL80211_IFTYPE_P2P_GO)))
8542 {
8543 /* Notify Mode change in case of concurrency.
8544 * Below function invokes TDLS teardown Functionality Since TDLS is
8545 * not Supported in case of concurrency i.e Once P2P session
8546 * is detected disable offchannel and teardown TDLS links
8547 */
8548 hddLog(LOG1,
8549 FL("Device mode = %d Interface type = %d"),
8550 pAdapter->device_mode, type);
8551 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
8552 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05308553
Jeff Johnson295189b2012-06-20 16:38:30 -07008554 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008555 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07008556 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07008557 )
8558 {
8559 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008560 if (!pWextState)
8561 {
8562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8563 "%s: pWextState is null", __func__);
8564 return VOS_STATUS_E_FAILURE;
8565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008566 pRoamProfile = &pWextState->roamProfile;
8567 LastBSSType = pRoamProfile->BSSType;
8568
8569 switch (type)
8570 {
8571 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008572 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008573 hddLog(VOS_TRACE_LEVEL_INFO,
8574 "%s: setting interface Type to INFRASTRUCTURE", __func__);
8575 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07008576#ifdef WLAN_FEATURE_11AC
8577 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
8578 {
8579 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
8580 }
8581#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308582 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07008583 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008584 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008585 //Check for sub-string p2p to confirm its a p2p interface
8586 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308587 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +05308588#ifdef FEATURE_WLAN_TDLS
8589 mutex_lock(&pHddCtx->tdls_lock);
8590 wlan_hdd_tdls_exit(pAdapter, TRUE);
8591 mutex_unlock(&pHddCtx->tdls_lock);
8592#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008593 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8594 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8595 }
8596 else
8597 {
8598 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008599 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008601 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05308602
Jeff Johnson295189b2012-06-20 16:38:30 -07008603 case NL80211_IFTYPE_ADHOC:
8604 hddLog(VOS_TRACE_LEVEL_INFO,
8605 "%s: setting interface Type to ADHOC", __func__);
8606 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
8607 pRoamProfile->phyMode =
8608 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07008609 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008610 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +05308611 hdd_set_ibss_ops( pAdapter );
8612 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +05308613
8614 status = hdd_sta_id_hash_attach(pAdapter);
8615 if (VOS_STATUS_SUCCESS != status) {
8616 hddLog(VOS_TRACE_LEVEL_ERROR,
8617 FL("Failed to initialize hash for IBSS"));
8618 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008619 break;
8620
8621 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008622 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008623 {
8624 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8625 "%s: setting interface Type to %s", __func__,
8626 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
8627
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008628 //Cancel any remain on channel for GO mode
8629 if (NL80211_IFTYPE_P2P_GO == type)
8630 {
8631 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
8632 }
Mohit Khanna0f232092012-09-11 14:46:08 -07008633 if (NL80211_IFTYPE_AP == type)
8634 {
8635 /* As Loading WLAN Driver one interface being created for p2p device
8636 * address. This will take one HW STA and the max number of clients
8637 * that can connect to softAP will be reduced by one. so while changing
8638 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
8639 * interface as it is not required in SoftAP mode.
8640 */
8641
8642 // Get P2P Adapter
8643 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
8644
8645 if (pP2pAdapter)
8646 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05308647 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +05308648 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07008649 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
8650 }
8651 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05308652 //Disable IMPS & BMPS for SAP/GO
8653 if(VOS_STATUS_E_FAILURE ==
8654 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
8655 {
8656 //Fail to Exit BMPS
8657 VOS_ASSERT(0);
8658 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05308659
8660 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
8661
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308662#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07008663
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308664 /* A Mutex Lock is introduced while changing the mode to
8665 * protect the concurrent access for the Adapters by TDLS
8666 * module.
8667 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308668 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308669#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008670 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +05308671 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008672 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07008673 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8674 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308675#ifdef FEATURE_WLAN_TDLS
8676 mutex_unlock(&pHddCtx->tdls_lock);
8677#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008678 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
8679 (pConfig->apRandomBssidEnabled))
8680 {
8681 /* To meet Android requirements create a randomized
8682 MAC address of the form 02:1A:11:Fx:xx:xx */
8683 get_random_bytes(&ndev->dev_addr[3], 3);
8684 ndev->dev_addr[0] = 0x02;
8685 ndev->dev_addr[1] = 0x1A;
8686 ndev->dev_addr[2] = 0x11;
8687 ndev->dev_addr[3] |= 0xF0;
8688 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
8689 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08008690 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
8691 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008692 }
8693
Jeff Johnson295189b2012-06-20 16:38:30 -07008694 hdd_set_ap_ops( pAdapter->dev );
8695
Kiet Lam10841362013-11-01 11:36:50 +05308696 /* This is for only SAP mode where users can
8697 * control country through ini.
8698 * P2P GO follows station country code
8699 * acquired during the STA scanning. */
8700 if((NL80211_IFTYPE_AP == type) &&
8701 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
8702 {
8703 int status = 0;
8704 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
8705 "%s: setting country code from INI ", __func__);
8706 init_completion(&pAdapter->change_country_code);
8707 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
8708 (void *)(tSmeChangeCountryCallback)
8709 wlan_hdd_change_country_code_cb,
8710 pConfig->apCntryCode, pAdapter,
8711 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05308712 eSIR_FALSE,
8713 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05308714 if (eHAL_STATUS_SUCCESS == status)
8715 {
8716 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308717 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05308718 &pAdapter->change_country_code,
8719 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308720 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05308721 {
8722 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308723 FL("SME Timed out while setting country code %ld"),
8724 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08008725
8726 if (pHddCtx->isLogpInProgress)
8727 {
8728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8729 "%s: LOGP in Progress. Ignore!!!", __func__);
8730 return -EAGAIN;
8731 }
Kiet Lam10841362013-11-01 11:36:50 +05308732 }
8733 }
8734 else
8735 {
8736 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008737 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05308738 return -EINVAL;
8739 }
8740 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008741 status = hdd_init_ap_mode(pAdapter);
8742 if(status != VOS_STATUS_SUCCESS)
8743 {
8744 hddLog(VOS_TRACE_LEVEL_FATAL,
8745 "%s: Error initializing the ap mode", __func__);
8746 return -EINVAL;
8747 }
8748 hdd_set_conparam(1);
8749
Nirav Shah7e3c8132015-06-22 23:51:42 +05308750 status = hdd_sta_id_hash_attach(pAdapter);
8751 if (VOS_STATUS_SUCCESS != status)
8752 {
8753 hddLog(VOS_TRACE_LEVEL_ERROR,
8754 FL("Failed to initialize hash for AP"));
8755 return -EINVAL;
8756 }
8757
Jeff Johnson295189b2012-06-20 16:38:30 -07008758 /*interface type changed update in wiphy structure*/
8759 if(wdev)
8760 {
8761 wdev->iftype = type;
8762 pHddCtx->change_iface = type;
8763 }
8764 else
8765 {
8766 hddLog(VOS_TRACE_LEVEL_ERROR,
8767 "%s: ERROR !!!! Wireless dev is NULL", __func__);
8768 return -EINVAL;
8769 }
8770 goto done;
8771 }
8772
8773 default:
8774 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8775 __func__);
8776 return -EOPNOTSUPP;
8777 }
8778 }
8779 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008780 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07008781 )
8782 {
8783 switch(type)
8784 {
8785 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008787 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05308788
8789 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308790#ifdef FEATURE_WLAN_TDLS
8791
8792 /* A Mutex Lock is introduced while changing the mode to
8793 * protect the concurrent access for the Adapters by TDLS
8794 * module.
8795 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308796 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308797#endif
c_hpothu002231a2015-02-05 14:58:51 +05308798 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008799 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008800 //Check for sub-string p2p to confirm its a p2p interface
8801 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008802 {
8803 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8804 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8805 }
8806 else
8807 {
8808 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008809 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008810 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008811 hdd_set_conparam(0);
8812 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008813 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
8814 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308815#ifdef FEATURE_WLAN_TDLS
8816 mutex_unlock(&pHddCtx->tdls_lock);
8817#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05308818 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008819 if( VOS_STATUS_SUCCESS != status )
8820 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07008821 /* In case of JB, for P2P-GO, only change interface will be called,
8822 * This is the right place to enable back bmps_imps()
8823 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308824 if (pHddCtx->hdd_wlan_suspended)
8825 {
8826 hdd_set_pwrparams(pHddCtx);
8827 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008828 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008829 goto done;
8830 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008831 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008832 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008833 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8834 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008835 goto done;
8836 default:
8837 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8838 __func__);
8839 return -EOPNOTSUPP;
8840
8841 }
8842
8843 }
8844 else
8845 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308846 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
8847 __func__, hdd_device_modetoString(pAdapter->device_mode),
8848 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008849 return -EOPNOTSUPP;
8850 }
8851
8852
8853 if(pRoamProfile)
8854 {
8855 if ( LastBSSType != pRoamProfile->BSSType )
8856 {
8857 /*interface type changed update in wiphy structure*/
8858 wdev->iftype = type;
8859
8860 /*the BSS mode changed, We need to issue disconnect
8861 if connected or in IBSS disconnect state*/
8862 if ( hdd_connGetConnectedBssType(
8863 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
8864 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
8865 {
8866 /*need to issue a disconnect to CSR.*/
8867 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8868 if( eHAL_STATUS_SUCCESS ==
8869 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8870 pAdapter->sessionId,
8871 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
8872 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308873 ret = wait_for_completion_interruptible_timeout(
8874 &pAdapter->disconnect_comp_var,
8875 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8876 if (ret <= 0)
8877 {
8878 hddLog(VOS_TRACE_LEVEL_ERROR,
8879 FL("wait on disconnect_comp_var failed %ld"), ret);
8880 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008881 }
8882 }
8883 }
8884 }
8885
8886done:
8887 /*set bitmask based on updated value*/
8888 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07008889
8890 /* Only STA mode support TM now
8891 * all other mode, TM feature should be disabled */
8892 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
8893 (~VOS_STA & pHddCtx->concurrency_mode) )
8894 {
8895 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
8896 }
8897
Jeff Johnson295189b2012-06-20 16:38:30 -07008898#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308899 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05308900 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07008901 {
8902 //we are ok to do AMP
8903 pHddCtx->isAmpAllowed = VOS_TRUE;
8904 }
8905#endif //WLAN_BTAMP_FEATURE
8906 EXIT();
8907 return 0;
8908}
8909
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308910/*
8911 * FUNCTION: wlan_hdd_cfg80211_change_iface
8912 * wrapper function to protect the actual implementation from SSR.
8913 */
8914int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
8915 struct net_device *ndev,
8916 enum nl80211_iftype type,
8917 u32 *flags,
8918 struct vif_params *params
8919 )
8920{
8921 int ret;
8922
8923 vos_ssr_protect(__func__);
8924 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
8925 vos_ssr_unprotect(__func__);
8926
8927 return ret;
8928}
8929
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008930#ifdef FEATURE_WLAN_TDLS
8931static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308932 struct net_device *dev,
8933#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
8934 const u8 *mac,
8935#else
8936 u8 *mac,
8937#endif
8938 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008939{
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008940 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008941 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308942 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308943 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308944 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308945 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008946
8947 ENTER();
8948
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308949 if (!dev) {
8950 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
8951 return -EINVAL;
8952 }
8953
8954 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8955 if (!pAdapter) {
8956 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
8957 return -EINVAL;
8958 }
8959
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308960 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008961 {
8962 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8963 "Invalid arguments");
8964 return -EINVAL;
8965 }
Hoonki Lee27511902013-03-14 18:19:06 -07008966
8967 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
8968 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
8969 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308970 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -07008971 "%s: TDLS mode is disabled OR not enabled in FW."
8972 MAC_ADDRESS_STR " Request declined.",
8973 __func__, MAC_ADDR_ARRAY(mac));
8974 return -ENOTSUPP;
8975 }
8976
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008977 if (pHddCtx->isLogpInProgress)
8978 {
8979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8980 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05308981 wlan_hdd_tdls_set_link_status(pAdapter,
8982 mac,
8983 eTDLS_LINK_IDLE,
8984 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008985 return -EBUSY;
8986 }
8987
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308988 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05308989 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008990
8991 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308992 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008993 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
8994 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308995 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008996 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008997 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308998 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008999
9000 /* in add station, we accept existing valid staId if there is */
9001 if ((0 == update) &&
9002 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
9003 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009004 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05309005 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009006 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009007 " link_status %d. staId %d. add station ignored.",
9008 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
9009 return 0;
9010 }
9011 /* in change station, we accept only when staId is valid */
9012 if ((1 == update) &&
9013 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
9014 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
9015 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05309016 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009017 "%s: " MAC_ADDRESS_STR
9018 " link status %d. staId %d. change station %s.",
9019 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
9020 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
9021 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009022 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07009023
9024 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05309025 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009026 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009027 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9028 "%s: " MAC_ADDRESS_STR
9029 " TDLS setup is ongoing. Request declined.",
9030 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07009031 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009032 }
9033
9034 /* first to check if we reached to maximum supported TDLS peer.
9035 TODO: for now, return -EPERM looks working fine,
9036 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05309037 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
9038 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009039 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009040 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9041 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05309042 " TDLS Max peer already connected. Request declined."
9043 " Num of peers (%d), Max allowed (%d).",
9044 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
9045 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07009046 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009047 }
9048 else
9049 {
9050 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05309051 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009052 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009053 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009054 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9055 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
9056 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009057 return -EPERM;
9058 }
9059 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009060 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05309061 wlan_hdd_tdls_set_link_status(pAdapter,
9062 mac,
9063 eTDLS_LINK_CONNECTING,
9064 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009065
Jeff Johnsond75fe012013-04-06 10:53:06 -07009066 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05309067 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009068 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05309069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009070 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07009071 if(StaParams->htcap_present)
9072 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05309073 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07009074 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05309075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07009076 "ht_capa->extended_capabilities: %0x",
9077 StaParams->HTCap.extendedHtCapInfo);
9078 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05309079 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009080 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05309081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009082 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07009083 if(StaParams->vhtcap_present)
9084 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05309085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07009086 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
9087 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
9088 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
9089 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009090 {
9091 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009092 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009093 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05309094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009095 "[%d]: %x ", i, StaParams->supported_rates[i]);
9096 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07009097 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05309098 else if ((1 == update) && (NULL == StaParams))
9099 {
9100 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9101 "%s : update is true, but staParams is NULL. Error!", __func__);
9102 return -EPERM;
9103 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009104
9105 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
9106
9107 if (!update)
9108 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05309109 /*Before adding sta make sure that device exited from BMPS*/
9110 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
9111 {
9112 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9113 "%s: Adding tdls peer sta. Disable BMPS", __func__);
9114 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
9115 if (status != VOS_STATUS_SUCCESS) {
9116 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
9117 }
9118 }
9119
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05309120 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009121 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05309122 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05309123 hddLog(VOS_TRACE_LEVEL_ERROR,
9124 FL("Failed to add TDLS peer STA. Enable Bmps"));
9125 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05309126 return -EPERM;
9127 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009128 }
9129 else
9130 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05309131 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009132 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05309133 if (ret != eHAL_STATUS_SUCCESS) {
9134 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
9135 return -EPERM;
9136 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009137 }
9138
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309139 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009140 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
9141
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309142 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009143 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009144 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309145 "%s: timeout waiting for tdls add station indication %ld",
9146 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07009147 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009148 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309149
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009150 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
9151 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009153 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07009154 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009155 }
9156
9157 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07009158
9159error:
Atul Mittal115287b2014-07-08 13:26:33 +05309160 wlan_hdd_tdls_set_link_status(pAdapter,
9161 mac,
9162 eTDLS_LINK_IDLE,
9163 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07009164 return -EPERM;
9165
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009166}
9167#endif
9168
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309169static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009170 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309171#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
9172 const u8 *mac,
9173#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009174 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309175#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009176 struct station_parameters *params)
9177{
9178 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05309179 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +05309180 hdd_context_t *pHddCtx;
9181 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009182 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309183 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07009184#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009185 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009186 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05309187 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07009188#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07009189
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05309190 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309191
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05309192 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +05309193 if ((NULL == pAdapter))
9194 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05309196 "invalid adapter ");
9197 return -EINVAL;
9198 }
9199
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309200 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9201 TRACE_CODE_HDD_CHANGE_STATION,
9202 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05309203 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +05309204
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309205 ret = wlan_hdd_validate_context(pHddCtx);
9206 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +05309207 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309208 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +05309209 }
9210
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309211 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9212
9213 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009214 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9216 "invalid HDD station context");
9217 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009218 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009219 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
9220
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009221 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
9222 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07009223 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009224 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07009225 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309226 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 WLANTL_STA_AUTHENTICATED);
9228
Gopichand Nakkala29149562013-05-10 21:43:41 +05309229 if (status != VOS_STATUS_SUCCESS)
9230 {
9231 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9232 "%s: Not able to change TL state to AUTHENTICATED", __func__);
9233 return -EINVAL;
9234 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009235 }
9236 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07009237 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
9238 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05309239#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009240 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
9241 StaParams.capability = params->capability;
9242 StaParams.uapsd_queues = params->uapsd_queues;
9243 StaParams.max_sp = params->max_sp;
9244
Naresh Jayaram3180aa42014-02-12 21:47:26 +05309245 /* Convert (first channel , number of channels) tuple to
9246 * the total list of channels. This goes with the assumption
9247 * that if the first channel is < 14, then the next channels
9248 * are an incremental of 1 else an incremental of 4 till the number
9249 * of channels.
9250 */
9251 if (0 != params->supported_channels_len) {
9252 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
9253 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
9254 {
9255 int wifi_chan_index;
9256 StaParams.supported_channels[j] = params->supported_channels[i];
9257 wifi_chan_index =
9258 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
9259 no_of_channels = params->supported_channels[i+1];
9260 for(k=1; k <= no_of_channels; k++)
9261 {
9262 StaParams.supported_channels[j+1] =
9263 StaParams.supported_channels[j] + wifi_chan_index;
9264 j+=1;
9265 }
9266 }
9267 StaParams.supported_channels_len = j;
9268 }
9269 vos_mem_copy(StaParams.supported_oper_classes,
9270 params->supported_oper_classes,
9271 params->supported_oper_classes_len);
9272 StaParams.supported_oper_classes_len =
9273 params->supported_oper_classes_len;
9274
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009275 if (0 != params->ext_capab_len)
9276 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
9277 sizeof(StaParams.extn_capability));
9278
9279 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07009280 {
9281 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009282 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07009283 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009284
9285 StaParams.supported_rates_len = params->supported_rates_len;
9286
9287 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
9288 * The supported_rates array , for all the structures propogating till Add Sta
9289 * to the firmware has to be modified , if the supplicant (ieee80211) is
9290 * modified to send more rates.
9291 */
9292
9293 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
9294 */
9295 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
9296 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
9297
9298 if (0 != StaParams.supported_rates_len) {
9299 int i = 0;
9300 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
9301 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009302 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009303 "Supported Rates with Length %d", StaParams.supported_rates_len);
9304 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009305 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009306 "[%d]: %0x", i, StaParams.supported_rates[i]);
9307 }
9308
9309 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07009310 {
9311 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009312 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07009313 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009314
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009315 if (0 != params->ext_capab_len ) {
9316 /*Define A Macro : TODO Sunil*/
9317 if ((1<<4) & StaParams.extn_capability[3]) {
9318 isBufSta = 1;
9319 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05309320 /* TDLS Channel Switching Support */
9321 if ((1<<6) & StaParams.extn_capability[3]) {
9322 isOffChannelSupported = 1;
9323 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009324 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05309325 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
9326 &StaParams, isBufSta,
9327 isOffChannelSupported);
9328
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309329 if (VOS_STATUS_SUCCESS != status) {
9330 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9331 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
9332 return -EINVAL;
9333 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009334 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
9335
9336 if (VOS_STATUS_SUCCESS != status) {
9337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9338 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
9339 return -EINVAL;
9340 }
9341 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07009342#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05309343 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009344 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009345 return status;
9346}
9347
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309348#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
9349static int wlan_hdd_change_station(struct wiphy *wiphy,
9350 struct net_device *dev,
9351 const u8 *mac,
9352 struct station_parameters *params)
9353#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309354static int wlan_hdd_change_station(struct wiphy *wiphy,
9355 struct net_device *dev,
9356 u8 *mac,
9357 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309358#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309359{
9360 int ret;
9361
9362 vos_ssr_protect(__func__);
9363 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
9364 vos_ssr_unprotect(__func__);
9365
9366 return ret;
9367}
9368
Jeff Johnson295189b2012-06-20 16:38:30 -07009369/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309370 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009371 * This function is used to initialize the key information
9372 */
9373#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309374static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009375 struct net_device *ndev,
9376 u8 key_index, bool pairwise,
9377 const u8 *mac_addr,
9378 struct key_params *params
9379 )
9380#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309381static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009382 struct net_device *ndev,
9383 u8 key_index, const u8 *mac_addr,
9384 struct key_params *params
9385 )
9386#endif
9387{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009388 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07009389 tCsrRoamSetKey setKey;
9390 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309391 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009392 v_U32_t roamId= 0xFF;
9393 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009394 hdd_hostapd_state_t *pHostapdState;
9395 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009396 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309397 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009398
9399 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309400
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309401 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9402 TRACE_CODE_HDD_CFG80211_ADD_KEY,
9403 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309404 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9405 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309406 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009407 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309408 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009409 }
9410
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309411 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9412 __func__, hdd_device_modetoString(pAdapter->device_mode),
9413 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009414
9415 if (CSR_MAX_NUM_KEY <= key_index)
9416 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009417 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009418 key_index);
9419
9420 return -EINVAL;
9421 }
9422
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009423 if (CSR_MAX_KEY_LEN < params->key_len)
9424 {
9425 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
9426 params->key_len);
9427
9428 return -EINVAL;
9429 }
9430
9431 hddLog(VOS_TRACE_LEVEL_INFO,
9432 "%s: called with key index = %d & key length %d",
9433 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07009434
9435 /*extract key idx, key len and key*/
9436 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9437 setKey.keyId = key_index;
9438 setKey.keyLength = params->key_len;
9439 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
9440
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009441 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07009442 {
9443 case WLAN_CIPHER_SUITE_WEP40:
9444 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
9445 break;
9446
9447 case WLAN_CIPHER_SUITE_WEP104:
9448 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
9449 break;
9450
9451 case WLAN_CIPHER_SUITE_TKIP:
9452 {
9453 u8 *pKey = &setKey.Key[0];
9454 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
9455
9456 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
9457
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009458 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07009459
9460 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009461 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07009462 |--------------|----------|----------|
9463 <---16bytes---><--8bytes--><--8bytes-->
9464
9465 */
9466 /*Sme expects the 32 bytes key to be in the below order
9467
9468 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009469 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07009470 |--------------|----------|----------|
9471 <---16bytes---><--8bytes--><--8bytes-->
9472 */
9473 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009474 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07009475
9476 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009477 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009478
9479 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009480 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009481
9482
9483 break;
9484 }
9485
9486 case WLAN_CIPHER_SUITE_CCMP:
9487 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
9488 break;
9489
9490#ifdef FEATURE_WLAN_WAPI
9491 case WLAN_CIPHER_SUITE_SMS4:
9492 {
9493 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9494 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
9495 params->key, params->key_len);
9496 return 0;
9497 }
9498#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009499
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009500#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009501 case WLAN_CIPHER_SUITE_KRK:
9502 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
9503 break;
9504#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009505
9506#ifdef WLAN_FEATURE_11W
9507 case WLAN_CIPHER_SUITE_AES_CMAC:
9508 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07009509 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07009510#endif
9511
Jeff Johnson295189b2012-06-20 16:38:30 -07009512 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009513 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07009514 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309515 status = -EOPNOTSUPP;
9516 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009517 }
9518
9519 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
9520 __func__, setKey.encType);
9521
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009522 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07009523#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9524 (!pairwise)
9525#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009526 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07009527#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009528 )
9529 {
9530 /* set group key*/
9531 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9532 "%s- %d: setting Broadcast key",
9533 __func__, __LINE__);
9534 setKey.keyDirection = eSIR_RX_ONLY;
9535 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9536 }
9537 else
9538 {
9539 /* set pairwise key*/
9540 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9541 "%s- %d: setting pairwise key",
9542 __func__, __LINE__);
9543 setKey.keyDirection = eSIR_TX_RX;
9544 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9545 }
9546 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
9547 {
9548 setKey.keyDirection = eSIR_TX_RX;
9549 /*Set the group key*/
9550 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9551 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009552
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009553 if ( 0 != status )
9554 {
9555 hddLog(VOS_TRACE_LEVEL_ERROR,
9556 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309557 status = -EINVAL;
9558 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009559 }
9560 /*Save the keys here and call sme_RoamSetKey for setting
9561 the PTK after peer joins the IBSS network*/
9562 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
9563 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309564 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009565 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05309566 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
9567 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
9568 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009569 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009570 if( pHostapdState->bssState == BSS_START )
9571 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009572 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9573 vos_status = wlan_hdd_check_ula_done(pAdapter);
9574
9575 if ( vos_status != VOS_STATUS_SUCCESS )
9576 {
9577 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9578 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9579 __LINE__, vos_status );
9580
9581 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9582
9583 status = -EINVAL;
9584 goto end;
9585 }
9586
Jeff Johnson295189b2012-06-20 16:38:30 -07009587 status = WLANSAP_SetKeySta( pVosContext, &setKey);
9588
9589 if ( status != eHAL_STATUS_SUCCESS )
9590 {
9591 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9592 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9593 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309594 status = -EINVAL;
9595 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009596 }
9597 }
9598
9599 /* Saving WEP keys */
9600 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
9601 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
9602 {
9603 //Save the wep key in ap context. Issue setkey after the BSS is started.
9604 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9605 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
9606 }
9607 else
9608 {
9609 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009610 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009611 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
9612 }
9613 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009614 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9615 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009616 {
9617 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9618 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9619
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309620#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9621 if (!pairwise)
9622#else
9623 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9624#endif
9625 {
9626 /* set group key*/
9627 if (pHddStaCtx->roam_info.deferKeyComplete)
9628 {
9629 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9630 "%s- %d: Perform Set key Complete",
9631 __func__, __LINE__);
9632 hdd_PerformRoamSetKeyComplete(pAdapter);
9633 }
9634 }
9635
Jeff Johnson295189b2012-06-20 16:38:30 -07009636 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
9637
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08009638 pWextState->roamProfile.Keys.defaultIndex = key_index;
9639
9640
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009641 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009642 params->key, params->key_len);
9643
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309644
Jeff Johnson295189b2012-06-20 16:38:30 -07009645 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9646
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309647 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309649 __func__, setKey.peerMac[0], setKey.peerMac[1],
9650 setKey.peerMac[2], setKey.peerMac[3],
9651 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009652 setKey.keyDirection);
9653
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009654 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +05309655
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009656 if ( vos_status != VOS_STATUS_SUCCESS )
9657 {
9658 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009659 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9660 __LINE__, vos_status );
9661
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009662 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009663
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009664 status = -EINVAL;
9665 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009666
9667 }
9668
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009669#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309670 /* The supplicant may attempt to set the PTK once pre-authentication
9671 is done. Save the key in the UMAC and include it in the ADD BSS
9672 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009673 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309674 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009675 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309676 hddLog(VOS_TRACE_LEVEL_INFO_MED,
9677 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309678 status = 0;
9679 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309680 }
9681 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
9682 {
9683 hddLog(VOS_TRACE_LEVEL_ERROR,
9684 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309685 status = -EINVAL;
9686 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009687 }
9688#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07009689
9690 /* issue set key request to SME*/
9691 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9692 pAdapter->sessionId, &setKey, &roamId );
9693
9694 if ( 0 != status )
9695 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309696 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009697 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
9698 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309699 status = -EINVAL;
9700 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009701 }
9702
9703
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309704 /* in case of IBSS as there was no information available about WEP keys during
9705 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07009706 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309707 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
9708 !( ( IW_AUTH_KEY_MGMT_802_1X
9709 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07009710 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
9711 )
9712 &&
9713 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
9714 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
9715 )
9716 )
9717 {
9718 setKey.keyDirection = eSIR_RX_ONLY;
9719 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9720
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309721 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009722 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309723 __func__, setKey.peerMac[0], setKey.peerMac[1],
9724 setKey.peerMac[2], setKey.peerMac[3],
9725 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009726 setKey.keyDirection);
9727
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309728 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009729 pAdapter->sessionId, &setKey, &roamId );
9730
9731 if ( 0 != status )
9732 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309733 hddLog(VOS_TRACE_LEVEL_ERROR,
9734 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009735 __func__, status);
9736 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309737 status = -EINVAL;
9738 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009739 }
9740 }
9741 }
9742
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309743end:
9744 /* Need to clear any trace of key value in the memory.
9745 * Thus zero out the memory even though it is local
9746 * variable.
9747 */
9748 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309749 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309750 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009751}
9752
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309753#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9754static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9755 struct net_device *ndev,
9756 u8 key_index, bool pairwise,
9757 const u8 *mac_addr,
9758 struct key_params *params
9759 )
9760#else
9761static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9762 struct net_device *ndev,
9763 u8 key_index, const u8 *mac_addr,
9764 struct key_params *params
9765 )
9766#endif
9767{
9768 int ret;
9769 vos_ssr_protect(__func__);
9770#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9771 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
9772 mac_addr, params);
9773#else
9774 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
9775 params);
9776#endif
9777 vos_ssr_unprotect(__func__);
9778
9779 return ret;
9780}
9781
Jeff Johnson295189b2012-06-20 16:38:30 -07009782/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309783 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009784 * This function is used to get the key information
9785 */
9786#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309787static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309788 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009789 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309790 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009791 const u8 *mac_addr, void *cookie,
9792 void (*callback)(void *cookie, struct key_params*)
9793 )
9794#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309795static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309796 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009797 struct net_device *ndev,
9798 u8 key_index, const u8 *mac_addr, void *cookie,
9799 void (*callback)(void *cookie, struct key_params*)
9800 )
9801#endif
9802{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309803 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309804 hdd_wext_state_t *pWextState = NULL;
9805 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009806 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309807 hdd_context_t *pHddCtx;
9808 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009809
9810 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309811
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309812 if (NULL == pAdapter)
9813 {
9814 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9815 "%s: HDD adapter is Null", __func__);
9816 return -ENODEV;
9817 }
9818
9819 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9820 ret = wlan_hdd_validate_context(pHddCtx);
9821 if (0 != ret)
9822 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309823 return ret;
9824 }
9825
9826 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9827 pRoamProfile = &(pWextState->roamProfile);
9828
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309829 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9830 __func__, hdd_device_modetoString(pAdapter->device_mode),
9831 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309832
Jeff Johnson295189b2012-06-20 16:38:30 -07009833 memset(&params, 0, sizeof(params));
9834
9835 if (CSR_MAX_NUM_KEY <= key_index)
9836 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309837 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07009838 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009840
9841 switch(pRoamProfile->EncryptionType.encryptionType[0])
9842 {
9843 case eCSR_ENCRYPT_TYPE_NONE:
9844 params.cipher = IW_AUTH_CIPHER_NONE;
9845 break;
9846
9847 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
9848 case eCSR_ENCRYPT_TYPE_WEP40:
9849 params.cipher = WLAN_CIPHER_SUITE_WEP40;
9850 break;
9851
9852 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
9853 case eCSR_ENCRYPT_TYPE_WEP104:
9854 params.cipher = WLAN_CIPHER_SUITE_WEP104;
9855 break;
9856
9857 case eCSR_ENCRYPT_TYPE_TKIP:
9858 params.cipher = WLAN_CIPHER_SUITE_TKIP;
9859 break;
9860
9861 case eCSR_ENCRYPT_TYPE_AES:
9862 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
9863 break;
9864
9865 default:
9866 params.cipher = IW_AUTH_CIPHER_NONE;
9867 break;
9868 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309869
c_hpothuaaf19692014-05-17 17:01:48 +05309870 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9871 TRACE_CODE_HDD_CFG80211_GET_KEY,
9872 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309873
Jeff Johnson295189b2012-06-20 16:38:30 -07009874 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
9875 params.seq_len = 0;
9876 params.seq = NULL;
9877 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
9878 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309879 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009880 return 0;
9881}
9882
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309883#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9884static int wlan_hdd_cfg80211_get_key(
9885 struct wiphy *wiphy,
9886 struct net_device *ndev,
9887 u8 key_index, bool pairwise,
9888 const u8 *mac_addr, void *cookie,
9889 void (*callback)(void *cookie, struct key_params*)
9890 )
9891#else
9892static int wlan_hdd_cfg80211_get_key(
9893 struct wiphy *wiphy,
9894 struct net_device *ndev,
9895 u8 key_index, const u8 *mac_addr, void *cookie,
9896 void (*callback)(void *cookie, struct key_params*)
9897 )
9898#endif
9899{
9900 int ret;
9901
9902 vos_ssr_protect(__func__);
9903#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9904 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
9905 mac_addr, cookie, callback);
9906#else
9907 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
9908 callback);
9909#endif
9910 vos_ssr_unprotect(__func__);
9911
9912 return ret;
9913}
9914
Jeff Johnson295189b2012-06-20 16:38:30 -07009915/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309916 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009917 * This function is used to delete the key information
9918 */
9919#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309920static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009921 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309922 u8 key_index,
9923 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009924 const u8 *mac_addr
9925 )
9926#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309927static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009928 struct net_device *ndev,
9929 u8 key_index,
9930 const u8 *mac_addr
9931 )
9932#endif
9933{
9934 int status = 0;
9935
9936 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309937 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009938 //it is observed that this is invalidating peer
9939 //key index whenever re-key is done. This is affecting data link.
9940 //It should be ok to ignore del_key.
9941#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309942 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
9943 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009944 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
9945 tCsrRoamSetKey setKey;
9946 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309947
Jeff Johnson295189b2012-06-20 16:38:30 -07009948 ENTER();
9949
9950 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
9951 __func__,pAdapter->device_mode);
9952
9953 if (CSR_MAX_NUM_KEY <= key_index)
9954 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309955 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009956 key_index);
9957
9958 return -EINVAL;
9959 }
9960
9961 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9962 setKey.keyId = key_index;
9963
9964 if (mac_addr)
9965 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9966 else
9967 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
9968
9969 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
9970
9971 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009972 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309973 )
9974 {
9975
9976 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07009977 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9978 if( pHostapdState->bssState == BSS_START)
9979 {
9980 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309981
Jeff Johnson295189b2012-06-20 16:38:30 -07009982 if ( status != eHAL_STATUS_SUCCESS )
9983 {
9984 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9985 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9986 __LINE__, status );
9987 }
9988 }
9989 }
9990 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309991 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07009992 )
9993 {
9994 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9995
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309996 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9997
9998 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009999 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010000 __func__, setKey.peerMac[0], setKey.peerMac[1],
10001 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -070010002 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010003 if(pAdapter->sessionCtx.station.conn_info.connState ==
10004 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -070010005 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010006 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070010007 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010008
Jeff Johnson295189b2012-06-20 16:38:30 -070010009 if ( 0 != status )
10010 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010011 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010012 "%s: sme_RoamSetKey failure, returned %d",
10013 __func__, status);
10014 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
10015 return -EINVAL;
10016 }
10017 }
10018 }
10019#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070010020 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010021 return status;
10022}
10023
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053010024#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
10025static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
10026 struct net_device *ndev,
10027 u8 key_index,
10028 bool pairwise,
10029 const u8 *mac_addr
10030 )
10031#else
10032static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
10033 struct net_device *ndev,
10034 u8 key_index,
10035 const u8 *mac_addr
10036 )
10037#endif
10038{
10039 int ret;
10040
10041 vos_ssr_protect(__func__);
10042#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
10043 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
10044 mac_addr);
10045#else
10046 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
10047#endif
10048 vos_ssr_unprotect(__func__);
10049
10050 return ret;
10051}
10052
Jeff Johnson295189b2012-06-20 16:38:30 -070010053/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053010054 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -070010055 * This function is used to set the default tx key index
10056 */
10057#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053010058static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010059 struct net_device *ndev,
10060 u8 key_index,
10061 bool unicast, bool multicast)
10062#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053010063static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010064 struct net_device *ndev,
10065 u8 key_index)
10066#endif
10067{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010068 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010069 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +053010070 hdd_wext_state_t *pWextState;
10071 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010072 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010073
10074 ENTER();
10075
Gopichand Nakkala29149562013-05-10 21:43:41 +053010076 if ((NULL == pAdapter))
10077 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +053010079 "invalid adapter");
10080 return -EINVAL;
10081 }
10082
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010083 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10084 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
10085 pAdapter->sessionId, key_index));
10086
Gopichand Nakkala29149562013-05-10 21:43:41 +053010087 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10088 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10089
10090 if ((NULL == pWextState) || (NULL == pHddStaCtx))
10091 {
10092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10093 "invalid Wext state or HDD context");
10094 return -EINVAL;
10095 }
10096
Arif Hussain6d2a3322013-11-17 19:50:10 -080010097 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010099
Jeff Johnson295189b2012-06-20 16:38:30 -070010100 if (CSR_MAX_NUM_KEY <= key_index)
10101 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010102 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010103 key_index);
10104
10105 return -EINVAL;
10106 }
10107
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010108 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10109 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010110 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010111 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010112 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010113 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010114
Jeff Johnson295189b2012-06-20 16:38:30 -070010115 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -070010116 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010117 )
Jeff Johnson295189b2012-06-20 16:38:30 -070010118 {
Gopichand Nakkala29149562013-05-10 21:43:41 +053010119 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -080010120 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010121 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -080010122 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -070010123 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010124 {
10125 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -070010126 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010127
Jeff Johnson295189b2012-06-20 16:38:30 -070010128 tCsrRoamSetKey setKey;
10129 v_U32_t roamId= 0xFF;
10130 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010131
10132 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010133 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010134
Jeff Johnson295189b2012-06-20 16:38:30 -070010135 Keys->defaultIndex = (u8)key_index;
10136 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
10137 setKey.keyId = key_index;
10138 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010139
10140 vos_mem_copy(&setKey.Key[0],
10141 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070010142 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010143
Gopichand Nakkala29149562013-05-10 21:43:41 +053010144 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010145
10146 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -070010147 &pHddStaCtx->conn_info.bssId[0],
10148 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010149
Gopichand Nakkala29149562013-05-10 21:43:41 +053010150 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
10151 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
10152 eCSR_ENCRYPT_TYPE_WEP104)
10153 {
10154 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
10155 even though ap is configured for WEP-40 encryption. In this canse the key length
10156 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
10157 type(104) and switching encryption type to 40*/
10158 pWextState->roamProfile.EncryptionType.encryptionType[0] =
10159 eCSR_ENCRYPT_TYPE_WEP40;
10160 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
10161 eCSR_ENCRYPT_TYPE_WEP40;
10162 }
10163
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010164 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -070010165 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010166
Jeff Johnson295189b2012-06-20 16:38:30 -070010167 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010168 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070010169 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010170
Jeff Johnson295189b2012-06-20 16:38:30 -070010171 if ( 0 != status )
10172 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010173 hddLog(VOS_TRACE_LEVEL_ERROR,
10174 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010175 status);
10176 return -EINVAL;
10177 }
10178 }
10179 }
10180
10181 /* In SoftAp mode setting key direction for default mode */
10182 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
10183 {
10184 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
10185 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
10186 (eCSR_ENCRYPT_TYPE_AES !=
10187 pWextState->roamProfile.EncryptionType.encryptionType[0])
10188 )
10189 {
10190 /* Saving key direction for default key index to TX default */
10191 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
10192 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
10193 }
10194 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010195 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010196 return status;
10197}
10198
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +053010199#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
10200static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
10201 struct net_device *ndev,
10202 u8 key_index,
10203 bool unicast, bool multicast)
10204#else
10205static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
10206 struct net_device *ndev,
10207 u8 key_index)
10208#endif
10209{
10210 int ret;
10211 vos_ssr_protect(__func__);
10212#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
10213 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
10214 multicast);
10215#else
10216 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
10217#endif
10218 vos_ssr_unprotect(__func__);
10219
10220 return ret;
10221}
10222
Jeff Johnson295189b2012-06-20 16:38:30 -070010223/*
10224 * FUNCTION: wlan_hdd_cfg80211_inform_bss
10225 * This function is used to inform the BSS details to nl80211 interface.
10226 */
10227static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
10228 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
10229{
10230 struct net_device *dev = pAdapter->dev;
10231 struct wireless_dev *wdev = dev->ieee80211_ptr;
10232 struct wiphy *wiphy = wdev->wiphy;
10233 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
10234 int chan_no;
10235 int ie_length;
10236 const char *ie;
10237 unsigned int freq;
10238 struct ieee80211_channel *chan;
10239 int rssi = 0;
10240 struct cfg80211_bss *bss = NULL;
10241
Jeff Johnson295189b2012-06-20 16:38:30 -070010242 if( NULL == pBssDesc )
10243 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010244 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010245 return bss;
10246 }
10247
10248 chan_no = pBssDesc->channelId;
10249 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
10250 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
10251
10252 if( NULL == ie )
10253 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010254 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010255 return bss;
10256 }
10257
10258#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
10259 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
10260 {
10261 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
10262 }
10263 else
10264 {
10265 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
10266 }
10267#else
10268 freq = ieee80211_channel_to_frequency(chan_no);
10269#endif
10270
10271 chan = __ieee80211_get_channel(wiphy, freq);
10272
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +053010273 if (!chan) {
10274 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
10275 return NULL;
10276 }
10277
Abhishek Singhaee43942014-06-16 18:55:47 +053010278 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -070010279
Anand N Sunkad9f80b742015-07-30 20:05:51 +053010280 return cfg80211_inform_bss(wiphy, chan,
10281#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
10282 CFG80211_BSS_FTYPE_UNKNOWN,
10283#endif
10284 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010285 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -070010286 pBssDesc->capabilityInfo,
10287 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +053010288 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -070010289}
10290
10291
10292
10293/*
10294 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
10295 * This function is used to inform the BSS details to nl80211 interface.
10296 */
10297struct cfg80211_bss*
10298wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
10299 tSirBssDescription *bss_desc
10300 )
10301{
10302 /*
10303 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
10304 already exists in bss data base of cfg80211 for that particular BSS ID.
10305 Using cfg80211_inform_bss_frame to update the bss entry instead of
10306 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
10307 now there is no possibility to get the mgmt(probe response) frame from PE,
10308 converting bss_desc to ieee80211_mgmt(probe response) and passing to
10309 cfg80211_inform_bss_frame.
10310 */
10311 struct net_device *dev = pAdapter->dev;
10312 struct wireless_dev *wdev = dev->ieee80211_ptr;
10313 struct wiphy *wiphy = wdev->wiphy;
10314 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080010315#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
10316 qcom_ie_age *qie_age = NULL;
10317 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
10318#else
Jeff Johnson295189b2012-06-20 16:38:30 -070010319 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080010320#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010321 const char *ie =
10322 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
10323 unsigned int freq;
10324 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053010325 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010326 struct cfg80211_bss *bss_status = NULL;
10327 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
10328 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070010329 hdd_context_t *pHddCtx;
10330 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070010331#ifdef WLAN_OPEN_SOURCE
10332 struct timespec ts;
10333#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010334
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010335
Wilson Yangf80a0542013-10-07 13:02:37 -070010336 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10337 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070010338 if (0 != status)
10339 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070010340 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070010341 }
10342
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053010343 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070010344 if (!mgmt)
10345 {
10346 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10347 "%s: memory allocation failed ", __func__);
10348 return NULL;
10349 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070010350
Jeff Johnson295189b2012-06-20 16:38:30 -070010351 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070010352
10353#ifdef WLAN_OPEN_SOURCE
10354 /* Android does not want the timestamp from the frame.
10355 Instead it wants a monotonic increasing value */
10356 get_monotonic_boottime(&ts);
10357 mgmt->u.probe_resp.timestamp =
10358 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
10359#else
10360 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070010361 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
10362 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070010363
10364#endif
10365
Jeff Johnson295189b2012-06-20 16:38:30 -070010366 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
10367 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080010368
10369#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
10370 /* GPS Requirement: need age ie per entry. Using vendor specific. */
10371 /* Assuming this is the last IE, copy at the end */
10372 ie_length -=sizeof(qcom_ie_age);
10373 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
10374 qie_age->element_id = QCOM_VENDOR_IE_ID;
10375 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
10376 qie_age->oui_1 = QCOM_OUI1;
10377 qie_age->oui_2 = QCOM_OUI2;
10378 qie_age->oui_3 = QCOM_OUI3;
10379 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
10380 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
10381#endif
10382
Jeff Johnson295189b2012-06-20 16:38:30 -070010383 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053010384 if (bss_desc->fProbeRsp)
10385 {
10386 mgmt->frame_control |=
10387 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
10388 }
10389 else
10390 {
10391 mgmt->frame_control |=
10392 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
10393 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010394
10395#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010396 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070010397 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
10398 {
10399 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
10400 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010401 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070010402 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
10403
10404 {
10405 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
10406 }
10407 else
10408 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010409 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
10410 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070010411 kfree(mgmt);
10412 return NULL;
10413 }
10414#else
10415 freq = ieee80211_channel_to_frequency(chan_no);
10416#endif
10417 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080010418 /*when the band is changed on the fly using the GUI, three things are done
10419 * 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)
10420 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
10421 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
10422 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
10423 * and discards the channels correponding to previous band and calls back with zero bss results.
10424 * 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
10425 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
10426 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
10427 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
10428 * So drop the bss and continue to next bss.
10429 */
10430 if(chan == NULL)
10431 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010432 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -070010433 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080010434 return NULL;
10435 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053010436 /*To keep the rssi icon of the connected AP in the scan window
10437 *and the rssi icon of the wireless networks in sync
10438 * */
10439 if (( eConnectionState_Associated ==
10440 pAdapter->sessionCtx.station.conn_info.connState ) &&
10441 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
10442 pAdapter->sessionCtx.station.conn_info.bssId,
10443 WNI_CFG_BSSID_LEN)) &&
10444 (pHddCtx->hdd_wlan_suspended == FALSE))
10445 {
10446 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
10447 rssi = (pAdapter->rssi * 100);
10448 }
10449 else
10450 {
10451 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
10452 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010453
Nirav Shah20ac06f2013-12-12 18:14:06 +053010454 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053010455 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
10456 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053010457
Jeff Johnson295189b2012-06-20 16:38:30 -070010458 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
10459 frame_len, rssi, GFP_KERNEL);
10460 kfree(mgmt);
10461 return bss_status;
10462}
10463
10464/*
10465 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
10466 * This function is used to update the BSS data base of CFG8011
10467 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010468struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070010469 tCsrRoamInfo *pRoamInfo
10470 )
10471{
10472 tCsrRoamConnectedProfile roamProfile;
10473 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10474 struct cfg80211_bss *bss = NULL;
10475
10476 ENTER();
10477
10478 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
10479 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
10480
10481 if (NULL != roamProfile.pBssDesc)
10482 {
Girish Gowlif4b68022014-08-28 23:18:57 +053010483 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10484 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010485
10486 if (NULL == bss)
10487 {
10488 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
10489 __func__);
10490 }
10491
10492 sme_RoamFreeConnectProfile(hHal, &roamProfile);
10493 }
10494 else
10495 {
10496 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
10497 __func__);
10498 }
10499 return bss;
10500}
10501
10502/*
10503 * FUNCTION: wlan_hdd_cfg80211_update_bss
10504 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010505static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
10506 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070010507 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010508{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010509 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010510 tCsrScanResultInfo *pScanResult;
10511 eHalStatus status = 0;
10512 tScanResultHandle pResult;
10513 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070010514 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010515 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070010516 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010517
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010518 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10519 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
10520 NO_SESSION, pAdapter->sessionId));
10521
Wilson Yangf80a0542013-10-07 13:02:37 -070010522 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10523
10524 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -070010525 {
Wilson Yangf80a0542013-10-07 13:02:37 -070010526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10527 "%s:LOGP in Progress. Ignore!!!",__func__);
10528 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010529 }
10530
Wilson Yangf80a0542013-10-07 13:02:37 -070010531
10532 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +053010533 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -070010534 {
10535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10536 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
10537 return VOS_STATUS_E_PERM;
10538 }
10539
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010540 if (pAdapter->request != NULL)
10541 {
10542 if ((pAdapter->request->n_ssids == 1)
10543 && (pAdapter->request->ssids != NULL)
10544 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
10545 is_p2p_scan = true;
10546 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010547 /*
10548 * start getting scan results and populate cgf80211 BSS database
10549 */
10550 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
10551
10552 /* no scan results */
10553 if (NULL == pResult)
10554 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010555 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
10556 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053010557 wlan_hdd_get_frame_logs(pAdapter,
10558 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070010559 return status;
10560 }
10561
10562 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
10563
10564 while (pScanResult)
10565 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010566 /*
10567 * cfg80211_inform_bss() is not updating ie field of bss entry, if
10568 * entry already exists in bss data base of cfg80211 for that
10569 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
10570 * bss entry instead of cfg80211_inform_bss, But this call expects
10571 * mgmt packet as input. As of now there is no possibility to get
10572 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070010573 * ieee80211_mgmt(probe response) and passing to c
10574 * fg80211_inform_bss_frame.
10575 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010576 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
10577 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
10578 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010579 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10580 continue; //Skip the non p2p bss entries
10581 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010582 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10583 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010584
Jeff Johnson295189b2012-06-20 16:38:30 -070010585
10586 if (NULL == bss_status)
10587 {
10588 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010589 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010590 }
10591 else
10592 {
Yue Maf49ba872013-08-19 12:04:25 -070010593 cfg80211_put_bss(
10594#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10595 wiphy,
10596#endif
10597 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010598 }
10599
10600 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10601 }
10602
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010603 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010604 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010605 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010606}
10607
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010608void
10609hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
10610{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010611 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080010612 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010613} /****** end hddPrintMacAddr() ******/
10614
10615void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010616hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010617{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010618 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010619 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010620 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
10621 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
10622 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010623} /****** end hddPrintPmkId() ******/
10624
10625//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
10626//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
10627
10628//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
10629//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
10630
10631#define dump_bssid(bssid) \
10632 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010633 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
10634 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010635 }
10636
10637#define dump_pmkid(pMac, pmkid) \
10638 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010639 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
10640 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010641 }
10642
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070010643#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010644/*
10645 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
10646 * This function is used to notify the supplicant of a new PMKSA candidate.
10647 */
10648int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010649 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010650 int index, bool preauth )
10651{
Jeff Johnsone7245742012-09-05 17:12:55 -070010652#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010653 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010654 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010655
10656 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070010657 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010658
10659 if( NULL == pRoamInfo )
10660 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010661 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010662 return -EINVAL;
10663 }
10664
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010665 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
10666 {
10667 dump_bssid(pRoamInfo->bssid);
10668 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010669 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010670 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010671#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010672 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010673}
10674#endif //FEATURE_WLAN_LFR
10675
Yue Maef608272013-04-08 23:09:17 -070010676#ifdef FEATURE_WLAN_LFR_METRICS
10677/*
10678 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
10679 * 802.11r/LFR metrics reporting function to report preauth initiation
10680 *
10681 */
10682#define MAX_LFR_METRICS_EVENT_LENGTH 100
10683VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
10684 tCsrRoamInfo *pRoamInfo)
10685{
10686 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10687 union iwreq_data wrqu;
10688
10689 ENTER();
10690
10691 if (NULL == pAdapter)
10692 {
10693 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10694 return VOS_STATUS_E_FAILURE;
10695 }
10696
10697 /* create the event */
10698 memset(&wrqu, 0, sizeof(wrqu));
10699 memset(metrics_notification, 0, sizeof(metrics_notification));
10700
10701 wrqu.data.pointer = metrics_notification;
10702 wrqu.data.length = scnprintf(metrics_notification,
10703 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
10704 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10705
10706 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10707
10708 EXIT();
10709
10710 return VOS_STATUS_SUCCESS;
10711}
10712
10713/*
10714 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
10715 * 802.11r/LFR metrics reporting function to report preauth completion
10716 * or failure
10717 */
10718VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
10719 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
10720{
10721 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10722 union iwreq_data wrqu;
10723
10724 ENTER();
10725
10726 if (NULL == pAdapter)
10727 {
10728 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10729 return VOS_STATUS_E_FAILURE;
10730 }
10731
10732 /* create the event */
10733 memset(&wrqu, 0, sizeof(wrqu));
10734 memset(metrics_notification, 0, sizeof(metrics_notification));
10735
10736 scnprintf(metrics_notification, sizeof(metrics_notification),
10737 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
10738 MAC_ADDR_ARRAY(pRoamInfo->bssid));
10739
10740 if (1 == preauth_status)
10741 strncat(metrics_notification, " TRUE", 5);
10742 else
10743 strncat(metrics_notification, " FALSE", 6);
10744
10745 wrqu.data.pointer = metrics_notification;
10746 wrqu.data.length = strlen(metrics_notification);
10747
10748 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10749
10750 EXIT();
10751
10752 return VOS_STATUS_SUCCESS;
10753}
10754
10755/*
10756 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
10757 * 802.11r/LFR metrics reporting function to report handover initiation
10758 *
10759 */
10760VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
10761 tCsrRoamInfo *pRoamInfo)
10762{
10763 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10764 union iwreq_data wrqu;
10765
10766 ENTER();
10767
10768 if (NULL == pAdapter)
10769 {
10770 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10771 return VOS_STATUS_E_FAILURE;
10772 }
10773
10774 /* create the event */
10775 memset(&wrqu, 0, sizeof(wrqu));
10776 memset(metrics_notification, 0, sizeof(metrics_notification));
10777
10778 wrqu.data.pointer = metrics_notification;
10779 wrqu.data.length = scnprintf(metrics_notification,
10780 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
10781 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10782
10783 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10784
10785 EXIT();
10786
10787 return VOS_STATUS_SUCCESS;
10788}
10789#endif
10790
Jeff Johnson295189b2012-06-20 16:38:30 -070010791/*
10792 * FUNCTION: hdd_cfg80211_scan_done_callback
10793 * scanning callback function, called after finishing scan
10794 *
10795 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010796static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070010797 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
10798{
10799 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010800 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070010801 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010802 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010803 struct cfg80211_scan_request *req = NULL;
10804 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010805 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010806 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010807 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010808 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010809
10810 ENTER();
10811
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010812 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053010813 if (NULL == pHddCtx) {
10814 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010815 goto allow_suspend;
10816 }
10817
10818 pScanInfo = &pHddCtx->scan_info;
10819
Jeff Johnson295189b2012-06-20 16:38:30 -070010820 hddLog(VOS_TRACE_LEVEL_INFO,
10821 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080010822 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010823 __func__, halHandle, pContext, (int) scanId, (int) status);
10824
Kiet Lamac06e2c2013-10-23 16:25:07 +053010825 pScanInfo->mScanPendingCounter = 0;
10826
Jeff Johnson295189b2012-06-20 16:38:30 -070010827 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010828 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070010829 &pScanInfo->scan_req_completion_event,
10830 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010831 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070010832 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010833 hddLog(VOS_TRACE_LEVEL_ERROR,
10834 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070010835 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010836 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010837 }
10838
Yue Maef608272013-04-08 23:09:17 -070010839 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010840 {
10841 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010842 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010843 }
10844
10845 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010846 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070010847 {
10848 hddLog(VOS_TRACE_LEVEL_INFO,
10849 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010850 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070010851 (int) scanId);
10852 }
10853
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010854 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010855 pAdapter);
10856
10857 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010858 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010859
10860
10861 /* If any client wait scan result through WEXT
10862 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010863 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070010864 {
10865 /* The other scan request waiting for current scan finish
10866 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010867 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010868 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010869 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070010870 }
10871 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010872 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010873 {
10874 struct net_device *dev = pAdapter->dev;
10875 union iwreq_data wrqu;
10876 int we_event;
10877 char *msg;
10878
10879 memset(&wrqu, '\0', sizeof(wrqu));
10880 we_event = SIOCGIWSCAN;
10881 msg = NULL;
10882 wireless_send_event(dev, we_event, &wrqu, msg);
10883 }
10884 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010885 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010886
10887 /* Get the Scan Req */
10888 req = pAdapter->request;
10889
10890 if (!req)
10891 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010892 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010893 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010894 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010895 }
10896
Jeff Johnson295189b2012-06-20 16:38:30 -070010897 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070010898 /* Scan is no longer pending */
10899 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010900
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010901 /* last_scan_timestamp is used to decide if new scan
10902 * is needed or not on station interface. If last station
10903 * scan time and new station scan time is less then
10904 * last_scan_timestamp ; driver will return cached scan.
10905 */
10906 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
10907 {
10908 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
10909
10910 if ( req->n_channels )
10911 {
10912 for (i = 0; i < req->n_channels ; i++ )
10913 {
10914 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
10915 }
10916 /* store no of channel scanned */
10917 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
10918 }
10919
10920 }
10921
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070010922 /*
10923 * cfg80211_scan_done informing NL80211 about completion
10924 * of scanning
10925 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010926 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
10927 {
10928 aborted = true;
10929 }
10930 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080010931 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070010932
Siddharth Bhal76972212014-10-15 16:22:51 +053010933 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
10934 /* Generate new random mac addr for next scan */
10935 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
10936 hdd_processSpoofMacAddrRequest(pHddCtx);
10937 }
10938
Jeff Johnsone7245742012-09-05 17:12:55 -070010939allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010940 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010941 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070010942
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010943 /* Acquire wakelock to handle the case where APP's tries to suspend
10944 * immediatly after the driver gets connect request(i.e after scan)
10945 * from supplicant, this result in app's is suspending and not able
10946 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010947 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010948
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010949#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010950 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010951#endif
10952
Jeff Johnson295189b2012-06-20 16:38:30 -070010953 EXIT();
10954 return 0;
10955}
10956
10957/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053010958 * FUNCTION: hdd_isConnectionInProgress
10959 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010960 *
10961 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010962v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010963{
10964 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10965 hdd_station_ctx_t *pHddStaCtx = NULL;
10966 hdd_adapter_t *pAdapter = NULL;
10967 VOS_STATUS status = 0;
10968 v_U8_t staId = 0;
10969 v_U8_t *staMac = NULL;
10970
c_hpothu9b781ba2013-12-30 20:57:45 +053010971 if (TRUE == pHddCtx->btCoexModeSet)
10972 {
10973 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053010974 FL("BTCoex Mode operation in progress"));
10975 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053010976 }
10977
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010978 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10979
10980 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10981 {
10982 pAdapter = pAdapterNode->pAdapter;
10983
10984 if( pAdapter )
10985 {
10986 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010987 "%s: Adapter with device mode %s (%d) exists",
10988 __func__, hdd_device_modetoString(pAdapter->device_mode),
10989 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010990 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053010991 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10992 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
10993 (eConnectionState_Connecting ==
10994 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
10995 {
10996 hddLog(VOS_TRACE_LEVEL_ERROR,
10997 "%s: %p(%d) Connection is in progress", __func__,
10998 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10999 return VOS_TRUE;
11000 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053011001 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053011002 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053011003 {
11004 hddLog(VOS_TRACE_LEVEL_ERROR,
11005 "%s: %p(%d) Reassociation is in progress", __func__,
11006 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
11007 return VOS_TRUE;
11008 }
11009 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011010 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
11011 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080011012 {
11013 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11014 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011015 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080011016 {
11017 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
11018 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080011019 "%s: client " MAC_ADDRESS_STR
11020 " is in the middle of WPS/EAPOL exchange.", __func__,
11021 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053011022 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080011023 }
11024 }
11025 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
11026 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
11027 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053011028 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
11029 ptSapContext pSapCtx = NULL;
11030 pSapCtx = VOS_GET_SAP_CB(pVosContext);
11031 if(pSapCtx == NULL){
11032 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11033 FL("psapCtx is NULL"));
11034 return VOS_FALSE;
11035 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080011036 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
11037 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053011038 if ((pSapCtx->aStaInfo[staId].isUsed) &&
11039 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080011040 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053011041 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080011042
11043 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080011044 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
11045 "middle of WPS/EAPOL exchange.", __func__,
11046 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053011047 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080011048 }
11049 }
11050 }
11051 }
11052 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
11053 pAdapterNode = pNext;
11054 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053011055 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011056}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080011057
11058/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011059 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070011060 * this scan respond to scan trigger and update cfg80211 scan database
11061 * later, scan dump command can be used to recieve scan results
11062 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011063int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080011064#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11065 struct net_device *dev,
11066#endif
11067 struct cfg80211_scan_request *request)
11068{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053011069 hdd_adapter_t *pAdapter = NULL;
11070 hdd_context_t *pHddCtx = NULL;
11071 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011072 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011073 tCsrScanRequest scanRequest;
11074 tANI_U8 *channelList = NULL, i;
11075 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011076 int status;
11077 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011078 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011079 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053011080 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053011081 bool is_p2p_scan = false;
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053011082 v_S7_t rssi=0;
11083 hdd_station_ctx_t *pHddStaCtx=NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011084
Siddharth Bhal0c162d02014-05-06 19:50:42 +053011085#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
11086 struct net_device *dev = NULL;
11087 if (NULL == request)
11088 {
11089 hddLog(VOS_TRACE_LEVEL_ERROR,
11090 "%s: scan req param null", __func__);
11091 return -EINVAL;
11092 }
11093 dev = request->wdev->netdev;
11094#endif
11095
11096 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
11097 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
11098 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11099
Jeff Johnson295189b2012-06-20 16:38:30 -070011100 ENTER();
11101
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011102 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
11103 __func__, hdd_device_modetoString(pAdapter->device_mode),
11104 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011105
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011106 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011107 if (0 != status)
11108 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011109 return status;
11110 }
11111
Siddharth Bhal0c162d02014-05-06 19:50:42 +053011112 if (NULL == pwextBuf)
11113 {
11114 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
11115 __func__);
11116 return -EIO;
11117 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011118 cfg_param = pHddCtx->cfg_ini;
11119 pScanInfo = &pHddCtx->scan_info;
11120
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053011121 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11122 if ( (pHddStaCtx != NULL) && (TRUE == hdd_connIsConnected(pHddStaCtx)))
11123 {
11124 wlan_hdd_get_roam_rssi(pAdapter, &rssi);
11125 hddLog(VOS_TRACE_LEVEL_INFO, FL("rssi: %d"), rssi);
11126 }
11127
Jeff Johnson295189b2012-06-20 16:38:30 -070011128#ifdef WLAN_BTAMP_FEATURE
11129 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011130 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070011131 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080011132 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011133 "%s: No scanning when AMP is on", __func__);
11134 return -EOPNOTSUPP;
11135 }
11136#endif
11137 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011138 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070011139 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011140 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011141 "%s: Not scanning on device_mode = %s (%d)",
11142 __func__, hdd_device_modetoString(pAdapter->device_mode),
11143 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070011144 return -EOPNOTSUPP;
11145 }
11146
11147 if (TRUE == pScanInfo->mScanPending)
11148 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053011149 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
11150 {
11151 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
11152 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011153 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070011154 }
11155
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053011156 // Don't allow scan if PNO scan is going on.
11157 if (pHddCtx->isPnoEnable)
11158 {
11159 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11160 FL("pno scan in progress"));
11161 return -EBUSY;
11162 }
11163
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011164 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070011165 //Channel and action frame is pending
11166 //Otherwise Cancel Remain On Channel and allow Scan
11167 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011168 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070011169 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053011170 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070011171 return -EBUSY;
11172 }
11173
Jeff Johnson295189b2012-06-20 16:38:30 -070011174 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
11175 {
11176 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080011177 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011178 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011179 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011180 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
11181 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053011182 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011183 "%s: MAX TM Level Scan not allowed", __func__);
11184 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011185 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070011186 }
11187 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
11188
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080011189 /* Check if scan is allowed at this point of time.
11190 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053011191 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080011192 {
11193 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
11194 return -EBUSY;
11195 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011196
Jeff Johnson295189b2012-06-20 16:38:30 -070011197 vos_mem_zero( &scanRequest, sizeof(scanRequest));
11198
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011199 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
11200 * Becasue of this, driver is assuming that this is not wildcard scan and so
11201 * is not aging out the scan results.
11202 */
11203 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070011204 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011205 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011206 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011207
11208 if ((request->ssids) && (0 < request->n_ssids))
11209 {
11210 tCsrSSIDInfo *SsidInfo;
11211 int j;
11212 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
11213 /* Allocate num_ssid tCsrSSIDInfo structure */
11214 SsidInfo = scanRequest.SSIDs.SSIDList =
11215 ( tCsrSSIDInfo *)vos_mem_malloc(
11216 request->n_ssids*sizeof(tCsrSSIDInfo));
11217
11218 if(NULL == scanRequest.SSIDs.SSIDList)
11219 {
11220 hddLog(VOS_TRACE_LEVEL_ERROR,
11221 "%s: memory alloc failed SSIDInfo buffer", __func__);
11222 return -ENOMEM;
11223 }
11224
11225 /* copy all the ssid's and their length */
11226 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
11227 {
11228 /* get the ssid length */
11229 SsidInfo->SSID.length = request->ssids[j].ssid_len;
11230 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
11231 SsidInfo->SSID.length);
11232 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
11233 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
11234 j, SsidInfo->SSID.ssId);
11235 }
11236 /* set the scan type to active */
11237 scanRequest.scanType = eSIR_ACTIVE_SCAN;
11238 }
11239 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070011240 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053011241 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11242 TRACE_CODE_HDD_CFG80211_SCAN,
11243 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070011244 /* set the scan type to active */
11245 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070011246 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011247 else
11248 {
11249 /*Set the scan type to default type, in this case it is ACTIVE*/
11250 scanRequest.scanType = pScanInfo->scan_mode;
11251 }
11252 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
11253 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070011254
11255 /* set BSSType to default type */
11256 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
11257
11258 /*TODO: scan the requested channels only*/
11259
11260 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011261 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070011262 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011263 hddLog(VOS_TRACE_LEVEL_WARN,
11264 "No of Scan Channels exceeded limit: %d", request->n_channels);
11265 request->n_channels = MAX_CHANNEL;
11266 }
11267
11268 hddLog(VOS_TRACE_LEVEL_INFO,
11269 "No of Scan Channels: %d", request->n_channels);
11270
11271
11272 if( request->n_channels )
11273 {
11274 char chList [(request->n_channels*5)+1];
11275 int len;
11276 channelList = vos_mem_malloc( request->n_channels );
11277 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053011278 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011279 hddLog(VOS_TRACE_LEVEL_ERROR,
11280 "%s: memory alloc failed channelList", __func__);
11281 status = -ENOMEM;
11282 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053011283 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011284
11285 for( i = 0, len = 0; i < request->n_channels ; i++ )
11286 {
11287 channelList[i] = request->channels[i]->hw_value;
11288 len += snprintf(chList+len, 5, "%d ", channelList[i]);
11289 }
11290
Nirav Shah20ac06f2013-12-12 18:14:06 +053011291 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011292 "Channel-List: %s ", chList);
11293 }
c_hpothu53512302014-04-15 18:49:53 +053011294
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011295 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
11296 scanRequest.ChannelInfo.ChannelList = channelList;
11297
11298 /* set requestType to full scan */
11299 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
11300
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011301 /* if there is back to back scan happening in driver with in
11302 * nDeferScanTimeInterval interval driver should defer new scan request
11303 * and should provide last cached scan results instead of new channel list.
11304 * This rule is not applicable if scan is p2p scan.
11305 * This condition will work only in case when last request no of channels
11306 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053011307 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053011308 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011309 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011310
Sushant Kaushik86592172015-04-27 16:35:03 +053011311 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
11312 /* if wps ie is NULL , then only defer scan */
11313 if ( pWpsIe == NULL &&
11314 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053011315 {
11316 if ( pScanInfo->last_scan_timestamp !=0 &&
11317 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
11318 {
11319 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
11320 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
11321 vos_mem_compare(pScanInfo->last_scan_channelList,
11322 channelList, pScanInfo->last_scan_numChannels))
11323 {
11324 hddLog(VOS_TRACE_LEVEL_WARN,
11325 " New and old station scan time differ is less then %u",
11326 pHddCtx->cfg_ini->nDeferScanTimeInterval);
11327
11328 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011329 pAdapter);
11330
Agarwal Ashish57e84372014-12-05 18:26:53 +053011331 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053011332 "Return old cached scan as all channels and no of channels are same");
11333
Agarwal Ashish57e84372014-12-05 18:26:53 +053011334 if (0 > ret)
11335 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011336
Agarwal Ashish57e84372014-12-05 18:26:53 +053011337 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053011338
11339 status = eHAL_STATUS_SUCCESS;
11340 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053011341 }
11342 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011343 }
11344
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011345 /* Flush the scan results(only p2p beacons) for STA scan and P2P
11346 * search (Flush on both full scan and social scan but not on single
11347 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
11348 */
11349
11350 /* Supplicant does single channel scan after 8-way handshake
11351 * and in that case driver shoudnt flush scan results. If
11352 * driver flushes the scan results here and unfortunately if
11353 * the AP doesnt respond to our probe req then association
11354 * fails which is not desired
11355 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053011356 if ((request->n_ssids == 1)
11357 && (request->ssids != NULL)
11358 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
11359 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011360
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053011361 if( is_p2p_scan ||
11362 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011363 {
11364 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
11365 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
11366 pAdapter->sessionId );
11367 }
11368
11369 if( request->ie_len )
11370 {
11371 /* save this for future association (join requires this) */
11372 /*TODO: Array needs to be converted to dynamic allocation,
11373 * as multiple ie.s can be sent in cfg80211_scan_request structure
11374 * CR 597966
11375 */
11376 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
11377 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
11378 pScanInfo->scanAddIE.length = request->ie_len;
11379
11380 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11381 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
11382 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070011383 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011384 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070011385 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011386 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
11387 memcpy( pwextBuf->roamProfile.addIEScan,
11388 request->ie, request->ie_len);
11389 }
11390 else
11391 {
11392 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
11393 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070011394 }
11395
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011396 }
11397 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
11398 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
11399
11400 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
11401 request->ie_len);
11402 if (pP2pIe != NULL)
11403 {
11404#ifdef WLAN_FEATURE_P2P_DEBUG
11405 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
11406 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
11407 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053011408 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011409 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
11410 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
11411 "Go nego completed to Connection is started");
11412 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
11413 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053011414 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011415 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
11416 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070011417 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011418 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
11419 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
11420 "Disconnected state to Connection is started");
11421 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
11422 "for 4way Handshake");
11423 }
11424#endif
11425
11426 /* no_cck will be set during p2p find to disable 11b rates */
11427 if(TRUE == request->no_cck)
11428 {
11429 hddLog(VOS_TRACE_LEVEL_INFO,
11430 "%s: This is a P2P Search", __func__);
11431 scanRequest.p2pSearch = 1;
11432
11433 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053011434 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011435 /* set requestType to P2P Discovery */
11436 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
11437 }
11438
11439 /*
11440 Skip Dfs Channel in case of P2P Search
11441 if it is set in ini file
11442 */
11443 if(cfg_param->skipDfsChnlInP2pSearch)
11444 {
11445 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053011446 }
11447 else
11448 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011449 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053011450 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011451
Agarwal Ashish4f616132013-12-30 23:32:50 +053011452 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011453 }
11454 }
11455
11456 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
11457
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053011458#ifdef FEATURE_WLAN_TDLS
11459 /* if tdls disagree scan right now, return immediately.
11460 tdls will schedule the scan when scan is allowed. (return SUCCESS)
11461 or will reject the scan if any TDLS is in progress. (return -EBUSY)
11462 */
11463 status = wlan_hdd_tdls_scan_callback (pAdapter,
11464 wiphy,
11465#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11466 dev,
11467#endif
11468 request);
11469 if(status <= 0)
11470 {
11471 if(!status)
11472 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
11473 "scan rejected %d", __func__, status);
11474 else
11475 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
11476 __func__, status);
11477
11478 return status;
11479 }
11480#endif
11481
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070011482 /* acquire the wakelock to avoid the apps suspend during the scan. To
11483 * address the following issues.
11484 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
11485 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
11486 * for long time, this result in apps running at full power for long time.
11487 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
11488 * be stuck in full power because of resume BMPS
11489 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011490 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070011491
Nirav Shah20ac06f2013-12-12 18:14:06 +053011492 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
11493 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011494 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
11495 scanRequest.requestType, scanRequest.scanType,
11496 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053011497 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
11498
Siddharth Bhal76972212014-10-15 16:22:51 +053011499 if (pHddCtx->spoofMacAddr.isEnabled)
11500 {
11501 hddLog(VOS_TRACE_LEVEL_INFO,
11502 "%s: MAC Spoofing enabled for current scan", __func__);
11503 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
11504 * to fill TxBds for probe request during current scan
11505 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011506 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053011507 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011508
11509 if(status != VOS_STATUS_SUCCESS)
11510 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011511 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011512 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053011513#ifdef FEATURE_WLAN_TDLS
11514 wlan_hdd_tdls_scan_done_callback(pAdapter);
11515#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011516 goto free_mem;
11517 }
Siddharth Bhal76972212014-10-15 16:22:51 +053011518 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053011519 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070011520 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011521 pAdapter->sessionId, &scanRequest, &scanId,
11522 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070011523
Jeff Johnson295189b2012-06-20 16:38:30 -070011524 if (eHAL_STATUS_SUCCESS != status)
11525 {
11526 hddLog(VOS_TRACE_LEVEL_ERROR,
11527 "%s: sme_ScanRequest returned error %d", __func__, status);
11528 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011529 if(eHAL_STATUS_RESOURCES == status)
11530 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053011531 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
11532 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011533 status = -EBUSY;
11534 } else {
11535 status = -EIO;
11536 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011537 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053011538
11539#ifdef FEATURE_WLAN_TDLS
11540 wlan_hdd_tdls_scan_done_callback(pAdapter);
11541#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011542 goto free_mem;
11543 }
11544
11545 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053011546 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011547 pAdapter->request = request;
11548 pScanInfo->scanId = scanId;
11549
11550 complete(&pScanInfo->scan_req_completion_event);
11551
11552free_mem:
11553 if( scanRequest.SSIDs.SSIDList )
11554 {
11555 vos_mem_free(scanRequest.SSIDs.SSIDList);
11556 }
11557
11558 if( channelList )
11559 vos_mem_free( channelList );
11560
11561 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011562 return status;
11563}
11564
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011565int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
11566#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11567 struct net_device *dev,
11568#endif
11569 struct cfg80211_scan_request *request)
11570{
11571 int ret;
11572
11573 vos_ssr_protect(__func__);
11574 ret = __wlan_hdd_cfg80211_scan(wiphy,
11575#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11576 dev,
11577#endif
11578 request);
11579 vos_ssr_unprotect(__func__);
11580
11581 return ret;
11582}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011583
11584void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
11585{
11586 v_U8_t iniDot11Mode =
11587 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
11588 eHddDot11Mode hddDot11Mode = iniDot11Mode;
11589
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011590 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
11591 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011592 switch ( iniDot11Mode )
11593 {
11594 case eHDD_DOT11_MODE_AUTO:
11595 case eHDD_DOT11_MODE_11ac:
11596 case eHDD_DOT11_MODE_11ac_ONLY:
11597#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053011598 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
11599 sme_IsFeatureSupportedByFW(DOT11AC) )
11600 hddDot11Mode = eHDD_DOT11_MODE_11ac;
11601 else
11602 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011603#else
11604 hddDot11Mode = eHDD_DOT11_MODE_11n;
11605#endif
11606 break;
11607 case eHDD_DOT11_MODE_11n:
11608 case eHDD_DOT11_MODE_11n_ONLY:
11609 hddDot11Mode = eHDD_DOT11_MODE_11n;
11610 break;
11611 default:
11612 hddDot11Mode = iniDot11Mode;
11613 break;
11614 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011615#ifdef WLAN_FEATURE_AP_HT40_24G
11616 if (operationChannel > SIR_11B_CHANNEL_END)
11617#endif
11618 {
11619 /* This call decides required channel bonding mode */
11620 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011621 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
11622 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011623 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011624}
11625
Jeff Johnson295189b2012-06-20 16:38:30 -070011626/*
11627 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011628 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011629 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011630int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011631 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070011632{
11633 int status = 0;
11634 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080011635 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011636 v_U32_t roamId;
11637 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070011638 eCsrAuthType RSNAuthType;
11639
11640 ENTER();
11641
11642 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080011643 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11644
11645 status = wlan_hdd_validate_context(pHddCtx);
11646 if (status)
11647 {
Yue Mae36e3552014-03-05 17:06:20 -080011648 return status;
11649 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011650
Jeff Johnson295189b2012-06-20 16:38:30 -070011651 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
11652 {
11653 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
11654 return -EINVAL;
11655 }
11656
11657 pRoamProfile = &pWextState->roamProfile;
11658
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011659 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070011660 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011661 hdd_station_ctx_t *pHddStaCtx;
11662 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011663
Siddharth Bhalda0d1622015-04-24 15:47:49 +053011664 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
11665
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011666 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070011667 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
11668 {
11669 /*QoS not enabled in cfg file*/
11670 pRoamProfile->uapsd_mask = 0;
11671 }
11672 else
11673 {
11674 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011675 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070011676 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
11677 }
11678
11679 pRoamProfile->SSIDs.numOfSSIDs = 1;
11680 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
11681 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011682 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070011683 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
11684 ssid, ssid_len);
11685
11686 if (bssid)
11687 {
11688 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
11689 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
11690 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011691 /* Save BSSID in seperate variable as well, as RoamProfile
11692 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070011693 case of join failure we should send valid BSSID to supplicant
11694 */
11695 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
11696 WNI_CFG_BSSID_LEN);
11697 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070011698 else
11699 {
11700 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
11701 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011702
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011703 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
11704 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011705 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
11706 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011707 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011708 /*set gen ie*/
11709 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
11710 /*set auth*/
11711 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
11712 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011713#ifdef FEATURE_WLAN_WAPI
11714 if (pAdapter->wapi_info.nWapiMode)
11715 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011716 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011717 switch (pAdapter->wapi_info.wapiAuthMode)
11718 {
11719 case WAPI_AUTH_MODE_PSK:
11720 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011721 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011722 pAdapter->wapi_info.wapiAuthMode);
11723 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
11724 break;
11725 }
11726 case WAPI_AUTH_MODE_CERT:
11727 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011728 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011729 pAdapter->wapi_info.wapiAuthMode);
11730 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
11731 break;
11732 }
11733 } // End of switch
11734 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
11735 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
11736 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011737 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011738 pRoamProfile->AuthType.numEntries = 1;
11739 pRoamProfile->EncryptionType.numEntries = 1;
11740 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11741 pRoamProfile->mcEncryptionType.numEntries = 1;
11742 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11743 }
11744 }
11745#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011746#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011747 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011748 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11749 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
11750 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011751 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
11752 sizeof (tSirGtkOffloadParams));
11753 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011754 }
11755#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011756 pRoamProfile->csrPersona = pAdapter->device_mode;
11757
Jeff Johnson32d95a32012-09-10 13:15:23 -070011758 if( operatingChannel )
11759 {
11760 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
11761 pRoamProfile->ChannelInfo.numOfChannels = 1;
11762 }
Chet Lanctot186b5732013-03-18 10:26:30 -070011763 else
11764 {
11765 pRoamProfile->ChannelInfo.ChannelList = NULL;
11766 pRoamProfile->ChannelInfo.numOfChannels = 0;
11767 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011768 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
11769 {
11770 hdd_select_cbmode(pAdapter,operatingChannel);
11771 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011772
Agarwal Ashish40f9b872015-09-01 16:17:35 +053011773 /*
11774 * Change conn_state to connecting before sme_RoamConnect(),
11775 * because sme_RoamConnect() has a direct path to call
11776 * hdd_smeRoamCallback(), which will change the conn_state
11777 * If direct path, conn_state will be accordingly changed
11778 * to NotConnected or Associated by either
11779 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
11780 * in sme_RoamCallback()
11781 * if sme_RomConnect is to be queued,
11782 * Connecting state will remain until it is completed.
11783 * If connection state is not changed,
11784 * connection state will remain in eConnectionState_NotConnected state.
11785 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
11786 * if conn state is eConnectionState_NotConnected.
11787 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
11788 * informed of connect result indication which is an issue.
11789 */
11790
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011791 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11792 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053011793 {
11794 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053011795 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011796 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
11797 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053011798 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011799 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011800 pAdapter->sessionId, pRoamProfile, &roamId);
11801
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011802 if ((eHAL_STATUS_SUCCESS != status) &&
11803 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11804 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011805
11806 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053011807 hddLog(VOS_TRACE_LEVEL_ERROR,
11808 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
11809 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011810 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011811 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011812 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011813 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011814
11815 pRoamProfile->ChannelInfo.ChannelList = NULL;
11816 pRoamProfile->ChannelInfo.numOfChannels = 0;
11817
Jeff Johnson295189b2012-06-20 16:38:30 -070011818 }
11819 else
11820 {
11821 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
11822 return -EINVAL;
11823 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080011824 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011825 return status;
11826}
11827
11828/*
11829 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
11830 * This function is used to set the authentication type (OPEN/SHARED).
11831 *
11832 */
11833static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
11834 enum nl80211_auth_type auth_type)
11835{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011836 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011837 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11838
11839 ENTER();
11840
11841 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011842 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070011843 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011844 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011845 hddLog(VOS_TRACE_LEVEL_INFO,
11846 "%s: set authentication type to AUTOSWITCH", __func__);
11847 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
11848 break;
11849
11850 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011851#ifdef WLAN_FEATURE_VOWIFI_11R
11852 case NL80211_AUTHTYPE_FT:
11853#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011854 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011855 "%s: set authentication type to OPEN", __func__);
11856 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11857 break;
11858
11859 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011860 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011861 "%s: set authentication type to SHARED", __func__);
11862 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
11863 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011864#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011865 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011866 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011867 "%s: set authentication type to CCKM WPA", __func__);
11868 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
11869 break;
11870#endif
11871
11872
11873 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011874 hddLog(VOS_TRACE_LEVEL_ERROR,
11875 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011876 auth_type);
11877 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
11878 return -EINVAL;
11879 }
11880
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011881 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011882 pHddStaCtx->conn_info.authType;
11883 return 0;
11884}
11885
11886/*
11887 * FUNCTION: wlan_hdd_set_akm_suite
11888 * This function is used to set the key mgmt type(PSK/8021x).
11889 *
11890 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011891static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011892 u32 key_mgmt
11893 )
11894{
11895 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11896 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053011897 /* Should be in ieee802_11_defs.h */
11898#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
11899#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070011900 /*set key mgmt type*/
11901 switch(key_mgmt)
11902 {
11903 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053011904 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011905#ifdef WLAN_FEATURE_VOWIFI_11R
11906 case WLAN_AKM_SUITE_FT_PSK:
11907#endif
11908 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070011909 __func__);
11910 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
11911 break;
11912
11913 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053011914 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011915#ifdef WLAN_FEATURE_VOWIFI_11R
11916 case WLAN_AKM_SUITE_FT_8021X:
11917#endif
11918 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011919 __func__);
11920 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11921 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011922#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011923#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
11924#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
11925 case WLAN_AKM_SUITE_CCKM:
11926 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
11927 __func__);
11928 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
11929 break;
11930#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070011931#ifndef WLAN_AKM_SUITE_OSEN
11932#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
11933 case WLAN_AKM_SUITE_OSEN:
11934 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
11935 __func__);
11936 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11937 break;
11938#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011939
11940 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011941 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011942 __func__, key_mgmt);
11943 return -EINVAL;
11944
11945 }
11946 return 0;
11947}
11948
11949/*
11950 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011951 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070011952 * (NONE/WEP40/WEP104/TKIP/CCMP).
11953 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011954static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
11955 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070011956 bool ucast
11957 )
11958{
11959 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011960 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011961 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11962
11963 ENTER();
11964
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011965 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011966 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053011967 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070011968 __func__, cipher);
11969 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11970 }
11971 else
11972 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011973
Jeff Johnson295189b2012-06-20 16:38:30 -070011974 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011975 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011976 {
11977 case IW_AUTH_CIPHER_NONE:
11978 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11979 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011980
Jeff Johnson295189b2012-06-20 16:38:30 -070011981 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011982 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070011983 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011984
Jeff Johnson295189b2012-06-20 16:38:30 -070011985 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011986 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070011987 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011988
Jeff Johnson295189b2012-06-20 16:38:30 -070011989 case WLAN_CIPHER_SUITE_TKIP:
11990 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
11991 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011992
Jeff Johnson295189b2012-06-20 16:38:30 -070011993 case WLAN_CIPHER_SUITE_CCMP:
11994 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11995 break;
11996#ifdef FEATURE_WLAN_WAPI
11997 case WLAN_CIPHER_SUITE_SMS4:
11998 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
11999 break;
12000#endif
12001
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012002#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070012003 case WLAN_CIPHER_SUITE_KRK:
12004 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
12005 break;
12006#endif
12007 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012008 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012009 __func__, cipher);
12010 return -EOPNOTSUPP;
12011 }
12012 }
12013
12014 if (ucast)
12015 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012016 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012017 __func__, encryptionType);
12018 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
12019 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012020 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070012021 encryptionType;
12022 }
12023 else
12024 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012025 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012026 __func__, encryptionType);
12027 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
12028 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
12029 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
12030 }
12031
12032 return 0;
12033}
12034
12035
12036/*
12037 * FUNCTION: wlan_hdd_cfg80211_set_ie
12038 * This function is used to parse WPA/RSN IE's.
12039 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012040int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012041#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12042 const u8 *ie,
12043#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012044 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012045#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012046 size_t ie_len
12047 )
12048{
12049 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012050#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12051 const u8 *genie = ie;
12052#else
Jeff Johnson295189b2012-06-20 16:38:30 -070012053 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012054#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012055 v_U16_t remLen = ie_len;
12056#ifdef FEATURE_WLAN_WAPI
12057 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
12058 u16 *tmp;
12059 v_U16_t akmsuiteCount;
12060 int *akmlist;
12061#endif
12062 ENTER();
12063
12064 /* clear previous assocAddIE */
12065 pWextState->assocAddIE.length = 0;
12066 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012067 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012068
12069 while (remLen >= 2)
12070 {
12071 v_U16_t eLen = 0;
12072 v_U8_t elementId;
12073 elementId = *genie++;
12074 eLen = *genie++;
12075 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012076
Arif Hussain6d2a3322013-11-17 19:50:10 -080012077 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070012078 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012079
12080 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070012081 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012082 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012083 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 -070012084 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012085 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012086 "%s: Invalid WPA IE", __func__);
12087 return -EINVAL;
12088 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012089 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070012090 {
12091 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012092 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012093 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012094
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053012095 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012096 {
Jeff Johnson902c9832012-12-10 14:28:09 -080012097 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
12098 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070012099 VOS_ASSERT(0);
12100 return -ENOMEM;
12101 }
12102 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
12103 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
12104 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012105
Jeff Johnson295189b2012-06-20 16:38:30 -070012106 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
12107 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
12108 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
12109 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012110 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
12111 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012112 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
12113 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
12114 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
12115 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
12116 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
12117 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012118 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053012119 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070012120 {
12121 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012122 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012123 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012124
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053012125 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012126 {
Jeff Johnson902c9832012-12-10 14:28:09 -080012127 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
12128 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070012129 VOS_ASSERT(0);
12130 return -ENOMEM;
12131 }
12132 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
12133 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
12134 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012135
Jeff Johnson295189b2012-06-20 16:38:30 -070012136 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
12137 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
12138 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012139#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012140 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
12141 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012142 /*Consider WFD IE, only for P2P Client */
12143 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
12144 {
12145 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012146 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012147 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012148
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053012149 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012150 {
Jeff Johnson902c9832012-12-10 14:28:09 -080012151 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
12152 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070012153 VOS_ASSERT(0);
12154 return -ENOMEM;
12155 }
12156 // WFD IE is saved to Additional IE ; it should be accumulated to handle
12157 // WPS IE + P2P IE + WFD IE
12158 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
12159 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012160
Jeff Johnson295189b2012-06-20 16:38:30 -070012161 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
12162 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
12163 }
12164#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012165 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012166 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070012167 HS20_OUI_TYPE_SIZE)) )
12168 {
12169 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012170 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070012171 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012172
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053012173 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070012174 {
Jeff Johnson902c9832012-12-10 14:28:09 -080012175 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
12176 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070012177 VOS_ASSERT(0);
12178 return -ENOMEM;
12179 }
12180 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
12181 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012182
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070012183 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
12184 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
12185 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012186 /* Appending OSEN Information Element in Assiciation Request */
12187 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
12188 OSEN_OUI_TYPE_SIZE)) )
12189 {
12190 v_U16_t curAddIELen = pWextState->assocAddIE.length;
12191 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
12192 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012193
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053012194 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012195 {
12196 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
12197 "Need bigger buffer space");
12198 VOS_ASSERT(0);
12199 return -ENOMEM;
12200 }
12201 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
12202 pWextState->assocAddIE.length += eLen + 2;
12203
12204 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
12205 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
12206 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
12207 }
12208
Abhishek Singh4322e622015-06-10 15:42:54 +053012209 /* Update only for WPA IE */
12210 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
12211 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070012212
12213 /* populating as ADDIE in beacon frames */
12214 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012215 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070012216 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
12217 {
12218 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
12219 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
12220 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
12221 {
12222 hddLog(LOGE,
12223 "Coldn't pass "
12224 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
12225 }
12226 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
12227 else
12228 hddLog(LOGE,
12229 "Could not pass on "
12230 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
12231
12232 /* IBSS mode doesn't contain params->proberesp_ies still
12233 beaconIE's need to be populated in probe response frames */
12234 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
12235 {
12236 u16 rem_probe_resp_ie_len = eLen + 2;
12237 u8 probe_rsp_ie_len[3] = {0};
12238 u8 counter = 0;
12239
12240 /* Check Probe Resp Length if it is greater then 255 then
12241 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
12242 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
12243 not able Store More then 255 bytes into One Variable */
12244
12245 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
12246 {
12247 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
12248 {
12249 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
12250 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
12251 }
12252 else
12253 {
12254 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
12255 rem_probe_resp_ie_len = 0;
12256 }
12257 }
12258
12259 rem_probe_resp_ie_len = 0;
12260
12261 if (probe_rsp_ie_len[0] > 0)
12262 {
12263 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
12264 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
12265 (tANI_U8*)(genie - 2),
12266 probe_rsp_ie_len[0], NULL,
12267 eANI_BOOLEAN_FALSE)
12268 == eHAL_STATUS_FAILURE)
12269 {
12270 hddLog(LOGE,
12271 "Could not pass"
12272 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
12273 }
12274 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
12275 }
12276
12277 if (probe_rsp_ie_len[1] > 0)
12278 {
12279 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
12280 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
12281 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
12282 probe_rsp_ie_len[1], NULL,
12283 eANI_BOOLEAN_FALSE)
12284 == eHAL_STATUS_FAILURE)
12285 {
12286 hddLog(LOGE,
12287 "Could not pass"
12288 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
12289 }
12290 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
12291 }
12292
12293 if (probe_rsp_ie_len[2] > 0)
12294 {
12295 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
12296 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
12297 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
12298 probe_rsp_ie_len[2], NULL,
12299 eANI_BOOLEAN_FALSE)
12300 == eHAL_STATUS_FAILURE)
12301 {
12302 hddLog(LOGE,
12303 "Could not pass"
12304 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
12305 }
12306 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
12307 }
12308
12309 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
12310 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
12311 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
12312 {
12313 hddLog(LOGE,
12314 "Could not pass"
12315 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
12316 }
12317 }
12318 else
12319 {
12320 // Reset WNI_CFG_PROBE_RSP Flags
12321 wlan_hdd_reset_prob_rspies(pAdapter);
12322
12323 hddLog(VOS_TRACE_LEVEL_INFO,
12324 "%s: No Probe Response IE received in set beacon",
12325 __func__);
12326 }
12327 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070012328 break;
12329 case DOT11F_EID_RSN:
12330 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
12331 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
12332 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
12333 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
12334 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
12335 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053012336
12337 /* Appending Extended Capabilities with Interworking bit set
12338 * in Assoc Req.
12339 *
12340 * In assoc req this EXT Cap will only be taken into account if
12341 * interworkingService bit is set to 1. Currently
12342 * driver is only interested in interworkingService capability
12343 * from supplicant. If in future any other EXT Cap info is
12344 * required from supplicat, it needs to be handled while
12345 * sending Assoc Req in LIM.
12346 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012347 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012348 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012349 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012350 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012351 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012352
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053012353 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012354 {
Jeff Johnson902c9832012-12-10 14:28:09 -080012355 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
12356 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012357 VOS_ASSERT(0);
12358 return -ENOMEM;
12359 }
12360 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
12361 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012362
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012363 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
12364 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
12365 break;
12366 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012367#ifdef FEATURE_WLAN_WAPI
12368 case WLAN_EID_WAPI:
12369 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070012370 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070012371 pAdapter->wapi_info.nWapiMode);
12372 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012373 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070012374 akmsuiteCount = WPA_GET_LE16(tmp);
12375 tmp = tmp + 1;
12376 akmlist = (int *)(tmp);
12377 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
12378 {
12379 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
12380 }
12381 else
12382 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012383 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070012384 VOS_ASSERT(0);
12385 return -EINVAL;
12386 }
12387
12388 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
12389 {
12390 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012391 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012392 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012393 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012395 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012396 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012397 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012398 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
12399 }
12400 break;
12401#endif
12402 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012403 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012404 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012405 /* when Unknown IE is received we should break and continue
12406 * to the next IE in the buffer instead we were returning
12407 * so changing this to break */
12408 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012409 }
12410 genie += eLen;
12411 remLen -= eLen;
12412 }
12413 EXIT();
12414 return 0;
12415}
12416
12417/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053012418 * FUNCTION: hdd_isWPAIEPresent
12419 * Parse the received IE to find the WPA IE
12420 *
12421 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012422static bool hdd_isWPAIEPresent(
12423#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
12424 const u8 *ie,
12425#else
12426 u8 *ie,
12427#endif
12428 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053012429{
12430 v_U8_t eLen = 0;
12431 v_U16_t remLen = ie_len;
12432 v_U8_t elementId = 0;
12433
12434 while (remLen >= 2)
12435 {
12436 elementId = *ie++;
12437 eLen = *ie++;
12438 remLen -= 2;
12439 if (eLen > remLen)
12440 {
12441 hddLog(VOS_TRACE_LEVEL_ERROR,
12442 "%s: IE length is wrong %d", __func__, eLen);
12443 return FALSE;
12444 }
12445 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
12446 {
12447 /* OUI - 0x00 0X50 0XF2
12448 WPA Information Element - 0x01
12449 WPA version - 0x01*/
12450 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
12451 return TRUE;
12452 }
12453 ie += eLen;
12454 remLen -= eLen;
12455 }
12456 return FALSE;
12457}
12458
12459/*
Jeff Johnson295189b2012-06-20 16:38:30 -070012460 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012461 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012462 * parameters during connect operation.
12463 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012464int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012465 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012466 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012467{
12468 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012469 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012470 ENTER();
12471
12472 /*set wpa version*/
12473 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
12474
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012475 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070012476 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053012477 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070012478 {
12479 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12480 }
12481 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
12482 {
12483 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12484 }
12485 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012486
12487 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012488 pWextState->wpaVersion);
12489
12490 /*set authentication type*/
12491 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
12492
12493 if (0 > status)
12494 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012495 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012496 "%s: failed to set authentication type ", __func__);
12497 return status;
12498 }
12499
12500 /*set key mgmt type*/
12501 if (req->crypto.n_akm_suites)
12502 {
12503 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
12504 if (0 > status)
12505 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012506 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070012507 __func__);
12508 return status;
12509 }
12510 }
12511
12512 /*set pairwise cipher type*/
12513 if (req->crypto.n_ciphers_pairwise)
12514 {
12515 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
12516 req->crypto.ciphers_pairwise[0], true);
12517 if (0 > status)
12518 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012519 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012520 "%s: failed to set unicast cipher type", __func__);
12521 return status;
12522 }
12523 }
12524 else
12525 {
12526 /*Reset previous cipher suite to none*/
12527 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
12528 if (0 > status)
12529 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012530 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012531 "%s: failed to set unicast cipher type", __func__);
12532 return status;
12533 }
12534 }
12535
12536 /*set group cipher type*/
12537 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
12538 false);
12539
12540 if (0 > status)
12541 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012542 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070012543 __func__);
12544 return status;
12545 }
12546
Chet Lanctot186b5732013-03-18 10:26:30 -070012547#ifdef WLAN_FEATURE_11W
12548 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
12549#endif
12550
Jeff Johnson295189b2012-06-20 16:38:30 -070012551 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
12552 if (req->ie_len)
12553 {
12554 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
12555 if ( 0 > status)
12556 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012557 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012558 __func__);
12559 return status;
12560 }
12561 }
12562
12563 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012564 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012565 {
12566 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
12567 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
12568 )
12569 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012570 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070012571 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
12572 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012573 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 __func__);
12575 return -EOPNOTSUPP;
12576 }
12577 else
12578 {
12579 u8 key_len = req->key_len;
12580 u8 key_idx = req->key_idx;
12581
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012582 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012583 && (CSR_MAX_NUM_KEY > key_idx)
12584 )
12585 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012586 hddLog(VOS_TRACE_LEVEL_INFO,
12587 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012588 __func__, key_idx, key_len);
12589 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012590 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012591 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012592 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070012593 (u8)key_len;
12594 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
12595 }
12596 }
12597 }
12598 }
12599
12600 return status;
12601}
12602
12603/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012604 * FUNCTION: wlan_hdd_try_disconnect
12605 * This function is used to disconnect from previous
12606 * connection
12607 */
12608static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
12609{
12610 long ret = 0;
12611 hdd_station_ctx_t *pHddStaCtx;
12612 eMib_dot11DesiredBssType connectedBssType;
12613
12614 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12615
12616 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
12617
12618 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
12619 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
12620 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
12621 {
12622 /* Issue disconnect to CSR */
12623 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12624 if( eHAL_STATUS_SUCCESS ==
12625 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12626 pAdapter->sessionId,
12627 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
12628 {
12629 ret = wait_for_completion_interruptible_timeout(
12630 &pAdapter->disconnect_comp_var,
12631 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12632 if (0 >= ret)
12633 {
12634 hddLog(LOGE, FL("Failed to receive disconnect event"));
12635 return -EALREADY;
12636 }
12637 }
12638 }
12639 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
12640 {
12641 ret = wait_for_completion_interruptible_timeout(
12642 &pAdapter->disconnect_comp_var,
12643 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12644 if (0 >= ret)
12645 {
12646 hddLog(LOGE, FL("Failed to receive disconnect event"));
12647 return -EALREADY;
12648 }
12649 }
12650
12651 return 0;
12652}
12653
12654/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053012655 * FUNCTION: __wlan_hdd_cfg80211_connect
12656 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070012657 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012658static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012659 struct net_device *ndev,
12660 struct cfg80211_connect_params *req
12661 )
12662{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012663 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012664 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012665 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053012666 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012667
12668 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012669
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012670 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12671 TRACE_CODE_HDD_CFG80211_CONNECT,
12672 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012673 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012674 "%s: device_mode = %s (%d)", __func__,
12675 hdd_device_modetoString(pAdapter->device_mode),
12676 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012677
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012678 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012679 if (!pHddCtx)
12680 {
12681 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12682 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053012683 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012684 }
12685
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012686 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012687 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012688 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012689 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012690 }
12691
Agarwal Ashish51325b52014-06-16 16:50:49 +053012692 if (vos_max_concurrent_connections_reached()) {
12693 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12694 return -ECONNREFUSED;
12695 }
12696
Jeff Johnson295189b2012-06-20 16:38:30 -070012697#ifdef WLAN_BTAMP_FEATURE
12698 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012699 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070012700 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012701 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012702 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080012703 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012704 }
12705#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012706
12707 //If Device Mode is Station Concurrent Sessions Exit BMps
12708 //P2P Mode will be taken care in Open/close adapter
12709 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012710 (vos_concurrent_open_sessions_running())) {
12711 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
12712 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012713 }
12714
12715 /*Try disconnecting if already in connected state*/
12716 status = wlan_hdd_try_disconnect(pAdapter);
12717 if ( 0 > status)
12718 {
12719 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12720 " connection"));
12721 return -EALREADY;
12722 }
12723
Jeff Johnson295189b2012-06-20 16:38:30 -070012724 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012725 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070012726
12727 if ( 0 > status)
12728 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012729 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070012730 __func__);
12731 return status;
12732 }
Mohit Khanna765234a2012-09-11 15:08:35 -070012733 if ( req->channel )
12734 {
12735 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
12736 req->ssid_len, req->bssid,
12737 req->channel->hw_value);
12738 }
12739 else
12740 {
12741 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012742 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070012743 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012744
Sushant Kaushikd7083982015-03-18 14:33:24 +053012745 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012746 {
12747 //ReEnable BMPS if disabled
12748 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
12749 (NULL != pHddCtx))
12750 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012751 if (pHddCtx->hdd_wlan_suspended)
12752 {
12753 hdd_set_pwrparams(pHddCtx);
12754 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012755 //ReEnable Bmps and Imps back
12756 hdd_enable_bmps_imps(pHddCtx);
12757 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053012758 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012759 return status;
12760 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012761 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012762 EXIT();
12763 return status;
12764}
12765
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012766static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
12767 struct net_device *ndev,
12768 struct cfg80211_connect_params *req)
12769{
12770 int ret;
12771 vos_ssr_protect(__func__);
12772 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
12773 vos_ssr_unprotect(__func__);
12774
12775 return ret;
12776}
Jeff Johnson295189b2012-06-20 16:38:30 -070012777
12778/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012779 * FUNCTION: wlan_hdd_disconnect
12780 * This function is used to issue a disconnect request to SME
12781 */
12782int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
12783{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012784 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012785 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012786 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012787 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012788
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012789 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012790
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012791 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012792 if (0 != status)
12793 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012794 return status;
12795 }
12796
Sushant Kaushikb4834d22015-07-15 15:29:05 +053012797 if (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)
12798 {
12799 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
12800 pAdapter->sessionId);
12801 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012802 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012803
Agarwal Ashish47d18112014-08-04 19:55:07 +053012804 /* Need to apply spin lock before decreasing active sessions
12805 * as there can be chance for double decrement if context switch
12806 * Calls hdd_DisConnectHandler.
12807 */
12808
12809 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012810 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
12811 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012812 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
12813 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053012814 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
12815 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012816
Abhishek Singhf4669da2014-05-26 15:07:49 +053012817 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053012818 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
12819
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012820 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012821
Mihir Shete182a0b22014-08-18 16:08:48 +053012822 /*
12823 * stop tx queues before deleting STA/BSS context from the firmware.
12824 * tx has to be disabled because the firmware can get busy dropping
12825 * the tx frames after BSS/STA has been deleted and will not send
12826 * back a response resulting in WDI timeout
12827 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053012828 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053012829 netif_tx_disable(pAdapter->dev);
12830 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012831
Mihir Shete182a0b22014-08-18 16:08:48 +053012832 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012833 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12834 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012835 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
12836 {
12837 hddLog(VOS_TRACE_LEVEL_INFO,
12838 FL("status = %d, already disconnected"),
12839 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012840
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012841 }
12842 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012843 {
12844 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012845 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012846 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012847 result = -EINVAL;
12848 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012849 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012850 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012851 &pAdapter->disconnect_comp_var,
12852 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012853 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012854 {
12855 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012856 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012857 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012858 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012859 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012860 {
12861 hddLog(VOS_TRACE_LEVEL_ERROR,
12862 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012863 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012864 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012865disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012866 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12867 FL("Set HDD connState to eConnectionState_NotConnected"));
12868 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
12869
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012870 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012871 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012872}
12873
12874
12875/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012876 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070012877 * This function is used to issue a disconnect request to SME
12878 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012879static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012880 struct net_device *dev,
12881 u16 reason
12882 )
12883{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012884 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012885 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012886 tCsrRoamProfile *pRoamProfile;
12887 hdd_station_ctx_t *pHddStaCtx;
12888 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012889#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012890 tANI_U8 staIdx;
12891#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012892
Jeff Johnson295189b2012-06-20 16:38:30 -070012893 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012894
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012895 if (!pAdapter) {
12896 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
12897 return -EINVAL;
12898 }
12899
12900 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12901 if (!pHddStaCtx) {
12902 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
12903 return -EINVAL;
12904 }
12905
12906 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12907 status = wlan_hdd_validate_context(pHddCtx);
12908 if (0 != status)
12909 {
12910 return status;
12911 }
12912
12913 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
12914
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012915 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12916 TRACE_CODE_HDD_CFG80211_DISCONNECT,
12917 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012918 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
12919 __func__, hdd_device_modetoString(pAdapter->device_mode),
12920 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012921
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012922 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
12923 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070012924
Jeff Johnson295189b2012-06-20 16:38:30 -070012925 if (NULL != pRoamProfile)
12926 {
12927 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012928 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
12929 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070012930 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012931 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070012932 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012933 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012934 switch(reason)
12935 {
12936 case WLAN_REASON_MIC_FAILURE:
12937 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
12938 break;
12939
12940 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
12941 case WLAN_REASON_DISASSOC_AP_BUSY:
12942 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
12943 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
12944 break;
12945
12946 case WLAN_REASON_PREV_AUTH_NOT_VALID:
12947 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053012948 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070012949 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
12950 break;
12951
Jeff Johnson295189b2012-06-20 16:38:30 -070012952 default:
12953 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
12954 break;
12955 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012956 pScanInfo = &pHddCtx->scan_info;
12957 if (pScanInfo->mScanPending)
12958 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012959 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012960 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053012961 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012962 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012963 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053012964 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012965#ifdef FEATURE_WLAN_TDLS
12966 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012967 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012968 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012969 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
12970 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012971 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012972 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012973 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012975 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012976 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012977 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012978 status = sme_DeleteTdlsPeerSta(
12979 WLAN_HDD_GET_HAL_CTX(pAdapter),
12980 pAdapter->sessionId,
12981 mac);
12982 if (status != eHAL_STATUS_SUCCESS) {
12983 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
12984 return -EPERM;
12985 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012986 }
12987 }
12988#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012989 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012990 status = wlan_hdd_disconnect(pAdapter, reasonCode);
12991 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070012992 {
12993 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012994 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012995 __func__, (int)status );
12996 return -EINVAL;
12997 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012998 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012999 else
13000 {
13001 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
13002 "called while in %d state", __func__,
13003 pHddStaCtx->conn_info.connState);
13004 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013005 }
13006 else
13007 {
13008 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
13009 }
13010
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013011 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013012 return status;
13013}
13014
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053013015static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
13016 struct net_device *dev,
13017 u16 reason
13018 )
13019{
13020 int ret;
13021 vos_ssr_protect(__func__);
13022 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
13023 vos_ssr_unprotect(__func__);
13024
13025 return ret;
13026}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053013027
Jeff Johnson295189b2012-06-20 16:38:30 -070013028/*
13029 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013030 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070013031 * settings in IBSS mode.
13032 */
13033static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013034 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070013035 struct cfg80211_ibss_params *params
13036 )
13037{
13038 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013039 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013040 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
13041 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013042
Jeff Johnson295189b2012-06-20 16:38:30 -070013043 ENTER();
13044
13045 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070013046 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070013047
13048 if (params->ie_len && ( NULL != params->ie) )
13049 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070013050 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
13051 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070013052 {
13053 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
13054 encryptionType = eCSR_ENCRYPT_TYPE_AES;
13055 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070013056 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070013057 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013058 tDot11fIEWPA dot11WPAIE;
13059 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070013060 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013061
Wilson Yang00256342013-10-10 23:13:38 -070013062 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070013063 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
13064 params->ie_len, DOT11F_EID_WPA);
13065 if ( NULL != ie )
13066 {
13067 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
13068 // Unpack the WPA IE
13069 //Skip past the EID byte and length byte - and four byte WiFi OUI
13070 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
13071 &ie[2+4],
13072 ie[1] - 4,
13073 &dot11WPAIE);
13074 /*Extract the multicast cipher, the encType for unicast
13075 cipher for wpa-none is none*/
13076 encryptionType =
13077 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
13078 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013079 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070013080
Jeff Johnson295189b2012-06-20 16:38:30 -070013081 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
13082
13083 if (0 > status)
13084 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013085 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070013086 __func__);
13087 return status;
13088 }
13089 }
13090
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013091 pWextState->roamProfile.AuthType.authType[0] =
13092 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070013093 eCSR_AUTH_TYPE_OPEN_SYSTEM;
13094
13095 if (params->privacy)
13096 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013097 /* Security enabled IBSS, At this time there is no information available
13098 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070013099 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013100 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070013101 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013102 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070013103 *enable privacy bit in beacons */
13104
13105 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
13106 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070013107 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
13108 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013109 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
13110 pWextState->roamProfile.EncryptionType.numEntries = 1;
13111 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013112 return status;
13113}
13114
13115/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013116 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013117 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070013118 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013119static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013120 struct net_device *dev,
13121 struct cfg80211_ibss_params *params
13122 )
13123{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013124 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070013125 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13126 tCsrRoamProfile *pRoamProfile;
13127 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013128 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13129 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013130 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070013131
13132 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013133
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013134 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13135 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
13136 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013137 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013138 "%s: device_mode = %s (%d)", __func__,
13139 hdd_device_modetoString(pAdapter->device_mode),
13140 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070013141
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013142 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013143 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070013144 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013145 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013146 }
13147
13148 if (NULL == pWextState)
13149 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013150 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070013151 __func__);
13152 return -EIO;
13153 }
13154
Agarwal Ashish51325b52014-06-16 16:50:49 +053013155 if (vos_max_concurrent_connections_reached()) {
13156 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
13157 return -ECONNREFUSED;
13158 }
13159
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053013160 /*Try disconnecting if already in connected state*/
13161 status = wlan_hdd_try_disconnect(pAdapter);
13162 if ( 0 > status)
13163 {
13164 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
13165 " IBSS connection"));
13166 return -EALREADY;
13167 }
13168
Jeff Johnson295189b2012-06-20 16:38:30 -070013169 pRoamProfile = &pWextState->roamProfile;
13170
13171 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
13172 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013173 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013174 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013175 return -EINVAL;
13176 }
13177
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070013178 /* BSSID is provided by upper layers hence no need to AUTO generate */
13179 if (NULL != params->bssid) {
13180 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
13181 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
13182 hddLog (VOS_TRACE_LEVEL_ERROR,
13183 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
13184 return -EIO;
13185 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013186 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070013187 }
krunal sonie9002db2013-11-25 14:24:17 -080013188 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
13189 {
13190 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
13191 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
13192 {
13193 hddLog (VOS_TRACE_LEVEL_ERROR,
13194 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
13195 return -EIO;
13196 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013197
13198 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080013199 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013200 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080013201 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070013202
Jeff Johnson295189b2012-06-20 16:38:30 -070013203 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070013204 if (NULL !=
13205#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
13206 params->chandef.chan)
13207#else
13208 params->channel)
13209#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013210 {
13211 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013212 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
13213 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
13214 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
13215 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013216
13217 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013218 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070013219 ieee80211_frequency_to_channel(
13220#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
13221 params->chandef.chan->center_freq);
13222#else
13223 params->channel->center_freq);
13224#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013225
13226 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
13227 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070013228 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013229 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
13230 __func__);
13231 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070013232 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013233
13234 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013235 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013236 if (channelNum == validChan[indx])
13237 {
13238 break;
13239 }
13240 }
13241 if (indx >= numChans)
13242 {
13243 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013244 __func__, channelNum);
13245 return -EINVAL;
13246 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013247 /* Set the Operational Channel */
13248 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
13249 channelNum);
13250 pRoamProfile->ChannelInfo.numOfChannels = 1;
13251 pHddStaCtx->conn_info.operationChannel = channelNum;
13252 pRoamProfile->ChannelInfo.ChannelList =
13253 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070013254 }
13255
13256 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013257 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070013258 if (status < 0)
13259 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013260 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070013261 __func__);
13262 return status;
13263 }
13264
13265 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013266 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070013267 params->ssid_len, params->bssid,
13268 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070013269
13270 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070013271 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013272
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013273 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013274 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013275}
13276
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013277static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
13278 struct net_device *dev,
13279 struct cfg80211_ibss_params *params
13280 )
13281{
13282 int ret = 0;
13283
13284 vos_ssr_protect(__func__);
13285 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
13286 vos_ssr_unprotect(__func__);
13287
13288 return ret;
13289}
13290
Jeff Johnson295189b2012-06-20 16:38:30 -070013291/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013292 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013293 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070013294 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013295static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013296 struct net_device *dev
13297 )
13298{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013299 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013300 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13301 tCsrRoamProfile *pRoamProfile;
13302 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013303 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013304
13305 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013306
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013307 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13308 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
13309 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013310 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013311 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013312 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013313 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013314 }
13315
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013316 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
13317 hdd_device_modetoString(pAdapter->device_mode),
13318 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070013319 if (NULL == pWextState)
13320 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013321 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070013322 __func__);
13323 return -EIO;
13324 }
13325
13326 pRoamProfile = &pWextState->roamProfile;
13327
13328 /* Issue disconnect only if interface type is set to IBSS */
13329 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
13330 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013331 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070013332 __func__);
13333 return -EINVAL;
13334 }
13335
13336 /* Issue Disconnect request */
13337 INIT_COMPLETION(pAdapter->disconnect_comp_var);
13338 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
13339 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
13340
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013341 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013342 return 0;
13343}
13344
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013345static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
13346 struct net_device *dev
13347 )
13348{
13349 int ret = 0;
13350
13351 vos_ssr_protect(__func__);
13352 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
13353 vos_ssr_unprotect(__func__);
13354
13355 return ret;
13356}
13357
Jeff Johnson295189b2012-06-20 16:38:30 -070013358/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013359 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070013360 * This function is used to set the phy parameters
13361 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
13362 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013363static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013364 u32 changed)
13365{
13366 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
13367 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013368 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013369
13370 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013371
13372 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013373 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
13374 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013375
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013376 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013377 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013378 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013379 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013380 }
13381
Jeff Johnson295189b2012-06-20 16:38:30 -070013382 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
13383 {
13384 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
13385 WNI_CFG_RTS_THRESHOLD_STAMAX :
13386 wiphy->rts_threshold;
13387
13388 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013389 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070013390 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013391 hddLog(VOS_TRACE_LEVEL_ERROR,
13392 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013393 __func__, rts_threshold);
13394 return -EINVAL;
13395 }
13396
13397 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
13398 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013399 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013400 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013401 hddLog(VOS_TRACE_LEVEL_ERROR,
13402 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013403 __func__, rts_threshold);
13404 return -EIO;
13405 }
13406
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013407 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013408 rts_threshold);
13409 }
13410
13411 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
13412 {
13413 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
13414 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
13415 wiphy->frag_threshold;
13416
13417 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013418 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013419 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013420 hddLog(VOS_TRACE_LEVEL_ERROR,
13421 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013422 frag_threshold);
13423 return -EINVAL;
13424 }
13425
13426 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
13427 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013428 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013429 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013430 hddLog(VOS_TRACE_LEVEL_ERROR,
13431 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013432 __func__, frag_threshold);
13433 return -EIO;
13434 }
13435
13436 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
13437 frag_threshold);
13438 }
13439
13440 if ((changed & WIPHY_PARAM_RETRY_SHORT)
13441 || (changed & WIPHY_PARAM_RETRY_LONG))
13442 {
13443 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
13444 wiphy->retry_short :
13445 wiphy->retry_long;
13446
13447 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
13448 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
13449 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013450 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013451 __func__, retry_value);
13452 return -EINVAL;
13453 }
13454
13455 if (changed & WIPHY_PARAM_RETRY_SHORT)
13456 {
13457 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
13458 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013459 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013460 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013461 hddLog(VOS_TRACE_LEVEL_ERROR,
13462 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013463 __func__, retry_value);
13464 return -EIO;
13465 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013466 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013467 __func__, retry_value);
13468 }
13469 else if (changed & WIPHY_PARAM_RETRY_SHORT)
13470 {
13471 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
13472 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013473 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013474 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013475 hddLog(VOS_TRACE_LEVEL_ERROR,
13476 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013477 __func__, retry_value);
13478 return -EIO;
13479 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013480 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013481 __func__, retry_value);
13482 }
13483 }
13484
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013485 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013486 return 0;
13487}
13488
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013489static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
13490 u32 changed)
13491{
13492 int ret;
13493
13494 vos_ssr_protect(__func__);
13495 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
13496 vos_ssr_unprotect(__func__);
13497
13498 return ret;
13499}
13500
Jeff Johnson295189b2012-06-20 16:38:30 -070013501/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013502 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013503 * This function is used to set the txpower
13504 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013505static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013506#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13507 struct wireless_dev *wdev,
13508#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013509#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013510 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013511#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013512 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013513#endif
13514 int dbm)
13515{
13516 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013517 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013518 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
13519 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013520 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013521
13522 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013523
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013524 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13525 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
13526 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013527 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013528 if (0 != status)
13529 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013530 return status;
13531 }
13532
13533 hHal = pHddCtx->hHal;
13534
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013535 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
13536 dbm, ccmCfgSetCallback,
13537 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013539 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013540 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
13541 return -EIO;
13542 }
13543
13544 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
13545 dbm);
13546
13547 switch(type)
13548 {
13549 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
13550 /* Fall through */
13551 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
13552 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
13553 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013554 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
13555 __func__);
13556 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070013557 }
13558 break;
13559 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013560 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070013561 __func__);
13562 return -EOPNOTSUPP;
13563 break;
13564 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013565 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
13566 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070013567 return -EIO;
13568 }
13569
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013570 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013571 return 0;
13572}
13573
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013574static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
13575#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13576 struct wireless_dev *wdev,
13577#endif
13578#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13579 enum tx_power_setting type,
13580#else
13581 enum nl80211_tx_power_setting type,
13582#endif
13583 int dbm)
13584{
13585 int ret;
13586 vos_ssr_protect(__func__);
13587 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
13588#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13589 wdev,
13590#endif
13591#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13592 type,
13593#else
13594 type,
13595#endif
13596 dbm);
13597 vos_ssr_unprotect(__func__);
13598
13599 return ret;
13600}
13601
Jeff Johnson295189b2012-06-20 16:38:30 -070013602/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013603 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013604 * This function is used to read the txpower
13605 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013606static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013607#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13608 struct wireless_dev *wdev,
13609#endif
13610 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070013611{
13612
13613 hdd_adapter_t *pAdapter;
13614 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013615 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013616
Jeff Johnsone7245742012-09-05 17:12:55 -070013617 ENTER();
13618
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013619 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013620 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013621 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013622 *dbm = 0;
13623 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013624 }
13625
Jeff Johnson295189b2012-06-20 16:38:30 -070013626 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
13627 if (NULL == pAdapter)
13628 {
13629 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
13630 return -ENOENT;
13631 }
13632
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053013633 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13634 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
13635 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070013636 wlan_hdd_get_classAstats(pAdapter);
13637 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
13638
Jeff Johnsone7245742012-09-05 17:12:55 -070013639 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013640 return 0;
13641}
13642
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013643static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
13644#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13645 struct wireless_dev *wdev,
13646#endif
13647 int *dbm)
13648{
13649 int ret;
13650
13651 vos_ssr_protect(__func__);
13652 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
13653#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13654 wdev,
13655#endif
13656 dbm);
13657 vos_ssr_unprotect(__func__);
13658
13659 return ret;
13660}
13661
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013662static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013663#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13664 const u8* mac,
13665#else
13666 u8* mac,
13667#endif
13668 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070013669{
13670 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13671 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13672 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053013673 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013674
13675 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
13676 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070013677
13678 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
13679 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
13680 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
13681 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
13682 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
13683 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
13684 tANI_U16 maxRate = 0;
13685 tANI_U16 myRate;
13686 tANI_U16 currentRate = 0;
13687 tANI_U8 maxSpeedMCS = 0;
13688 tANI_U8 maxMCSIdx = 0;
13689 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053013690 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013691 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013692 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013693
Leo Chang6f8870f2013-03-26 18:11:36 -070013694#ifdef WLAN_FEATURE_11AC
13695 tANI_U32 vht_mcs_map;
13696 eDataRate11ACMaxMcs vhtMaxMcs;
13697#endif /* WLAN_FEATURE_11AC */
13698
Jeff Johnsone7245742012-09-05 17:12:55 -070013699 ENTER();
13700
Jeff Johnson295189b2012-06-20 16:38:30 -070013701 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
13702 (0 == ssidlen))
13703 {
13704 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
13705 " Invalid ssidlen, %d", __func__, ssidlen);
13706 /*To keep GUI happy*/
13707 return 0;
13708 }
13709
Mukul Sharma811205f2014-07-09 21:07:30 +053013710 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
13711 {
13712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13713 "%s: Roaming in progress, so unable to proceed this request", __func__);
13714 return 0;
13715 }
13716
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013717 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013718 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013719 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013720 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013721 }
13722
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053013723 wlan_hdd_get_station_stats(pAdapter);
13724 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013725
Kiet Lam3b17fc82013-09-27 05:24:08 +053013726 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
13727 sinfo->filled |= STATION_INFO_SIGNAL;
13728
c_hpothu09f19542014-05-30 21:53:31 +053013729 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053013730 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
13731 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053013732 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053013733 {
13734 rate_flags = pAdapter->maxRateFlags;
13735 }
c_hpothu44ff4e02014-05-08 00:13:57 +053013736
Jeff Johnson295189b2012-06-20 16:38:30 -070013737 //convert to the UI units of 100kbps
13738 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
13739
13740#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070013741 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 -070013742 sinfo->signal,
13743 pCfg->reportMaxLinkSpeed,
13744 myRate,
13745 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013746 (int) pCfg->linkSpeedRssiMid,
13747 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070013748 (int) rate_flags,
13749 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013750#endif //LINKSPEED_DEBUG_ENABLED
13751
13752 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
13753 {
13754 // we do not want to necessarily report the current speed
13755 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
13756 {
13757 // report the max possible speed
13758 rssidx = 0;
13759 }
13760 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
13761 {
13762 // report the max possible speed with RSSI scaling
13763 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
13764 {
13765 // report the max possible speed
13766 rssidx = 0;
13767 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013768 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070013769 {
13770 // report middle speed
13771 rssidx = 1;
13772 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013773 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
13774 {
13775 // report middle speed
13776 rssidx = 2;
13777 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013778 else
13779 {
13780 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013781 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070013782 }
13783 }
13784 else
13785 {
13786 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
13787 hddLog(VOS_TRACE_LEVEL_ERROR,
13788 "%s: Invalid value for reportMaxLinkSpeed: %u",
13789 __func__, pCfg->reportMaxLinkSpeed);
13790 rssidx = 0;
13791 }
13792
13793 maxRate = 0;
13794
13795 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013796 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
13797 OperationalRates, &ORLeng))
13798 {
13799 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13800 /*To keep GUI happy*/
13801 return 0;
13802 }
13803
Jeff Johnson295189b2012-06-20 16:38:30 -070013804 for (i = 0; i < ORLeng; i++)
13805 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013806 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013807 {
13808 /* Validate Rate Set */
13809 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
13810 {
13811 currentRate = supported_data_rate[j].supported_rate[rssidx];
13812 break;
13813 }
13814 }
13815 /* Update MAX rate */
13816 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13817 }
13818
13819 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013820 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
13821 ExtendedRates, &ERLeng))
13822 {
13823 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13824 /*To keep GUI happy*/
13825 return 0;
13826 }
13827
Jeff Johnson295189b2012-06-20 16:38:30 -070013828 for (i = 0; i < ERLeng; i++)
13829 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013830 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013831 {
13832 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
13833 {
13834 currentRate = supported_data_rate[j].supported_rate[rssidx];
13835 break;
13836 }
13837 }
13838 /* Update MAX rate */
13839 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13840 }
c_hpothu79aab322014-07-14 21:11:01 +053013841
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013842 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053013843 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013844 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053013845 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070013846 {
c_hpothu79aab322014-07-14 21:11:01 +053013847 if (rate_flags & eHAL_TX_RATE_VHT80)
13848 mode = 2;
13849 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
13850 mode = 1;
13851 else
13852 mode = 0;
13853
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013854 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
13855 MCSRates, &MCSLeng))
13856 {
13857 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13858 /*To keep GUI happy*/
13859 return 0;
13860 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013861 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070013862#ifdef WLAN_FEATURE_11AC
13863 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013864 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070013865 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013866 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013867 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070013868 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070013869 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013870 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013871 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013872 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070013873 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013874 maxMCSIdx = 7;
13875 }
13876 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
13877 {
13878 maxMCSIdx = 8;
13879 }
13880 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
13881 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013882 //VHT20 is supporting 0~8
13883 if (rate_flags & eHAL_TX_RATE_VHT20)
13884 maxMCSIdx = 8;
13885 else
13886 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070013887 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013888
c_hpothu79aab322014-07-14 21:11:01 +053013889 if (0 != rssidx)/*check for scaled */
13890 {
13891 //get middle rate MCS index if rssi=1/2
13892 for (i=0; i <= maxMCSIdx; i++)
13893 {
13894 if (sinfo->signal <= rssiMcsTbl[mode][i])
13895 {
13896 maxMCSIdx = i;
13897 break;
13898 }
13899 }
13900 }
13901
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013902 if (rate_flags & eHAL_TX_RATE_VHT80)
13903 {
13904 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
13905 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
13906 }
13907 else if (rate_flags & eHAL_TX_RATE_VHT40)
13908 {
13909 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
13910 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
13911 }
13912 else if (rate_flags & eHAL_TX_RATE_VHT20)
13913 {
13914 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
13915 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
13916 }
13917
Leo Chang6f8870f2013-03-26 18:11:36 -070013918 maxSpeedMCS = 1;
13919 if (currentRate > maxRate)
13920 {
13921 maxRate = currentRate;
13922 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013923
Leo Chang6f8870f2013-03-26 18:11:36 -070013924 }
13925 else
13926#endif /* WLAN_FEATURE_11AC */
13927 {
13928 if (rate_flags & eHAL_TX_RATE_HT40)
13929 {
13930 rateFlag |= 1;
13931 }
13932 if (rate_flags & eHAL_TX_RATE_SGI)
13933 {
13934 rateFlag |= 2;
13935 }
13936
Girish Gowli01abcee2014-07-31 20:18:55 +053013937 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053013938 if (rssidx == 1 || rssidx == 2)
13939 {
13940 //get middle rate MCS index if rssi=1/2
13941 for (i=0; i <= 7; i++)
13942 {
13943 if (sinfo->signal <= rssiMcsTbl[mode][i])
13944 {
13945 temp = i+1;
13946 break;
13947 }
13948 }
13949 }
c_hpothu79aab322014-07-14 21:11:01 +053013950
13951 for (i = 0; i < MCSLeng; i++)
13952 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013953 for (j = 0; j < temp; j++)
13954 {
13955 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
13956 {
13957 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013958 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013959 break;
13960 }
13961 }
13962 if ((j < temp) && (currentRate > maxRate))
13963 {
13964 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070013965 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013966 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013967 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013968 }
13969 }
13970
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013971 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
13972 {
13973 maxRate = myRate;
13974 maxSpeedMCS = 1;
13975 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13976 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013977 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053013978 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070013979 {
13980 maxRate = myRate;
13981 if (rate_flags & eHAL_TX_RATE_LEGACY)
13982 {
13983 maxSpeedMCS = 0;
13984 }
13985 else
13986 {
13987 maxSpeedMCS = 1;
13988 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13989 }
13990 }
13991
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013992 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070013993 {
13994 sinfo->txrate.legacy = maxRate;
13995#ifdef LINKSPEED_DEBUG_ENABLED
13996 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
13997#endif //LINKSPEED_DEBUG_ENABLED
13998 }
13999 else
14000 {
14001 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070014002#ifdef WLAN_FEATURE_11AC
14003 sinfo->txrate.nss = 1;
14004 if (rate_flags & eHAL_TX_RATE_VHT80)
14005 {
14006 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053014007 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070014008 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053014009 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070014010 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053014011 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
14012 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
14013 }
14014 else if (rate_flags & eHAL_TX_RATE_VHT20)
14015 {
14016 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
14017 }
14018#endif /* WLAN_FEATURE_11AC */
14019 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
14020 {
14021 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
14022 if (rate_flags & eHAL_TX_RATE_HT40)
14023 {
14024 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
14025 }
Leo Chang6f8870f2013-03-26 18:11:36 -070014026 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 if (rate_flags & eHAL_TX_RATE_SGI)
14028 {
14029 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
14030 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053014031
Jeff Johnson295189b2012-06-20 16:38:30 -070014032#ifdef LINKSPEED_DEBUG_ENABLED
14033 pr_info("Reporting MCS rate %d flags %x\n",
14034 sinfo->txrate.mcs,
14035 sinfo->txrate.flags );
14036#endif //LINKSPEED_DEBUG_ENABLED
14037 }
14038 }
14039 else
14040 {
14041 // report current rate instead of max rate
14042
14043 if (rate_flags & eHAL_TX_RATE_LEGACY)
14044 {
14045 //provide to the UI in units of 100kbps
14046 sinfo->txrate.legacy = myRate;
14047#ifdef LINKSPEED_DEBUG_ENABLED
14048 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
14049#endif //LINKSPEED_DEBUG_ENABLED
14050 }
14051 else
14052 {
14053 //must be MCS
14054 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070014055#ifdef WLAN_FEATURE_11AC
14056 sinfo->txrate.nss = 1;
14057 if (rate_flags & eHAL_TX_RATE_VHT80)
14058 {
14059 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
14060 }
14061 else
14062#endif /* WLAN_FEATURE_11AC */
14063 {
14064 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
14065 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014066 if (rate_flags & eHAL_TX_RATE_SGI)
14067 {
14068 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
14069 }
14070 if (rate_flags & eHAL_TX_RATE_HT40)
14071 {
14072 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
14073 }
Leo Chang6f8870f2013-03-26 18:11:36 -070014074#ifdef WLAN_FEATURE_11AC
14075 else if (rate_flags & eHAL_TX_RATE_VHT80)
14076 {
14077 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
14078 }
14079#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070014080#ifdef LINKSPEED_DEBUG_ENABLED
14081 pr_info("Reporting actual MCS rate %d flags %x\n",
14082 sinfo->txrate.mcs,
14083 sinfo->txrate.flags );
14084#endif //LINKSPEED_DEBUG_ENABLED
14085 }
14086 }
14087 sinfo->filled |= STATION_INFO_TX_BITRATE;
14088
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070014089 sinfo->tx_packets =
14090 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
14091 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
14092 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
14093 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
14094
14095 sinfo->tx_retries =
14096 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
14097 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
14098 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
14099 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
14100
14101 sinfo->tx_failed =
14102 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
14103 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
14104 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
14105 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
14106
14107 sinfo->filled |=
14108 STATION_INFO_TX_PACKETS |
14109 STATION_INFO_TX_RETRIES |
14110 STATION_INFO_TX_FAILED;
14111
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014112 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14113 TRACE_CODE_HDD_CFG80211_GET_STA,
14114 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070014115 EXIT();
14116 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014117}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014118#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
14119static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
14120 const u8* mac, struct station_info *sinfo)
14121#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014122static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
14123 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014124#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014125{
14126 int ret;
14127
14128 vos_ssr_protect(__func__);
14129 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
14130 vos_ssr_unprotect(__func__);
14131
14132 return ret;
14133}
14134
14135static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070014136 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070014137{
14138 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053014139 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070014140 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014141 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014142
Jeff Johnsone7245742012-09-05 17:12:55 -070014143 ENTER();
14144
Jeff Johnson295189b2012-06-20 16:38:30 -070014145 if (NULL == pAdapter)
14146 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014147 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014148 return -ENODEV;
14149 }
14150
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014151 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14152 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
14153 pAdapter->sessionId, timeout));
14154
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053014155 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014156 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014157 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014158 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014159 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014160 }
14161
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053014162 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
14163 (TRUE == pHddCtx->hdd_wlan_suspended) &&
14164 (pHddCtx->cfg_ini->fhostArpOffload) &&
14165 (eConnectionState_Associated ==
14166 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
14167 {
Amar Singhald53568e2013-09-26 11:03:45 -070014168
14169 hddLog(VOS_TRACE_LEVEL_INFO,
14170 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053014171 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053014172 if (!VOS_IS_STATUS_SUCCESS(vos_status))
14173 {
14174 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014175 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053014176 __func__, vos_status);
14177 }
14178 }
14179
Jeff Johnson295189b2012-06-20 16:38:30 -070014180 /**The get power cmd from the supplicant gets updated by the nl only
14181 *on successful execution of the function call
14182 *we are oppositely mapped w.r.t mode in the driver
14183 **/
14184 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
14185
14186 if (VOS_STATUS_E_FAILURE == vos_status)
14187 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053014188 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14189 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014190 return -EINVAL;
14191 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014192 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070014193 return 0;
14194}
14195
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014196static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
14197 struct net_device *dev, bool mode, int timeout)
14198{
14199 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070014200
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014201 vos_ssr_protect(__func__);
14202 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
14203 vos_ssr_unprotect(__func__);
14204
14205 return ret;
14206}
Jeff Johnson295189b2012-06-20 16:38:30 -070014207#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014208static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
14209 struct net_device *netdev,
14210 u8 key_index)
14211{
14212 ENTER();
14213 return 0;
14214}
14215
Jeff Johnson295189b2012-06-20 16:38:30 -070014216static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014217 struct net_device *netdev,
14218 u8 key_index)
14219{
14220 int ret;
14221 vos_ssr_protect(__func__);
14222 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
14223 vos_ssr_unprotect(__func__);
14224 return ret;
14225}
14226#endif //LINUX_VERSION_CODE
14227
14228#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
14229static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
14230 struct net_device *dev,
14231 struct ieee80211_txq_params *params)
14232{
14233 ENTER();
14234 return 0;
14235}
14236#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
14237static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
14238 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070014239{
Jeff Johnsone7245742012-09-05 17:12:55 -070014240 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070014241 return 0;
14242}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014243#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070014244
14245#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
14246static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014247 struct net_device *dev,
14248 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070014249{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014250 int ret;
14251
14252 vos_ssr_protect(__func__);
14253 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
14254 vos_ssr_unprotect(__func__);
14255 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070014256}
14257#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
14258static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
14259 struct ieee80211_txq_params *params)
14260{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014261 int ret;
14262
14263 vos_ssr_protect(__func__);
14264 ret = __wlan_hdd_set_txq_params(wiphy, params);
14265 vos_ssr_unprotect(__func__);
14266 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070014267}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014268#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014269
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014270static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014271 struct net_device *dev,
14272 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070014273{
14274 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014275 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014276 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014277 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014278 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014279 v_CONTEXT_t pVosContext = NULL;
14280 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014281
Jeff Johnsone7245742012-09-05 17:12:55 -070014282 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014283
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014284 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070014285 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014286 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014287 return -EINVAL;
14288 }
14289
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014290 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14291 TRACE_CODE_HDD_CFG80211_DEL_STA,
14292 pAdapter->sessionId, pAdapter->device_mode));
14293
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014294 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14295 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014296 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014297 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014298 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014299 }
14300
Jeff Johnson295189b2012-06-20 16:38:30 -070014301 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070014302 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070014303 )
14304 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014305 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
14306 pSapCtx = VOS_GET_SAP_CB(pVosContext);
14307 if(pSapCtx == NULL){
14308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14309 FL("psapCtx is NULL"));
14310 return -ENOENT;
14311 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014312 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070014313 {
14314 v_U16_t i;
14315 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
14316 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014317 if ((pSapCtx->aStaInfo[i].isUsed) &&
14318 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070014319 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014320 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014321 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014322 ETHER_ADDR_LEN);
14323
Jeff Johnson295189b2012-06-20 16:38:30 -070014324 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080014325 "%s: Delete STA with MAC::"
14326 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014327 __func__,
14328 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
14329 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070014330 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014331 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014332 }
14333 }
14334 }
14335 else
14336 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014337
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014338 vos_status = hdd_softap_GetStaId(pAdapter,
14339 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014340 if (!VOS_IS_STATUS_SUCCESS(vos_status))
14341 {
14342 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080014343 "%s: Skip this DEL STA as this is not used::"
14344 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014345 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014346 return -ENOENT;
14347 }
14348
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014349 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014350 {
14351 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080014352 "%s: Skip this DEL STA as deauth is in progress::"
14353 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014354 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014355 return -ENOENT;
14356 }
14357
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014358 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014359
Jeff Johnson295189b2012-06-20 16:38:30 -070014360 hddLog(VOS_TRACE_LEVEL_INFO,
14361 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080014362 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014363 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014364 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014365
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014366 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014367 if (!VOS_IS_STATUS_SUCCESS(vos_status))
14368 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014369 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014370 hddLog(VOS_TRACE_LEVEL_INFO,
14371 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080014372 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014373 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014374 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014375 return -ENOENT;
14376 }
14377
Jeff Johnson295189b2012-06-20 16:38:30 -070014378 }
14379 }
14380
14381 EXIT();
14382
14383 return 0;
14384}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014385
14386#ifdef CFG80211_DEL_STA_V2
14387static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14388 struct net_device *dev,
14389 struct station_del_parameters *param)
14390#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014391#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
14392static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14393 struct net_device *dev, const u8 *mac)
14394#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014395static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14396 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014397#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014398#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014399{
14400 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014401 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070014402
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014403 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014404
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014405#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014406 if (NULL == param) {
14407 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014408 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014409 return -EINVAL;
14410 }
14411
14412 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
14413 param->subtype, &delStaParams);
14414
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014415#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053014416 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014417 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014418#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014419 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
14420
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014421 vos_ssr_unprotect(__func__);
14422
14423 return ret;
14424}
14425
14426static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014427 struct net_device *dev,
14428#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14429 const u8 *mac,
14430#else
14431 u8 *mac,
14432#endif
14433 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014434{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014435 hdd_adapter_t *pAdapter;
14436 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014437 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014438#ifdef FEATURE_WLAN_TDLS
14439 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014440
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014441 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014442
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014443 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14444 if (NULL == pAdapter)
14445 {
14446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14447 "%s: Adapter is NULL",__func__);
14448 return -EINVAL;
14449 }
14450 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14451 status = wlan_hdd_validate_context(pHddCtx);
14452 if (0 != status)
14453 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014454 return status;
14455 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014456
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014457 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14458 TRACE_CODE_HDD_CFG80211_ADD_STA,
14459 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014460 mask = params->sta_flags_mask;
14461
14462 set = params->sta_flags_set;
14463
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014464 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014465 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
14466 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014467
14468 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
14469 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080014470 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014471 }
14472 }
14473#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014474 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014475 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014476}
14477
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014478#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
14479static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
14480 struct net_device *dev, const u8 *mac,
14481 struct station_parameters *params)
14482#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014483static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
14484 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014485#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014486{
14487 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014488
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014489 vos_ssr_protect(__func__);
14490 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
14491 vos_ssr_unprotect(__func__);
14492
14493 return ret;
14494}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014495#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070014496
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014497static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070014498 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014499{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014500 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14501 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014502 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014503 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014504 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014505 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070014506
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014507 ENTER();
14508
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014509 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014510 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014511 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014512 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014513 return -EINVAL;
14514 }
14515
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014516 if (!pmksa) {
14517 hddLog(LOGE, FL("pmksa is NULL"));
14518 return -EINVAL;
14519 }
14520
14521 if (!pmksa->bssid || !pmksa->pmkid) {
14522 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
14523 pmksa->bssid, pmksa->pmkid);
14524 return -EINVAL;
14525 }
14526
14527 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
14528 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14529
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014530 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14531 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014532 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014533 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014534 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014535 }
14536
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014537 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014538 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14539
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014540 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
14541 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014542
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014543 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014544 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014545 &pmk_id, 1, FALSE);
14546
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014547 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14548 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
14549 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014550
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014551 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014552 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014553}
14554
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014555static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
14556 struct cfg80211_pmksa *pmksa)
14557{
14558 int ret;
14559
14560 vos_ssr_protect(__func__);
14561 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
14562 vos_ssr_unprotect(__func__);
14563
14564 return ret;
14565}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014566
Wilson Yang6507c4e2013-10-01 20:11:19 -070014567
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014568static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070014569 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014570{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014571 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14572 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014573 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014574 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014575
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014576 ENTER();
14577
Wilson Yang6507c4e2013-10-01 20:11:19 -070014578 /* Validate pAdapter */
14579 if (NULL == pAdapter)
14580 {
14581 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
14582 return -EINVAL;
14583 }
14584
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014585 if (!pmksa) {
14586 hddLog(LOGE, FL("pmksa is NULL"));
14587 return -EINVAL;
14588 }
14589
14590 if (!pmksa->bssid) {
14591 hddLog(LOGE, FL("pmksa->bssid is NULL"));
14592 return -EINVAL;
14593 }
14594
Kiet Lam98c46a12014-10-31 15:34:57 -070014595 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
14596 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14597
Wilson Yang6507c4e2013-10-01 20:11:19 -070014598 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14599 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014600 if (0 != status)
14601 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014602 return status;
14603 }
14604
14605 /*Retrieve halHandle*/
14606 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14607
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014608 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14609 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
14610 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014611 /* Delete the PMKID CSR cache */
14612 if (eHAL_STATUS_SUCCESS !=
14613 sme_RoamDelPMKIDfromCache(halHandle,
14614 pAdapter->sessionId, pmksa->bssid, FALSE)) {
14615 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
14616 MAC_ADDR_ARRAY(pmksa->bssid));
14617 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014618 }
14619
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014620 EXIT();
14621 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014622}
14623
Wilson Yang6507c4e2013-10-01 20:11:19 -070014624
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014625static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
14626 struct cfg80211_pmksa *pmksa)
14627{
14628 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014629
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014630 vos_ssr_protect(__func__);
14631 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
14632 vos_ssr_unprotect(__func__);
14633
14634 return ret;
14635
14636}
14637
14638static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014639{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014640 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14641 tHalHandle halHandle;
14642 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014643 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014644
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014645 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070014646
14647 /* Validate pAdapter */
14648 if (NULL == pAdapter)
14649 {
14650 hddLog(VOS_TRACE_LEVEL_ERROR,
14651 "%s: Invalid Adapter" ,__func__);
14652 return -EINVAL;
14653 }
14654
14655 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14656 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014657 if (0 != status)
14658 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014659 return status;
14660 }
14661
14662 /*Retrieve halHandle*/
14663 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14664
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014665 /* Flush the PMKID cache in CSR */
14666 if (eHAL_STATUS_SUCCESS !=
14667 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
14668 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
14669 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014670 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014671 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080014672 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014673}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014674
14675static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
14676{
14677 int ret;
14678
14679 vos_ssr_protect(__func__);
14680 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
14681 vos_ssr_unprotect(__func__);
14682
14683 return ret;
14684}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014685#endif
14686
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014687#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014688static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14689 struct net_device *dev,
14690 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014691{
14692 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14693 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014694 hdd_context_t *pHddCtx;
14695 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014696
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014697 ENTER();
14698
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014699 if (NULL == pAdapter)
14700 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014701 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014702 return -ENODEV;
14703 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014704 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14705 ret = wlan_hdd_validate_context(pHddCtx);
14706 if (0 != ret)
14707 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014708 return ret;
14709 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014710 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014711 if (NULL == pHddStaCtx)
14712 {
14713 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
14714 return -EINVAL;
14715 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014716
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014717 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14718 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
14719 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014720 // Added for debug on reception of Re-assoc Req.
14721 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
14722 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014723 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014724 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080014725 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014726 }
14727
14728#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080014729 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014730 ftie->ie_len);
14731#endif
14732
14733 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014734 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14735 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014736 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014737
14738 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014739 return 0;
14740}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014741
14742static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14743 struct net_device *dev,
14744 struct cfg80211_update_ft_ies_params *ftie)
14745{
14746 int ret;
14747
14748 vos_ssr_protect(__func__);
14749 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
14750 vos_ssr_unprotect(__func__);
14751
14752 return ret;
14753}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014754#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014755
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014756#ifdef FEATURE_WLAN_SCAN_PNO
14757
14758void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
14759 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
14760{
14761 int ret;
14762 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
14763 hdd_context_t *pHddCtx;
14764
Nirav Shah80830bf2013-12-31 16:35:12 +053014765 ENTER();
14766
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014767 if (NULL == pAdapter)
14768 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014769 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014770 "%s: HDD adapter is Null", __func__);
14771 return ;
14772 }
14773
14774 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14775 if (NULL == pHddCtx)
14776 {
14777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14778 "%s: HDD context is Null!!!", __func__);
14779 return ;
14780 }
14781
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014782 spin_lock(&pHddCtx->schedScan_lock);
14783 if (TRUE == pHddCtx->isWiphySuspended)
14784 {
14785 pHddCtx->isSchedScanUpdatePending = TRUE;
14786 spin_unlock(&pHddCtx->schedScan_lock);
14787 hddLog(VOS_TRACE_LEVEL_INFO,
14788 "%s: Update cfg80211 scan database after it resume", __func__);
14789 return ;
14790 }
14791 spin_unlock(&pHddCtx->schedScan_lock);
14792
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014793 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
14794
14795 if (0 > ret)
14796 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
14797
14798 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14800 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014801}
14802
14803/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014804 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014805 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014806 */
14807static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
14808{
14809 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
14810 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014811 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014812 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14813 int status = 0;
14814 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
14815
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014816 /* The current firmware design does not allow PNO during any
14817 * active sessions. Hence, determine the active sessions
14818 * and return a failure.
14819 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014820 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
14821 {
14822 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014823 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014824
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014825 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
14826 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
14827 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
14828 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
14829 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053014830 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014831 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014832 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014833 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014834 }
14835 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14836 pAdapterNode = pNext;
14837 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014838 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014839}
14840
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014841void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
14842{
14843 hdd_adapter_t *pAdapter = callbackContext;
14844 hdd_context_t *pHddCtx;
14845
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014846 ENTER();
14847
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014848 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
14849 {
14850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14851 FL("Invalid adapter or adapter has invalid magic"));
14852 return;
14853 }
14854
14855 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14856 if (0 != wlan_hdd_validate_context(pHddCtx))
14857 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014858 return;
14859 }
14860
c_hpothub53c45d2014-08-18 16:53:14 +053014861 if (VOS_STATUS_SUCCESS != status)
14862 {
14863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014864 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053014865 pHddCtx->isPnoEnable = FALSE;
14866 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014867
14868 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
14869 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014870 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014871}
14872
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014873/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014874 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
14875 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014876 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014877static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014878 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14879{
14880 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014881 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014882 hdd_context_t *pHddCtx;
14883 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014884 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053014885 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
14886 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014887 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14888 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014889 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014890 hdd_config_t *pConfig = NULL;
14891 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014892
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014893 ENTER();
14894
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014895 if (NULL == pAdapter)
14896 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014898 "%s: HDD adapter is Null", __func__);
14899 return -ENODEV;
14900 }
14901
14902 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014903 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014904
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014905 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014906 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014907 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014908 }
14909
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014910 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014911 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14912 if (NULL == hHal)
14913 {
14914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14915 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014916 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014917 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014918 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14919 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
14920 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053014921 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014922 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053014923 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014924 {
14925 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14926 "%s: aborting the existing scan is unsuccessfull", __func__);
14927 return -EBUSY;
14928 }
14929
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014930 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014931 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014933 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014934 return -EBUSY;
14935 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014936
c_hpothu37f21312014-04-09 21:49:54 +053014937 if (TRUE == pHddCtx->isPnoEnable)
14938 {
14939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14940 FL("already PNO is enabled"));
14941 return -EBUSY;
14942 }
c_hpothu225aa7c2014-10-22 17:45:13 +053014943
14944 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
14945 {
14946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14947 "%s: abort ROC failed ", __func__);
14948 return -EBUSY;
14949 }
14950
c_hpothu37f21312014-04-09 21:49:54 +053014951 pHddCtx->isPnoEnable = TRUE;
14952
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014953 pnoRequest.enable = 1; /*Enable PNO */
14954 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014955
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014956 if (( !pnoRequest.ucNetworksCount ) ||
14957 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014958 {
14959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014960 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014961 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014962 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014963 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014964 goto error;
14965 }
14966
14967 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
14968 {
14969 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014970 "%s: Incorrect number of channels %d",
14971 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014972 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014973 goto error;
14974 }
14975
14976 /* Framework provides one set of channels(all)
14977 * common for all saved profile */
14978 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14979 channels_allowed, &num_channels_allowed))
14980 {
14981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14982 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014983 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014984 goto error;
14985 }
14986 /* Checking each channel against allowed channel list */
14987 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053014988 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014989 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014990 char chList [(request->n_channels*5)+1];
14991 int len;
14992 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014993 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014994 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014995 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014996 if (request->channels[i]->hw_value == channels_allowed[indx])
14997 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014998 if ((!pConfig->enableDFSPnoChnlScan) &&
14999 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
15000 {
15001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15002 "%s : Dropping DFS channel : %d",
15003 __func__,channels_allowed[indx]);
15004 num_ignore_dfs_ch++;
15005 break;
15006 }
15007
Nirav Shah80830bf2013-12-31 16:35:12 +053015008 valid_ch[num_ch++] = request->channels[i]->hw_value;
15009 len += snprintf(chList+len, 5, "%d ",
15010 request->channels[i]->hw_value);
15011 break ;
15012 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015013 }
15014 }
Nirav Shah80830bf2013-12-31 16:35:12 +053015015 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015016
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053015017 /*If all channels are DFS and dropped, then ignore the PNO request*/
15018 if (num_ignore_dfs_ch == request->n_channels)
15019 {
15020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15021 "%s : All requested channels are DFS channels", __func__);
15022 ret = -EINVAL;
15023 goto error;
15024 }
15025 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015026
15027 pnoRequest.aNetworks =
15028 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
15029 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015030 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015031 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15032 FL("failed to allocate memory aNetworks %u"),
15033 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
15034 goto error;
15035 }
15036 vos_mem_zero(pnoRequest.aNetworks,
15037 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
15038
15039 /* Filling per profile params */
15040 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
15041 {
15042 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015043 request->match_sets[i].ssid.ssid_len;
15044
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015045 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
15046 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015047 {
15048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053015049 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015050 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053015051 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015052 goto error;
15053 }
15054
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015055 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015056 request->match_sets[i].ssid.ssid,
15057 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053015058 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15059 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015060 i, pnoRequest.aNetworks[i].ssId.ssId);
15061 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
15062 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
15063 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015064
15065 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015066 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
15067 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015068
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015069 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015070 }
15071
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053015072 for (i = 0; i < request->n_ssids; i++)
15073 {
15074 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015075 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053015076 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015077 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053015078 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015079 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053015080 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015081 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053015082 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015083 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053015084 break;
15085 }
15086 j++;
15087 }
15088 }
15089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15090 "Number of hidden networks being Configured = %d",
15091 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053015092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080015093 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015094
15095 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
15096 if (pnoRequest.p24GProbeTemplate == NULL)
15097 {
15098 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15099 FL("failed to allocate memory p24GProbeTemplate %u"),
15100 SIR_PNO_MAX_PB_REQ_SIZE);
15101 goto error;
15102 }
15103
15104 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
15105 if (pnoRequest.p5GProbeTemplate == NULL)
15106 {
15107 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15108 FL("failed to allocate memory p5GProbeTemplate %u"),
15109 SIR_PNO_MAX_PB_REQ_SIZE);
15110 goto error;
15111 }
15112
15113 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
15114 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
15115
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053015116 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
15117 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053015118 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015119 pnoRequest.us24GProbeTemplateLen = request->ie_len;
15120 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
15121 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053015122
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015123 pnoRequest.us5GProbeTemplateLen = request->ie_len;
15124 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
15125 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053015126 }
15127
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053015128 /* Driver gets only one time interval which is hardcoded in
15129 * supplicant for 10000ms. Taking power consumption into account 6 timers
15130 * will be used, Timervalue is increased exponentially i.e 10,20,40,
15131 * 80,160,320 secs. And number of scan cycle for each timer
15132 * is configurable through INI param gPNOScanTimerRepeatValue.
15133 * If it is set to 0 only one timer will be used and PNO scan cycle
15134 * will be repeated after each interval specified by supplicant
15135 * till PNO is disabled.
15136 */
15137 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015138 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053015139 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015140 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053015141 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
15142
15143 tempInterval = (request->interval)/1000;
15144 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15145 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
15146 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015147 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053015148 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015149 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053015150 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015151 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053015152 tempInterval *= 2;
15153 }
15154 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015155 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053015156
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015157 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015158
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053015159 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015160 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
15161 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053015162 pAdapter->pno_req_status = 0;
15163
Nirav Shah80830bf2013-12-31 16:35:12 +053015164 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15165 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015166 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
15167 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053015168
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015169 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015170 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015171 hdd_cfg80211_sched_scan_done_callback, pAdapter);
15172 if (eHAL_STATUS_SUCCESS != status)
15173 {
15174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053015175 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053015176 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015177 goto error;
15178 }
15179
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053015180 ret = wait_for_completion_timeout(
15181 &pAdapter->pno_comp_var,
15182 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
15183 if (0 >= ret)
15184 {
15185 // Did not receive the response for PNO enable in time.
15186 // Assuming the PNO enable was success.
15187 // Returning error from here, because we timeout, results
15188 // in side effect of Wifi (Wifi Setting) not to work.
15189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15190 FL("Timed out waiting for PNO to be Enabled"));
15191 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053015192 }
15193
15194 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053015195 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015196
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015197error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053015198 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15199 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053015200 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015201 if (pnoRequest.aNetworks)
15202 vos_mem_free(pnoRequest.aNetworks);
15203 if (pnoRequest.p24GProbeTemplate)
15204 vos_mem_free(pnoRequest.p24GProbeTemplate);
15205 if (pnoRequest.p5GProbeTemplate)
15206 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015207
15208 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053015209 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015210}
15211
15212/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053015213 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
15214 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015215 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053015216static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
15217 struct net_device *dev, struct cfg80211_sched_scan_request *request)
15218{
15219 int ret;
15220
15221 vos_ssr_protect(__func__);
15222 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
15223 vos_ssr_unprotect(__func__);
15224
15225 return ret;
15226}
15227
15228/*
15229 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
15230 * Function to disable PNO
15231 */
15232static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015233 struct net_device *dev)
15234{
15235 eHalStatus status = eHAL_STATUS_FAILURE;
15236 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15237 hdd_context_t *pHddCtx;
15238 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015239 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053015240 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015241
15242 ENTER();
15243
15244 if (NULL == pAdapter)
15245 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015247 "%s: HDD adapter is Null", __func__);
15248 return -ENODEV;
15249 }
15250
15251 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015252
Kamath Vinayakba5313f2013-08-22 15:52:39 +053015253 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015254 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015255 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053015256 "%s: HDD context is Null", __func__);
15257 return -ENODEV;
15258 }
15259
15260 /* The return 0 is intentional when isLogpInProgress and
15261 * isLoadUnloadInProgress. We did observe a crash due to a return of
15262 * failure in sched_scan_stop , especially for a case where the unload
15263 * of the happens at the same time. The function __cfg80211_stop_sched_scan
15264 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
15265 * success. If it returns a failure , then its next invocation due to the
15266 * clean up of the second interface will have the dev pointer corresponding
15267 * to the first one leading to a crash.
15268 */
15269 if (pHddCtx->isLogpInProgress)
15270 {
15271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15272 "%s: LOGP in Progress. Ignore!!!", __func__);
15273 return ret;
15274 }
15275
Mihir Shete18156292014-03-11 15:38:30 +053015276 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053015277 {
15278 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15279 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
15280 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015281 }
15282
15283 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
15284 if (NULL == hHal)
15285 {
15286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15287 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015288 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015289 }
15290
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015291 pnoRequest.enable = 0; /* Disable PNO */
15292 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015293
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053015294 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15295 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
15296 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015297 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015298 pAdapter->sessionId,
15299 NULL, pAdapter);
15300 if (eHAL_STATUS_SUCCESS != status)
15301 {
15302 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15303 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053015304 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053015305 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015306 }
c_hpothu37f21312014-04-09 21:49:54 +053015307 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015308
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053015309error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015310 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053015311 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015312
15313 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053015314 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015315}
15316
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053015317/*
15318 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
15319 * NL interface to disable PNO
15320 */
15321static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
15322 struct net_device *dev)
15323{
15324 int ret;
15325
15326 vos_ssr_protect(__func__);
15327 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
15328 vos_ssr_unprotect(__func__);
15329
15330 return ret;
15331}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015332#endif /*FEATURE_WLAN_SCAN_PNO*/
15333
15334
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015335#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015336#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015337static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15338 struct net_device *dev,
15339 u8 *peer, u8 action_code,
15340 u8 dialog_token,
15341 u16 status_code, u32 peer_capability,
15342 const u8 *buf, size_t len)
15343#else /* TDLS_MGMT_VERSION2 */
15344#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
15345static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15346 struct net_device *dev,
15347 const u8 *peer, u8 action_code,
15348 u8 dialog_token, u16 status_code,
15349 u32 peer_capability, bool initiator,
15350 const u8 *buf, size_t len)
15351#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
15352static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15353 struct net_device *dev,
15354 const u8 *peer, u8 action_code,
15355 u8 dialog_token, u16 status_code,
15356 u32 peer_capability, const u8 *buf,
15357 size_t len)
15358#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
15359static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15360 struct net_device *dev,
15361 u8 *peer, u8 action_code,
15362 u8 dialog_token,
15363 u16 status_code, u32 peer_capability,
15364 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015365#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015366static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15367 struct net_device *dev,
15368 u8 *peer, u8 action_code,
15369 u8 dialog_token,
15370 u16 status_code, const u8 *buf,
15371 size_t len)
15372#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015373#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015374{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015375 hdd_adapter_t *pAdapter;
15376 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015377 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070015378 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080015379 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070015380 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015381 int ret;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015382#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015383 u32 peer_capability = 0;
15384#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015385 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015386 hdd_station_ctx_t *pHddStaCtx = NULL;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015387
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015388 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15389 if (NULL == pAdapter)
15390 {
15391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15392 "%s: Adapter is NULL",__func__);
15393 return -EINVAL;
15394 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015395 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15396 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
15397 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015398
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015399 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015400 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015401 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015402 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015403 "Invalid arguments");
15404 return -EINVAL;
15405 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015406
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015407 if (pHddCtx->isLogpInProgress)
15408 {
15409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15410 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053015411 wlan_hdd_tdls_set_link_status(pAdapter,
15412 peer,
15413 eTDLS_LINK_IDLE,
15414 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015415 return -EBUSY;
15416 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015417
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015418 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
15419 {
15420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15421 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
15422 return -EAGAIN;
15423 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015424
Hoonki Lee27511902013-03-14 18:19:06 -070015425 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015426 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015427 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070015428 "%s: TDLS mode is disabled OR not enabled in FW."
15429 MAC_ADDRESS_STR " action %d declined.",
15430 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015431 return -ENOTSUPP;
15432 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015433
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015434 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15435
15436 if( NULL == pHddStaCtx )
15437 {
15438 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15439 "%s: HDD station context NULL ",__func__);
15440 return -EINVAL;
15441 }
15442
15443 /* STA should be connected and authenticated
15444 * before sending any TDLS frames
15445 */
15446 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
15447 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
15448 {
15449 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15450 "STA is not connected or unauthenticated. "
15451 "connState %u, uIsAuthenticated %u",
15452 pHddStaCtx->conn_info.connState,
15453 pHddStaCtx->conn_info.uIsAuthenticated);
15454 return -EAGAIN;
15455 }
15456
Hoonki Lee27511902013-03-14 18:19:06 -070015457 /* other than teardown frame, other mgmt frames are not sent if disabled */
15458 if (SIR_MAC_TDLS_TEARDOWN != action_code)
15459 {
15460 /* if tdls_mode is disabled to respond to peer's request */
15461 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
15462 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015463 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070015464 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015465 " TDLS mode is disabled. action %d declined.",
15466 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070015467
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015468 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070015469 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053015470
15471 if (vos_max_concurrent_connections_reached())
15472 {
15473 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15474 return -EINVAL;
15475 }
Hoonki Lee27511902013-03-14 18:19:06 -070015476 }
15477
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015478 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
15479 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053015480 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015481 {
15482 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015483 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015484 " TDLS setup is ongoing. action %d declined.",
15485 __func__, MAC_ADDR_ARRAY(peer), action_code);
15486 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015487 }
15488 }
15489
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015490 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
15491 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080015492 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015493 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15494 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080015495 {
15496 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
15497 we return error code at 'add_station()'. Hence we have this
15498 check again in addtion to add_station().
15499 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015500 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080015501 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015502 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15503 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015504 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
15505 __func__, MAC_ADDR_ARRAY(peer), action_code,
15506 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053015507 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080015508 }
15509 else
15510 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015511 /* maximum reached. tweak to send error code to peer and return
15512 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080015513 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015514 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15515 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015516 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
15517 __func__, MAC_ADDR_ARRAY(peer), status_code,
15518 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070015519 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015520 /* fall through to send setup resp with failure status
15521 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080015522 }
15523 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015524 else
15525 {
15526 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053015527 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015528 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015529 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015530 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015531 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
15532 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015533 return -EPERM;
15534 }
15535 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015536 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015537
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015538 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053015539 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015540 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
15541 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015542
Hoonki Leea34dd892013-02-05 22:56:02 -080015543 /*Except teardown responder will not be used so just make 0*/
15544 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015545 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080015546 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015547
15548 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015549 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015550
15551 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
15552 responder = pTdlsPeer->is_responder;
15553 else
Hoonki Leea34dd892013-02-05 22:56:02 -080015554 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015555 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053015556 "%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 -070015557 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
15558 dialog_token, status_code, len);
15559 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080015560 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015561 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015562
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015563 /* For explicit trigger of DIS_REQ come out of BMPS for
15564 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070015565 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015566 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
15567 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070015568 {
15569 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
15570 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015571 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015572 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015573 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
15574 if (status != VOS_STATUS_SUCCESS) {
15575 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
15576 }
Hoonki Lee14621352013-04-16 17:51:19 -070015577 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015578 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015579 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015580 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
15581 }
15582 }
Hoonki Lee14621352013-04-16 17:51:19 -070015583 }
15584
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015585 /* make sure doesn't call send_mgmt() while it is pending */
15586 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
15587 {
15588 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015589 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015590 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015591 ret = -EBUSY;
15592 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015593 }
15594
15595 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015596 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
15597
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015598 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
15599 pAdapter->sessionId, peer, action_code, dialog_token,
15600 status_code, peer_capability, (tANI_U8 *)buf, len,
15601 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015602
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015603 if (VOS_STATUS_SUCCESS != status)
15604 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15606 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015607 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015608 ret = -EINVAL;
15609 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015610 }
15611
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015612 if ((SIR_MAC_TDLS_DIS_REQ == action_code) ||
15613 (SIR_MAC_TDLS_DIS_RSP == action_code))
15614 {
15615 /* for DIS_REQ/DIS_RSP, supplicant don't consider the return status.
15616 * So we no need to wait for tdls_mgmt_comp for sending ack status.
15617 */
15618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15619 "%s: tx done for frm %u", __func__, action_code);
15620 return 0;
15621 }
15622
15623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15624 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
15625 WAIT_TIME_TDLS_MGMT);
15626
Hoonki Leed37cbb32013-04-20 00:31:14 -070015627 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
15628 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
15629
15630 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015631 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070015632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070015633 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070015634 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015635 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080015636
15637 if (pHddCtx->isLogpInProgress)
15638 {
15639 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15640 "%s: LOGP in Progress. Ignore!!!", __func__);
15641 return -EAGAIN;
15642 }
15643
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015644 ret = -EINVAL;
15645 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015646 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015647 else
15648 {
15649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15650 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
15651 __func__, rc, pAdapter->mgmtTxCompletionStatus);
15652 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015653
Gopichand Nakkala05922802013-03-14 12:23:19 -070015654 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070015655 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015656 ret = max_sta_failed;
15657 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070015658 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015659
Hoonki Leea34dd892013-02-05 22:56:02 -080015660 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
15661 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015662 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015663 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15664 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015665 }
15666 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
15667 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015668 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015669 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15670 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015671 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015672
15673 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015674
15675tx_failed:
15676 /* add_station will be called before sending TDLS_SETUP_REQ and
15677 * TDLS_SETUP_RSP and as part of add_station driver will enable
15678 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
15679 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
15680 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
15681 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
15682 */
15683
15684 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
15685 (SIR_MAC_TDLS_SETUP_RSP == action_code))
15686 wlan_hdd_tdls_check_bmps(pAdapter);
15687 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015688}
15689
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015690#if TDLS_MGMT_VERSION2
15691static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15692 u8 *peer, u8 action_code, u8 dialog_token,
15693 u16 status_code, u32 peer_capability,
15694 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015695#else /* TDLS_MGMT_VERSION2 */
15696#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
15697static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15698 struct net_device *dev,
15699 const u8 *peer, u8 action_code,
15700 u8 dialog_token, u16 status_code,
15701 u32 peer_capability, bool initiator,
15702 const u8 *buf, size_t len)
15703#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
15704static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15705 struct net_device *dev,
15706 const u8 *peer, u8 action_code,
15707 u8 dialog_token, u16 status_code,
15708 u32 peer_capability, const u8 *buf,
15709 size_t len)
15710#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
15711static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15712 struct net_device *dev,
15713 u8 *peer, u8 action_code,
15714 u8 dialog_token,
15715 u16 status_code, u32 peer_capability,
15716 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015717#else
15718static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15719 u8 *peer, u8 action_code, u8 dialog_token,
15720 u16 status_code, const u8 *buf, size_t len)
15721#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015722#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015723{
15724 int ret;
15725
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015726 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015727#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015728 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15729 dialog_token, status_code,
15730 peer_capability, buf, len);
15731#else /* TDLS_MGMT_VERSION2 */
15732#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
15733 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15734 dialog_token, status_code,
15735 peer_capability, initiator,
15736 buf, len);
15737#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
15738 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15739 dialog_token, status_code,
15740 peer_capability, buf, len);
15741#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
15742 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15743 dialog_token, status_code,
15744 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015745#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015746 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15747 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015748#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015749#endif
15750 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015751
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015752 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015753}
Atul Mittal115287b2014-07-08 13:26:33 +053015754
15755int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015756#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15757 const u8 *peer,
15758#else
Atul Mittal115287b2014-07-08 13:26:33 +053015759 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015760#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015761 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053015762 cfg80211_exttdls_callback callback)
15763{
15764
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015765 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053015766 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015767 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053015768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15769 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
15770 __func__, MAC_ADDR_ARRAY(peer));
15771
15772 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15773 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15774
15775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015776 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15777 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15778 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015779 return -ENOTSUPP;
15780 }
15781
15782 /* To cater the requirement of establishing the TDLS link
15783 * irrespective of the data traffic , get an entry of TDLS peer.
15784 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015785 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015786 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
15787 if (pTdlsPeer == NULL) {
15788 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15789 "%s: peer " MAC_ADDRESS_STR " not existing",
15790 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015791 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015792 return -EINVAL;
15793 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015794 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015795
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015796 /* check FW TDLS Off Channel capability */
15797 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015798 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015799 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015800 {
15801 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
15802 pTdlsPeer->peerParams.global_operating_class =
15803 tdls_peer_params->global_operating_class;
15804 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
15805 pTdlsPeer->peerParams.min_bandwidth_kbps =
15806 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015807 /* check configured channel is valid, non dfs and
15808 * not current operating channel */
15809 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
15810 tdls_peer_params->channel)) &&
15811 (pHddStaCtx) &&
15812 (tdls_peer_params->channel !=
15813 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015814 {
15815 pTdlsPeer->isOffChannelConfigured = TRUE;
15816 }
15817 else
15818 {
15819 pTdlsPeer->isOffChannelConfigured = FALSE;
15820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15821 "%s: Configured Tdls Off Channel is not valid", __func__);
15822
15823 }
15824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015825 "%s: tdls_off_channel %d isOffChannelConfigured %d "
15826 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015827 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015828 pTdlsPeer->isOffChannelConfigured,
15829 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015830 }
15831 else
15832 {
15833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015834 "%s: TDLS off channel FW capability %d, "
15835 "host capab %d or Invalid TDLS Peer Params", __func__,
15836 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
15837 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015838 }
15839
Atul Mittal115287b2014-07-08 13:26:33 +053015840 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
15841
15842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15843 " %s TDLS Add Force Peer Failed",
15844 __func__);
15845 return -EINVAL;
15846 }
15847 /*EXT TDLS*/
15848
15849 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
15850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15851 " %s TDLS set callback Failed",
15852 __func__);
15853 return -EINVAL;
15854 }
15855
15856 return(0);
15857
15858}
15859
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015860int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
15861#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15862 const u8 *peer
15863#else
15864 u8 *peer
15865#endif
15866)
Atul Mittal115287b2014-07-08 13:26:33 +053015867{
15868
15869 hddTdlsPeer_t *pTdlsPeer;
15870 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15872 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
15873 __func__, MAC_ADDR_ARRAY(peer));
15874
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015875 if (0 != wlan_hdd_validate_context(pHddCtx)) {
15876 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
15877 return -EINVAL;
15878 }
15879
Atul Mittal115287b2014-07-08 13:26:33 +053015880 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15881 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15882
15883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015884 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15885 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15886 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015887 return -ENOTSUPP;
15888 }
15889
15890
15891 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15892
15893 if ( NULL == pTdlsPeer ) {
15894 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015895 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053015896 __func__, MAC_ADDR_ARRAY(peer));
15897 return -EINVAL;
15898 }
15899 else {
15900 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
15901 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015902 /* if channel switch is configured, reset
15903 the channel for this peer */
15904 if (TRUE == pTdlsPeer->isOffChannelConfigured)
15905 {
15906 pTdlsPeer->peerParams.channel = 0;
15907 pTdlsPeer->isOffChannelConfigured = FALSE;
15908 }
Atul Mittal115287b2014-07-08 13:26:33 +053015909 }
15910
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015911 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
15912 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053015913 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015914 }
Atul Mittal115287b2014-07-08 13:26:33 +053015915
15916 /*EXT TDLS*/
15917
15918 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
15919
15920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15921 " %s TDLS set callback Failed",
15922 __func__);
15923 return -EINVAL;
15924 }
15925 return(0);
15926
15927}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015928static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015929#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15930 const u8 *peer,
15931#else
15932 u8 *peer,
15933#endif
15934 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015935{
15936 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15937 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015938 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015939 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015940
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015941 ENTER();
15942
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015943 if (!pAdapter) {
15944 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15945 return -EINVAL;
15946 }
15947
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015948 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15949 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
15950 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015951 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015952 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015953 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070015954 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015955 return -EINVAL;
15956 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015957
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015958 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015959 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015960 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015961 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015962 }
15963
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015964
15965 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015966 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015967 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015968 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015969 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
15970 "Cannot process TDLS commands",
15971 pHddCtx->cfg_ini->fEnableTDLSSupport,
15972 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015973 return -ENOTSUPP;
15974 }
15975
15976 switch (oper) {
15977 case NL80211_TDLS_ENABLE_LINK:
15978 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015979 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015980 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015981 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053015982 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015983 tANI_U16 numCurrTdlsPeers = 0;
15984 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015985 tANI_U8 suppChannelLen = 0;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015986
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15988 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
15989 __func__, MAC_ADDR_ARRAY(peer));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015990 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015991 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015992 if ( NULL == pTdlsPeer ) {
15993 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15994 " (oper %d) not exsting. ignored",
15995 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15996 return -EINVAL;
15997 }
15998
15999 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16000 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
16001 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
16002 "NL80211_TDLS_ENABLE_LINK");
16003
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070016004 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
16005 {
16006 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
16007 MAC_ADDRESS_STR " failed",
16008 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
16009 return -EINVAL;
16010 }
16011
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053016012 /* before starting tdls connection, set tdls
16013 * off channel established status to default value */
16014 pTdlsPeer->isOffChannelEstablished = FALSE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016015 /* TDLS Off Channel, Disable tdls channel switch,
16016 when there are more than one tdls link */
16017 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053016018 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016019 {
16020 /* get connected peer and send disable tdls off chan */
16021 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053016022 if ((connPeer) &&
16023 (connPeer->isOffChannelSupported == TRUE) &&
16024 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016025 {
16026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16027 "%s: More then one peer connected, Disable "
16028 "TDLS channel switch", __func__);
16029
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053016030 connPeer->isOffChannelEstablished = FALSE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053016031 ret = sme_SendTdlsChanSwitchReq(
16032 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016033 pAdapter->sessionId,
16034 connPeer->peerMac,
16035 connPeer->peerParams.channel,
16036 TDLS_OFF_CHANNEL_BW_OFFSET,
16037 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053016038 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053016039 hddLog(VOS_TRACE_LEVEL_ERROR,
16040 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053016041 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016042 }
16043 else
16044 {
16045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16046 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053016047 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016048 "isOffChannelConfigured %d",
16049 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053016050 (connPeer ? (connPeer->isOffChannelSupported)
16051 : -1),
16052 (connPeer ? (connPeer->isOffChannelConfigured)
16053 : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016054 }
16055 }
16056
Hoonki Lee5305c3a2013-04-29 23:28:59 -070016057 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016058 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053016059 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053016060
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053016061 if (0 != wlan_hdd_tdls_get_link_establish_params(
16062 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053016063 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053016064 return -EINVAL;
16065 }
16066 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053016067
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053016068 ret = sme_SendTdlsLinkEstablishParams(
16069 WLAN_HDD_GET_HAL_CTX(pAdapter),
16070 pAdapter->sessionId, peer,
16071 &tdlsLinkEstablishParams);
16072 if (ret != VOS_STATUS_SUCCESS) {
16073 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
16074 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053016075 /* Send TDLS peer UAPSD capabilities to the firmware and
16076 * register with the TL on after the response for this operation
16077 * is received .
16078 */
16079 ret = wait_for_completion_interruptible_timeout(
16080 &pAdapter->tdls_link_establish_req_comp,
16081 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
16082 if (ret <= 0)
16083 {
16084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053016085 FL("Link Establish Request Failed Status %ld"),
16086 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053016087 return -EINVAL;
16088 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053016089 }
Atul Mittal115287b2014-07-08 13:26:33 +053016090 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
16091 eTDLS_LINK_CONNECTED,
16092 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053016093 staDesc.ucSTAId = pTdlsPeer->staId;
16094 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053016095 ret = WLANTL_UpdateTdlsSTAClient(
16096 pHddCtx->pvosContext,
16097 &staDesc);
16098 if (ret != VOS_STATUS_SUCCESS) {
16099 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
16100 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053016101
Gopichand Nakkala471708b2013-06-04 20:03:01 +053016102 /* Mark TDLS client Authenticated .*/
16103 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
16104 pTdlsPeer->staId,
16105 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070016106 if (VOS_STATUS_SUCCESS == status)
16107 {
Hoonki Lee14621352013-04-16 17:51:19 -070016108 if (pTdlsPeer->is_responder == 0)
16109 {
16110 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
16111
16112 wlan_hdd_tdls_timer_restart(pAdapter,
16113 &pTdlsPeer->initiatorWaitTimeoutTimer,
16114 WAIT_TIME_TDLS_INITIATOR);
16115 /* suspend initiator TX until it receives direct packet from the
16116 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053016117 ret = WLANTL_SuspendDataTx(
16118 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
16119 &staId, NULL);
16120 if (ret != VOS_STATUS_SUCCESS) {
16121 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
16122 }
Hoonki Lee14621352013-04-16 17:51:19 -070016123 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016124
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053016125 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053016126 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053016127 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053016128 suppChannelLen =
16129 tdlsLinkEstablishParams.supportedChannelsLen;
16130
16131 if ((suppChannelLen > 0) &&
16132 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
16133 {
16134 tANI_U8 suppPeerChannel = 0;
16135 int i = 0;
16136 for (i = 0U; i < suppChannelLen; i++)
16137 {
16138 suppPeerChannel =
16139 tdlsLinkEstablishParams.supportedChannels[i];
16140
16141 pTdlsPeer->isOffChannelSupported = FALSE;
16142 if (suppPeerChannel ==
16143 pTdlsPeer->peerParams.channel)
16144 {
16145 pTdlsPeer->isOffChannelSupported = TRUE;
16146 break;
16147 }
16148 }
16149 }
16150 else
16151 {
16152 pTdlsPeer->isOffChannelSupported = FALSE;
16153 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053016154 }
16155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16156 "%s: TDLS channel switch request for channel "
16157 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053016158 "%d isOffChannelSupported %d", __func__,
16159 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053016160 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053016161 suppChannelLen,
16162 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053016163
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016164 /* TDLS Off Channel, Enable tdls channel switch,
16165 when their is only one tdls link and it supports */
16166 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
16167 if ((numCurrTdlsPeers == 1) &&
16168 (TRUE == pTdlsPeer->isOffChannelSupported) &&
16169 (TRUE == pTdlsPeer->isOffChannelConfigured))
16170 {
16171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16172 "%s: Send TDLS channel switch request for channel %d",
16173 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053016174
16175 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016176 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
16177 pAdapter->sessionId,
16178 pTdlsPeer->peerMac,
16179 pTdlsPeer->peerParams.channel,
16180 TDLS_OFF_CHANNEL_BW_OFFSET,
16181 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053016182 if (ret != VOS_STATUS_SUCCESS) {
16183 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
16184 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016185 }
16186 else
16187 {
16188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16189 "%s: TDLS channel switch request not sent"
16190 " numCurrTdlsPeers %d "
16191 "isOffChannelSupported %d "
16192 "isOffChannelConfigured %d",
16193 __func__, numCurrTdlsPeers,
16194 pTdlsPeer->isOffChannelSupported,
16195 pTdlsPeer->isOffChannelConfigured);
16196 }
16197
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070016198 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016199 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053016200
16201 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053016202 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
16203 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053016204 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053016205 int ac;
16206 uint8 ucAc[4] = { WLANTL_AC_VO,
16207 WLANTL_AC_VI,
16208 WLANTL_AC_BK,
16209 WLANTL_AC_BE };
16210 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
16211 for(ac=0; ac < 4; ac++)
16212 {
16213 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
16214 pTdlsPeer->staId, ucAc[ac],
16215 tlTid[ac], tlTid[ac], 0, 0,
16216 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053016217 if (status != VOS_STATUS_SUCCESS) {
16218 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
16219 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053016220 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053016221 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016222 }
16223
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016224 }
16225 break;
16226 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080016227 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016228 tANI_U16 numCurrTdlsPeers = 0;
16229 hddTdlsPeer_t *connPeer = NULL;
16230
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053016231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16232 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
16233 __func__, MAC_ADDR_ARRAY(peer));
16234
Sunil Dutt41de4e22013-11-14 18:09:02 +053016235 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
16236
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053016237
Sunil Dutt41de4e22013-11-14 18:09:02 +053016238 if ( NULL == pTdlsPeer ) {
16239 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
16240 " (oper %d) not exsting. ignored",
16241 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
16242 return -EINVAL;
16243 }
16244
16245 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16246 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
16247 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
16248 "NL80211_TDLS_DISABLE_LINK");
16249
Hoonki Lee5305c3a2013-04-29 23:28:59 -070016250 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080016251 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070016252 long status;
16253
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053016254 /* set tdls off channel status to false for this peer */
16255 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053016256 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
16257 eTDLS_LINK_TEARING,
16258 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
16259 eTDLS_LINK_UNSPECIFIED:
16260 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070016261 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
16262
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053016263 status = sme_DeleteTdlsPeerSta(
16264 WLAN_HDD_GET_HAL_CTX(pAdapter),
16265 pAdapter->sessionId, peer );
16266 if (status != VOS_STATUS_SUCCESS) {
16267 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
16268 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070016269
16270 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
16271 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053016272 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053016273 eTDLS_LINK_IDLE,
16274 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070016275 if (status <= 0)
16276 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070016277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16278 "%s: Del station failed status %ld",
16279 __func__, status);
16280 return -EPERM;
16281 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016282
16283 /* TDLS Off Channel, Enable tdls channel switch,
16284 when their is only one tdls link and it supports */
16285 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
16286 if (numCurrTdlsPeers == 1)
16287 {
16288 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
16289 if ((connPeer) &&
16290 (connPeer->isOffChannelSupported == TRUE) &&
16291 (connPeer->isOffChannelConfigured == TRUE))
16292 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053016293 connPeer->isOffChannelEstablished = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053016294 status = sme_SendTdlsChanSwitchReq(
16295 WLAN_HDD_GET_HAL_CTX(pAdapter),
16296 pAdapter->sessionId,
16297 connPeer->peerMac,
16298 connPeer->peerParams.channel,
16299 TDLS_OFF_CHANNEL_BW_OFFSET,
16300 TDLS_CHANNEL_SWITCH_ENABLE);
16301 if (status != VOS_STATUS_SUCCESS) {
16302 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
16303 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016304 }
16305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16306 "%s: TDLS channel switch "
16307 "isOffChannelSupported %d "
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053016308 "isOffChannelConfigured %d "
16309 "isOffChannelEstablished %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016310 __func__,
16311 (connPeer ? connPeer->isOffChannelSupported : -1),
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053016312 (connPeer ? connPeer->isOffChannelConfigured : -1),
16313 (connPeer ? connPeer->isOffChannelEstablished : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016314 }
16315 else
16316 {
16317 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16318 "%s: TDLS channel switch request not sent "
16319 "numCurrTdlsPeers %d ",
16320 __func__, numCurrTdlsPeers);
16321 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080016322 }
16323 else
16324 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16326 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080016327 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080016328 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016329 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016330 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053016331 {
Atul Mittal115287b2014-07-08 13:26:33 +053016332 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053016333
Atul Mittal115287b2014-07-08 13:26:33 +053016334 if (0 != status)
16335 {
16336 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053016337 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053016338 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053016339 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053016340 break;
16341 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016342 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053016343 {
Atul Mittal115287b2014-07-08 13:26:33 +053016344 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
16345 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016346 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053016347 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053016348
Atul Mittal115287b2014-07-08 13:26:33 +053016349 if (0 != status)
16350 {
16351 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053016352 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053016353 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053016354 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053016355 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053016356 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016357 case NL80211_TDLS_DISCOVERY_REQ:
16358 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053016360 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016361 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016362 return -ENOTSUPP;
16363 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16365 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016366 return -ENOTSUPP;
16367 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016368
16369 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016370 return 0;
16371}
Chilam NG571c65a2013-01-19 12:27:36 +053016372
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016373static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016374#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16375 const u8 *peer,
16376#else
16377 u8 *peer,
16378#endif
16379 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016380{
16381 int ret;
16382
16383 vos_ssr_protect(__func__);
16384 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
16385 vos_ssr_unprotect(__func__);
16386
16387 return ret;
16388}
16389
Chilam NG571c65a2013-01-19 12:27:36 +053016390int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
16391 struct net_device *dev, u8 *peer)
16392{
Arif Hussaina7c8e412013-11-20 11:06:42 -080016393 hddLog(VOS_TRACE_LEVEL_INFO,
16394 "tdls send discover req: "MAC_ADDRESS_STR,
16395 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053016396
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016397#if TDLS_MGMT_VERSION2
16398 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16399 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16400#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016401#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
16402 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16403 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
16404#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16405 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16406 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16407#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
16408 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16409 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16410#else
Chilam NG571c65a2013-01-19 12:27:36 +053016411 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16412 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016413#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016414#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053016415}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016416#endif
16417
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016418#ifdef WLAN_FEATURE_GTK_OFFLOAD
16419/*
16420 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
16421 * Callback rountine called upon receiving response for
16422 * get offload info
16423 */
16424void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
16425 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
16426{
16427
16428 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016429 tANI_U8 tempReplayCounter[8];
16430 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016431
16432 ENTER();
16433
16434 if (NULL == pAdapter)
16435 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053016436 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016437 "%s: HDD adapter is Null", __func__);
16438 return ;
16439 }
16440
16441 if (NULL == pGtkOffloadGetInfoRsp)
16442 {
16443 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16444 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
16445 return ;
16446 }
16447
16448 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
16449 {
16450 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16451 "%s: wlan Failed to get replay counter value",
16452 __func__);
16453 return ;
16454 }
16455
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016456 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16457 /* Update replay counter */
16458 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
16459 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
16460
16461 {
16462 /* changing from little to big endian since supplicant
16463 * works on big endian format
16464 */
16465 int i;
16466 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
16467
16468 for (i = 0; i < 8; i++)
16469 {
16470 tempReplayCounter[7-i] = (tANI_U8)p[i];
16471 }
16472 }
16473
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016474 /* Update replay counter to NL */
16475 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016476 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016477}
16478
16479/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016480 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016481 * This function is used to offload GTK rekeying job to the firmware.
16482 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016483int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016484 struct cfg80211_gtk_rekey_data *data)
16485{
16486 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16487 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16488 hdd_station_ctx_t *pHddStaCtx;
16489 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016490 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016491 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016492 eHalStatus status = eHAL_STATUS_FAILURE;
16493
16494 ENTER();
16495
16496 if (NULL == pAdapter)
16497 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016498 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016499 "%s: HDD adapter is Null", __func__);
16500 return -ENODEV;
16501 }
16502
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016503 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16504 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
16505 pAdapter->sessionId, pAdapter->device_mode));
16506
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016507 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016508 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016509 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016510 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016511 }
16512
16513 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16514 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
16515 if (NULL == hHal)
16516 {
16517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16518 "%s: HAL context is Null!!!", __func__);
16519 return -EAGAIN;
16520 }
16521
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016522 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
16523 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
16524 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
16525 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016526 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016527 {
16528 /* changing from big to little endian since driver
16529 * works on little endian format
16530 */
16531 tANI_U8 *p =
16532 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
16533 int i;
16534
16535 for (i = 0; i < 8; i++)
16536 {
16537 p[7-i] = data->replay_ctr[i];
16538 }
16539 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016540
16541 if (TRUE == pHddCtx->hdd_wlan_suspended)
16542 {
16543 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016544 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
16545 sizeof (tSirGtkOffloadParams));
16546 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016547 pAdapter->sessionId);
16548
16549 if (eHAL_STATUS_SUCCESS != status)
16550 {
16551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16552 "%s: sme_SetGTKOffload failed, returned %d",
16553 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053016554
16555 /* Need to clear any trace of key value in the memory.
16556 * Thus zero out the memory even though it is local
16557 * variable.
16558 */
16559 vos_mem_zero(&hddGtkOffloadReqParams,
16560 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016561 return status;
16562 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16564 "%s: sme_SetGTKOffload successfull", __func__);
16565 }
16566 else
16567 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16569 "%s: wlan not suspended GTKOffload request is stored",
16570 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016571 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016572
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053016573 /* Need to clear any trace of key value in the memory.
16574 * Thus zero out the memory even though it is local
16575 * variable.
16576 */
16577 vos_mem_zero(&hddGtkOffloadReqParams,
16578 sizeof(hddGtkOffloadReqParams));
16579
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016580 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016581 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016582}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016583
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016584int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
16585 struct cfg80211_gtk_rekey_data *data)
16586{
16587 int ret;
16588
16589 vos_ssr_protect(__func__);
16590 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
16591 vos_ssr_unprotect(__func__);
16592
16593 return ret;
16594}
16595#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016596/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016597 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016598 * This function is used to set access control policy
16599 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016600static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16601 struct net_device *dev,
16602 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016603{
16604 int i;
16605 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16606 hdd_hostapd_state_t *pHostapdState;
16607 tsap_Config_t *pConfig;
16608 v_CONTEXT_t pVosContext = NULL;
16609 hdd_context_t *pHddCtx;
16610 int status;
16611
16612 ENTER();
16613
16614 if (NULL == pAdapter)
16615 {
16616 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16617 "%s: HDD adapter is Null", __func__);
16618 return -ENODEV;
16619 }
16620
16621 if (NULL == params)
16622 {
16623 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16624 "%s: params is Null", __func__);
16625 return -EINVAL;
16626 }
16627
16628 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16629 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016630 if (0 != status)
16631 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016632 return status;
16633 }
16634
16635 pVosContext = pHddCtx->pvosContext;
16636 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
16637
16638 if (NULL == pHostapdState)
16639 {
16640 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16641 "%s: pHostapdState is Null", __func__);
16642 return -EINVAL;
16643 }
16644
16645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
16646 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016647 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16648 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
16649 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016650
16651 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
16652 {
16653 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
16654
16655 /* default value */
16656 pConfig->num_accept_mac = 0;
16657 pConfig->num_deny_mac = 0;
16658
16659 /**
16660 * access control policy
16661 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
16662 * listed in hostapd.deny file.
16663 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
16664 * listed in hostapd.accept file.
16665 */
16666 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
16667 {
16668 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
16669 }
16670 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
16671 {
16672 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
16673 }
16674 else
16675 {
16676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16677 "%s:Acl Policy : %d is not supported",
16678 __func__, params->acl_policy);
16679 return -ENOTSUPP;
16680 }
16681
16682 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
16683 {
16684 pConfig->num_accept_mac = params->n_acl_entries;
16685 for (i = 0; i < params->n_acl_entries; i++)
16686 {
16687 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16688 "** Add ACL MAC entry %i in WhiletList :"
16689 MAC_ADDRESS_STR, i,
16690 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16691
16692 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
16693 sizeof(qcmacaddr));
16694 }
16695 }
16696 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
16697 {
16698 pConfig->num_deny_mac = params->n_acl_entries;
16699 for (i = 0; i < params->n_acl_entries; i++)
16700 {
16701 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16702 "** Add ACL MAC entry %i in BlackList :"
16703 MAC_ADDRESS_STR, i,
16704 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16705
16706 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
16707 sizeof(qcmacaddr));
16708 }
16709 }
16710
16711 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
16712 {
16713 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16714 "%s: SAP Set Mac Acl fail", __func__);
16715 return -EINVAL;
16716 }
16717 }
16718 else
16719 {
16720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053016721 "%s: Invalid device_mode = %s (%d)",
16722 __func__, hdd_device_modetoString(pAdapter->device_mode),
16723 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016724 return -EINVAL;
16725 }
16726
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016727 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016728 return 0;
16729}
16730
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016731static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16732 struct net_device *dev,
16733 const struct cfg80211_acl_data *params)
16734{
16735 int ret;
16736 vos_ssr_protect(__func__);
16737 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
16738 vos_ssr_unprotect(__func__);
16739
16740 return ret;
16741}
16742
Leo Chang9056f462013-08-01 19:21:11 -070016743#ifdef WLAN_NL80211_TESTMODE
16744#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070016745void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070016746(
16747 void *pAdapter,
16748 void *indCont
16749)
16750{
Leo Changd9df8aa2013-09-26 13:32:26 -070016751 tSirLPHBInd *lphbInd;
16752 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053016753 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070016754
16755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016756 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070016757
c_hpothu73f35e62014-04-18 13:40:08 +053016758 if (pAdapter == NULL)
16759 {
16760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16761 "%s: pAdapter is NULL\n",__func__);
16762 return;
16763 }
16764
Leo Chang9056f462013-08-01 19:21:11 -070016765 if (NULL == indCont)
16766 {
16767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016768 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070016769 return;
16770 }
16771
c_hpothu73f35e62014-04-18 13:40:08 +053016772 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070016773 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070016774 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053016775 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070016776 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070016777 GFP_ATOMIC);
16778 if (!skb)
16779 {
16780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16781 "LPHB timeout, NL buffer alloc fail");
16782 return;
16783 }
16784
Leo Changac3ba772013-10-07 09:47:04 -070016785 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070016786 {
16787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16788 "WLAN_HDD_TM_ATTR_CMD put fail");
16789 goto nla_put_failure;
16790 }
Leo Changac3ba772013-10-07 09:47:04 -070016791 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070016792 {
16793 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16794 "WLAN_HDD_TM_ATTR_TYPE put fail");
16795 goto nla_put_failure;
16796 }
Leo Changac3ba772013-10-07 09:47:04 -070016797 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070016798 sizeof(tSirLPHBInd), lphbInd))
16799 {
16800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16801 "WLAN_HDD_TM_ATTR_DATA put fail");
16802 goto nla_put_failure;
16803 }
Leo Chang9056f462013-08-01 19:21:11 -070016804 cfg80211_testmode_event(skb, GFP_ATOMIC);
16805 return;
16806
16807nla_put_failure:
16808 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16809 "NLA Put fail");
16810 kfree_skb(skb);
16811
16812 return;
16813}
16814#endif /* FEATURE_WLAN_LPHB */
16815
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016816static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070016817{
16818 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
16819 int err = 0;
16820#ifdef FEATURE_WLAN_LPHB
16821 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070016822 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016823
16824 ENTER();
16825
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016826 err = wlan_hdd_validate_context(pHddCtx);
16827 if (0 != err)
16828 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016829 return err;
16830 }
Leo Chang9056f462013-08-01 19:21:11 -070016831#endif /* FEATURE_WLAN_LPHB */
16832
16833 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
16834 if (err)
16835 {
16836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16837 "%s Testmode INV ATTR", __func__);
16838 return err;
16839 }
16840
16841 if (!tb[WLAN_HDD_TM_ATTR_CMD])
16842 {
16843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16844 "%s Testmode INV CMD", __func__);
16845 return -EINVAL;
16846 }
16847
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016848 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16849 TRACE_CODE_HDD_CFG80211_TESTMODE,
16850 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070016851 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
16852 {
16853#ifdef FEATURE_WLAN_LPHB
16854 /* Low Power Heartbeat configuration request */
16855 case WLAN_HDD_TM_CMD_WLAN_HB:
16856 {
16857 int buf_len;
16858 void *buf;
16859 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080016860 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070016861
16862 if (!tb[WLAN_HDD_TM_ATTR_DATA])
16863 {
16864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16865 "%s Testmode INV DATA", __func__);
16866 return -EINVAL;
16867 }
16868
16869 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
16870 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080016871
16872 hb_params_temp =(tSirLPHBReq *)buf;
16873 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
16874 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
16875 return -EINVAL;
16876
Leo Chang9056f462013-08-01 19:21:11 -070016877 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
16878 if (NULL == hb_params)
16879 {
16880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16881 "%s Request Buffer Alloc Fail", __func__);
16882 return -EINVAL;
16883 }
16884
16885 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070016886 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
16887 hb_params,
16888 wlan_hdd_cfg80211_lphb_ind_handler);
16889 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070016890 {
Leo Changd9df8aa2013-09-26 13:32:26 -070016891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16892 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070016893 vos_mem_free(hb_params);
16894 }
Leo Chang9056f462013-08-01 19:21:11 -070016895 return 0;
16896 }
16897#endif /* FEATURE_WLAN_LPHB */
16898 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16900 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070016901 return -EOPNOTSUPP;
16902 }
16903
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016904 EXIT();
16905 return err;
Leo Chang9056f462013-08-01 19:21:11 -070016906}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016907
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053016908static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
16909#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
16910 struct wireless_dev *wdev,
16911#endif
16912 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016913{
16914 int ret;
16915
16916 vos_ssr_protect(__func__);
16917 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
16918 vos_ssr_unprotect(__func__);
16919
16920 return ret;
16921}
Leo Chang9056f462013-08-01 19:21:11 -070016922#endif /* CONFIG_NL80211_TESTMODE */
16923
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016924static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016925 struct net_device *dev,
16926 int idx, struct survey_info *survey)
16927{
16928 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16929 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053016930 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016931 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053016932 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016933 v_S7_t snr,rssi;
16934 int status, i, j, filled = 0;
16935
16936 ENTER();
16937
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016938 if (NULL == pAdapter)
16939 {
16940 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16941 "%s: HDD adapter is Null", __func__);
16942 return -ENODEV;
16943 }
16944
16945 if (NULL == wiphy)
16946 {
16947 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16948 "%s: wiphy is Null", __func__);
16949 return -ENODEV;
16950 }
16951
16952 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16953 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016954 if (0 != status)
16955 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016956 return status;
16957 }
16958
Mihir Sheted9072e02013-08-21 17:02:29 +053016959 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16960
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016961 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053016962 0 != pAdapter->survey_idx ||
16963 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016964 {
16965 /* The survey dump ops when implemented completely is expected to
16966 * return a survey of all channels and the ops is called by the
16967 * kernel with incremental values of the argument 'idx' till it
16968 * returns -ENONET. But we can only support the survey for the
16969 * operating channel for now. survey_idx is used to track
16970 * that the ops is called only once and then return -ENONET for
16971 * the next iteration
16972 */
16973 pAdapter->survey_idx = 0;
16974 return -ENONET;
16975 }
16976
Mukul Sharma9d5233b2015-06-11 20:28:20 +053016977 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
16978 {
16979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16980 "%s: Roaming in progress, hence return ", __func__);
16981 return -ENONET;
16982 }
16983
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016984 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16985
16986 wlan_hdd_get_snr(pAdapter, &snr);
16987 wlan_hdd_get_rssi(pAdapter, &rssi);
16988
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016989 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16990 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
16991 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016992 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
16993 hdd_wlan_get_freq(channel, &freq);
16994
16995
16996 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
16997 {
16998 if (NULL == wiphy->bands[i])
16999 {
17000 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
17001 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
17002 continue;
17003 }
17004
17005 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
17006 {
17007 struct ieee80211_supported_band *band = wiphy->bands[i];
17008
17009 if (band->channels[j].center_freq == (v_U16_t)freq)
17010 {
17011 survey->channel = &band->channels[j];
17012 /* The Rx BDs contain SNR values in dB for the received frames
17013 * while the supplicant expects noise. So we calculate and
17014 * return the value of noise (dBm)
17015 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
17016 */
17017 survey->noise = rssi - snr;
17018 survey->filled = SURVEY_INFO_NOISE_DBM;
17019 filled = 1;
17020 }
17021 }
17022 }
17023
17024 if (filled)
17025 pAdapter->survey_idx = 1;
17026 else
17027 {
17028 pAdapter->survey_idx = 0;
17029 return -ENONET;
17030 }
17031
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017032 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053017033 return 0;
17034}
17035
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053017036static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
17037 struct net_device *dev,
17038 int idx, struct survey_info *survey)
17039{
17040 int ret;
17041
17042 vos_ssr_protect(__func__);
17043 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
17044 vos_ssr_unprotect(__func__);
17045
17046 return ret;
17047}
17048
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017049/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053017050 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017051 * this is called when cfg80211 driver resume
17052 * driver updates latest sched_scan scan result(if any) to cfg80211 database
17053 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053017054int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017055{
17056 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
17057 hdd_adapter_t *pAdapter;
17058 hdd_adapter_list_node_t *pAdapterNode, *pNext;
17059 VOS_STATUS status = VOS_STATUS_SUCCESS;
17060
17061 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017062
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053017063 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017064 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017065 return 0;
17066 }
17067
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017068 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
17069 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017070 spin_lock(&pHddCtx->schedScan_lock);
17071 pHddCtx->isWiphySuspended = FALSE;
17072 if (TRUE != pHddCtx->isSchedScanUpdatePending)
17073 {
17074 spin_unlock(&pHddCtx->schedScan_lock);
17075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17076 "%s: Return resume is not due to PNO indication", __func__);
17077 return 0;
17078 }
17079 // Reset flag to avoid updatating cfg80211 data old results again
17080 pHddCtx->isSchedScanUpdatePending = FALSE;
17081 spin_unlock(&pHddCtx->schedScan_lock);
17082
17083 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
17084
17085 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
17086 {
17087 pAdapter = pAdapterNode->pAdapter;
17088 if ( (NULL != pAdapter) &&
17089 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
17090 {
17091 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053017092 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
17094 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053017095 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017096 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053017097 {
17098 /* Acquire wakelock to handle the case where APP's tries to
17099 * suspend immediately after updating the scan results. Whis
17100 * results in app's is in suspended state and not able to
17101 * process the connect request to AP
17102 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053017103 hdd_prevent_suspend_timeout(2000,
17104 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017105 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053017106 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017107
17108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17109 "%s : cfg80211 scan result database updated", __func__);
17110
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017111 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017112 return 0;
17113
17114 }
17115 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
17116 pAdapterNode = pNext;
17117 }
17118
17119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
17120 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017121 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017122 return 0;
17123}
17124
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053017125int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
17126{
17127 int ret;
17128
17129 vos_ssr_protect(__func__);
17130 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
17131 vos_ssr_unprotect(__func__);
17132
17133 return ret;
17134}
17135
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017136/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053017137 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017138 * this is called when cfg80211 driver suspends
17139 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053017140int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017141 struct cfg80211_wowlan *wow)
17142{
17143 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017144 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017145
17146 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053017147
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017148 ret = wlan_hdd_validate_context(pHddCtx);
17149 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017150 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017151 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017152 }
17153
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053017154
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053017155 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
17156 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
17157 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017158 pHddCtx->isWiphySuspended = TRUE;
17159
17160 EXIT();
17161
17162 return 0;
17163}
17164
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053017165int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
17166 struct cfg80211_wowlan *wow)
17167{
17168 int ret;
17169
17170 vos_ssr_protect(__func__);
17171 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
17172 vos_ssr_unprotect(__func__);
17173
17174 return ret;
17175}
Jeff Johnson295189b2012-06-20 16:38:30 -070017176/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053017177static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070017178{
17179 .add_virtual_intf = wlan_hdd_add_virtual_intf,
17180 .del_virtual_intf = wlan_hdd_del_virtual_intf,
17181 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
17182 .change_station = wlan_hdd_change_station,
17183#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
17184 .add_beacon = wlan_hdd_cfg80211_add_beacon,
17185 .del_beacon = wlan_hdd_cfg80211_del_beacon,
17186 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017187#else
17188 .start_ap = wlan_hdd_cfg80211_start_ap,
17189 .change_beacon = wlan_hdd_cfg80211_change_beacon,
17190 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070017191#endif
17192 .change_bss = wlan_hdd_cfg80211_change_bss,
17193 .add_key = wlan_hdd_cfg80211_add_key,
17194 .get_key = wlan_hdd_cfg80211_get_key,
17195 .del_key = wlan_hdd_cfg80211_del_key,
17196 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080017197#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070017198 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080017199#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017200 .scan = wlan_hdd_cfg80211_scan,
17201 .connect = wlan_hdd_cfg80211_connect,
17202 .disconnect = wlan_hdd_cfg80211_disconnect,
17203 .join_ibss = wlan_hdd_cfg80211_join_ibss,
17204 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
17205 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
17206 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
17207 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070017208 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
17209 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053017210 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070017211#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
17212 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
17213 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
17214 .set_txq_params = wlan_hdd_set_txq_params,
17215#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017216 .get_station = wlan_hdd_cfg80211_get_station,
17217 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
17218 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017219 .add_station = wlan_hdd_cfg80211_add_station,
17220#ifdef FEATURE_WLAN_LFR
17221 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
17222 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
17223 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
17224#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070017225#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
17226 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
17227#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017228#ifdef FEATURE_WLAN_TDLS
17229 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
17230 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
17231#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053017232#ifdef WLAN_FEATURE_GTK_OFFLOAD
17233 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
17234#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053017235#ifdef FEATURE_WLAN_SCAN_PNO
17236 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
17237 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
17238#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053017239 .resume = wlan_hdd_cfg80211_resume_wlan,
17240 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053017241 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070017242#ifdef WLAN_NL80211_TESTMODE
17243 .testmode_cmd = wlan_hdd_cfg80211_testmode,
17244#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053017245 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070017246};
17247