blob: 4745aae234566ea8ed4efcf47f7097adbd25e1eb [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +053026 *
Kiet Lamaa8e15a2014-02-11 23:30:06 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Kiet Lama7f454d2014-07-24 12:04:06 -070030
31
Jeff Johnson295189b2012-06-20 16:38:30 -070032/**========================================================================
33
34 \file wlan_hdd_cfg80211.c
35
36 \brief WLAN Host Device Driver implementation
37
Jeff Johnson295189b2012-06-20 16:38:30 -070038 ========================================================================*/
39
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070040/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070041
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070042 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070043
44
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070045 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070047
48
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070049 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070050
51
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070052 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070053 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070054 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070055
56 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070057 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070058 ==========================================================================*/
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060
61#include <linux/version.h>
62#include <linux/module.h>
63#include <linux/kernel.h>
64#include <linux/init.h>
65#include <linux/wireless.h>
66#include <wlan_hdd_includes.h>
67#include <net/arp.h>
68#include <net/cfg80211.h>
69#include <linux/wireless.h>
70#include <wlan_hdd_wowl.h>
71#include <aniGlobal.h>
72#include "ccmApi.h"
73#include "sirParams.h"
74#include "dot11f.h"
75#include "wlan_hdd_assoc.h"
76#include "wlan_hdd_wext.h"
77#include "sme_Api.h"
78#include "wlan_hdd_p2p.h"
79#include "wlan_hdd_cfg80211.h"
80#include "wlan_hdd_hostapd.h"
81#include "sapInternal.h"
82#include "wlan_hdd_softap_tx_rx.h"
83#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053084#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053085#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053086#include "wlan_hdd_trace.h"
87#include "vos_types.h"
88#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070089#ifdef WLAN_BTAMP_FEATURE
90#include "bap_hdd_misc.h"
91#endif
92#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080093#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053094#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053095#include "wlan_qct_wda.h"
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053096#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070097#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070098
99#define g_mode_rates_size (12)
100#define a_mode_rates_size (8)
101#define FREQ_BASE_80211G (2407)
102#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700103#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530104#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800106 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
108#define HDD2GHZCHAN(freq, chan, flag) { \
109 .band = IEEE80211_BAND_2GHZ, \
110 .center_freq = (freq), \
111 .hw_value = (chan),\
112 .flags = (flag), \
113 .max_antenna_gain = 0 ,\
114 .max_power = 30, \
115}
116
117#define HDD5GHZCHAN(freq, chan, flag) { \
118 .band = IEEE80211_BAND_5GHZ, \
119 .center_freq = (freq), \
120 .hw_value = (chan),\
121 .flags = (flag), \
122 .max_antenna_gain = 0 ,\
123 .max_power = 30, \
124}
125
126#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
127{\
128 .bitrate = rate, \
129 .hw_value = rate_id, \
130 .flags = flag, \
131}
132
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530133#ifdef WLAN_FEATURE_VOWIFI_11R
134#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
135#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
136#endif
137
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530138#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530139#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530140
Sunil Duttc69bccb2014-05-26 21:30:20 +0530141#ifdef WLAN_FEATURE_LINK_LAYER_STATS
142/*
143 * Used to allocate the size of 4096 for the link layer stats.
144 * The size of 4096 is considered assuming that all data per
145 * respective event fit with in the limit.Please take a call
146 * on the limit based on the data requirements on link layer
147 * statistics.
148 */
149#define LL_STATS_EVENT_BUF_SIZE 4096
150#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530151#ifdef WLAN_FEATURE_EXTSCAN
152/*
153 * Used to allocate the size of 4096 for the EXTScan NL data.
154 * The size of 4096 is considered assuming that all data per
155 * respective event fit with in the limit.Please take a call
156 * on the limit based on the data requirements.
157 */
158
159#define EXTSCAN_EVENT_BUF_SIZE 4096
160#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
161#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530162
Atul Mittal115287b2014-07-08 13:26:33 +0530163/*EXT TDLS*/
164/*
165 * Used to allocate the size of 4096 for the TDLS.
166 * The size of 4096 is considered assuming that all data per
167 * respective event fit with in the limit.Please take a call
168 * on the limit based on the data requirements on link layer
169 * statistics.
170 */
171#define EXTTDLS_EVENT_BUF_SIZE 4096
172
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530173static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700174{
175 WLAN_CIPHER_SUITE_WEP40,
176 WLAN_CIPHER_SUITE_WEP104,
177 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800178#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700179#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
180 WLAN_CIPHER_SUITE_KRK,
181 WLAN_CIPHER_SUITE_CCMP,
182#else
183 WLAN_CIPHER_SUITE_CCMP,
184#endif
185#ifdef FEATURE_WLAN_WAPI
186 WLAN_CIPHER_SUITE_SMS4,
187#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700188#ifdef WLAN_FEATURE_11W
189 WLAN_CIPHER_SUITE_AES_CMAC,
190#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700191};
192
193static inline int is_broadcast_ether_addr(const u8 *addr)
194{
195 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
196 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
197}
198
199static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530200{
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 HDD2GHZCHAN(2412, 1, 0) ,
202 HDD2GHZCHAN(2417, 2, 0) ,
203 HDD2GHZCHAN(2422, 3, 0) ,
204 HDD2GHZCHAN(2427, 4, 0) ,
205 HDD2GHZCHAN(2432, 5, 0) ,
206 HDD2GHZCHAN(2437, 6, 0) ,
207 HDD2GHZCHAN(2442, 7, 0) ,
208 HDD2GHZCHAN(2447, 8, 0) ,
209 HDD2GHZCHAN(2452, 9, 0) ,
210 HDD2GHZCHAN(2457, 10, 0) ,
211 HDD2GHZCHAN(2462, 11, 0) ,
212 HDD2GHZCHAN(2467, 12, 0) ,
213 HDD2GHZCHAN(2472, 13, 0) ,
214 HDD2GHZCHAN(2484, 14, 0) ,
215};
216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
218{
219 HDD2GHZCHAN(2412, 1, 0) ,
220 HDD2GHZCHAN(2437, 6, 0) ,
221 HDD2GHZCHAN(2462, 11, 0) ,
222};
Jeff Johnson295189b2012-06-20 16:38:30 -0700223
224static struct ieee80211_channel hdd_channels_5_GHZ[] =
225{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700226 HDD5GHZCHAN(4920, 240, 0) ,
227 HDD5GHZCHAN(4940, 244, 0) ,
228 HDD5GHZCHAN(4960, 248, 0) ,
229 HDD5GHZCHAN(4980, 252, 0) ,
230 HDD5GHZCHAN(5040, 208, 0) ,
231 HDD5GHZCHAN(5060, 212, 0) ,
232 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 HDD5GHZCHAN(5180, 36, 0) ,
234 HDD5GHZCHAN(5200, 40, 0) ,
235 HDD5GHZCHAN(5220, 44, 0) ,
236 HDD5GHZCHAN(5240, 48, 0) ,
237 HDD5GHZCHAN(5260, 52, 0) ,
238 HDD5GHZCHAN(5280, 56, 0) ,
239 HDD5GHZCHAN(5300, 60, 0) ,
240 HDD5GHZCHAN(5320, 64, 0) ,
241 HDD5GHZCHAN(5500,100, 0) ,
242 HDD5GHZCHAN(5520,104, 0) ,
243 HDD5GHZCHAN(5540,108, 0) ,
244 HDD5GHZCHAN(5560,112, 0) ,
245 HDD5GHZCHAN(5580,116, 0) ,
246 HDD5GHZCHAN(5600,120, 0) ,
247 HDD5GHZCHAN(5620,124, 0) ,
248 HDD5GHZCHAN(5640,128, 0) ,
249 HDD5GHZCHAN(5660,132, 0) ,
250 HDD5GHZCHAN(5680,136, 0) ,
251 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800252#ifdef FEATURE_WLAN_CH144
253 HDD5GHZCHAN(5720,144, 0) ,
254#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 HDD5GHZCHAN(5745,149, 0) ,
256 HDD5GHZCHAN(5765,153, 0) ,
257 HDD5GHZCHAN(5785,157, 0) ,
258 HDD5GHZCHAN(5805,161, 0) ,
259 HDD5GHZCHAN(5825,165, 0) ,
260};
261
262static struct ieee80211_rate g_mode_rates[] =
263{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530264 HDD_G_MODE_RATETAB(10, 0x1, 0),
265 HDD_G_MODE_RATETAB(20, 0x2, 0),
266 HDD_G_MODE_RATETAB(55, 0x4, 0),
267 HDD_G_MODE_RATETAB(110, 0x8, 0),
268 HDD_G_MODE_RATETAB(60, 0x10, 0),
269 HDD_G_MODE_RATETAB(90, 0x20, 0),
270 HDD_G_MODE_RATETAB(120, 0x40, 0),
271 HDD_G_MODE_RATETAB(180, 0x80, 0),
272 HDD_G_MODE_RATETAB(240, 0x100, 0),
273 HDD_G_MODE_RATETAB(360, 0x200, 0),
274 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530276};
Jeff Johnson295189b2012-06-20 16:38:30 -0700277
278static struct ieee80211_rate a_mode_rates[] =
279{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530280 HDD_G_MODE_RATETAB(60, 0x10, 0),
281 HDD_G_MODE_RATETAB(90, 0x20, 0),
282 HDD_G_MODE_RATETAB(120, 0x40, 0),
283 HDD_G_MODE_RATETAB(180, 0x80, 0),
284 HDD_G_MODE_RATETAB(240, 0x100, 0),
285 HDD_G_MODE_RATETAB(360, 0x200, 0),
286 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 HDD_G_MODE_RATETAB(540, 0x800, 0),
288};
289
290static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
291{
292 .channels = hdd_channels_2_4_GHZ,
293 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
294 .band = IEEE80211_BAND_2GHZ,
295 .bitrates = g_mode_rates,
296 .n_bitrates = g_mode_rates_size,
297 .ht_cap.ht_supported = 1,
298 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
299 | IEEE80211_HT_CAP_GRN_FLD
300 | IEEE80211_HT_CAP_DSSSCCK40
301 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
302 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
303 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
304 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
305 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
306 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
307};
308
Jeff Johnson295189b2012-06-20 16:38:30 -0700309static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
310{
311 .channels = hdd_social_channels_2_4_GHZ,
312 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
313 .band = IEEE80211_BAND_2GHZ,
314 .bitrates = g_mode_rates,
315 .n_bitrates = g_mode_rates_size,
316 .ht_cap.ht_supported = 1,
317 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
318 | IEEE80211_HT_CAP_GRN_FLD
319 | IEEE80211_HT_CAP_DSSSCCK40
320 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
321 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
322 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
323 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
324 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
325 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
326};
Jeff Johnson295189b2012-06-20 16:38:30 -0700327
328static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
329{
330 .channels = hdd_channels_5_GHZ,
331 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
332 .band = IEEE80211_BAND_5GHZ,
333 .bitrates = a_mode_rates,
334 .n_bitrates = a_mode_rates_size,
335 .ht_cap.ht_supported = 1,
336 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
337 | IEEE80211_HT_CAP_GRN_FLD
338 | IEEE80211_HT_CAP_DSSSCCK40
339 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
340 | IEEE80211_HT_CAP_SGI_40
341 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
342 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
343 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
344 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
345 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
346 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
347};
348
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530349/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700350 TX/RX direction for each kind of interface */
351static const struct ieee80211_txrx_stypes
352wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
353 [NL80211_IFTYPE_STATION] = {
354 .tx = 0xffff,
355 .rx = BIT(SIR_MAC_MGMT_ACTION) |
356 BIT(SIR_MAC_MGMT_PROBE_REQ),
357 },
358 [NL80211_IFTYPE_AP] = {
359 .tx = 0xffff,
360 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
361 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
362 BIT(SIR_MAC_MGMT_PROBE_REQ) |
363 BIT(SIR_MAC_MGMT_DISASSOC) |
364 BIT(SIR_MAC_MGMT_AUTH) |
365 BIT(SIR_MAC_MGMT_DEAUTH) |
366 BIT(SIR_MAC_MGMT_ACTION),
367 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700368 [NL80211_IFTYPE_ADHOC] = {
369 .tx = 0xffff,
370 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
371 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
372 BIT(SIR_MAC_MGMT_PROBE_REQ) |
373 BIT(SIR_MAC_MGMT_DISASSOC) |
374 BIT(SIR_MAC_MGMT_AUTH) |
375 BIT(SIR_MAC_MGMT_DEAUTH) |
376 BIT(SIR_MAC_MGMT_ACTION),
377 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 [NL80211_IFTYPE_P2P_CLIENT] = {
379 .tx = 0xffff,
380 .rx = BIT(SIR_MAC_MGMT_ACTION) |
381 BIT(SIR_MAC_MGMT_PROBE_REQ),
382 },
383 [NL80211_IFTYPE_P2P_GO] = {
384 /* This is also same as for SoftAP */
385 .tx = 0xffff,
386 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
387 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
388 BIT(SIR_MAC_MGMT_PROBE_REQ) |
389 BIT(SIR_MAC_MGMT_DISASSOC) |
390 BIT(SIR_MAC_MGMT_AUTH) |
391 BIT(SIR_MAC_MGMT_DEAUTH) |
392 BIT(SIR_MAC_MGMT_ACTION),
393 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700394};
395
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800396#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800397static const struct ieee80211_iface_limit
398wlan_hdd_iface_limit[] = {
399 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800400 /* max = 3 ; Our driver create two interfaces during driver init
401 * wlan0 and p2p0 interfaces. p2p0 is considered as station
402 * interface until a group is formed. In JB architecture, once the
403 * group is formed, interface type of p2p0 is changed to P2P GO or
404 * Client.
405 * When supplicant remove the group, it first issue a set interface
406 * cmd to change the mode back to Station. In JB this works fine as
407 * we advertize two station type interface during driver init.
408 * Some vendors create separate interface for P2P GO/Client,
409 * after group formation(Third one). But while group remove
410 * supplicant first tries to change the mode(3rd interface) to STATION
411 * But as we advertized only two sta type interfaces nl80211 was
412 * returning error for the third one which was leading to failure in
413 * delete interface. Ideally while removing the group, supplicant
414 * should not try to change the 3rd interface mode to Station type.
415 * Till we get a fix in wpa_supplicant, we advertize max STA
416 * interface type to 3
417 */
418 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800419 .types = BIT(NL80211_IFTYPE_STATION),
420 },
421 {
422 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700423 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800424 },
425 {
426 .max = 1,
427 .types = BIT(NL80211_IFTYPE_P2P_GO) |
428 BIT(NL80211_IFTYPE_P2P_CLIENT),
429 },
430};
431
432/* By default, only single channel concurrency is allowed */
433static struct ieee80211_iface_combination
434wlan_hdd_iface_combination = {
435 .limits = wlan_hdd_iface_limit,
436 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800437 /*
438 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
439 * and p2p0 interfaces during driver init
440 * Some vendors create separate interface for P2P operations.
441 * wlan0: STA interface
442 * p2p0: P2P Device interface, action frames goes
443 * through this interface.
444 * p2p-xx: P2P interface, After GO negotiation this interface is
445 * created for p2p operations(GO/CLIENT interface).
446 */
447 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800448 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
449 .beacon_int_infra_match = false,
450};
451#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800452
Jeff Johnson295189b2012-06-20 16:38:30 -0700453static struct cfg80211_ops wlan_hdd_cfg80211_ops;
454
455/* Data rate 100KBPS based on IE Index */
456struct index_data_rate_type
457{
458 v_U8_t beacon_rate_index;
459 v_U16_t supported_rate[4];
460};
461
462/* 11B, 11G Rate table include Basic rate and Extended rate
463 The IDX field is the rate index
464 The HI field is the rate when RSSI is strong or being ignored
465 (in this case we report actual rate)
466 The MID field is the rate when RSSI is moderate
467 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
468 The LO field is the rate when RSSI is low
469 (in this case we don't report rates, actual current rate used)
470 */
471static const struct
472{
473 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700474 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700475} supported_data_rate[] =
476{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700477/* IDX HI HM LM LO (RSSI-based index */
478 {2, { 10, 10, 10, 0}},
479 {4, { 20, 20, 10, 0}},
480 {11, { 55, 20, 10, 0}},
481 {12, { 60, 55, 20, 0}},
482 {18, { 90, 55, 20, 0}},
483 {22, {110, 55, 20, 0}},
484 {24, {120, 90, 60, 0}},
485 {36, {180, 120, 60, 0}},
486 {44, {220, 180, 60, 0}},
487 {48, {240, 180, 90, 0}},
488 {66, {330, 180, 90, 0}},
489 {72, {360, 240, 90, 0}},
490 {96, {480, 240, 120, 0}},
491 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700492};
493
494/* MCS Based rate table */
495static struct index_data_rate_type supported_mcs_rate[] =
496{
497/* MCS L20 L40 S20 S40 */
498 {0, {65, 135, 72, 150}},
499 {1, {130, 270, 144, 300}},
500 {2, {195, 405, 217, 450}},
501 {3, {260, 540, 289, 600}},
502 {4, {390, 810, 433, 900}},
503 {5, {520, 1080, 578, 1200}},
504 {6, {585, 1215, 650, 1350}},
505 {7, {650, 1350, 722, 1500}}
506};
507
Leo Chang6f8870f2013-03-26 18:11:36 -0700508#ifdef WLAN_FEATURE_11AC
509
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530510#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700511
512struct index_vht_data_rate_type
513{
514 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530515 v_U16_t supported_VHT80_rate[2];
516 v_U16_t supported_VHT40_rate[2];
517 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700518};
519
520typedef enum
521{
522 DATA_RATE_11AC_MAX_MCS_7,
523 DATA_RATE_11AC_MAX_MCS_8,
524 DATA_RATE_11AC_MAX_MCS_9,
525 DATA_RATE_11AC_MAX_MCS_NA
526} eDataRate11ACMaxMcs;
527
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530528/* SSID broadcast type */
529typedef enum eSSIDBcastType
530{
531 eBCAST_UNKNOWN = 0,
532 eBCAST_NORMAL = 1,
533 eBCAST_HIDDEN = 2,
534} tSSIDBcastType;
535
Leo Chang6f8870f2013-03-26 18:11:36 -0700536/* MCS Based VHT rate table */
537static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
538{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530539/* MCS L80 S80 L40 S40 L20 S40*/
540 {0, {293, 325}, {135, 150}, {65, 72}},
541 {1, {585, 650}, {270, 300}, {130, 144}},
542 {2, {878, 975}, {405, 450}, {195, 217}},
543 {3, {1170, 1300}, {540, 600}, {260, 289}},
544 {4, {1755, 1950}, {810, 900}, {390, 433}},
545 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
546 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
547 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
548 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
549 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700550};
551#endif /* WLAN_FEATURE_11AC */
552
c_hpothu79aab322014-07-14 21:11:01 +0530553/*array index points to MCS and array value points respective rssi*/
554static int rssiMcsTbl[][10] =
555{
556/*MCS 0 1 2 3 4 5 6 7 8 9*/
557 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
558 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
559 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
560};
561
Jeff Johnson295189b2012-06-20 16:38:30 -0700562extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530563#ifdef FEATURE_WLAN_SCAN_PNO
564static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
565#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700566
Leo Chang9056f462013-08-01 19:21:11 -0700567#ifdef WLAN_NL80211_TESTMODE
568enum wlan_hdd_tm_attr
569{
570 WLAN_HDD_TM_ATTR_INVALID = 0,
571 WLAN_HDD_TM_ATTR_CMD = 1,
572 WLAN_HDD_TM_ATTR_DATA = 2,
573 WLAN_HDD_TM_ATTR_TYPE = 3,
574 /* keep last */
575 WLAN_HDD_TM_ATTR_AFTER_LAST,
576 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
577};
578
579enum wlan_hdd_tm_cmd
580{
581 WLAN_HDD_TM_CMD_WLAN_HB = 1,
582};
583
584#define WLAN_HDD_TM_DATA_MAX_LEN 5000
585
586static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
587{
588 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
589 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
590 .len = WLAN_HDD_TM_DATA_MAX_LEN },
591};
592#endif /* WLAN_NL80211_TESTMODE */
593
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800594#ifdef FEATURE_WLAN_CH_AVOID
595/*
596 * FUNCTION: wlan_hdd_send_avoid_freq_event
597 * This is called when wlan driver needs to send vendor specific
598 * avoid frequency range event to userspace
599 */
600int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
601 tHddAvoidFreqList *pAvoidFreqList)
602{
603 struct sk_buff *vendor_event;
604
605 ENTER();
606
607 if (!pHddCtx)
608 {
609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
610 "%s: HDD context is null", __func__);
611 return -1;
612 }
613
614 if (!pAvoidFreqList)
615 {
616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
617 "%s: pAvoidFreqList is null", __func__);
618 return -1;
619 }
620
621 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
622 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530623 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800624 GFP_KERNEL);
625 if (!vendor_event)
626 {
627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
628 "%s: cfg80211_vendor_event_alloc failed", __func__);
629 return -1;
630 }
631
632 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
633 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
634
635 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
636
637 EXIT();
638 return 0;
639}
640#endif /* FEATURE_WLAN_CH_AVOID */
641
Srinivas Dasari030bad32015-02-18 23:23:54 +0530642/*
643 * FUNCTION: __wlan_hdd_cfg80211_nan_request
644 * This is called when wlan driver needs to send vendor specific
645 * nan request event.
646 */
647static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
648 struct wireless_dev *wdev,
649 const void *data, int data_len)
650{
651 tNanRequestReq nan_req;
652 VOS_STATUS status;
653 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530654 struct net_device *dev = wdev->netdev;
655 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
656 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530657 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
658
659 if (0 == data_len)
660 {
661 hddLog(VOS_TRACE_LEVEL_ERROR,
662 FL("NAN - Invalid Request, length = 0"));
663 return ret_val;
664 }
665
666 if (NULL == data)
667 {
668 hddLog(VOS_TRACE_LEVEL_ERROR,
669 FL("NAN - Invalid Request, data is NULL"));
670 return ret_val;
671 }
672
673 status = wlan_hdd_validate_context(pHddCtx);
674 if (0 != status)
675 {
676 hddLog(VOS_TRACE_LEVEL_ERROR,
677 FL("HDD context is not valid"));
678 return -EINVAL;
679 }
680
681 hddLog(LOG1, FL("Received NAN command"));
682 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
683 (tANI_U8 *)data, data_len);
684
685 /* check the NAN Capability */
686 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
687 {
688 hddLog(VOS_TRACE_LEVEL_ERROR,
689 FL("NAN is not supported by Firmware"));
690 return -EINVAL;
691 }
692
693 nan_req.request_data_len = data_len;
694 nan_req.request_data = data;
695
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530696 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530697 if (VOS_STATUS_SUCCESS == status)
698 {
699 ret_val = 0;
700 }
701 return ret_val;
702}
703
704/*
705 * FUNCTION: wlan_hdd_cfg80211_nan_request
706 * Wrapper to protect the nan vendor command from ssr
707 */
708static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
709 struct wireless_dev *wdev,
710 const void *data, int data_len)
711{
712 int ret;
713
714 vos_ssr_protect(__func__);
715 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
716 vos_ssr_unprotect(__func__);
717
718 return ret;
719}
720
721/*
722 * FUNCTION: wlan_hdd_cfg80211_nan_callback
723 * This is a callback function and it gets called
724 * when we need to report nan response event to
725 * upper layers.
726 */
727static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
728{
729 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
730 struct sk_buff *vendor_event;
731 int status;
732 tSirNanEvent *data;
733
734 ENTER();
735 if (NULL == msg)
736 {
737 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
738 FL(" msg received here is null"));
739 return;
740 }
741 data = msg;
742
743 status = wlan_hdd_validate_context(pHddCtx);
744
745 if (0 != status)
746 {
747 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
748 FL("HDD context is not valid"));
749 return;
750 }
751
752 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
753 data->event_data_len +
754 NLMSG_HDRLEN,
755 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
756 GFP_KERNEL);
757
758 if (!vendor_event)
759 {
760 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
761 FL("cfg80211_vendor_event_alloc failed"));
762 return;
763 }
764 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
765 data->event_data_len, data->event_data))
766 {
767 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
768 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
769 kfree_skb(vendor_event);
770 return;
771 }
772 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
773 EXIT();
774}
775
776/*
777 * FUNCTION: wlan_hdd_cfg80211_nan_init
778 * This function is called to register the callback to sme layer
779 */
780inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
781{
782 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
783}
784
785
Sunil Duttc69bccb2014-05-26 21:30:20 +0530786#ifdef WLAN_FEATURE_LINK_LAYER_STATS
787
788static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
789 struct sk_buff *vendor_event)
790{
791 if (nla_put_u8(vendor_event,
792 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
793 stats->rate.preamble) ||
794 nla_put_u8(vendor_event,
795 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
796 stats->rate.nss) ||
797 nla_put_u8(vendor_event,
798 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
799 stats->rate.bw) ||
800 nla_put_u8(vendor_event,
801 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
802 stats->rate.rateMcsIdx) ||
803 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
804 stats->rate.bitrate ) ||
805 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
806 stats->txMpdu ) ||
807 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
808 stats->rxMpdu ) ||
809 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
810 stats->mpduLost ) ||
811 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
812 stats->retries) ||
813 nla_put_u32(vendor_event,
814 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
815 stats->retriesShort ) ||
816 nla_put_u32(vendor_event,
817 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
818 stats->retriesLong))
819 {
820 hddLog(VOS_TRACE_LEVEL_ERROR,
821 FL("QCA_WLAN_VENDOR_ATTR put fail"));
822 return FALSE;
823 }
824 return TRUE;
825}
826
827static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
828 struct sk_buff *vendor_event)
829{
830 u32 i = 0;
831 struct nlattr *rateInfo;
832 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
833 stats->type) ||
834 nla_put(vendor_event,
835 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
836 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
837 nla_put_u32(vendor_event,
838 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
839 stats->capabilities) ||
840 nla_put_u32(vendor_event,
841 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
842 stats->numRate))
843 {
844 hddLog(VOS_TRACE_LEVEL_ERROR,
845 FL("QCA_WLAN_VENDOR_ATTR put fail"));
846 goto error;
847 }
848
849 rateInfo = nla_nest_start(vendor_event,
850 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530851 if(!rateInfo)
852 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530853 for (i = 0; i < stats->numRate; i++)
854 {
855 struct nlattr *rates;
856 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
857 stats->rateStats +
858 (i * sizeof(tSirWifiRateStat)));
859 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530860 if(!rates)
861 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530862
863 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
864 {
865 hddLog(VOS_TRACE_LEVEL_ERROR,
866 FL("QCA_WLAN_VENDOR_ATTR put fail"));
867 return FALSE;
868 }
869 nla_nest_end(vendor_event, rates);
870 }
871 nla_nest_end(vendor_event, rateInfo);
872
873 return TRUE;
874error:
875 return FALSE;
876}
877
878static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
879 struct sk_buff *vendor_event)
880{
881 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
882 stats->ac ) ||
883 nla_put_u32(vendor_event,
884 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
885 stats->txMpdu ) ||
886 nla_put_u32(vendor_event,
887 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
888 stats->rxMpdu ) ||
889 nla_put_u32(vendor_event,
890 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
891 stats->txMcast ) ||
892 nla_put_u32(vendor_event,
893 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
894 stats->rxMcast ) ||
895 nla_put_u32(vendor_event,
896 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
897 stats->rxAmpdu ) ||
898 nla_put_u32(vendor_event,
899 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
900 stats->txAmpdu ) ||
901 nla_put_u32(vendor_event,
902 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
903 stats->mpduLost )||
904 nla_put_u32(vendor_event,
905 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
906 stats->retries ) ||
907 nla_put_u32(vendor_event,
908 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
909 stats->retriesShort ) ||
910 nla_put_u32(vendor_event,
911 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
912 stats->retriesLong ) ||
913 nla_put_u32(vendor_event,
914 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
915 stats->contentionTimeMin ) ||
916 nla_put_u32(vendor_event,
917 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
918 stats->contentionTimeMax ) ||
919 nla_put_u32(vendor_event,
920 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
921 stats->contentionTimeAvg ) ||
922 nla_put_u32(vendor_event,
923 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
924 stats->contentionNumSamples ))
925 {
926 hddLog(VOS_TRACE_LEVEL_ERROR,
927 FL("QCA_WLAN_VENDOR_ATTR put fail") );
928 return FALSE;
929 }
930 return TRUE;
931}
932
933static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
934 struct sk_buff *vendor_event)
935{
Dino Myclec8f3f332014-07-21 16:48:27 +0530936 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530937 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
938 nla_put(vendor_event,
939 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
940 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
941 nla_put_u32(vendor_event,
942 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
943 stats->state ) ||
944 nla_put_u32(vendor_event,
945 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
946 stats->roaming ) ||
947 nla_put_u32(vendor_event,
948 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
949 stats->capabilities ) ||
950 nla_put(vendor_event,
951 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
952 strlen(stats->ssid), stats->ssid) ||
953 nla_put(vendor_event,
954 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
955 WNI_CFG_BSSID_LEN, stats->bssid) ||
956 nla_put(vendor_event,
957 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
958 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
959 nla_put(vendor_event,
960 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
961 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
962 )
963 {
964 hddLog(VOS_TRACE_LEVEL_ERROR,
965 FL("QCA_WLAN_VENDOR_ATTR put fail") );
966 return FALSE;
967 }
968 return TRUE;
969}
970
Dino Mycle3b9536d2014-07-09 22:05:24 +0530971static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
972 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530973 struct sk_buff *vendor_event)
974{
975 int i = 0;
976 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530977 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
978 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530979 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530980
Sunil Duttc69bccb2014-05-26 21:30:20 +0530981 if (FALSE == put_wifi_interface_info(
982 &pWifiIfaceStat->info,
983 vendor_event))
984 {
985 hddLog(VOS_TRACE_LEVEL_ERROR,
986 FL("QCA_WLAN_VENDOR_ATTR put fail") );
987 return FALSE;
988
989 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530990 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
991 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
992 if (NULL == pWifiIfaceStatTL)
993 {
994 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
995 return FALSE;
996 }
997
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530998 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
999 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
1000 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
1001 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1002
1003 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1004 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1005 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1006 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301007
1008 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1009 {
1010 if (VOS_STATUS_SUCCESS ==
1011 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1012 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1013 {
1014 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1015 * obtained from TL structure
1016 */
1017
1018 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1019 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301020 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1021
Srinivas Dasari98947432014-11-07 19:41:24 +05301022 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1023 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1024 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1025 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1026 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1027 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1028 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1029 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301030
Srinivas Dasari98947432014-11-07 19:41:24 +05301031 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1032 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1033 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1034 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1035 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1036 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1037 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1038 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301039
Srinivas Dasari98947432014-11-07 19:41:24 +05301040 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1041 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1042 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1043 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1044 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1045 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1046 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1047 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301048 }
1049 else
1050 {
1051 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1052 }
1053
Dino Mycle3b9536d2014-07-09 22:05:24 +05301054 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1055 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1056 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1057 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1058 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1059 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1060 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1061 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1062 }
1063 else
1064 {
1065 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1066 }
1067
1068
Sunil Duttc69bccb2014-05-26 21:30:20 +05301069
1070 if (nla_put_u32(vendor_event,
1071 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1072 pWifiIfaceStat->beaconRx) ||
1073 nla_put_u32(vendor_event,
1074 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1075 pWifiIfaceStat->mgmtRx) ||
1076 nla_put_u32(vendor_event,
1077 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1078 pWifiIfaceStat->mgmtActionRx) ||
1079 nla_put_u32(vendor_event,
1080 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1081 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301082 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301083 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1084 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301085 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301086 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1087 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301088 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301089 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1090 pWifiIfaceStat->rssiAck))
1091 {
1092 hddLog(VOS_TRACE_LEVEL_ERROR,
1093 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301094 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301095 return FALSE;
1096 }
1097
1098 wmmInfo = nla_nest_start(vendor_event,
1099 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301100 if(!wmmInfo)
1101 {
1102 vos_mem_free(pWifiIfaceStatTL);
1103 return FALSE;
1104 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301105 for (i = 0; i < WIFI_AC_MAX; i++)
1106 {
1107 struct nlattr *wmmStats;
1108 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301109 if(!wmmStats)
1110 {
1111 vos_mem_free(pWifiIfaceStatTL);
1112 return FALSE;
1113 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301114 if (FALSE == put_wifi_wmm_ac_stat(
1115 &pWifiIfaceStat->AccessclassStats[i],
1116 vendor_event))
1117 {
1118 hddLog(VOS_TRACE_LEVEL_ERROR,
1119 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301120 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301121 return FALSE;
1122 }
1123
1124 nla_nest_end(vendor_event, wmmStats);
1125 }
1126 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301127 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301128 return TRUE;
1129}
1130
1131static tSirWifiInterfaceMode
1132 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1133{
1134 switch (deviceMode)
1135 {
1136 case WLAN_HDD_INFRA_STATION:
1137 return WIFI_INTERFACE_STA;
1138 case WLAN_HDD_SOFTAP:
1139 return WIFI_INTERFACE_SOFTAP;
1140 case WLAN_HDD_P2P_CLIENT:
1141 return WIFI_INTERFACE_P2P_CLIENT;
1142 case WLAN_HDD_P2P_GO:
1143 return WIFI_INTERFACE_P2P_GO;
1144 case WLAN_HDD_IBSS:
1145 return WIFI_INTERFACE_IBSS;
1146 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301147 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301148 }
1149}
1150
1151static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1152 tpSirWifiInterfaceInfo pInfo)
1153{
1154 v_U8_t *staMac = NULL;
1155 hdd_station_ctx_t *pHddStaCtx;
1156 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1157 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1158
1159 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1160
1161 vos_mem_copy(pInfo->macAddr,
1162 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1163
1164 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1165 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1166 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1167 {
1168 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1169 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1170 {
1171 pInfo->state = WIFI_DISCONNECTED;
1172 }
1173 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1174 {
1175 hddLog(VOS_TRACE_LEVEL_ERROR,
1176 "%s: Session ID %d, Connection is in progress", __func__,
1177 pAdapter->sessionId);
1178 pInfo->state = WIFI_ASSOCIATING;
1179 }
1180 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1181 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1182 {
1183 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1184 hddLog(VOS_TRACE_LEVEL_ERROR,
1185 "%s: client " MAC_ADDRESS_STR
1186 " is in the middle of WPS/EAPOL exchange.", __func__,
1187 MAC_ADDR_ARRAY(staMac));
1188 pInfo->state = WIFI_AUTHENTICATING;
1189 }
1190 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1191 {
1192 pInfo->state = WIFI_ASSOCIATED;
1193 vos_mem_copy(pInfo->bssid,
1194 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1195 vos_mem_copy(pInfo->ssid,
1196 pHddStaCtx->conn_info.SSID.SSID.ssId,
1197 pHddStaCtx->conn_info.SSID.SSID.length);
1198 //NULL Terminate the string.
1199 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1200 }
1201 }
1202 vos_mem_copy(pInfo->countryStr,
1203 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1204
1205 vos_mem_copy(pInfo->apCountryStr,
1206 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1207
1208 return TRUE;
1209}
1210
1211/*
1212 * hdd_link_layer_process_peer_stats () - This function is called after
1213 * receiving Link Layer Peer statistics from FW.This function converts
1214 * the firmware data to the NL data and sends the same to the kernel/upper
1215 * layers.
1216 */
1217static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1218 v_VOID_t *pData)
1219{
1220 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1221 tpSirWifiRateStat pWifiRateStat;
1222 tpSirWifiPeerStat pWifiPeerStat;
1223 tpSirWifiPeerInfo pWifiPeerInfo;
1224 struct nlattr *peerInfo;
1225 struct sk_buff *vendor_event;
1226 int status, i;
1227
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301228 ENTER();
1229
Sunil Duttc69bccb2014-05-26 21:30:20 +05301230 status = wlan_hdd_validate_context(pHddCtx);
1231 if (0 != status)
1232 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301233 return;
1234 }
1235
1236 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1237
1238 hddLog(VOS_TRACE_LEVEL_INFO,
1239 "LL_STATS_PEER_ALL : numPeers %u",
1240 pWifiPeerStat->numPeers);
1241 {
1242 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1243 {
1244 pWifiPeerInfo = (tpSirWifiPeerInfo)
1245 ((uint8 *)pWifiPeerStat->peerInfo +
1246 ( i * sizeof(tSirWifiPeerInfo)));
1247
Dasari Srinivas1be0c4e2014-10-19 13:03:41 +05301248 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) {
1249 pWifiPeerInfo->type = WIFI_PEER_AP;
1250 }
1251 if (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) {
1252 pWifiPeerInfo->type = WIFI_PEER_P2P_GO;
1253 }
1254
Sunil Duttc69bccb2014-05-26 21:30:20 +05301255 hddLog(VOS_TRACE_LEVEL_INFO,
1256 " %d) LL_STATS Channel Stats "
1257 " Peer Type %u "
1258 " peerMacAddress %pM "
1259 " capabilities 0x%x "
1260 " numRate %u ",
1261 i,
1262 pWifiPeerInfo->type,
1263 pWifiPeerInfo->peerMacAddress,
1264 pWifiPeerInfo->capabilities,
1265 pWifiPeerInfo->numRate);
1266 {
1267 int j;
1268 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1269 {
1270 pWifiRateStat = (tpSirWifiRateStat)
1271 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1272 ( j * sizeof(tSirWifiRateStat)));
1273
1274 hddLog(VOS_TRACE_LEVEL_INFO,
1275 " peer Rate Stats "
1276 " preamble %u "
1277 " nss %u "
1278 " bw %u "
1279 " rateMcsIdx %u "
1280 " reserved %u "
1281 " bitrate %u "
1282 " txMpdu %u "
1283 " rxMpdu %u "
1284 " mpduLost %u "
1285 " retries %u "
1286 " retriesShort %u "
1287 " retriesLong %u",
1288 pWifiRateStat->rate.preamble,
1289 pWifiRateStat->rate.nss,
1290 pWifiRateStat->rate.bw,
1291 pWifiRateStat->rate.rateMcsIdx,
1292 pWifiRateStat->rate.reserved,
1293 pWifiRateStat->rate.bitrate,
1294 pWifiRateStat->txMpdu,
1295 pWifiRateStat->rxMpdu,
1296 pWifiRateStat->mpduLost,
1297 pWifiRateStat->retries,
1298 pWifiRateStat->retriesShort,
1299 pWifiRateStat->retriesLong);
1300 }
1301 }
1302 }
1303 }
1304
1305 /*
1306 * Allocate a size of 4096 for the peer stats comprising
1307 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1308 * sizeof (tSirWifiRateStat).Each field is put with an
1309 * NL attribute.The size of 4096 is considered assuming
1310 * that number of rates shall not exceed beyond 50 with
1311 * the sizeof (tSirWifiRateStat) being 32.
1312 */
1313 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1314 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1315 QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX,
1316 GFP_KERNEL);
1317 if (!vendor_event)
1318 {
1319 hddLog(VOS_TRACE_LEVEL_ERROR,
1320 "%s: cfg80211_vendor_event_alloc failed",
1321 __func__);
1322 return;
1323 }
1324 if (nla_put_u32(vendor_event,
1325 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1326 pWifiPeerStat->numPeers))
1327 {
1328 hddLog(VOS_TRACE_LEVEL_ERROR,
1329 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1330 kfree_skb(vendor_event);
1331 return;
1332 }
1333
1334 peerInfo = nla_nest_start(vendor_event,
1335 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301336 if(!peerInfo)
1337 {
1338 hddLog(VOS_TRACE_LEVEL_ERROR,
1339 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1340 __func__);
1341 kfree_skb(vendor_event);
1342 return;
1343 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301344
1345 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1346 pWifiPeerStat->peerInfo);
1347
1348 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1349 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301350 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301351 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301352
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301353 if(!peers)
1354 {
1355 hddLog(VOS_TRACE_LEVEL_ERROR,
1356 "%s: peer stats put fail",
1357 __func__);
1358 kfree_skb(vendor_event);
1359 return;
1360 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301361 if (FALSE == put_wifi_peer_info(
1362 pWifiPeerInfo, vendor_event))
1363 {
1364 hddLog(VOS_TRACE_LEVEL_ERROR,
1365 "%s: put_wifi_peer_info put fail", __func__);
1366 kfree_skb(vendor_event);
1367 return;
1368 }
1369
1370 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1371 pWifiPeerStat->peerInfo +
1372 (i * sizeof(tSirWifiPeerInfo)) +
1373 (numRate * sizeof (tSirWifiRateStat)));
1374 nla_nest_end(vendor_event, peers);
1375 }
1376 nla_nest_end(vendor_event, peerInfo);
1377 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301378
1379 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301380}
1381
1382/*
1383 * hdd_link_layer_process_iface_stats () - This function is called after
1384 * receiving Link Layer Interface statistics from FW.This function converts
1385 * the firmware data to the NL data and sends the same to the kernel/upper
1386 * layers.
1387 */
1388static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1389 v_VOID_t *pData)
1390{
1391 tpSirWifiIfaceStat pWifiIfaceStat;
1392 struct sk_buff *vendor_event;
1393 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1394 int status;
1395
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301396 ENTER();
1397
Sunil Duttc69bccb2014-05-26 21:30:20 +05301398 status = wlan_hdd_validate_context(pHddCtx);
1399 if (0 != status)
1400 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301401 return;
1402 }
1403 /*
1404 * Allocate a size of 4096 for the interface stats comprising
1405 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1406 * assuming that all these fit with in the limit.Please take
1407 * a call on the limit based on the data requirements on
1408 * interface statistics.
1409 */
1410 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1411 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1412 QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX,
1413 GFP_KERNEL);
1414 if (!vendor_event)
1415 {
1416 hddLog(VOS_TRACE_LEVEL_ERROR,
1417 FL("cfg80211_vendor_event_alloc failed") );
1418 return;
1419 }
1420
1421 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1422
Dino Mycle3b9536d2014-07-09 22:05:24 +05301423
1424 if (FALSE == hdd_get_interface_info( pAdapter,
1425 &pWifiIfaceStat->info))
1426 {
1427 hddLog(VOS_TRACE_LEVEL_ERROR,
1428 FL("hdd_get_interface_info get fail") );
1429 kfree_skb(vendor_event);
1430 return;
1431 }
1432
1433 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1434 vendor_event))
1435 {
1436 hddLog(VOS_TRACE_LEVEL_ERROR,
1437 FL("put_wifi_iface_stats fail") );
1438 kfree_skb(vendor_event);
1439 return;
1440 }
1441
Sunil Duttc69bccb2014-05-26 21:30:20 +05301442 hddLog(VOS_TRACE_LEVEL_INFO,
1443 "WMI_LINK_STATS_IFACE Data");
1444
1445 hddLog(VOS_TRACE_LEVEL_INFO,
1446 "LL_STATS_IFACE: "
1447 " Mode %u "
1448 " MAC %pM "
1449 " State %u "
1450 " Roaming %u "
1451 " capabilities 0x%x "
1452 " SSID %s "
1453 " BSSID %pM",
1454 pWifiIfaceStat->info.mode,
1455 pWifiIfaceStat->info.macAddr,
1456 pWifiIfaceStat->info.state,
1457 pWifiIfaceStat->info.roaming,
1458 pWifiIfaceStat->info.capabilities,
1459 pWifiIfaceStat->info.ssid,
1460 pWifiIfaceStat->info.bssid);
1461
1462 hddLog(VOS_TRACE_LEVEL_INFO,
1463 " AP country str: %c%c%c",
1464 pWifiIfaceStat->info.apCountryStr[0],
1465 pWifiIfaceStat->info.apCountryStr[1],
1466 pWifiIfaceStat->info.apCountryStr[2]);
1467
1468
1469 hddLog(VOS_TRACE_LEVEL_INFO,
1470 " Country Str Association: %c%c%c",
1471 pWifiIfaceStat->info.countryStr[0],
1472 pWifiIfaceStat->info.countryStr[1],
1473 pWifiIfaceStat->info.countryStr[2]);
1474
1475 hddLog(VOS_TRACE_LEVEL_INFO,
1476 " beaconRx %u "
1477 " mgmtRx %u "
1478 " mgmtActionRx %u "
1479 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301480 " rssiMgmt %d "
1481 " rssiData %d "
1482 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301483 pWifiIfaceStat->beaconRx,
1484 pWifiIfaceStat->mgmtRx,
1485 pWifiIfaceStat->mgmtActionRx,
1486 pWifiIfaceStat->mgmtActionTx,
1487 pWifiIfaceStat->rssiMgmt,
1488 pWifiIfaceStat->rssiData,
1489 pWifiIfaceStat->rssiAck );
1490
1491
1492 {
1493 int i;
1494 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1495 {
1496 hddLog(VOS_TRACE_LEVEL_INFO,
1497
1498 " %d) LL_STATS IFACE: "
1499 " ac: %u txMpdu: %u "
1500 " rxMpdu: %u txMcast: %u "
1501 " rxMcast: %u rxAmpdu: %u "
1502 " txAmpdu: %u mpduLost: %u "
1503 " retries: %u retriesShort: %u "
1504 " retriesLong: %u contentionTimeMin: %u "
1505 " contentionTimeMax: %u contentionTimeAvg: %u "
1506 " contentionNumSamples: %u",
1507 i,
1508 pWifiIfaceStat->AccessclassStats[i].ac,
1509 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1510 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1511 pWifiIfaceStat->AccessclassStats[i].txMcast,
1512 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1513 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1514 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1515 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1516 pWifiIfaceStat->AccessclassStats[i].retries,
1517 pWifiIfaceStat->
1518 AccessclassStats[i].retriesShort,
1519 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1520 pWifiIfaceStat->
1521 AccessclassStats[i].contentionTimeMin,
1522 pWifiIfaceStat->
1523 AccessclassStats[i].contentionTimeMax,
1524 pWifiIfaceStat->
1525 AccessclassStats[i].contentionTimeAvg,
1526 pWifiIfaceStat->
1527 AccessclassStats[i].contentionNumSamples);
1528
1529 }
1530 }
1531
Sunil Duttc69bccb2014-05-26 21:30:20 +05301532 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301533
1534 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301535}
1536
1537/*
1538 * hdd_link_layer_process_radio_stats () - This function is called after
1539 * receiving Link Layer Radio statistics from FW.This function converts
1540 * the firmware data to the NL data and sends the same to the kernel/upper
1541 * layers.
1542 */
1543static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1544 v_VOID_t *pData)
1545{
1546 int status, i;
1547 tpSirWifiRadioStat pWifiRadioStat;
1548 tpSirWifiChannelStats pWifiChannelStats;
1549 struct sk_buff *vendor_event;
1550 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1551 struct nlattr *chList;
1552
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301553 ENTER();
1554
Sunil Duttc69bccb2014-05-26 21:30:20 +05301555 status = wlan_hdd_validate_context(pHddCtx);
1556 if (0 != status)
1557 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301558 return;
1559 }
1560 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1561
1562 hddLog(VOS_TRACE_LEVEL_INFO,
1563 "LL_STATS_RADIO"
1564 " radio is %d onTime is %u "
1565 " txTime is %u rxTime is %u "
1566 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301567 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301568 " onTimePnoScan is %u onTimeHs20 is %u "
1569 " numChannels is %u",
1570 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1571 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1572 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301573 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301574 pWifiRadioStat->onTimeRoamScan,
1575 pWifiRadioStat->onTimePnoScan,
1576 pWifiRadioStat->onTimeHs20,
1577 pWifiRadioStat->numChannels);
1578 /*
1579 * Allocate a size of 4096 for the Radio stats comprising
1580 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1581 * (tSirWifiChannelStats).Each channel data is put with an
1582 * NL attribute.The size of 4096 is considered assuming that
1583 * number of channels shall not exceed beyond 60 with the
1584 * sizeof (tSirWifiChannelStats) being 24 bytes.
1585 */
1586
1587 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1588 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN ,
1589 QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX,
1590 GFP_KERNEL);
1591
1592 if (!vendor_event)
1593 {
1594 hddLog(VOS_TRACE_LEVEL_ERROR,
1595 FL("cfg80211_vendor_event_alloc failed") );
1596 return;
1597 }
1598
1599 if (nla_put_u32(vendor_event,
1600 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1601 pWifiRadioStat->radio) ||
1602 nla_put_u32(vendor_event,
1603 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1604 pWifiRadioStat->onTime) ||
1605 nla_put_u32(vendor_event,
1606 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1607 pWifiRadioStat->txTime) ||
1608 nla_put_u32(vendor_event,
1609 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1610 pWifiRadioStat->rxTime) ||
1611 nla_put_u32(vendor_event,
1612 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1613 pWifiRadioStat->onTimeScan) ||
1614 nla_put_u32(vendor_event,
1615 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1616 pWifiRadioStat->onTimeNbd) ||
1617 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301618 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1619 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301620 nla_put_u32(vendor_event,
1621 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1622 pWifiRadioStat->onTimeRoamScan) ||
1623 nla_put_u32(vendor_event,
1624 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1625 pWifiRadioStat->onTimePnoScan) ||
1626 nla_put_u32(vendor_event,
1627 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1628 pWifiRadioStat->onTimeHs20) ||
1629 nla_put_u32(vendor_event,
1630 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1631 pWifiRadioStat->numChannels))
1632 {
1633 hddLog(VOS_TRACE_LEVEL_ERROR,
1634 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1635 kfree_skb(vendor_event);
1636 return ;
1637 }
1638
1639 chList = nla_nest_start(vendor_event,
1640 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301641 if(!chList)
1642 {
1643 hddLog(VOS_TRACE_LEVEL_ERROR,
1644 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1645 __func__);
1646 kfree_skb(vendor_event);
1647 return;
1648 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301649 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1650 {
1651 struct nlattr *chInfo;
1652
1653 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1654 pWifiRadioStat->channels +
1655 (i * sizeof(tSirWifiChannelStats)));
1656
1657 hddLog(VOS_TRACE_LEVEL_INFO,
1658 " %d) Channel Info"
1659 " width is %u "
1660 " CenterFreq %u "
1661 " CenterFreq0 %u "
1662 " CenterFreq1 %u "
1663 " onTime %u "
1664 " ccaBusyTime %u",
1665 i,
1666 pWifiChannelStats->channel.width,
1667 pWifiChannelStats->channel.centerFreq,
1668 pWifiChannelStats->channel.centerFreq0,
1669 pWifiChannelStats->channel.centerFreq1,
1670 pWifiChannelStats->onTime,
1671 pWifiChannelStats->ccaBusyTime);
1672
1673
1674 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301675 if(!chInfo)
1676 {
1677 hddLog(VOS_TRACE_LEVEL_ERROR,
1678 "%s: failed to put chInfo",
1679 __func__);
1680 kfree_skb(vendor_event);
1681 return;
1682 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301683
1684 if (nla_put_u32(vendor_event,
1685 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1686 pWifiChannelStats->channel.width) ||
1687 nla_put_u32(vendor_event,
1688 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1689 pWifiChannelStats->channel.centerFreq) ||
1690 nla_put_u32(vendor_event,
1691 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1692 pWifiChannelStats->channel.centerFreq0) ||
1693 nla_put_u32(vendor_event,
1694 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1695 pWifiChannelStats->channel.centerFreq1) ||
1696 nla_put_u32(vendor_event,
1697 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1698 pWifiChannelStats->onTime) ||
1699 nla_put_u32(vendor_event,
1700 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1701 pWifiChannelStats->ccaBusyTime))
1702 {
1703 hddLog(VOS_TRACE_LEVEL_ERROR,
1704 FL("cfg80211_vendor_event_alloc failed") );
1705 kfree_skb(vendor_event);
1706 return ;
1707 }
1708 nla_nest_end(vendor_event, chInfo);
1709 }
1710 nla_nest_end(vendor_event, chList);
1711
1712 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301713
1714 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301715 return;
1716}
1717
1718/*
1719 * hdd_link_layer_stats_ind_callback () - This function is called after
1720 * receiving Link Layer indications from FW.This callback converts the firmware
1721 * data to the NL data and send the same to the kernel/upper layers.
1722 */
1723static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1724 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301725 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301726{
Dino Mycled3d50022014-07-07 12:58:25 +05301727 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1728 hdd_adapter_t *pAdapter = NULL;
1729 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301730 int status;
1731
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301732 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301733
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301734 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301735 if (0 != status)
1736 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301737 return;
1738 }
1739
Dino Mycled3d50022014-07-07 12:58:25 +05301740 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1741 if (NULL == pAdapter)
1742 {
1743 hddLog(VOS_TRACE_LEVEL_ERROR,
1744 FL(" MAC address %pM does not exist with host"),
1745 macAddr);
1746 return;
1747 }
1748
Sunil Duttc69bccb2014-05-26 21:30:20 +05301749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301750 "%s: Interface: %s LLStats indType: %d", __func__,
1751 pAdapter->dev->name, indType);
1752
Sunil Duttc69bccb2014-05-26 21:30:20 +05301753 switch (indType)
1754 {
1755 case SIR_HAL_LL_STATS_RESULTS_RSP:
1756 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301757 hddLog(VOS_TRACE_LEVEL_INFO,
1758 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1759 hddLog(VOS_TRACE_LEVEL_INFO,
1760 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1761 linkLayerStatsResults->paramId);
1762 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301763 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1764 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301765 hddLog(VOS_TRACE_LEVEL_INFO,
1766 "LL_STATS RESULTS RESPONSE respId = %u",
1767 linkLayerStatsResults->respId);
1768 hddLog(VOS_TRACE_LEVEL_INFO,
1769 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1770 linkLayerStatsResults->moreResultToFollow);
1771 hddLog(VOS_TRACE_LEVEL_INFO,
1772 "LL_STATS RESULTS RESPONSE result = %p",
1773 linkLayerStatsResults->result);
1774 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1775 {
1776 hdd_link_layer_process_radio_stats(pAdapter,
1777 (v_VOID_t *)linkLayerStatsResults->result);
1778 }
1779 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1780 {
1781 hdd_link_layer_process_iface_stats(pAdapter,
1782 (v_VOID_t *)linkLayerStatsResults->result);
1783 }
1784 else if ( linkLayerStatsResults->paramId &
1785 WMI_LINK_STATS_ALL_PEER )
1786 {
1787 hdd_link_layer_process_peer_stats(pAdapter,
1788 (v_VOID_t *)linkLayerStatsResults->result);
1789 } /* WMI_LINK_STATS_ALL_PEER */
1790 else
1791 {
1792 hddLog(VOS_TRACE_LEVEL_ERROR,
1793 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1794 }
1795
1796 break;
1797 }
1798 default:
1799 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1800 break;
1801 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301802
1803 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301804 return;
1805}
1806
1807const struct
1808nla_policy
1809qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1810{
1811 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1812 { .type = NLA_U32 },
1813 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1814 { .type = NLA_U32 },
1815};
1816
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301817static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1818 struct wireless_dev *wdev,
1819 const void *data,
1820 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301821{
1822 int status;
1823 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301824 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301825 struct net_device *dev = wdev->netdev;
1826 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1827 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Srinivas Dasari98947432014-11-07 19:41:24 +05301828 hdd_station_ctx_t *pHddStaCtx;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301829
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301830 ENTER();
1831
Sunil Duttc69bccb2014-05-26 21:30:20 +05301832 status = wlan_hdd_validate_context(pHddCtx);
1833 if (0 != status)
1834 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301835 return -EINVAL;
1836 }
1837
1838 if (NULL == pAdapter)
1839 {
1840 hddLog(VOS_TRACE_LEVEL_ERROR,
1841 FL("HDD adapter is Null"));
1842 return -ENODEV;
1843 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301844 /* check the LLStats Capability */
1845 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1846 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1847 {
1848 hddLog(VOS_TRACE_LEVEL_ERROR,
1849 FL("Link Layer Statistics not supported by Firmware"));
1850 return -EINVAL;
1851 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301852
1853 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1854 (struct nlattr *)data,
1855 data_len, qca_wlan_vendor_ll_set_policy))
1856 {
1857 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1858 return -EINVAL;
1859 }
1860 if (!tb_vendor
1861 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1862 {
1863 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1864 return -EINVAL;
1865 }
1866 if (!tb_vendor[
1867 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1868 {
1869 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1870 return -EINVAL;
1871 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301872 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301873 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301874
Dino Mycledf0a5d92014-07-04 09:41:55 +05301875 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301876 nla_get_u32(
1877 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1878
Dino Mycledf0a5d92014-07-04 09:41:55 +05301879 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301880 nla_get_u32(
1881 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1882
Dino Mycled3d50022014-07-07 12:58:25 +05301883 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1884 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301885
1886
1887 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301888 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301889 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301890 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301891 hddLog(VOS_TRACE_LEVEL_INFO,
1892 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301893 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301894 hddLog(VOS_TRACE_LEVEL_INFO,
1895 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301896 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301897
1898 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1899 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301900 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301901 {
1902 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1903 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301904 return -EINVAL;
1905
1906 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301907
1908 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1909 if (VOS_STATUS_SUCCESS !=
1910 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1911 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE))
1912 {
1913 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1914 "WLANTL_ClearInterfaceStats Failed", __func__);
1915 return -EINVAL;
1916 }
1917
1918 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1919 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1920 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1921 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1922
Sunil Duttc69bccb2014-05-26 21:30:20 +05301923 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301924 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301925 {
1926 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1927 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301928 return -EINVAL;
1929 }
1930
1931 pAdapter->isLinkLayerStatsSet = 1;
1932
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301933 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301934 return 0;
1935}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301936static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1937 struct wireless_dev *wdev,
1938 const void *data,
1939 int data_len)
1940{
1941 int ret = 0;
1942
1943 vos_ssr_protect(__func__);
1944 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1945 vos_ssr_unprotect(__func__);
1946
1947 return ret;
1948}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301949
1950const struct
1951nla_policy
1952qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1953{
1954 /* Unsigned 32bit value provided by the caller issuing the GET stats
1955 * command. When reporting
1956 * the stats results, the driver uses the same value to indicate
1957 * which GET request the results
1958 * correspond to.
1959 */
1960 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1961
1962 /* Unsigned 32bit value . bit mask to identify what statistics are
1963 requested for retrieval */
1964 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1965};
1966
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301967static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1968 struct wireless_dev *wdev,
1969 const void *data,
1970 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301971{
1972 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1973 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301974 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301975 struct net_device *dev = wdev->netdev;
1976 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1977 int status;
1978
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301979 ENTER();
1980
Sunil Duttc69bccb2014-05-26 21:30:20 +05301981 status = wlan_hdd_validate_context(pHddCtx);
1982 if (0 != status)
1983 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301984 return -EINVAL ;
1985 }
1986
1987 if (NULL == pAdapter)
1988 {
1989 hddLog(VOS_TRACE_LEVEL_FATAL,
1990 "%s: HDD adapter is Null", __func__);
1991 return -ENODEV;
1992 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301993 /* check the LLStats Capability */
1994 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1995 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1996 {
1997 hddLog(VOS_TRACE_LEVEL_ERROR,
1998 FL("Link Layer Statistics not supported by Firmware"));
1999 return -EINVAL;
2000 }
2001
Sunil Duttc69bccb2014-05-26 21:30:20 +05302002
2003 if (!pAdapter->isLinkLayerStatsSet)
2004 {
2005 hddLog(VOS_TRACE_LEVEL_FATAL,
2006 "%s: isLinkLayerStatsSet : %d",
2007 __func__, pAdapter->isLinkLayerStatsSet);
2008 return -EINVAL;
2009 }
2010
2011 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2012 (struct nlattr *)data,
2013 data_len, qca_wlan_vendor_ll_get_policy))
2014 {
2015 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2016 return -EINVAL;
2017 }
2018
2019 if (!tb_vendor
2020 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2021 {
2022 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2023 return -EINVAL;
2024 }
2025
2026 if (!tb_vendor
2027 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2028 {
2029 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
2030 return -EINVAL;
2031 }
2032
Sunil Duttc69bccb2014-05-26 21:30:20 +05302033
Dino Mycledf0a5d92014-07-04 09:41:55 +05302034 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302035 nla_get_u32( tb_vendor[
2036 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05302037 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302038 nla_get_u32( tb_vendor[
2039 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
2040
Dino Mycled3d50022014-07-07 12:58:25 +05302041 vos_mem_copy(linkLayerStatsGetReq.macAddr,
2042 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302043
2044 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302045 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302046 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302047 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302048 hddLog(VOS_TRACE_LEVEL_INFO,
2049 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302050 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302051
2052 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302053 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302054 {
2055 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2056 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302057 return -EINVAL;
2058 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302059
2060 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302061 return 0;
2062}
2063
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302064static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2065 struct wireless_dev *wdev,
2066 const void *data,
2067 int data_len)
2068{
2069 int ret = 0;
2070
2071 vos_ssr_protect(__func__);
2072 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
2073 vos_ssr_unprotect(__func__);
2074
2075 return ret;
2076}
2077
Sunil Duttc69bccb2014-05-26 21:30:20 +05302078const struct
2079nla_policy
2080qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
2081{
2082 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
2083 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
2084 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
2085 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
2086};
2087
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302088static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2089 struct wireless_dev *wdev,
2090 const void *data,
2091 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302092{
2093 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2094 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302095 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302096 struct net_device *dev = wdev->netdev;
2097 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2098 u32 statsClearReqMask;
2099 u8 stopReq;
2100 int status;
2101
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302102 ENTER();
2103
Sunil Duttc69bccb2014-05-26 21:30:20 +05302104 status = wlan_hdd_validate_context(pHddCtx);
2105 if (0 != status)
2106 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302107 return -EINVAL;
2108 }
2109
2110 if (NULL == pAdapter)
2111 {
2112 hddLog(VOS_TRACE_LEVEL_FATAL,
2113 "%s: HDD adapter is Null", __func__);
2114 return -ENODEV;
2115 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302116 /* check the LLStats Capability */
2117 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2118 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2119 {
2120 hddLog(VOS_TRACE_LEVEL_ERROR,
2121 FL("Enable LLStats Capability"));
2122 return -EINVAL;
2123 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302124
2125 if (!pAdapter->isLinkLayerStatsSet)
2126 {
2127 hddLog(VOS_TRACE_LEVEL_FATAL,
2128 "%s: isLinkLayerStatsSet : %d",
2129 __func__, pAdapter->isLinkLayerStatsSet);
2130 return -EINVAL;
2131 }
2132
2133 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2134 (struct nlattr *)data,
2135 data_len, qca_wlan_vendor_ll_clr_policy))
2136 {
2137 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2138 return -EINVAL;
2139 }
2140
2141 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2142
2143 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2144 {
2145 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2146 return -EINVAL;
2147
2148 }
2149
Sunil Duttc69bccb2014-05-26 21:30:20 +05302150
Dino Mycledf0a5d92014-07-04 09:41:55 +05302151 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302152 nla_get_u32(
2153 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2154
Dino Mycledf0a5d92014-07-04 09:41:55 +05302155 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302156 nla_get_u8(
2157 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2158
2159 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302160 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302161
Dino Mycled3d50022014-07-07 12:58:25 +05302162 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2163 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302164
2165 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302166 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302167 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302168 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302169 hddLog(VOS_TRACE_LEVEL_INFO,
2170 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302171 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302172 hddLog(VOS_TRACE_LEVEL_INFO,
2173 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302174 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302175
2176 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302177 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302178 {
2179 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302180 hdd_station_ctx_t *pHddStaCtx;
2181
2182 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2183 if (VOS_STATUS_SUCCESS !=
2184 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2185 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2186 {
2187 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2188 "WLANTL_ClearInterfaceStats Failed", __func__);
2189 return -EINVAL;
2190 }
2191 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2192 (statsClearReqMask & WIFI_STATS_IFACE)) {
2193 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2194 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2195 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2196 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2197 }
2198
Sunil Duttc69bccb2014-05-26 21:30:20 +05302199 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2200 2 * sizeof(u32) +
2201 NLMSG_HDRLEN);
2202
2203 if (temp_skbuff != NULL)
2204 {
2205
2206 if (nla_put_u32(temp_skbuff,
2207 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2208 statsClearReqMask) ||
2209 nla_put_u32(temp_skbuff,
2210 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2211 stopReq))
2212 {
2213 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2214 kfree_skb(temp_skbuff);
2215 return -EINVAL;
2216 }
2217 /* If the ask is to stop the stats collection as part of clear
2218 * (stopReq = 1) , ensure that no further requests of get
2219 * go to the firmware by having isLinkLayerStatsSet set to 0.
2220 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302221 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302222 * case the firmware is just asked to clear the statistics.
2223 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302224 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302225 pAdapter->isLinkLayerStatsSet = 0;
2226 return cfg80211_vendor_cmd_reply(temp_skbuff);
2227 }
2228 return -ENOMEM;
2229 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302230
2231 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302232 return -EINVAL;
2233}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302234static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2235 struct wireless_dev *wdev,
2236 const void *data,
2237 int data_len)
2238{
2239 int ret = 0;
2240
2241 vos_ssr_protect(__func__);
2242 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2243 vos_ssr_unprotect(__func__);
2244
2245 return ret;
2246
2247
2248}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302249#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2250
Dino Mycle6fb96c12014-06-10 11:52:40 +05302251#ifdef WLAN_FEATURE_EXTSCAN
2252static const struct nla_policy
2253wlan_hdd_extscan_config_policy
2254 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2255{
2256 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2257 { .type = NLA_U32 },
2258 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2259 { .type = NLA_U32 },
2260 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2261 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2262 { .type = NLA_U32 },
2263 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2264 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2265
2266 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2267 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2268 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2269 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2270 { .type = NLA_U8 },
2271 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2272 { .type = NLA_U32 },
2273 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2274 { .type = NLA_U32 },
2275 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2276 { .type = NLA_U32 },
2277 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] =
2278 { .type = NLA_U8 },
2279 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2280 { .type = NLA_U8 },
2281 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2282 { .type = NLA_U8 },
2283
2284 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2285 { .type = NLA_U32 },
2286 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2287 { .type = NLA_UNSPEC },
2288 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2289 { .type = NLA_S32 },
2290 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2291 { .type = NLA_S32 },
2292 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2293 { .type = NLA_U32 },
2294 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2295 { .type = NLA_U32 },
2296 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] =
2297 { .type = NLA_U32 },
2298 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]
2299 = { .type = NLA_U32 },
2300 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] =
2301 { .type = NLA_U32 },
2302 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type =
2303 NLA_U32 },
2304};
2305
2306static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg)
2307{
2308 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2309 struct sk_buff *skb = NULL;
2310 tpSirEXTScanCapabilitiesEvent pData =
2311 (tpSirEXTScanCapabilitiesEvent) pMsg;
2312
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302313 ENTER();
2314
2315 if (wlan_hdd_validate_context(pHddCtx))
2316 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302317 return;
2318 }
2319
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302320 if (!pMsg)
2321 {
2322 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2323 return;
2324 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302325 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2326 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2327 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
2328 GFP_KERNEL);
2329
2330 if (!skb) {
2331 hddLog(VOS_TRACE_LEVEL_ERROR,
2332 FL("cfg80211_vendor_event_alloc failed"));
2333 return;
2334 }
2335
2336 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2337 hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize);
2338 hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets);
2339 hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan);
2340 hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)",
2341 pData->maxRssiSampleSize);
2342 hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)",
2343 pData->maxScanReportingThreshold);
2344 hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs);
2345 hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)",
2346 pData->maxSignificantWifiChangeAPs);
2347 hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)",
2348 pData->maxBsidHistoryEntries);
2349
2350 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2351 pData->requestId) ||
2352 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) ||
2353 nla_put_u32(skb,
2354 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
2355 pData->scanCacheSize) ||
2356 nla_put_u32(skb,
2357 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
2358 pData->scanBuckets) ||
2359 nla_put_u32(skb,
2360 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
2361 pData->maxApPerScan) ||
2362 nla_put_u32(skb,
2363 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
2364 pData->maxRssiSampleSize) ||
2365 nla_put_u32(skb,
2366 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
2367 pData->maxScanReportingThreshold) ||
2368 nla_put_u32(skb,
2369 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS,
2370 pData->maxHotlistAPs) ||
2371 nla_put_u32(skb,
2372 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
2373 pData->maxSignificantWifiChangeAPs) ||
2374 nla_put_u32(skb,
2375 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
2376 pData->maxBsidHistoryEntries)) {
2377 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2378 goto nla_put_failure;
2379 }
2380
2381 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302382 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302383 return;
2384
2385nla_put_failure:
2386 kfree_skb(skb);
2387 return;
2388}
2389
2390
2391static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2392{
2393 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2394 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2395 struct sk_buff *skb = NULL;
2396 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
2397
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302398 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302399
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302400 if (wlan_hdd_validate_context(pHddCtx)){
2401 return;
2402 }
2403 if (!pMsg)
2404 {
2405 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302406 return;
2407 }
2408
2409 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2410 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2411 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
2412 GFP_KERNEL);
2413
2414 if (!skb) {
2415 hddLog(VOS_TRACE_LEVEL_ERROR,
2416 FL("cfg80211_vendor_event_alloc failed"));
2417 return;
2418 }
2419 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2420 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2421 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2422
2423 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2424 pData->requestId) ||
2425 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2426 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2427 goto nla_put_failure;
2428 }
2429
2430 /*
2431 * Store the Request ID for comparing with the requestID obtained
2432 * in other requests.HDD shall return a failure is the extscan_stop
2433 * request is issued with a different requestId as that of the
2434 * extscan_start request. Also, This requestId shall be used while
2435 * indicating the full scan results to the upper layers.
2436 * The requestId is stored with the assumption that the firmware
2437 * shall return the ext scan start request's requestId in ext scan
2438 * start response.
2439 */
2440 if (pData->status == 0)
2441 pMac->sme.extScanStartReqId = pData->requestId;
2442
2443
2444 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302445 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302446 return;
2447
2448nla_put_failure:
2449 kfree_skb(skb);
2450 return;
2451}
2452
2453
2454static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2455{
2456 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2457 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2458 struct sk_buff *skb = NULL;
2459
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302460 ENTER();
2461
2462 if (wlan_hdd_validate_context(pHddCtx)){
2463 return;
2464 }
2465 if (!pMsg)
2466 {
2467 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302468 return;
2469 }
2470
2471 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2472 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2473 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2474 GFP_KERNEL);
2475
2476 if (!skb) {
2477 hddLog(VOS_TRACE_LEVEL_ERROR,
2478 FL("cfg80211_vendor_event_alloc failed"));
2479 return;
2480 }
2481 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2482 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2483
2484 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2485 pData->requestId) ||
2486 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2487 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2488 goto nla_put_failure;
2489 }
2490
2491 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302492 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302493 return;
2494
2495nla_put_failure:
2496 kfree_skb(skb);
2497 return;
2498}
2499
2500
2501static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2502 void *pMsg)
2503{
2504 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2505 struct sk_buff *skb = NULL;
2506 tpSirEXTScanSetBssidHotListRspParams pData =
2507 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2508
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302509 ENTER();
2510
2511 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302512 return;
2513 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302514 if (!pMsg)
2515 {
2516 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2517 return;
2518 }
2519
Dino Mycle6fb96c12014-06-10 11:52:40 +05302520 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2521 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2522 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2523 GFP_KERNEL);
2524
2525 if (!skb) {
2526 hddLog(VOS_TRACE_LEVEL_ERROR,
2527 FL("cfg80211_vendor_event_alloc failed"));
2528 return;
2529 }
2530 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2531 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2532 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2533
2534 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2535 pData->requestId) ||
2536 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2537 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2538 goto nla_put_failure;
2539 }
2540
2541 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302542 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302543 return;
2544
2545nla_put_failure:
2546 kfree_skb(skb);
2547 return;
2548}
2549
2550static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2551 void *pMsg)
2552{
2553 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2554 struct sk_buff *skb = NULL;
2555 tpSirEXTScanResetBssidHotlistRspParams pData =
2556 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2557
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302558 ENTER();
2559
2560 if (wlan_hdd_validate_context(pHddCtx)) {
2561 return;
2562 }
2563 if (!pMsg)
2564 {
2565 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302566 return;
2567 }
2568
2569 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2570 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2571 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2572 GFP_KERNEL);
2573
2574 if (!skb) {
2575 hddLog(VOS_TRACE_LEVEL_ERROR,
2576 FL("cfg80211_vendor_event_alloc failed"));
2577 return;
2578 }
2579 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2580 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2581
2582 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2583 pData->requestId) ||
2584 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2585 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2586 goto nla_put_failure;
2587 }
2588
2589 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302590 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302591 return;
2592
2593nla_put_failure:
2594 kfree_skb(skb);
2595 return;
2596}
2597
2598
2599static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2600 void *pMsg)
2601{
2602 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2603 struct sk_buff *skb = NULL;
2604 tpSirEXTScanSetSignificantChangeRspParams pData =
2605 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2606
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302607 ENTER();
2608
2609 if (wlan_hdd_validate_context(pHddCtx)) {
2610 return;
2611 }
2612 if (!pMsg)
2613 {
2614 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302615 return;
2616 }
2617
2618 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2619 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2620 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2621 GFP_KERNEL);
2622
2623 if (!skb) {
2624 hddLog(VOS_TRACE_LEVEL_ERROR,
2625 FL("cfg80211_vendor_event_alloc failed"));
2626 return;
2627 }
2628 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2629 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2630 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2631
2632 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2633 pData->requestId) ||
2634 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2635 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2636 goto nla_put_failure;
2637 }
2638
2639 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302640 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302641 return;
2642
2643nla_put_failure:
2644 kfree_skb(skb);
2645 return;
2646}
2647
2648
2649static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2650 void *pMsg)
2651{
2652 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2653 struct sk_buff *skb = NULL;
2654 tpSirEXTScanResetSignificantChangeRspParams pData =
2655 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2656
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302657 ENTER();
2658
2659 if (wlan_hdd_validate_context(pHddCtx)) {
2660 return;
2661 }
2662 if (!pMsg)
2663 {
2664 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302665 return;
2666 }
2667
2668 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2669 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2670 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2671 GFP_KERNEL);
2672
2673 if (!skb) {
2674 hddLog(VOS_TRACE_LEVEL_ERROR,
2675 FL("cfg80211_vendor_event_alloc failed"));
2676 return;
2677 }
2678 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2679 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2680 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2681
2682 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2683 pData->requestId) ||
2684 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2685 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2686 goto nla_put_failure;
2687 }
2688
2689 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302690 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302691 return;
2692
2693nla_put_failure:
2694 kfree_skb(skb);
2695 return;
2696}
2697
2698static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2699 void *pMsg)
2700{
2701 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2702 struct sk_buff *skb = NULL;
2703 tANI_U32 i = 0, j, resultsPerEvent;
2704 tANI_S32 totalResults;
2705 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2706 tpSirWifiScanResult pSirWifiScanResult;
2707
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302708 ENTER();
2709
2710 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302711 return;
2712 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302713 if (!pMsg)
2714 {
2715 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2716 return;
2717 }
2718
Dino Mycle6fb96c12014-06-10 11:52:40 +05302719 totalResults = pData->numOfAps;
2720 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2721 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2722 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2723
2724 do{
2725 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2726 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2727 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2728
2729 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2730 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2731 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2732 GFP_KERNEL);
2733
2734 if (!skb) {
2735 hddLog(VOS_TRACE_LEVEL_ERROR,
2736 FL("cfg80211_vendor_event_alloc failed"));
2737 return;
2738 }
2739
2740 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2741
2742 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2743 pData->requestId) ||
2744 nla_put_u32(skb,
2745 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2746 resultsPerEvent)) {
2747 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2748 goto fail;
2749 }
2750 if (nla_put_u8(skb,
2751 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2752 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2753 {
2754 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2755 goto fail;
2756 }
2757
2758 if (resultsPerEvent) {
2759 struct nlattr *aps;
2760
2761 aps = nla_nest_start(skb,
2762 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2763 if (!aps)
2764 {
2765 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2766 goto fail;
2767 }
2768
2769 for (j = 0; j < resultsPerEvent; j++, i++) {
2770 struct nlattr *ap;
2771 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2772 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2773
2774 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2775 "Ssid (%s)"
2776 "Bssid: %pM "
2777 "Channel (%u)"
2778 "Rssi (%d)"
2779 "RTT (%u)"
2780 "RTT_SD (%u)",
2781 i,
2782 pSirWifiScanResult->ts,
2783 pSirWifiScanResult->ssid,
2784 pSirWifiScanResult->bssid,
2785 pSirWifiScanResult->channel,
2786 pSirWifiScanResult->rssi,
2787 pSirWifiScanResult->rtt,
2788 pSirWifiScanResult->rtt_sd);
2789
2790 ap = nla_nest_start(skb, j + 1);
2791 if (!ap)
2792 {
2793 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2794 goto fail;
2795 }
2796
2797 if (nla_put_u64(skb,
2798 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2799 pSirWifiScanResult->ts) )
2800 {
2801 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2802 goto fail;
2803 }
2804 if (nla_put(skb,
2805 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2806 sizeof(pSirWifiScanResult->ssid),
2807 pSirWifiScanResult->ssid) )
2808 {
2809 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2810 goto fail;
2811 }
2812 if (nla_put(skb,
2813 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2814 sizeof(pSirWifiScanResult->bssid),
2815 pSirWifiScanResult->bssid) )
2816 {
2817 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2818 goto fail;
2819 }
2820 if (nla_put_u32(skb,
2821 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2822 pSirWifiScanResult->channel) )
2823 {
2824 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2825 goto fail;
2826 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302827 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302828 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2829 pSirWifiScanResult->rssi) )
2830 {
2831 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2832 goto fail;
2833 }
2834 if (nla_put_u32(skb,
2835 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2836 pSirWifiScanResult->rtt) )
2837 {
2838 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2839 goto fail;
2840 }
2841 if (nla_put_u32(skb,
2842 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2843 pSirWifiScanResult->rtt_sd))
2844 {
2845 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2846 goto fail;
2847 }
2848
2849 nla_nest_end(skb, ap);
2850 }
2851 nla_nest_end(skb, aps);
2852
2853 }
2854 cfg80211_vendor_event(skb, GFP_KERNEL);
2855 } while (totalResults > 0);
2856
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302857 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302858 return;
2859fail:
2860 kfree_skb(skb);
2861 return;
2862}
2863
2864static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2865 void *pMsg)
2866{
2867 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2868 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2869 struct sk_buff *skb = NULL;
2870 tANI_U32 i;
2871
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302872 ENTER();
2873
2874 if (wlan_hdd_validate_context(pHddCtx)) {
2875 return;
2876 }
2877 if (!pMsg)
2878 {
2879 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302880 return;
2881 }
2882
2883 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2884 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2885 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
2886 GFP_KERNEL);
2887
2888 if (!skb) {
2889 hddLog(VOS_TRACE_LEVEL_ERROR,
2890 FL("cfg80211_vendor_event_alloc failed"));
2891 return;
2892 }
2893 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2894 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2895 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2896 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2897
2898 for (i = 0; i < pData->numOfAps; i++) {
2899 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2900 "Ssid (%s) "
2901 "Bssid (" MAC_ADDRESS_STR ") "
2902 "Channel (%u) "
2903 "Rssi (%d) "
2904 "RTT (%u) "
2905 "RTT_SD (%u) ",
2906 i,
2907 pData->ap[i].ts,
2908 pData->ap[i].ssid,
2909 MAC_ADDR_ARRAY(pData->ap[i].bssid),
2910 pData->ap[i].channel,
2911 pData->ap[i].rssi,
2912 pData->ap[i].rtt,
2913 pData->ap[i].rtt_sd);
2914 }
2915
2916 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2917 pData->requestId) ||
2918 nla_put_u32(skb,
2919 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2920 pData->numOfAps)) {
2921 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2922 goto fail;
2923 }
2924 if (pData->numOfAps) {
2925 struct nlattr *aps;
2926
2927 aps = nla_nest_start(skb,
2928 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2929 if (!aps)
2930 goto fail;
2931
2932 for (i = 0; i < pData->numOfAps; i++) {
2933 struct nlattr *ap;
2934
2935 ap = nla_nest_start(skb, i + 1);
2936 if (!ap)
2937 goto fail;
2938
2939 if (nla_put_u64(skb,
2940 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2941 pData->ap[i].ts) ||
2942 nla_put(skb,
2943 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2944 sizeof(pData->ap[i].ssid),
2945 pData->ap[i].ssid) ||
2946 nla_put(skb,
2947 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2948 sizeof(pData->ap[i].bssid),
2949 pData->ap[i].bssid) ||
2950 nla_put_u32(skb,
2951 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2952 pData->ap[i].channel) ||
2953 nla_put_s32(skb,
2954 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2955 pData->ap[i].rssi) ||
2956 nla_put_u32(skb,
2957 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2958 pData->ap[i].rtt) ||
2959 nla_put_u32(skb,
2960 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2961 pData->ap[i].rtt_sd))
2962 goto fail;
2963
2964 nla_nest_end(skb, ap);
2965 }
2966 nla_nest_end(skb, aps);
2967
2968 if (nla_put_u8(skb,
2969 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2970 pData->moreData))
2971 goto fail;
2972 }
2973
2974 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302975 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302976 return;
2977
2978fail:
2979 kfree_skb(skb);
2980 return;
2981
2982}
2983static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
2984 void *pMsg)
2985{
2986 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2987 struct sk_buff *skb = NULL;
2988 tANI_U32 i, j;
2989 tpSirWifiSignificantChangeEvent pData =
2990 (tpSirWifiSignificantChangeEvent) pMsg;
2991
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302992 ENTER();
2993
2994 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302995 return;
2996 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302997 if (!pMsg)
2998 {
2999 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3000 return;
3001 }
3002
Dino Mycle6fb96c12014-06-10 11:52:40 +05303003 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3004 EXTSCAN_EVENT_BUF_SIZE,
3005 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
3006 GFP_KERNEL);
3007
3008 if (!skb) {
3009 hddLog(VOS_TRACE_LEVEL_ERROR,
3010 FL("cfg80211_vendor_event_alloc failed"));
3011 return;
3012 }
3013 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3014 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3015 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
3016 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
3017 pData->numSigRssiBss);
3018 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
3019
3020 for (i = 0; i < pData->numSigRssiBss; i++) {
3021 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
3022 " num RSSI %u ",
3023 i, pData->sigRssiResult[i].bssid,
3024 pData->sigRssiResult[i].channel,
3025 pData->sigRssiResult[i].numRssi);
3026
3027 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
3028
3029 hddLog(VOS_TRACE_LEVEL_INFO,
3030 " [%d]",
Dino Myclec8f3f332014-07-21 16:48:27 +05303031 pData->sigRssiResult[i].rssi[j]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303032
3033 }
3034 }
3035
3036
3037 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3038 pData->requestId) ||
3039 nla_put_u32(skb,
3040 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3041 pData->numSigRssiBss)) {
3042 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3043 goto fail;
3044 }
3045
3046 if (pData->numSigRssiBss) {
3047 struct nlattr *aps;
3048 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3049 if (!aps)
3050 goto fail;
3051 for (i = 0; i < pData->numSigRssiBss; i++) {
3052 struct nlattr *ap;
3053
3054 ap = nla_nest_start(skb, i);
3055 if (!ap)
3056 goto fail;
3057 if (nla_put(skb,
3058 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
3059 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
3060 nla_put_u32(skb,
3061 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
3062 pData->sigRssiResult[i].channel) ||
3063 nla_put_u32(skb,
3064 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
3065 pData->sigRssiResult[i].numRssi) ||
3066 nla_put(skb,
3067 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
3068 sizeof(s32) * pData->sigRssiResult[i].numRssi,
3069 pData->sigRssiResult[i].rssi))
3070 goto fail;
3071 nla_nest_end(skb, ap);
3072 }
3073 nla_nest_end(skb, aps);
3074 if (nla_put_u8(skb,
3075 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3076 pData->moreData))
3077 goto fail;
3078 }
3079 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303080 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303081 return;
3082fail:
3083 kfree_skb(skb);
3084 return;
3085}
3086
3087static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3088 void *pMsg)
3089{
3090 struct sk_buff *skb;
3091 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3092 tpSirWifiFullScanResultEvent pData =
3093 (tpSirWifiFullScanResultEvent) (pMsg);
3094
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303095 ENTER();
3096
3097 if (wlan_hdd_validate_context(pHddCtx)) {
3098 return;
3099 }
3100 if (!pMsg)
3101 {
3102 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303103 return;
3104 }
3105
3106 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3107 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3108 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3109 GFP_KERNEL);
3110
3111 if (!skb) {
3112 hddLog(VOS_TRACE_LEVEL_ERROR,
3113 FL("cfg80211_vendor_event_alloc failed"));
3114 return;
3115 }
3116
3117 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3118 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3119 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3120 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3121 "Ssid (%s)"
3122 "Bssid (" MAC_ADDRESS_STR ")"
3123 "Channel (%u)"
3124 "Rssi (%d)"
3125 "RTT (%u)"
3126 "RTT_SD (%u)"),
3127 pData->ap.ts,
3128 pData->ap.ssid,
3129 MAC_ADDR_ARRAY(pData->ap.bssid),
3130 pData->ap.channel,
3131 pData->ap.rssi,
3132 pData->ap.rtt,
3133 pData->ap.rtt_sd);
3134 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3135 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3136 pData->requestId) ||
3137 nla_put_u64(skb,
3138 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3139 pData->ap.ts) ||
3140 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3141 sizeof(pData->ap.ssid),
3142 pData->ap.ssid) ||
3143 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3144 WNI_CFG_BSSID_LEN,
3145 pData->ap.bssid) ||
3146 nla_put_u32(skb,
3147 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3148 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303149 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303150 pData->ap.rssi) ||
3151 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3152 pData->ap.rtt) ||
3153 nla_put_u32(skb,
3154 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3155 pData->ap.rtt_sd) ||
3156 nla_put_u16(skb,
3157 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3158 pData->ap.beaconPeriod) ||
3159 nla_put_u16(skb,
3160 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3161 pData->ap.capability) ||
3162 nla_put_u32(skb,
3163 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3164 pData->ieLength))
3165 {
3166 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3167 goto nla_put_failure;
3168 }
3169 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3170 pData->ieLength,
3171 pData->ie))
3172 {
3173 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3174 goto nla_put_failure;
3175 }
3176
3177 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303178 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303179 return;
3180
3181nla_put_failure:
3182 kfree_skb(skb);
3183 return;
3184}
3185
3186static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3187 void *pMsg)
3188{
3189 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3190 struct sk_buff *skb = NULL;
3191 tpSirEXTScanResultsAvailableIndParams pData =
3192 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3193
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303194 ENTER();
3195
3196 if (wlan_hdd_validate_context(pHddCtx)){
3197 return;
3198 }
3199 if (!pMsg)
3200 {
3201 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303202 return;
3203 }
3204
3205 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3206 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3207 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3208 GFP_KERNEL);
3209
3210 if (!skb) {
3211 hddLog(VOS_TRACE_LEVEL_ERROR,
3212 FL("cfg80211_vendor_event_alloc failed"));
3213 return;
3214 }
3215
3216 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3217 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3218 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3219 pData->numResultsAvailable);
3220 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3221 pData->requestId) ||
3222 nla_put_u32(skb,
3223 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3224 pData->numResultsAvailable)) {
3225 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3226 goto nla_put_failure;
3227 }
3228
3229 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303230 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303231 return;
3232
3233nla_put_failure:
3234 kfree_skb(skb);
3235 return;
3236}
3237
3238static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3239{
3240 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3241 struct sk_buff *skb = NULL;
3242 tpSirEXTScanProgressIndParams pData =
3243 (tpSirEXTScanProgressIndParams) pMsg;
3244
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303245 ENTER();
3246
3247 if (wlan_hdd_validate_context(pHddCtx)){
3248 return;
3249 }
3250 if (!pMsg)
3251 {
3252 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303253 return;
3254 }
3255
3256 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3257 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3258 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3259 GFP_KERNEL);
3260
3261 if (!skb) {
3262 hddLog(VOS_TRACE_LEVEL_ERROR,
3263 FL("cfg80211_vendor_event_alloc failed"));
3264 return;
3265 }
3266 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3267 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3268 pData->extScanEventType);
3269 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3270 pData->status);
3271
3272 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3273 pData->extScanEventType) ||
3274 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303275 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3276 pData->requestId) ||
3277 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303278 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3279 pData->status)) {
3280 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3281 goto nla_put_failure;
3282 }
3283
3284 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303285 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303286 return;
3287
3288nla_put_failure:
3289 kfree_skb(skb);
3290 return;
3291}
3292
3293void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3294 void *pMsg)
3295{
3296 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3297
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303298 ENTER();
3299
Dino Mycle6fb96c12014-06-10 11:52:40 +05303300 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303301 return;
3302 }
3303
3304 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3305
3306
3307 switch(evType) {
3308 case SIR_HAL_EXTSCAN_START_RSP:
3309 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3310 break;
3311
3312 case SIR_HAL_EXTSCAN_STOP_RSP:
3313 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3314 break;
3315 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3316 /* There is no need to send this response to upper layer
3317 Just log the message */
3318 hddLog(VOS_TRACE_LEVEL_INFO,
3319 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3320 break;
3321 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3322 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3323 break;
3324
3325 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3326 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3327 break;
3328
3329 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
3330 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
3331 break;
3332
3333 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
3334 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
3335 break;
3336 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
3337 wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg);
3338 break;
3339 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3340 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3341 break;
3342 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3343 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3344 break;
3345 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3346 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3347 break;
3348 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3349 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3350 break;
3351 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
3352 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
3353 break;
3354 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3355 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3356 break;
3357 default:
3358 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3359 break;
3360 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303361 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303362}
3363
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303364static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3365 struct wireless_dev *wdev,
3366 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303367{
Dino Myclee8843b32014-07-04 14:21:45 +05303368 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303369 struct net_device *dev = wdev->netdev;
3370 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3371 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3372 struct nlattr
3373 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3374 eHalStatus status;
3375
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303376 ENTER();
3377
Dino Mycle6fb96c12014-06-10 11:52:40 +05303378 status = wlan_hdd_validate_context(pHddCtx);
3379 if (0 != status)
3380 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303381 return -EINVAL;
3382 }
Dino Myclee8843b32014-07-04 14:21:45 +05303383 /* check the EXTScan Capability */
3384 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3385 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3386 {
3387 hddLog(VOS_TRACE_LEVEL_ERROR,
3388 FL("EXTScan not enabled/supported by Firmware"));
3389 return -EINVAL;
3390 }
3391
Dino Mycle6fb96c12014-06-10 11:52:40 +05303392 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3393 data, dataLen,
3394 wlan_hdd_extscan_config_policy)) {
3395 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3396 return -EINVAL;
3397 }
3398
3399 /* Parse and fetch request Id */
3400 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3401 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3402 return -EINVAL;
3403 }
3404
Dino Mycle6fb96c12014-06-10 11:52:40 +05303405
Dino Myclee8843b32014-07-04 14:21:45 +05303406 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303407 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303408 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303409
Dino Myclee8843b32014-07-04 14:21:45 +05303410 reqMsg.sessionId = pAdapter->sessionId;
3411 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303412
Dino Myclee8843b32014-07-04 14:21:45 +05303413 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303414 if (!HAL_STATUS_SUCCESS(status)) {
3415 hddLog(VOS_TRACE_LEVEL_ERROR,
3416 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303417 return -EINVAL;
3418 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303419 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303420 return 0;
3421}
3422
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303423static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3424 struct wireless_dev *wdev,
3425 const void *data, int dataLen)
3426{
3427 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303428
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303429 vos_ssr_protect(__func__);
3430 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3431 vos_ssr_unprotect(__func__);
3432
3433 return ret;
3434}
3435
3436static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3437 struct wireless_dev *wdev,
3438 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303439{
Dino Myclee8843b32014-07-04 14:21:45 +05303440 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303441 struct net_device *dev = wdev->netdev;
3442 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3443 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3444 struct nlattr
3445 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3446 eHalStatus status;
3447
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303448 ENTER();
3449
Dino Mycle6fb96c12014-06-10 11:52:40 +05303450 status = wlan_hdd_validate_context(pHddCtx);
3451 if (0 != status)
3452 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303453 return -EINVAL;
3454 }
Dino Myclee8843b32014-07-04 14:21:45 +05303455 /* check the EXTScan Capability */
3456 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3457 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3458 {
3459 hddLog(VOS_TRACE_LEVEL_ERROR,
3460 FL("EXTScan not enabled/supported by Firmware"));
3461 return -EINVAL;
3462 }
3463
Dino Mycle6fb96c12014-06-10 11:52:40 +05303464 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3465 data, dataLen,
3466 wlan_hdd_extscan_config_policy)) {
3467 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3468 return -EINVAL;
3469 }
3470 /* Parse and fetch request Id */
3471 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3472 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3473 return -EINVAL;
3474 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303475
Dino Myclee8843b32014-07-04 14:21:45 +05303476 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303477 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3478
Dino Myclee8843b32014-07-04 14:21:45 +05303479 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303480
Dino Myclee8843b32014-07-04 14:21:45 +05303481 reqMsg.sessionId = pAdapter->sessionId;
3482 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303483
3484 /* Parse and fetch flush parameter */
3485 if (!tb
3486 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3487 {
3488 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3489 goto failed;
3490 }
Dino Myclee8843b32014-07-04 14:21:45 +05303491 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303492 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3493
Dino Myclee8843b32014-07-04 14:21:45 +05303494 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303495
Dino Myclee8843b32014-07-04 14:21:45 +05303496 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303497 if (!HAL_STATUS_SUCCESS(status)) {
3498 hddLog(VOS_TRACE_LEVEL_ERROR,
3499 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303500 return -EINVAL;
3501 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303502 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303503 return 0;
3504
3505failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303506 return -EINVAL;
3507}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303508static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3509 struct wireless_dev *wdev,
3510 const void *data, int dataLen)
3511{
3512 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303513
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303514 vos_ssr_protect(__func__);
3515 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3516 vos_ssr_unprotect(__func__);
3517
3518 return ret;
3519}
3520
3521static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303522 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303523 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303524{
3525 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3526 struct net_device *dev = wdev->netdev;
3527 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3528 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3529 struct nlattr
3530 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3531 struct nlattr
3532 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3533 struct nlattr *apTh;
3534 eHalStatus status;
3535 tANI_U8 i = 0;
3536 int rem;
3537
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303538 ENTER();
3539
Dino Mycle6fb96c12014-06-10 11:52:40 +05303540 status = wlan_hdd_validate_context(pHddCtx);
3541 if (0 != status)
3542 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303543 return -EINVAL;
3544 }
Dino Myclee8843b32014-07-04 14:21:45 +05303545 /* check the EXTScan Capability */
3546 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3547 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3548 {
3549 hddLog(VOS_TRACE_LEVEL_ERROR,
3550 FL("EXTScan not enabled/supported by Firmware"));
3551 return -EINVAL;
3552 }
3553
Dino Mycle6fb96c12014-06-10 11:52:40 +05303554 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3555 data, dataLen,
3556 wlan_hdd_extscan_config_policy)) {
3557 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3558 return -EINVAL;
3559 }
3560
3561 /* Parse and fetch request Id */
3562 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3563 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3564 return -EINVAL;
3565 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303566 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3567 vos_mem_malloc(sizeof(*pReqMsg));
3568 if (!pReqMsg) {
3569 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3570 return -ENOMEM;
3571 }
3572
Dino Myclee8843b32014-07-04 14:21:45 +05303573
Dino Mycle6fb96c12014-06-10 11:52:40 +05303574 pReqMsg->requestId = nla_get_u32(
3575 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3576 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3577
3578 /* Parse and fetch number of APs */
3579 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3580 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3581 goto fail;
3582 }
3583
3584 pReqMsg->sessionId = pAdapter->sessionId;
3585 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3586
3587 pReqMsg->numAp = nla_get_u32(
3588 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3589 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3590
3591 nla_for_each_nested(apTh,
3592 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3593 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3594 nla_data(apTh), nla_len(apTh),
3595 NULL)) {
3596 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3597 goto fail;
3598 }
3599
3600 /* Parse and fetch MAC address */
3601 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3602 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3603 goto fail;
3604 }
3605 memcpy(pReqMsg->ap[i].bssid, nla_data(
3606 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3607 sizeof(tSirMacAddr));
3608 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3609
3610 /* Parse and fetch low RSSI */
3611 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3612 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3613 goto fail;
3614 }
3615 pReqMsg->ap[i].low = nla_get_s32(
3616 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3617 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3618
3619 /* Parse and fetch high RSSI */
3620 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3621 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3622 goto fail;
3623 }
3624 pReqMsg->ap[i].high = nla_get_s32(
3625 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3626 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3627 pReqMsg->ap[i].high);
3628
3629 /* Parse and fetch channel */
3630 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3631 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3632 goto fail;
3633 }
3634 pReqMsg->ap[i].channel = nla_get_u32(
3635 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3636 hddLog(VOS_TRACE_LEVEL_INFO,
3637 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3638 i++;
3639 }
3640 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3641 if (!HAL_STATUS_SUCCESS(status)) {
3642 hddLog(VOS_TRACE_LEVEL_ERROR,
3643 FL("sme_SetBssHotlist failed(err=%d)"), status);
3644 vos_mem_free(pReqMsg);
3645 return -EINVAL;
3646 }
3647
Dino Myclee8843b32014-07-04 14:21:45 +05303648 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303649 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303650 return 0;
3651
3652fail:
3653 vos_mem_free(pReqMsg);
3654 return -EINVAL;
3655}
3656
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303657static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3658 struct wireless_dev *wdev,
3659 const void *data, int dataLen)
3660{
3661 int ret = 0;
3662
3663 vos_ssr_protect(__func__);
3664 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3665 dataLen);
3666 vos_ssr_unprotect(__func__);
3667
3668 return ret;
3669}
3670
3671static int __wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303672 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303673 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303674{
3675 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3676 struct net_device *dev = wdev->netdev;
3677 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3678 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3679 struct nlattr
3680 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3681 struct nlattr
3682 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3683 struct nlattr *apTh;
3684 eHalStatus status;
3685 int i = 0;
3686 int rem;
3687
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303688 ENTER();
3689
Dino Mycle6fb96c12014-06-10 11:52:40 +05303690 status = wlan_hdd_validate_context(pHddCtx);
3691 if (0 != status)
3692 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303693 return -EINVAL;
3694 }
Dino Myclee8843b32014-07-04 14:21:45 +05303695 /* check the EXTScan Capability */
3696 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3697 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3698 {
3699 hddLog(VOS_TRACE_LEVEL_ERROR,
3700 FL("EXTScan not enabled/supported by Firmware"));
3701 return -EINVAL;
3702 }
3703
Dino Mycle6fb96c12014-06-10 11:52:40 +05303704 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3705 data, dataLen,
3706 wlan_hdd_extscan_config_policy)) {
3707 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3708 return -EINVAL;
3709 }
3710
3711 /* Parse and fetch request Id */
3712 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3713 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3714 return -EINVAL;
3715 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303716 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303717 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303718 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303719 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3720 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303721 }
3722
Dino Myclee8843b32014-07-04 14:21:45 +05303723
3724
Dino Mycle6fb96c12014-06-10 11:52:40 +05303725 pReqMsg->requestId = nla_get_u32(
3726 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3727 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3728
3729 /* Parse and fetch RSSI sample size */
3730 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3731 {
3732 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3733 goto fail;
3734 }
3735 pReqMsg->rssiSampleSize = nla_get_u32(
3736 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3737 hddLog(VOS_TRACE_LEVEL_INFO,
3738 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3739
3740 /* Parse and fetch lost AP sample size */
3741 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3742 {
3743 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3744 goto fail;
3745 }
3746 pReqMsg->lostApSampleSize = nla_get_u32(
3747 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3748 hddLog(VOS_TRACE_LEVEL_INFO,
3749 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3750 /* Parse and fetch minimum Breaching */
3751 if (!tb
3752 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3753 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3754 goto fail;
3755 }
3756 pReqMsg->minBreaching = nla_get_u32(
3757 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3758 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3759
3760 /* Parse and fetch number of APs */
3761 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3762 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3763 goto fail;
3764 }
3765 pReqMsg->numAp = nla_get_u32(
3766 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3767 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3768
3769 pReqMsg->sessionId = pAdapter->sessionId;
3770 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3771
3772 nla_for_each_nested(apTh,
3773 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3774 if(nla_parse(tb2,
3775 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3776 nla_data(apTh), nla_len(apTh),
3777 NULL)) {
3778 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3779 goto fail;
3780 }
3781
3782 /* Parse and fetch MAC address */
3783 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3784 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3785 goto fail;
3786 }
3787 memcpy(pReqMsg->ap[i].bssid, nla_data(
3788 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3789 sizeof(tSirMacAddr));
3790
3791 /* Parse and fetch low RSSI */
3792 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3793 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3794 goto fail;
3795 }
3796 pReqMsg->ap[i].low = nla_get_s32(
3797 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3798 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3799
3800 /* Parse and fetch high RSSI */
3801 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3802 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3803 goto fail;
3804 }
3805 pReqMsg->ap[i].high = nla_get_s32(
3806 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3807 hddLog(VOS_TRACE_LEVEL_INFO,
3808 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
3809
3810 /* Parse and fetch channel */
3811 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3812 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3813 goto fail;
3814 }
3815 pReqMsg->ap[i].channel = nla_get_u32(
3816 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3817 hddLog(VOS_TRACE_LEVEL_INFO,
3818 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3819 i++;
3820 }
3821
3822 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
3823 if (!HAL_STATUS_SUCCESS(status)) {
3824 hddLog(VOS_TRACE_LEVEL_ERROR,
3825 FL("sme_SetSignificantChange failed(err=%d)"), status);
3826 vos_mem_free(pReqMsg);
3827 return -EINVAL;
3828 }
Dino Myclee8843b32014-07-04 14:21:45 +05303829 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303830 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303831 return 0;
3832
3833fail:
3834 vos_mem_free(pReqMsg);
3835 return -EINVAL;
3836}
3837
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303838static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
3839 struct wireless_dev *wdev,
3840 const void *data, int dataLen)
3841{
3842 int ret = 0;
3843
3844 vos_ssr_protect(__func__);
3845 ret = __wlan_hdd_cfg80211_extscan_set_significant_change(wiphy, wdev, data,
3846 dataLen);
3847 vos_ssr_unprotect(__func__);
3848
3849 return ret;
3850}
3851
3852static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303853 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303854 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303855{
3856 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3857 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3858 tANI_U8 numChannels = 0;
3859 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3860 tANI_U32 requestId;
3861 tWifiBand wifiBand;
3862 eHalStatus status;
3863 struct sk_buff *replySkb;
3864 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303865 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303866
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303867 ENTER();
3868
Dino Mycle6fb96c12014-06-10 11:52:40 +05303869 status = wlan_hdd_validate_context(pHddCtx);
3870 if (0 != status)
3871 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303872 return -EINVAL;
3873 }
Dino Myclee8843b32014-07-04 14:21:45 +05303874
Dino Mycle6fb96c12014-06-10 11:52:40 +05303875 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3876 data, dataLen,
3877 wlan_hdd_extscan_config_policy)) {
3878 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3879 return -EINVAL;
3880 }
3881
3882 /* Parse and fetch request Id */
3883 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3884 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3885 return -EINVAL;
3886 }
3887 requestId = nla_get_u32(
3888 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3889 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3890
3891 /* Parse and fetch wifi band */
3892 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3893 {
3894 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3895 return -EINVAL;
3896 }
3897 wifiBand = nla_get_u32(
3898 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3899 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3900
3901 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
3902 wifiBand, ChannelList,
3903 &numChannels);
3904 if (eHAL_STATUS_SUCCESS != status) {
3905 hddLog(VOS_TRACE_LEVEL_ERROR,
3906 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
3907 return -EINVAL;
3908 }
3909 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
3910 for (i = 0; i < numChannels; i++)
3911 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
3912
3913 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
3914 sizeof(u32) * numChannels +
3915 NLMSG_HDRLEN);
3916
3917 if (!replySkb) {
3918 hddLog(VOS_TRACE_LEVEL_ERROR,
3919 FL("valid channels: buffer alloc fail"));
3920 return -EINVAL;
3921 }
3922 if (nla_put_u32(replySkb,
3923 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
3924 numChannels) ||
3925 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
3926 sizeof(u32) * numChannels, ChannelList)) {
3927
3928 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3929 kfree_skb(replySkb);
3930 return -EINVAL;
3931 }
3932
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303933 ret = cfg80211_vendor_cmd_reply(replySkb);
3934
3935 EXIT();
3936 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303937}
3938
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303939static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
3940 struct wireless_dev *wdev,
3941 const void *data, int dataLen)
3942{
3943 int ret = 0;
3944
3945 vos_ssr_protect(__func__);
3946 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
3947 dataLen);
3948 vos_ssr_unprotect(__func__);
3949
3950 return ret;
3951}
3952
3953static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303954 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303955 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303956{
Dino Myclee8843b32014-07-04 14:21:45 +05303957 tpSirEXTScanStartReqParams pReqMsg = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303958 struct net_device *dev = wdev->netdev;
3959 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3960 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3961 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3962 struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3963 struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3964 struct nlattr *buckets;
3965 struct nlattr *channels;
3966 int rem1;
3967 int rem2;
3968 eHalStatus status;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303969 tANI_U32 j = 0, index = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303970
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303971 ENTER();
3972
Dino Mycle6fb96c12014-06-10 11:52:40 +05303973 status = wlan_hdd_validate_context(pHddCtx);
3974 if (0 != status)
3975 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303976 return -EINVAL;
3977 }
Dino Myclee8843b32014-07-04 14:21:45 +05303978 /* check the EXTScan Capability */
3979 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3980 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3981 {
3982 hddLog(VOS_TRACE_LEVEL_ERROR,
3983 FL("EXTScan not enabled/supported by Firmware"));
3984 return -EINVAL;
3985 }
3986
Dino Mycle6fb96c12014-06-10 11:52:40 +05303987 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3988 data, dataLen,
3989 wlan_hdd_extscan_config_policy)) {
3990 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3991 return -EINVAL;
3992 }
3993
3994 /* Parse and fetch request Id */
3995 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3996 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3997 return -EINVAL;
3998 }
3999
Dino Myclee8843b32014-07-04 14:21:45 +05304000 pReqMsg = (tpSirEXTScanStartReqParams)
4001 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304002 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304003 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4004 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304005 }
4006
4007 pReqMsg->requestId = nla_get_u32(
4008 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4009 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4010
4011 pReqMsg->sessionId = pAdapter->sessionId;
4012 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4013
4014 /* Parse and fetch base period */
4015 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) {
4016 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4017 goto fail;
4018 }
4019 pReqMsg->basePeriod = nla_get_u32(
4020 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]);
4021 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4022 pReqMsg->basePeriod);
4023
4024 /* Parse and fetch max AP per scan */
4025 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) {
4026 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4027 goto fail;
4028 }
4029 pReqMsg->maxAPperScan = nla_get_u32(
4030 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]);
4031 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4032 pReqMsg->maxAPperScan);
4033
4034 /* Parse and fetch report threshold */
4035 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) {
4036 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4037 goto fail;
4038 }
4039 pReqMsg->reportThreshold = nla_get_u8(
4040 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]);
4041 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
4042 pReqMsg->reportThreshold);
4043
4044 /* Parse and fetch number of buckets */
4045 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) {
4046 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4047 goto fail;
4048 }
4049 pReqMsg->numBuckets = nla_get_u8(
4050 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]);
4051 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4052 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4053 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4054 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4055 }
4056 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4057 pReqMsg->numBuckets);
4058 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4059 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4060 goto fail;
4061 }
4062
4063 nla_for_each_nested(buckets,
4064 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4065 if(nla_parse(bucket,
4066 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4067 nla_data(buckets), nla_len(buckets), NULL)) { //policy
4068 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4069 goto fail;
4070 }
4071
4072 /* Parse and fetch bucket spec */
4073 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4074 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed"));
4075 goto fail;
4076 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304077
4078 pReqMsg->buckets[index].bucket = nla_get_u8(
4079 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4080
4081 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"),
4082 pReqMsg->buckets[index].bucket);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304083
4084 /* Parse and fetch wifi band */
4085 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4086 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4087 goto fail;
4088 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304089 pReqMsg->buckets[index].band = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304090 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4091 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304092 pReqMsg->buckets[index].band);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304093
4094 /* Parse and fetch period */
4095 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4096 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed"));
4097 goto fail;
4098 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304099 pReqMsg->buckets[index].period = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304100 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4101 hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304102 pReqMsg->buckets[index].period);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304103
4104 /* Parse and fetch report events */
4105 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4106 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed"));
4107 goto fail;
4108 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304109 pReqMsg->buckets[index].reportEvents = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304110 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4111 hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304112 pReqMsg->buckets[index].reportEvents);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304113
4114 /* Parse and fetch number of channels */
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304115 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS])
4116 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304117 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed"));
4118 goto fail;
4119 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304120 pReqMsg->buckets[index].numChannels = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304121 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4122 hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304123 pReqMsg->buckets[index].numChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304124
4125 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4126 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed"));
4127 goto fail;
4128 }
4129
4130 j = 0;
4131 nla_for_each_nested(channels,
4132 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4133 if(nla_parse(channel,
4134 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4135 nla_data(channels), nla_len(channels),
4136 NULL)) { //wlan_hdd_extscan_config_policy here
4137 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4138 goto fail;
4139 }
4140
4141 /* Parse and fetch channel */
4142 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4143 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4144 goto fail;
4145 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304146 pReqMsg->buckets[index].channels[j].channel = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304147 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4148 hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304149 pReqMsg->buckets[index].channels[j].channel);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304150
4151 /* Parse and fetch dwell time */
4152 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4153 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed"));
4154 goto fail;
4155 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304156 pReqMsg->buckets[index].channels[j].dwellTimeMs = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304157 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4158 hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304159 pReqMsg->buckets[index].channels[j].dwellTimeMs);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304160
4161 /* Parse and fetch channel spec passive */
4162 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4163 hddLog(VOS_TRACE_LEVEL_ERROR,
4164 FL("attr channel spec passive failed"));
4165 goto fail;
4166 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304167 pReqMsg->buckets[index].channels[j].passive = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304168 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4169 hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304170 pReqMsg->buckets[index].channels[j].passive);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304171 j++;
4172 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304173 index++;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304174 }
4175 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4176 if (!HAL_STATUS_SUCCESS(status)) {
4177 hddLog(VOS_TRACE_LEVEL_ERROR,
4178 FL("sme_EXTScanStart failed(err=%d)"), status);
4179 vos_mem_free(pReqMsg);
4180 return -EINVAL;
4181 }
4182
Dino Myclee8843b32014-07-04 14:21:45 +05304183 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304184 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304185 return 0;
4186
4187fail:
4188 vos_mem_free(pReqMsg);
4189 return -EINVAL;
4190}
4191
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304192static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4193 struct wireless_dev *wdev,
4194 const void *data, int dataLen)
4195{
4196 int ret = 0;
4197
4198 vos_ssr_protect(__func__);
4199 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4200 vos_ssr_unprotect(__func__);
4201
4202 return ret;
4203}
4204
4205static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304206 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304207 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304208{
Dino Myclee8843b32014-07-04 14:21:45 +05304209 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304210 struct net_device *dev = wdev->netdev;
4211 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4212 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4213 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4214 eHalStatus status;
4215
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304216 ENTER();
4217
Dino Mycle6fb96c12014-06-10 11:52:40 +05304218 status = wlan_hdd_validate_context(pHddCtx);
4219 if (0 != status)
4220 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304221 return -EINVAL;
4222 }
Dino Myclee8843b32014-07-04 14:21:45 +05304223 /* check the EXTScan Capability */
4224 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4225 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4226 {
4227 hddLog(VOS_TRACE_LEVEL_ERROR,
4228 FL("EXTScan not enabled/supported by Firmware"));
4229 return -EINVAL;
4230 }
4231
Dino Mycle6fb96c12014-06-10 11:52:40 +05304232 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4233 data, dataLen,
4234 wlan_hdd_extscan_config_policy)) {
4235 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4236 return -EINVAL;
4237 }
4238
4239 /* Parse and fetch request Id */
4240 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4241 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4242 return -EINVAL;
4243 }
4244
Dino Myclee8843b32014-07-04 14:21:45 +05304245 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304246 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304247 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304248
Dino Myclee8843b32014-07-04 14:21:45 +05304249 reqMsg.sessionId = pAdapter->sessionId;
4250 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304251
Dino Myclee8843b32014-07-04 14:21:45 +05304252 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304253 if (!HAL_STATUS_SUCCESS(status)) {
4254 hddLog(VOS_TRACE_LEVEL_ERROR,
4255 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304256 return -EINVAL;
4257 }
4258
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304259 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304260 return 0;
4261}
4262
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304263static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4264 struct wireless_dev *wdev,
4265 const void *data, int dataLen)
4266{
4267 int ret = 0;
4268
4269 vos_ssr_protect(__func__);
4270 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4271 vos_ssr_unprotect(__func__);
4272
4273 return ret;
4274}
4275
4276static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304277 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304278 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304279{
Dino Myclee8843b32014-07-04 14:21:45 +05304280 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304281 struct net_device *dev = wdev->netdev;
4282 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4283 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4284 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4285 eHalStatus status;
4286
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304287 ENTER();
4288
Dino Mycle6fb96c12014-06-10 11:52:40 +05304289 status = wlan_hdd_validate_context(pHddCtx);
4290 if (0 != status)
4291 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304292 return -EINVAL;
4293 }
Dino Myclee8843b32014-07-04 14:21:45 +05304294 /* check the EXTScan Capability */
4295 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4296 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4297 {
4298 hddLog(VOS_TRACE_LEVEL_ERROR,
4299 FL("EXTScan not enabled/supported by Firmware"));
4300 return -EINVAL;
4301 }
4302
Dino Mycle6fb96c12014-06-10 11:52:40 +05304303 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4304 data, dataLen,
4305 wlan_hdd_extscan_config_policy)) {
4306 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4307 return -EINVAL;
4308 }
4309
4310 /* Parse and fetch request Id */
4311 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4312 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4313 return -EINVAL;
4314 }
4315
Dino Myclee8843b32014-07-04 14:21:45 +05304316 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304317 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304318 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304319
Dino Myclee8843b32014-07-04 14:21:45 +05304320 reqMsg.sessionId = pAdapter->sessionId;
4321 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304322
Dino Myclee8843b32014-07-04 14:21:45 +05304323 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304324 if (!HAL_STATUS_SUCCESS(status)) {
4325 hddLog(VOS_TRACE_LEVEL_ERROR,
4326 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304327 return -EINVAL;
4328 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304329 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304330 return 0;
4331}
4332
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304333static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4334 struct wireless_dev *wdev,
4335 const void *data, int dataLen)
4336{
4337 int ret = 0;
4338
4339 vos_ssr_protect(__func__);
4340 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4341 vos_ssr_unprotect(__func__);
4342
4343 return ret;
4344}
4345
4346static int __wlan_hdd_cfg80211_extscan_reset_significant_change(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304347 struct wiphy *wiphy,
4348 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304349 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304350{
Dino Myclee8843b32014-07-04 14:21:45 +05304351 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304352 struct net_device *dev = wdev->netdev;
4353 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4354 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4355 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4356 eHalStatus status;
4357
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304358 ENTER();
4359
Dino Mycle6fb96c12014-06-10 11:52:40 +05304360 status = wlan_hdd_validate_context(pHddCtx);
4361 if (0 != status)
4362 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304363 return -EINVAL;
4364 }
Dino Myclee8843b32014-07-04 14:21:45 +05304365 /* check the EXTScan Capability */
4366 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4367 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4368 {
4369 hddLog(VOS_TRACE_LEVEL_ERROR,
4370 FL("EXTScan not enabled/supported by Firmware"));
4371 return -EINVAL;
4372 }
4373
Dino Mycle6fb96c12014-06-10 11:52:40 +05304374 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4375 data, dataLen,
4376 wlan_hdd_extscan_config_policy)) {
4377 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4378 return -EINVAL;
4379 }
4380
4381 /* Parse and fetch request Id */
4382 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4383 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4384 return -EINVAL;
4385 }
4386
Dino Mycle6fb96c12014-06-10 11:52:40 +05304387
Dino Myclee8843b32014-07-04 14:21:45 +05304388 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304389 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304390 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304391
Dino Myclee8843b32014-07-04 14:21:45 +05304392 reqMsg.sessionId = pAdapter->sessionId;
4393 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304394
Dino Myclee8843b32014-07-04 14:21:45 +05304395 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304396 if (!HAL_STATUS_SUCCESS(status)) {
4397 hddLog(VOS_TRACE_LEVEL_ERROR,
4398 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304399 return -EINVAL;
4400 }
4401
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304402 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304403 return 0;
4404}
4405
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304406static int wlan_hdd_cfg80211_extscan_reset_significant_change(
4407 struct wiphy *wiphy,
4408 struct wireless_dev *wdev,
4409 const void *data, int dataLen)
4410{
4411 int ret = 0;
4412
4413 vos_ssr_protect(__func__);
4414 ret = __wlan_hdd_cfg80211_extscan_reset_significant_change(wiphy,
4415 wdev, data,
4416 dataLen);
4417 vos_ssr_unprotect(__func__);
4418
4419 return ret;
4420}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304421#endif /* WLAN_FEATURE_EXTSCAN */
4422
Atul Mittal115287b2014-07-08 13:26:33 +05304423/*EXT TDLS*/
4424static const struct nla_policy
4425wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4426{
4427 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4428 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4429 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4430 {.type = NLA_S32 },
4431 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4432 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4433
4434};
4435
4436static const struct nla_policy
4437wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4438{
4439 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4440
4441};
4442
4443static const struct nla_policy
4444wlan_hdd_tdls_config_state_change_policy[
4445 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4446{
4447 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4448 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4449 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304450 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4451 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4452 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304453
4454};
4455
4456static const struct nla_policy
4457wlan_hdd_tdls_config_get_status_policy[
4458 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4459{
4460 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4461 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4462 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304463 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4464 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4465 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304466
4467};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304468
4469static const struct nla_policy
4470wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4471{
4472 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4473};
4474
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304475static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304476 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304477 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304478 int data_len)
4479{
4480
4481 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4482 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4483
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304484 ENTER();
4485
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304486 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304487 return -EINVAL;
4488 }
4489 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
4490 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN disabled in ini"));
4491 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304492 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304493 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
4494 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN not supported by FW"));
4495 return -ENOTSUPP;
4496 }
4497
4498 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4499 data, data_len, wlan_hdd_mac_config)) {
4500 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4501 return -EINVAL;
4502 }
4503
4504 /* Parse and fetch mac address */
4505 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4506 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4507 return -EINVAL;
4508 }
4509
4510 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4511 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4512 VOS_MAC_ADDR_LAST_3_BYTES);
4513
Siddharth Bhal76972212014-10-15 16:22:51 +05304514 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4515
4516 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304517 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4518 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304519 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4520 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4521 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4522 {
4523 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4524 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4525 VOS_MAC_ADDRESS_LEN);
4526 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304527 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304528
Siddharth Bhal76972212014-10-15 16:22:51 +05304529 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
4530 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304531 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4532 }
4533
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304534 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304535 return 0;
4536}
4537
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304538static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4539 struct wireless_dev *wdev,
4540 const void *data,
4541 int data_len)
4542{
4543 int ret = 0;
4544
4545 vos_ssr_protect(__func__);
4546 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
4547 vos_ssr_unprotect(__func__);
4548
4549 return ret;
4550}
4551
4552static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304553 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304554 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304555 int data_len)
4556{
4557 u8 peer[6] = {0};
4558 struct net_device *dev = wdev->netdev;
4559 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4560 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4561 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4562 eHalStatus ret;
4563 tANI_S32 state;
4564 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304565 tANI_S32 global_operating_class = 0;
4566 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304567 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304568 int retVal;
4569
4570 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304571
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304572 if (!pAdapter) {
4573 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4574 return -EINVAL;
4575 }
4576
Atul Mittal115287b2014-07-08 13:26:33 +05304577 ret = wlan_hdd_validate_context(pHddCtx);
4578 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304579 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304580 return -EINVAL;
4581 }
4582 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304583 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304584 return -ENOTSUPP;
4585 }
4586 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4587 data, data_len,
4588 wlan_hdd_tdls_config_get_status_policy)) {
4589 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4590 return -EINVAL;
4591 }
4592
4593 /* Parse and fetch mac address */
4594 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4595 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4596 return -EINVAL;
4597 }
4598
4599 memcpy(peer, nla_data(
4600 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4601 sizeof(peer));
4602 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4603
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05304604 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05304605
Atul Mittal115287b2014-07-08 13:26:33 +05304606 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304607 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304608 NLMSG_HDRLEN);
4609
4610 if (!skb) {
4611 hddLog(VOS_TRACE_LEVEL_ERROR,
4612 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4613 return -EINVAL;
4614 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304615 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 +05304616 reason,
4617 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304618 global_operating_class,
4619 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304620 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304621 if (nla_put_s32(skb,
4622 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4623 state) ||
4624 nla_put_s32(skb,
4625 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4626 reason) ||
4627 nla_put_s32(skb,
4628 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4629 global_operating_class) ||
4630 nla_put_s32(skb,
4631 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4632 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304633
4634 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4635 goto nla_put_failure;
4636 }
4637
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304638 retVal = cfg80211_vendor_cmd_reply(skb);
4639 EXIT();
4640 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05304641
4642nla_put_failure:
4643 kfree_skb(skb);
4644 return -EINVAL;
4645}
4646
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304647static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4648 struct wireless_dev *wdev,
4649 const void *data,
4650 int data_len)
4651{
4652 int ret = 0;
4653
4654 vos_ssr_protect(__func__);
4655 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
4656 vos_ssr_unprotect(__func__);
4657
4658 return ret;
4659}
4660
Atul Mittal115287b2014-07-08 13:26:33 +05304661static int wlan_hdd_cfg80211_exttdls_callback(tANI_U8* mac,
4662 tANI_S32 state,
4663 tANI_S32 reason,
4664 void *ctx)
4665{
4666 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05304667 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304668 tANI_S32 global_operating_class = 0;
4669 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304670 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05304671
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304672 ENTER();
4673
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304674 if (!pAdapter) {
4675 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4676 return -EINVAL;
4677 }
4678
4679 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05304680 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304681 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304682 return -EINVAL;
4683 }
4684
4685 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304686 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304687 return -ENOTSUPP;
4688 }
4689 skb = cfg80211_vendor_event_alloc(
4690 pHddCtx->wiphy,
4691 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4692 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4693 GFP_KERNEL);
4694
4695 if (!skb) {
4696 hddLog(VOS_TRACE_LEVEL_ERROR,
4697 FL("cfg80211_vendor_event_alloc failed"));
4698 return -EINVAL;
4699 }
4700 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304701 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4702 reason,
4703 state,
4704 global_operating_class,
4705 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304706 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4707 MAC_ADDR_ARRAY(mac));
4708
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304709 if (nla_put(skb,
4710 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4711 VOS_MAC_ADDR_SIZE, mac) ||
4712 nla_put_s32(skb,
4713 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4714 state) ||
4715 nla_put_s32(skb,
4716 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4717 reason) ||
4718 nla_put_s32(skb,
4719 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4720 channel) ||
4721 nla_put_s32(skb,
4722 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4723 global_operating_class)
4724 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304725 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4726 goto nla_put_failure;
4727 }
4728
4729 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304730 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05304731 return (0);
4732
4733nla_put_failure:
4734 kfree_skb(skb);
4735 return -EINVAL;
4736}
4737
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304738static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304739 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304740 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304741 int data_len)
4742{
4743 u8 peer[6] = {0};
4744 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304745 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4746 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4747 eHalStatus status;
4748 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304749 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304750 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304751
4752 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304753
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304754 if (!dev) {
4755 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4756 return -EINVAL;
4757 }
4758
4759 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4760 if (!pAdapter) {
4761 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4762 return -EINVAL;
4763 }
4764
Atul Mittal115287b2014-07-08 13:26:33 +05304765 status = wlan_hdd_validate_context(pHddCtx);
4766 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304767 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304768 return -EINVAL;
4769 }
4770 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304771 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304772 return -ENOTSUPP;
4773 }
4774 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4775 data, data_len,
4776 wlan_hdd_tdls_config_enable_policy)) {
4777 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4778 return -EINVAL;
4779 }
4780
4781 /* Parse and fetch mac address */
4782 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4783 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4784 return -EINVAL;
4785 }
4786
4787 memcpy(peer, nla_data(
4788 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4789 sizeof(peer));
4790 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4791
4792 /* Parse and fetch channel */
4793 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4794 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4795 return -EINVAL;
4796 }
4797 pReqMsg.channel = nla_get_s32(
4798 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4799 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4800
4801 /* Parse and fetch global operating class */
4802 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4803 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4804 return -EINVAL;
4805 }
4806 pReqMsg.global_operating_class = nla_get_s32(
4807 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4808 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4809 pReqMsg.global_operating_class);
4810
4811 /* Parse and fetch latency ms */
4812 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4813 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4814 return -EINVAL;
4815 }
4816 pReqMsg.max_latency_ms = nla_get_s32(
4817 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4818 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4819 pReqMsg.max_latency_ms);
4820
4821 /* Parse and fetch required bandwidth kbps */
4822 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4823 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4824 return -EINVAL;
4825 }
4826
4827 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4828 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4829 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4830 pReqMsg.min_bandwidth_kbps);
4831
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304832 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05304833 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05304834 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304835 wlan_hdd_cfg80211_exttdls_callback);
4836
4837 EXIT();
4838 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304839}
4840
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304841static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4842 struct wireless_dev *wdev,
4843 const void *data,
4844 int data_len)
4845{
4846 int ret = 0;
4847
4848 vos_ssr_protect(__func__);
4849 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
4850 vos_ssr_unprotect(__func__);
4851
4852 return ret;
4853}
4854
4855static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304856 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304857 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304858 int data_len)
4859{
4860 u8 peer[6] = {0};
4861 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304862 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4863 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4864 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304865 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304866 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304867
4868 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304869
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304870 if (!dev) {
4871 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4872 return -EINVAL;
4873 }
4874
4875 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4876 if (!pAdapter) {
4877 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
4878 return -EINVAL;
4879 }
4880
Atul Mittal115287b2014-07-08 13:26:33 +05304881 status = wlan_hdd_validate_context(pHddCtx);
4882 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304883 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304884 return -EINVAL;
4885 }
4886 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304887 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304888 return -ENOTSUPP;
4889 }
4890 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4891 data, data_len,
4892 wlan_hdd_tdls_config_disable_policy)) {
4893 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4894 return -EINVAL;
4895 }
4896 /* Parse and fetch mac address */
4897 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
4898 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4899 return -EINVAL;
4900 }
4901
4902 memcpy(peer, nla_data(
4903 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
4904 sizeof(peer));
4905 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4906
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304907 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
4908
4909 EXIT();
4910 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304911}
4912
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304913static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
4914 struct wireless_dev *wdev,
4915 const void *data,
4916 int data_len)
4917{
4918 int ret = 0;
4919
4920 vos_ssr_protect(__func__);
4921 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
4922 vos_ssr_unprotect(__func__);
4923
4924 return ret;
4925}
4926
Dasari Srinivas7875a302014-09-26 17:50:57 +05304927static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304928__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05304929 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304930 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05304931{
4932 struct net_device *dev = wdev->netdev;
4933 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4934 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4935 struct sk_buff *skb = NULL;
4936 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304937 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05304938
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304939 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304940
4941 ret = wlan_hdd_validate_context(pHddCtx);
4942 if (0 != ret)
4943 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304944 return ret;
4945 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304946 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
4947 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
4948 fset |= WIFI_FEATURE_INFRA;
4949 }
4950
4951 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
4952 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
4953 fset |= WIFI_FEATURE_INFRA_5G;
4954 }
4955
4956#ifdef WLAN_FEATURE_P2P
4957 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
4958 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
4959 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
4960 fset |= WIFI_FEATURE_P2P;
4961 }
4962#endif
4963
4964 /* Soft-AP is supported currently by default */
4965 fset |= WIFI_FEATURE_SOFT_AP;
4966
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05304967 /* HOTSPOT is a supplicant feature, enable it by default */
4968 fset |= WIFI_FEATURE_HOTSPOT;
4969
Dasari Srinivas7875a302014-09-26 17:50:57 +05304970#ifdef WLAN_FEATURE_EXTSCAN
4971 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
4972 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
4973 hddLog(LOG1, FL("EXTScan is supported by firmware"));
4974 fset |= WIFI_FEATURE_EXTSCAN;
4975 }
4976#endif
4977
Dasari Srinivas7875a302014-09-26 17:50:57 +05304978 if (sme_IsFeatureSupportedByFW(NAN)) {
4979 hddLog(LOG1, FL("NAN is supported by firmware"));
4980 fset |= WIFI_FEATURE_NAN;
4981 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304982
4983 /* D2D RTT is not supported currently by default */
4984 if (sme_IsFeatureSupportedByFW(RTT)) {
4985 hddLog(LOG1, FL("RTT is supported by firmware"));
4986 fset |= WIFI_FEATURE_D2AP_RTT;
4987 }
4988
4989#ifdef FEATURE_WLAN_BATCH_SCAN
4990 if (fset & WIFI_FEATURE_EXTSCAN) {
4991 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
4992 fset &= ~WIFI_FEATURE_BATCH_SCAN;
4993 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
4994 hddLog(LOG1, FL("Batch scan is supported by firmware"));
4995 fset |= WIFI_FEATURE_BATCH_SCAN;
4996 }
4997#endif
4998
4999#ifdef FEATURE_WLAN_SCAN_PNO
5000 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5001 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5002 hddLog(LOG1, FL("PNO is supported by firmware"));
5003 fset |= WIFI_FEATURE_PNO;
5004 }
5005#endif
5006
5007 /* STA+STA is supported currently by default */
5008 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5009
5010#ifdef FEATURE_WLAN_TDLS
5011 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5012 sme_IsFeatureSupportedByFW(TDLS)) {
5013 hddLog(LOG1, FL("TDLS is supported by firmware"));
5014 fset |= WIFI_FEATURE_TDLS;
5015 }
5016
5017 /* TDLS_OFFCHANNEL is not supported currently by default */
5018#endif
5019
5020#ifdef WLAN_AP_STA_CONCURRENCY
5021 /* AP+STA concurrency is supported currently by default */
5022 fset |= WIFI_FEATURE_AP_STA;
5023#endif
5024
5025 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5026 NLMSG_HDRLEN);
5027
5028 if (!skb) {
5029 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5030 return -EINVAL;
5031 }
5032 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5033
5034 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5035 hddLog(LOGE, FL("nla put fail"));
5036 goto nla_put_failure;
5037 }
5038
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305039 ret = cfg80211_vendor_cmd_reply(skb);
5040 EXIT();
5041 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305042
5043nla_put_failure:
5044 kfree_skb(skb);
5045 return -EINVAL;
5046}
5047
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305048static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305049wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5050 struct wireless_dev *wdev,
5051 const void *data, int data_len)
5052{
5053 int ret = 0;
5054
5055 vos_ssr_protect(__func__);
5056 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5057 vos_ssr_unprotect(__func__);
5058
5059 return ret;
5060}
5061
5062static int
5063__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305064 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305065 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305066{
5067 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5068 uint8_t i, feature_sets, max_feature_sets;
5069 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5070 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305071 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5072 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305073
5074 ENTER();
5075
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305076 ret = wlan_hdd_validate_context(pHddCtx);
5077 if (0 != ret)
5078 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305079 return ret;
5080 }
5081
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305082 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5083 data, data_len, NULL)) {
5084 hddLog(LOGE, FL("Invalid ATTR"));
5085 return -EINVAL;
5086 }
5087
5088 /* Parse and fetch max feature set */
5089 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5090 hddLog(LOGE, FL("Attr max feature set size failed"));
5091 return -EINVAL;
5092 }
5093 max_feature_sets = nla_get_u32(
5094 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5095 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5096
5097 /* Fill feature combination matrix */
5098 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305099 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5100 WIFI_FEATURE_P2P;
5101
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305102 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5103 WIFI_FEATURE_SOFT_AP;
5104
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305105 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5106 WIFI_FEATURE_SOFT_AP;
5107
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305108 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5109 WIFI_FEATURE_SOFT_AP |
5110 WIFI_FEATURE_P2P;
5111
5112 /* Add more feature combinations here */
5113
5114 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5115 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5116 hddLog(LOG1, "Feature set matrix");
5117 for (i = 0; i < feature_sets; i++)
5118 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5119
5120 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5121 sizeof(u32) * feature_sets +
5122 NLMSG_HDRLEN);
5123
5124 if (reply_skb) {
5125 if (nla_put_u32(reply_skb,
5126 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5127 feature_sets) ||
5128 nla_put(reply_skb,
5129 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5130 sizeof(u32) * feature_sets, feature_set_matrix)) {
5131 hddLog(LOGE, FL("nla put fail"));
5132 kfree_skb(reply_skb);
5133 return -EINVAL;
5134 }
5135
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305136 ret = cfg80211_vendor_cmd_reply(reply_skb);
5137 EXIT();
5138 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305139 }
5140 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5141 return -ENOMEM;
5142
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305143}
5144
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305145static int
5146wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5147 struct wireless_dev *wdev,
5148 const void *data, int data_len)
5149{
5150 int ret = 0;
5151
5152 vos_ssr_protect(__func__);
5153 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5154 data_len);
5155 vos_ssr_unprotect(__func__);
5156
5157 return ret;
5158}
5159
Agarwal Ashish738843c2014-09-25 12:27:56 +05305160static const struct nla_policy
5161wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5162 +1] =
5163{
5164 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5165};
5166
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305167static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305168 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305169 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305170 int data_len)
5171{
5172 struct net_device *dev = wdev->netdev;
5173 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5174 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5175 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5176 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5177 eHalStatus status;
5178 u32 dfsFlag = 0;
5179
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305180 ENTER();
5181
Agarwal Ashish738843c2014-09-25 12:27:56 +05305182 status = wlan_hdd_validate_context(pHddCtx);
5183 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305184 return -EINVAL;
5185 }
5186 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5187 data, data_len,
5188 wlan_hdd_set_no_dfs_flag_config_policy)) {
5189 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5190 return -EINVAL;
5191 }
5192
5193 /* Parse and fetch required bandwidth kbps */
5194 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5195 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5196 return -EINVAL;
5197 }
5198
5199 dfsFlag = nla_get_u32(
5200 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5201 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
5202 dfsFlag);
5203
5204 pHddCtx->disable_dfs_flag = dfsFlag;
5205
5206 sme_disable_dfs_channel(hHal, dfsFlag);
5207 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305208
5209 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05305210 return 0;
5211}
Atul Mittal115287b2014-07-08 13:26:33 +05305212
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305213static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
5214 struct wireless_dev *wdev,
5215 const void *data,
5216 int data_len)
5217{
5218 int ret = 0;
5219
5220 vos_ssr_protect(__func__);
5221 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
5222 vos_ssr_unprotect(__func__);
5223
5224 return ret;
5225
5226}
5227
Mukul Sharma2a271632014-10-13 14:59:01 +05305228const struct
5229nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
5230{
5231 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
5232 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
5233};
5234
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305235static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05305236 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05305237{
5238
5239 u8 bssid[6] = {0};
5240 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5241 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5242 eHalStatus status = eHAL_STATUS_SUCCESS;
5243 v_U32_t isFwrRoamEnabled = FALSE;
5244 int ret;
5245
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305246 ENTER();
5247
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305248 ret = wlan_hdd_validate_context(pHddCtx);
5249 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305250 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05305251 }
5252
5253 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
5254 data, data_len,
5255 qca_wlan_vendor_attr);
5256 if (ret){
5257 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5258 return -EINVAL;
5259 }
5260
5261 /* Parse and fetch Enable flag */
5262 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
5263 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
5264 return -EINVAL;
5265 }
5266
5267 isFwrRoamEnabled = nla_get_u32(
5268 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
5269
5270 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
5271
5272 /* Parse and fetch bssid */
5273 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
5274 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
5275 return -EINVAL;
5276 }
5277
5278 memcpy(bssid, nla_data(
5279 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
5280 sizeof(bssid));
5281 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
5282
5283 //Update roaming
5284 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305285 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05305286 return status;
5287}
5288
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305289static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
5290 struct wireless_dev *wdev, const void *data, int data_len)
5291{
5292 int ret = 0;
5293
5294 vos_ssr_protect(__func__);
5295 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
5296 vos_ssr_unprotect(__func__);
5297
5298 return ret;
5299}
5300
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305301/**
5302 * __wlan_hdd_cfg80211_setband() - set band
5303 * @wiphy: Pointer to wireless phy
5304 * @wdev: Pointer to wireless device
5305 * @data: Pointer to data
5306 * @data_len: Data length
5307 *
5308 * Return: 0 on success, negative errno on failure
5309 */
5310static int
5311__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5312 struct wireless_dev *wdev,
5313 const void *data,
5314 int data_len)
5315{
5316 struct net_device *dev = wdev->netdev;
5317 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5318 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5319 int ret;
5320 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
5321 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
5322
5323 ENTER();
5324
5325 ret = wlan_hdd_validate_context(hdd_ctx);
5326 if (0 != ret) {
5327 hddLog(LOGE, FL("HDD context is not valid"));
5328 return ret;
5329 }
5330
5331 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
5332 policy)) {
5333 hddLog(LOGE, FL("Invalid ATTR"));
5334 return -EINVAL;
5335 }
5336
5337 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
5338 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
5339 return -EINVAL;
5340 }
5341
5342 return hdd_setBand(dev,
5343 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
5344}
5345
5346/**
5347 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
5348 * @wiphy: wiphy structure pointer
5349 * @wdev: Wireless device structure pointer
5350 * @data: Pointer to the data received
5351 * @data_len: Length of @data
5352 *
5353 * Return: 0 on success; errno on failure
5354 */
5355static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5356 struct wireless_dev *wdev,
5357 const void *data,
5358 int data_len)
5359{
5360 int ret = 0;
5361
5362 vos_ssr_protect(__func__);
5363 ret = __wlan_hdd_cfg80211_setband(wiphy,
5364 wdev, data, data_len);
5365 vos_ssr_unprotect(__func__);
5366
5367 return ret;
5368}
5369
Sunil Duttc69bccb2014-05-26 21:30:20 +05305370const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
5371{
Mukul Sharma2a271632014-10-13 14:59:01 +05305372 {
5373 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5374 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
5375 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5376 WIPHY_VENDOR_CMD_NEED_NETDEV |
5377 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305378 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05305379 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305380
5381 {
5382 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5383 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
5384 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5385 WIPHY_VENDOR_CMD_NEED_NETDEV |
5386 WIPHY_VENDOR_CMD_NEED_RUNNING,
5387 .doit = wlan_hdd_cfg80211_nan_request
5388 },
5389
Sunil Duttc69bccb2014-05-26 21:30:20 +05305390#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5391 {
5392 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5393 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
5394 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5395 WIPHY_VENDOR_CMD_NEED_NETDEV |
5396 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305397 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05305398 },
5399
5400 {
5401 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5402 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
5403 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5404 WIPHY_VENDOR_CMD_NEED_NETDEV |
5405 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305406 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05305407 },
5408
5409 {
5410 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5411 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
5412 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5413 WIPHY_VENDOR_CMD_NEED_NETDEV |
5414 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305415 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05305416 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305417#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305418#ifdef WLAN_FEATURE_EXTSCAN
5419 {
5420 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5421 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
5422 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5423 WIPHY_VENDOR_CMD_NEED_NETDEV |
5424 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305425 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05305426 },
5427 {
5428 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5429 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
5430 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5431 WIPHY_VENDOR_CMD_NEED_NETDEV |
5432 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305433 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05305434 },
5435 {
5436 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5437 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
5438 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5439 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305440 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05305441 },
5442 {
5443 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5444 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
5445 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5446 WIPHY_VENDOR_CMD_NEED_NETDEV |
5447 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305448 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05305449 },
5450 {
5451 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5452 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
5453 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5454 WIPHY_VENDOR_CMD_NEED_NETDEV |
5455 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305456 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05305457 },
5458 {
5459 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5460 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
5461 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5462 WIPHY_VENDOR_CMD_NEED_NETDEV |
5463 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305464 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305465 },
5466 {
5467 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5468 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
5469 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5470 WIPHY_VENDOR_CMD_NEED_NETDEV |
5471 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305472 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305473 },
5474 {
5475 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5476 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
5477 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5478 WIPHY_VENDOR_CMD_NEED_NETDEV |
5479 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305480 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305481 },
5482 {
5483 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5484 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
5485 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5486 WIPHY_VENDOR_CMD_NEED_NETDEV |
5487 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305488 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305489 },
5490#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305491/*EXT TDLS*/
5492 {
5493 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5494 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
5495 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5496 WIPHY_VENDOR_CMD_NEED_NETDEV |
5497 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305498 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05305499 },
5500 {
5501 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5502 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
5503 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5504 WIPHY_VENDOR_CMD_NEED_NETDEV |
5505 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305506 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05305507 },
5508 {
5509 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5510 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
5511 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5512 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305513 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05305514 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05305515 {
5516 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5517 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
5518 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5519 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305520 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05305521 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05305522 {
5523 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5524 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
5525 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5526 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305527 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05305528 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305529 {
5530 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5531 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
5532 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5533 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305534 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305535 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305536 {
5537 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5538 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
5539 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5540 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305541 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305542 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305543 {
5544 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5545 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
5546 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5547 WIPHY_VENDOR_CMD_NEED_NETDEV |
5548 WIPHY_VENDOR_CMD_NEED_RUNNING,
5549 .doit = wlan_hdd_cfg80211_setband
5550 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05305551};
5552
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005553/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05305554static const
5555struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005556{
5557#ifdef FEATURE_WLAN_CH_AVOID
5558 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05305559 .vendor_id = QCA_NL80211_VENDOR_ID,
5560 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005561 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305562#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
5563#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5564 {
5565 /* Index = 1*/
5566 .vendor_id = QCA_NL80211_VENDOR_ID,
5567 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
5568 },
5569 {
5570 /* Index = 2*/
5571 .vendor_id = QCA_NL80211_VENDOR_ID,
5572 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
5573 },
5574 {
5575 /* Index = 3*/
5576 .vendor_id = QCA_NL80211_VENDOR_ID,
5577 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
5578 },
5579 {
5580 /* Index = 4*/
5581 .vendor_id = QCA_NL80211_VENDOR_ID,
5582 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
5583 },
5584 {
5585 /* Index = 5*/
5586 .vendor_id = QCA_NL80211_VENDOR_ID,
5587 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
5588 },
5589 {
5590 /* Index = 6*/
5591 .vendor_id = QCA_NL80211_VENDOR_ID,
5592 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
5593 },
5594#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305595#ifdef WLAN_FEATURE_EXTSCAN
5596 {
5597 .vendor_id = QCA_NL80211_VENDOR_ID,
5598 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
5599 },
5600 {
5601 .vendor_id = QCA_NL80211_VENDOR_ID,
5602 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
5603 },
5604 {
5605 .vendor_id = QCA_NL80211_VENDOR_ID,
5606 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
5607 },
5608 {
5609 .vendor_id = QCA_NL80211_VENDOR_ID,
5610 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
5611 },
5612 {
5613 .vendor_id = QCA_NL80211_VENDOR_ID,
5614 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
5615 },
5616 {
5617 .vendor_id = QCA_NL80211_VENDOR_ID,
5618 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
5619 },
5620 {
5621 .vendor_id = QCA_NL80211_VENDOR_ID,
5622 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
5623 },
5624 {
5625 .vendor_id = QCA_NL80211_VENDOR_ID,
5626 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
5627 },
5628 {
5629 .vendor_id = QCA_NL80211_VENDOR_ID,
5630 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
5631 },
5632 {
5633 .vendor_id = QCA_NL80211_VENDOR_ID,
5634 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
5635 },
5636 {
5637 .vendor_id = QCA_NL80211_VENDOR_ID,
5638 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
5639 },
5640 {
5641 .vendor_id = QCA_NL80211_VENDOR_ID,
5642 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
5643 },
5644 {
5645 .vendor_id = QCA_NL80211_VENDOR_ID,
5646 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
5647 },
5648#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305649/*EXT TDLS*/
5650 {
5651 .vendor_id = QCA_NL80211_VENDOR_ID,
5652 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
5653 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305654
5655 {
5656 .vendor_id = QCA_NL80211_VENDOR_ID,
5657 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
5658 },
5659
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005660};
5661
Jeff Johnson295189b2012-06-20 16:38:30 -07005662/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305663 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305664 * This function is called by hdd_wlan_startup()
5665 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305666 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305668struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07005669{
5670 struct wiphy *wiphy;
5671 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305672 /*
5673 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07005674 */
5675 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
5676
5677 if (!wiphy)
5678 {
5679 /* Print error and jump into err label and free the memory */
5680 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
5681 return NULL;
5682 }
5683
Sunil Duttc69bccb2014-05-26 21:30:20 +05305684
Jeff Johnson295189b2012-06-20 16:38:30 -07005685 return wiphy;
5686}
5687
5688/*
5689 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305690 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07005691 * private ioctl to change the band value
5692 */
5693int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
5694{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305695 int i, j;
5696 eNVChannelEnabledType channelEnabledState;
5697
Jeff Johnsone7245742012-09-05 17:12:55 -07005698 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305699
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305700 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305702
5703 if (NULL == wiphy->bands[i])
5704 {
5705 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5706 __func__, i);
5707 continue;
5708 }
5709
5710 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5711 {
5712 struct ieee80211_supported_band *band = wiphy->bands[i];
5713
5714 channelEnabledState = vos_nv_getChannelEnabledState(
5715 band->channels[j].hw_value);
5716
5717 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
5718 {
Abhishek Singh678227a2014-11-04 10:52:38 +05305719 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305720 continue;
5721 }
5722 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
5723 {
5724 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5725 continue;
5726 }
5727
5728 if (NV_CHANNEL_DISABLE == channelEnabledState ||
5729 NV_CHANNEL_INVALID == channelEnabledState)
5730 {
5731 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5732 }
5733 else if (NV_CHANNEL_DFS == channelEnabledState)
5734 {
5735 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5736 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
5737 }
5738 else
5739 {
5740 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
5741 |IEEE80211_CHAN_RADAR);
5742 }
5743 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005744 }
5745 return 0;
5746}
5747/*
5748 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305749 * This function is called by hdd_wlan_startup()
5750 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07005751 * This function is used to initialize and register wiphy structure.
5752 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305753int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005754 struct wiphy *wiphy,
5755 hdd_config_t *pCfg
5756 )
5757{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305758 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305759 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5760
Jeff Johnsone7245742012-09-05 17:12:55 -07005761 ENTER();
5762
Jeff Johnson295189b2012-06-20 16:38:30 -07005763 /* Now bind the underlying wlan device with wiphy */
5764 set_wiphy_dev(wiphy, dev);
5765
5766 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005767
Kiet Lam6c583332013-10-14 05:37:09 +05305768#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07005769 /* the flag for the other case would be initialzed in
5770 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07005771 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05305772#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005773
Amar Singhalfddc28c2013-09-05 13:03:40 -07005774 /* This will disable updating of NL channels from passive to
5775 * active if a beacon is received on passive channel. */
5776 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -07005777
Amar Singhalfddc28c2013-09-05 13:03:40 -07005778
Amar Singhala49cbc52013-10-08 18:37:44 -07005779
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005780#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07005781 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
5782 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
5783 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07005784 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +05305785 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005786#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005787
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005788#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005789 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08005790#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005791 || pCfg->isFastRoamIniFeatureEnabled
5792#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005793#ifdef FEATURE_WLAN_ESE
5794 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005795#endif
5796 )
5797 {
5798 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
5799 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08005800#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005801#ifdef FEATURE_WLAN_TDLS
5802 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
5803 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
5804#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305805#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05305806 if (pCfg->configPNOScanSupport)
5807 {
5808 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
5809 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
5810 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
5811 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
5812 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305813#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005814
Abhishek Singh10d85972015-04-17 10:27:23 +05305815#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5816 wiphy->features |= NL80211_FEATURE_HT_IBSS;
5817#endif
5818
Amar Singhalfddc28c2013-09-05 13:03:40 -07005819#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005820 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
5821 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07005822 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005823 driver need to determine what to do with both
5824 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07005825
5826 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07005827#else
5828 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005829#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005830
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305831 wiphy->max_scan_ssids = MAX_SCAN_SSID;
5832
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05305833 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07005834
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305835 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
5836
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05305838 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
5839 | BIT(NL80211_IFTYPE_ADHOC)
5840 | BIT(NL80211_IFTYPE_P2P_CLIENT)
5841 | BIT(NL80211_IFTYPE_P2P_GO)
5842 | BIT(NL80211_IFTYPE_AP);
5843
5844 if (VOS_MONITOR_MODE == hdd_get_conparam())
5845 {
5846 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
5847 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005848
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305849 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005850 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305851#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5852 if( pCfg->enableMCC )
5853 {
5854 /* Currently, supports up to two channels */
5855 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005856
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305857 if( !pCfg->allowMCCGODiffBI )
5858 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005859
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305860 }
5861 wiphy->iface_combinations = &wlan_hdd_iface_combination;
5862 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005863#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305864 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005865
Jeff Johnson295189b2012-06-20 16:38:30 -07005866 /* Before registering we need to update the ht capabilitied based
5867 * on ini values*/
5868 if( !pCfg->ShortGI20MhzEnable )
5869 {
5870 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5871 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5872 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5873 }
5874
5875 if( !pCfg->ShortGI40MhzEnable )
5876 {
5877 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
5878 }
5879
5880 if( !pCfg->nChannelBondingMode5GHz )
5881 {
5882 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5883 }
5884
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305885 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305886 if (true == hdd_is_5g_supported(pHddCtx))
5887 {
5888 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
5889 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305890
5891 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
5892 {
5893
5894 if (NULL == wiphy->bands[i])
5895 {
5896 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5897 __func__, i);
5898 continue;
5899 }
5900
5901 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5902 {
5903 struct ieee80211_supported_band *band = wiphy->bands[i];
5904
5905 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
5906 {
5907 // Enable social channels for P2P
5908 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
5909 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5910 else
5911 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5912 continue;
5913 }
5914 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
5915 {
5916 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5917 continue;
5918 }
5919 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 }
5921 /*Initialise the supported cipher suite details*/
5922 wiphy->cipher_suites = hdd_cipher_suites;
5923 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
5924
5925 /*signal strength in mBm (100*dBm) */
5926 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
5927
5928#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05305929 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07005930#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005931
Sunil Duttc69bccb2014-05-26 21:30:20 +05305932 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
5933 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005934 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
5935 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
5936
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305937 EXIT();
5938 return 0;
5939}
5940
5941/* In this function we are registering wiphy. */
5942int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
5943{
5944 ENTER();
5945 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005946 if (0 > wiphy_register(wiphy))
5947 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305948 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07005949 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
5950 return -EIO;
5951 }
5952
5953 EXIT();
5954 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305955}
Jeff Johnson295189b2012-06-20 16:38:30 -07005956
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305957/* In this function we are updating channel list when,
5958 regulatory domain is FCC and country code is US.
5959 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
5960 As per FCC smart phone is not a indoor device.
5961 GO should not opeate on indoor channels */
5962void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
5963{
5964 int j;
5965 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5966 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
5967 //Default counrtycode from NV at the time of wiphy initialization.
5968 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
5969 &defaultCountryCode[0]))
5970 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005971 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305972 }
5973 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
5974 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305975 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
5976 {
5977 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
5978 return;
5979 }
5980 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
5981 {
5982 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
5983 // Mark UNII -1 band channel as passive
5984 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
5985 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
5986 }
5987 }
5988}
5989
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305990/* This function registers for all frame which supplicant is interested in */
5991void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005992{
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5994 /* Register for all P2P action, public action etc frames */
5995 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5996
Jeff Johnsone7245742012-09-05 17:12:55 -07005997 ENTER();
5998
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 /* Right now we are registering these frame when driver is getting
6000 initialized. Once we will move to 2.6.37 kernel, in which we have
6001 frame register ops, we will move this code as a part of that */
6002 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306003 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6005
6006 /* GAS Initial Response */
6007 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6008 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306009
Jeff Johnson295189b2012-06-20 16:38:30 -07006010 /* GAS Comeback Request */
6011 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6012 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6013
6014 /* GAS Comeback Response */
6015 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6016 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6017
6018 /* P2P Public Action */
6019 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306020 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 P2P_PUBLIC_ACTION_FRAME_SIZE );
6022
6023 /* P2P Action */
6024 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6025 (v_U8_t*)P2P_ACTION_FRAME,
6026 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07006027
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05306028 /* WNM BSS Transition Request frame */
6029 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6030 (v_U8_t*)WNM_BSS_ACTION_FRAME,
6031 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006032
6033 /* WNM-Notification */
6034 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6035 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6036 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006037}
6038
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05306039void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07006040{
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6042 /* Register for all P2P action, public action etc frames */
6043 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
6044
Jeff Johnsone7245742012-09-05 17:12:55 -07006045 ENTER();
6046
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 /* Right now we are registering these frame when driver is getting
6048 initialized. Once we will move to 2.6.37 kernel, in which we have
6049 frame register ops, we will move this code as a part of that */
6050 /* GAS Initial Request */
6051
6052 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6053 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6054
6055 /* GAS Initial Response */
6056 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6057 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306058
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 /* GAS Comeback Request */
6060 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6061 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6062
6063 /* GAS Comeback Response */
6064 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6065 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6066
6067 /* P2P Public Action */
6068 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306069 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006070 P2P_PUBLIC_ACTION_FRAME_SIZE );
6071
6072 /* P2P Action */
6073 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6074 (v_U8_t*)P2P_ACTION_FRAME,
6075 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006076 /* WNM-Notification */
6077 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6078 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6079 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006080}
6081
6082#ifdef FEATURE_WLAN_WAPI
6083void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
6084 const u8 *mac_addr, u8 *key , int key_Len)
6085{
6086 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6087 tCsrRoamSetKey setKey;
6088 v_BOOL_t isConnected = TRUE;
6089 int status = 0;
6090 v_U32_t roamId= 0xFF;
6091 tANI_U8 *pKeyPtr = NULL;
6092 int n = 0;
6093
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306094 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
6095 __func__, hdd_device_modetoString(pAdapter->device_mode),
6096 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006097
Gopichand Nakkalae7480202013-02-11 15:24:22 +05306098 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006099 setKey.keyId = key_index; // Store Key ID
6100 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
6101 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
6102 setKey.paeRole = 0 ; // the PAE role
6103 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
6104 {
6105 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
6106 }
6107 else
6108 {
6109 isConnected = hdd_connIsConnected(pHddStaCtx);
6110 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
6111 }
6112 setKey.keyLength = key_Len;
6113 pKeyPtr = setKey.Key;
6114 memcpy( pKeyPtr, key, key_Len);
6115
Arif Hussain6d2a3322013-11-17 19:50:10 -08006116 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 __func__, key_Len);
6118 for (n = 0 ; n < key_Len; n++)
6119 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
6120 __func__,n,setKey.Key[n]);
6121
6122 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6123 if ( isConnected )
6124 {
6125 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
6126 pAdapter->sessionId, &setKey, &roamId );
6127 }
6128 if ( status != 0 )
6129 {
6130 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6131 "[%4d] sme_RoamSetKey returned ERROR status= %d",
6132 __LINE__, status );
6133 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6134 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05306135 /* Need to clear any trace of key value in the memory.
6136 * Thus zero out the memory even though it is local
6137 * variable.
6138 */
6139 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006140}
6141#endif /* FEATURE_WLAN_WAPI*/
6142
6143#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306144int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006145 beacon_data_t **ppBeacon,
6146 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006147#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306148int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006149 beacon_data_t **ppBeacon,
6150 struct cfg80211_beacon_data *params,
6151 int dtim_period)
6152#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306153{
Jeff Johnson295189b2012-06-20 16:38:30 -07006154 int size;
6155 beacon_data_t *beacon = NULL;
6156 beacon_data_t *old = NULL;
6157 int head_len,tail_len;
6158
Jeff Johnsone7245742012-09-05 17:12:55 -07006159 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006160 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306161 {
6162 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6163 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006164 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006166
6167 old = pAdapter->sessionCtx.ap.beacon;
6168
6169 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306170 {
6171 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6172 FL("session(%d) old and new heads points to NULL"),
6173 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306175 }
6176
6177 if (params->tail && !params->tail_len)
6178 {
6179 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6180 FL("tail_len is zero but tail is not NULL"));
6181 return -EINVAL;
6182 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006183
Jeff Johnson295189b2012-06-20 16:38:30 -07006184#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
6185 /* Kernel 3.0 is not updating dtim_period for set beacon */
6186 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306187 {
6188 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6189 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306191 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006192#endif
6193
6194 if(params->head)
6195 head_len = params->head_len;
6196 else
6197 head_len = old->head_len;
6198
6199 if(params->tail || !old)
6200 tail_len = params->tail_len;
6201 else
6202 tail_len = old->tail_len;
6203
6204 size = sizeof(beacon_data_t) + head_len + tail_len;
6205
6206 beacon = kzalloc(size, GFP_KERNEL);
6207
6208 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306209 {
6210 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6211 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006212 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306213 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006214
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006215#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 if(params->dtim_period || !old )
6217 beacon->dtim_period = params->dtim_period;
6218 else
6219 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006220#else
6221 if(dtim_period || !old )
6222 beacon->dtim_period = dtim_period;
6223 else
6224 beacon->dtim_period = old->dtim_period;
6225#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306226
Jeff Johnson295189b2012-06-20 16:38:30 -07006227 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
6228 beacon->tail = beacon->head + head_len;
6229 beacon->head_len = head_len;
6230 beacon->tail_len = tail_len;
6231
6232 if(params->head) {
6233 memcpy (beacon->head,params->head,beacon->head_len);
6234 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306235 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 if(old)
6237 memcpy (beacon->head,old->head,beacon->head_len);
6238 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306239
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 if(params->tail) {
6241 memcpy (beacon->tail,params->tail,beacon->tail_len);
6242 }
6243 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306244 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 memcpy (beacon->tail,old->tail,beacon->tail_len);
6246 }
6247
6248 *ppBeacon = beacon;
6249
6250 kfree(old);
6251
6252 return 0;
6253
6254}
Jeff Johnson295189b2012-06-20 16:38:30 -07006255
6256v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
6257{
6258 int left = length;
6259 v_U8_t *ptr = pIes;
6260 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306261
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306263 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 elem_id = ptr[0];
6265 elem_len = ptr[1];
6266 left -= 2;
6267 if(elem_len > left)
6268 {
6269 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006270 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006271 eid,elem_len,left);
6272 return NULL;
6273 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306274 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006275 {
6276 return ptr;
6277 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306278
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 left -= elem_len;
6280 ptr += (elem_len + 2);
6281 }
6282 return NULL;
6283}
6284
Jeff Johnson295189b2012-06-20 16:38:30 -07006285/* Check if rate is 11g rate or not */
6286static int wlan_hdd_rate_is_11g(u8 rate)
6287{
Sanjay Devnani28322e22013-06-21 16:13:40 -07006288 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006289 u8 i;
6290 for (i = 0; i < 8; i++)
6291 {
6292 if(rate == gRateArray[i])
6293 return TRUE;
6294 }
6295 return FALSE;
6296}
6297
6298/* Check for 11g rate and set proper 11g only mode */
6299static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
6300 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
6301{
6302 u8 i, num_rates = pIe[0];
6303
6304 pIe += 1;
6305 for ( i = 0; i < num_rates; i++)
6306 {
6307 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
6308 {
6309 /* If rate set have 11g rate than change the mode to 11G */
6310 *pSapHw_mode = eSAP_DOT11_MODE_11g;
6311 if (pIe[i] & BASIC_RATE_MASK)
6312 {
6313 /* If we have 11g rate as basic rate, it means mode
6314 is 11g only mode.
6315 */
6316 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
6317 *pCheckRatesfor11g = FALSE;
6318 }
6319 }
6320 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
6321 {
6322 *require_ht = TRUE;
6323 }
6324 }
6325 return;
6326}
6327
6328static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
6329{
6330 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6331 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6332 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6333 u8 checkRatesfor11g = TRUE;
6334 u8 require_ht = FALSE;
6335 u8 *pIe=NULL;
6336
6337 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
6338
6339 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
6340 pBeacon->head_len, WLAN_EID_SUPP_RATES);
6341 if (pIe != NULL)
6342 {
6343 pIe += 1;
6344 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6345 &pConfig->SapHw_mode);
6346 }
6347
6348 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6349 WLAN_EID_EXT_SUPP_RATES);
6350 if (pIe != NULL)
6351 {
6352
6353 pIe += 1;
6354 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6355 &pConfig->SapHw_mode);
6356 }
6357
6358 if( pConfig->channel > 14 )
6359 {
6360 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
6361 }
6362
6363 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6364 WLAN_EID_HT_CAPABILITY);
6365
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306366 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006367 {
6368 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
6369 if(require_ht)
6370 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
6371 }
6372}
6373
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306374static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
6375 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
6376{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006377 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306378 v_U8_t *pIe = NULL;
6379 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6380
6381 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
6382 pBeacon->tail, pBeacon->tail_len);
6383
6384 if (pIe)
6385 {
6386 ielen = pIe[1] + 2;
6387 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6388 {
6389 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
6390 }
6391 else
6392 {
6393 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
6394 return -EINVAL;
6395 }
6396 *total_ielen += ielen;
6397 }
6398 return 0;
6399}
6400
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006401static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
6402 v_U8_t *genie, v_U8_t *total_ielen)
6403{
6404 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6405 int left = pBeacon->tail_len;
6406 v_U8_t *ptr = pBeacon->tail;
6407 v_U8_t elem_id, elem_len;
6408 v_U16_t ielen = 0;
6409
6410 if ( NULL == ptr || 0 == left )
6411 return;
6412
6413 while (left >= 2)
6414 {
6415 elem_id = ptr[0];
6416 elem_len = ptr[1];
6417 left -= 2;
6418 if (elem_len > left)
6419 {
6420 hddLog( VOS_TRACE_LEVEL_ERROR,
6421 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
6422 elem_id, elem_len, left);
6423 return;
6424 }
6425 if (IE_EID_VENDOR == elem_id)
6426 {
6427 /* skipping the VSIE's which we don't want to include or
6428 * it will be included by existing code
6429 */
6430 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
6431#ifdef WLAN_FEATURE_WFD
6432 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
6433#endif
6434 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6435 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6436 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
6437 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6438 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
6439 {
6440 ielen = ptr[1] + 2;
6441 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6442 {
6443 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
6444 *total_ielen += ielen;
6445 }
6446 else
6447 {
6448 hddLog( VOS_TRACE_LEVEL_ERROR,
6449 "IE Length is too big "
6450 "IEs eid=%d elem_len=%d total_ie_lent=%d",
6451 elem_id, elem_len, *total_ielen);
6452 }
6453 }
6454 }
6455
6456 left -= elem_len;
6457 ptr += (elem_len + 2);
6458 }
6459 return;
6460}
6461
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006462#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006463static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6464 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006465#else
6466static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6467 struct cfg80211_beacon_data *params)
6468#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006469{
6470 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306471 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006472 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07006473 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006474
6475 genie = vos_mem_malloc(MAX_GENIE_LEN);
6476
6477 if(genie == NULL) {
6478
6479 return -ENOMEM;
6480 }
6481
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306482 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6483 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006484 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306485 hddLog(LOGE,
6486 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306487 ret = -EINVAL;
6488 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006489 }
6490
6491#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306492 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6493 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
6494 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306495 hddLog(LOGE,
6496 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306497 ret = -EINVAL;
6498 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006499 }
6500#endif
6501
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306502 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6503 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006504 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306505 hddLog(LOGE,
6506 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306507 ret = -EINVAL;
6508 goto done;
6509 }
6510
6511 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
6512 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006513 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006515
6516 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6517 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
6518 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6519 {
6520 hddLog(LOGE,
6521 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006522 ret = -EINVAL;
6523 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006524 }
6525
6526 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6527 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6528 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6529 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6530 ==eHAL_STATUS_FAILURE)
6531 {
6532 hddLog(LOGE,
6533 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006534 ret = -EINVAL;
6535 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006536 }
6537
6538 // Added for ProResp IE
6539 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
6540 {
6541 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
6542 u8 probe_rsp_ie_len[3] = {0};
6543 u8 counter = 0;
6544 /* Check Probe Resp Length if it is greater then 255 then Store
6545 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
6546 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
6547 Store More then 255 bytes into One Variable.
6548 */
6549 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6550 {
6551 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6552 {
6553 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6554 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6555 }
6556 else
6557 {
6558 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6559 rem_probe_resp_ie_len = 0;
6560 }
6561 }
6562
6563 rem_probe_resp_ie_len = 0;
6564
6565 if (probe_rsp_ie_len[0] > 0)
6566 {
6567 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6568 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6569 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6570 probe_rsp_ie_len[0], NULL,
6571 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6572 {
6573 hddLog(LOGE,
6574 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006575 ret = -EINVAL;
6576 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006577 }
6578 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6579 }
6580
6581 if (probe_rsp_ie_len[1] > 0)
6582 {
6583 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6584 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6585 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6586 probe_rsp_ie_len[1], NULL,
6587 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6588 {
6589 hddLog(LOGE,
6590 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006591 ret = -EINVAL;
6592 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006593 }
6594 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6595 }
6596
6597 if (probe_rsp_ie_len[2] > 0)
6598 {
6599 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6600 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6601 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6602 probe_rsp_ie_len[2], NULL,
6603 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6604 {
6605 hddLog(LOGE,
6606 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006607 ret = -EINVAL;
6608 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 }
6610 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6611 }
6612
6613 if (probe_rsp_ie_len[1] == 0 )
6614 {
6615 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6616 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
6617 eANI_BOOLEAN_FALSE) )
6618 {
6619 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006620 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006621 }
6622 }
6623
6624 if (probe_rsp_ie_len[2] == 0 )
6625 {
6626 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6627 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
6628 eANI_BOOLEAN_FALSE) )
6629 {
6630 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006631 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 }
6633 }
6634
6635 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6636 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6637 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6638 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6639 == eHAL_STATUS_FAILURE)
6640 {
6641 hddLog(LOGE,
6642 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006643 ret = -EINVAL;
6644 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 }
6646 }
6647 else
6648 {
6649 // Reset WNI_CFG_PROBE_RSP Flags
6650 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
6651
6652 hddLog(VOS_TRACE_LEVEL_INFO,
6653 "%s: No Probe Response IE received in set beacon",
6654 __func__);
6655 }
6656
6657 // Added for AssocResp IE
6658 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
6659 {
6660 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6661 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
6662 params->assocresp_ies_len, NULL,
6663 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6664 {
6665 hddLog(LOGE,
6666 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006667 ret = -EINVAL;
6668 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006669 }
6670
6671 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6672 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
6673 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6674 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6675 == eHAL_STATUS_FAILURE)
6676 {
6677 hddLog(LOGE,
6678 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006679 ret = -EINVAL;
6680 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 }
6682 }
6683 else
6684 {
6685 hddLog(VOS_TRACE_LEVEL_INFO,
6686 "%s: No Assoc Response IE received in set beacon",
6687 __func__);
6688
6689 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6690 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6691 eANI_BOOLEAN_FALSE) )
6692 {
6693 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006694 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006695 }
6696 }
6697
Jeff Johnsone7245742012-09-05 17:12:55 -07006698done:
Jeff Johnson295189b2012-06-20 16:38:30 -07006699 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306700 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006701}
Jeff Johnson295189b2012-06-20 16:38:30 -07006702
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306703/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 * FUNCTION: wlan_hdd_validate_operation_channel
6705 * called by wlan_hdd_cfg80211_start_bss() and
6706 * wlan_hdd_cfg80211_set_channel()
6707 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306708 * channel list.
6709 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07006710VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006711{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306712
Jeff Johnson295189b2012-06-20 16:38:30 -07006713 v_U32_t num_ch = 0;
6714 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6715 u32 indx = 0;
6716 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306717 v_U8_t fValidChannel = FALSE, count = 0;
6718 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306719
Jeff Johnson295189b2012-06-20 16:38:30 -07006720 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6721
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306722 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006723 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306724 /* Validate the channel */
6725 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306727 if ( channel == rfChannels[count].channelNum )
6728 {
6729 fValidChannel = TRUE;
6730 break;
6731 }
6732 }
6733 if (fValidChannel != TRUE)
6734 {
6735 hddLog(VOS_TRACE_LEVEL_ERROR,
6736 "%s: Invalid Channel [%d]", __func__, channel);
6737 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006738 }
6739 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306740 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306742 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6743 valid_ch, &num_ch))
6744 {
6745 hddLog(VOS_TRACE_LEVEL_ERROR,
6746 "%s: failed to get valid channel list", __func__);
6747 return VOS_STATUS_E_FAILURE;
6748 }
6749 for (indx = 0; indx < num_ch; indx++)
6750 {
6751 if (channel == valid_ch[indx])
6752 {
6753 break;
6754 }
6755 }
6756
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306757 if (indx >= num_ch)
6758 {
6759 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6760 {
6761 eCsrBand band;
6762 unsigned int freq;
6763
6764 sme_GetFreqBand(hHal, &band);
6765
6766 if (eCSR_BAND_5G == band)
6767 {
6768#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
6769 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
6770 {
6771 freq = ieee80211_channel_to_frequency(channel,
6772 IEEE80211_BAND_2GHZ);
6773 }
6774 else
6775 {
6776 freq = ieee80211_channel_to_frequency(channel,
6777 IEEE80211_BAND_5GHZ);
6778 }
6779#else
6780 freq = ieee80211_channel_to_frequency(channel);
6781#endif
6782 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
6783 return VOS_STATUS_SUCCESS;
6784 }
6785 }
6786
6787 hddLog(VOS_TRACE_LEVEL_ERROR,
6788 "%s: Invalid Channel [%d]", __func__, channel);
6789 return VOS_STATUS_E_FAILURE;
6790 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006791 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306792
Jeff Johnson295189b2012-06-20 16:38:30 -07006793 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306794
Jeff Johnson295189b2012-06-20 16:38:30 -07006795}
6796
Viral Modi3a32cc52013-02-08 11:14:52 -08006797/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306798 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08006799 * This function is used to set the channel number
6800 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306801static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08006802 struct ieee80211_channel *chan,
6803 enum nl80211_channel_type channel_type
6804 )
6805{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306806 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08006807 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07006808 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08006809 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306810 hdd_context_t *pHddCtx;
6811 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006812
6813 ENTER();
6814
6815 if( NULL == dev )
6816 {
6817 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006818 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006819 return -ENODEV;
6820 }
6821 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306822
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306823 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6824 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
6825 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08006826 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306827 "%s: device_mode = %s (%d) freq = %d", __func__,
6828 hdd_device_modetoString(pAdapter->device_mode),
6829 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306830
6831 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6832 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306833 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08006834 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306835 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006836 }
6837
6838 /*
6839 * Do freq to chan conversion
6840 * TODO: for 11a
6841 */
6842
6843 channel = ieee80211_frequency_to_channel(freq);
6844
6845 /* Check freq range */
6846 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
6847 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
6848 {
6849 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006850 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08006851 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
6852 WNI_CFG_CURRENT_CHANNEL_STAMAX);
6853 return -EINVAL;
6854 }
6855
6856 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6857
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05306858 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
6859 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08006860 {
6861 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
6862 {
6863 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006864 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08006865 return -EINVAL;
6866 }
6867 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6868 "%s: set channel to [%d] for device mode =%d",
6869 __func__, channel,pAdapter->device_mode);
6870 }
6871 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08006872 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08006873 )
6874 {
6875 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6876 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
6877 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6878
6879 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
6880 {
6881 /* Link is up then return cant set channel*/
6882 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006883 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006884 return -EINVAL;
6885 }
6886
6887 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
6888 pHddStaCtx->conn_info.operationChannel = channel;
6889 pRoamProfile->ChannelInfo.ChannelList =
6890 &pHddStaCtx->conn_info.operationChannel;
6891 }
6892 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08006893 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08006894 )
6895 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306896 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6897 {
6898 if(VOS_STATUS_SUCCESS !=
6899 wlan_hdd_validate_operation_channel(pAdapter,channel))
6900 {
6901 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006902 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306903 return -EINVAL;
6904 }
6905 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6906 }
6907 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08006908 {
6909 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
6910
6911 /* If auto channel selection is configured as enable/ 1 then ignore
6912 channel set by supplicant
6913 */
6914 if ( cfg_param->apAutoChannelSelection )
6915 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306916 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
6917 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08006918 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306919 "%s: set channel to auto channel (0) for device mode =%s (%d)",
6920 __func__, hdd_device_modetoString(pAdapter->device_mode),
6921 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08006922 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306923 else
6924 {
6925 if(VOS_STATUS_SUCCESS !=
6926 wlan_hdd_validate_operation_channel(pAdapter,channel))
6927 {
6928 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006929 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306930 return -EINVAL;
6931 }
6932 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6933 }
Viral Modi3a32cc52013-02-08 11:14:52 -08006934 }
6935 }
6936 else
6937 {
6938 hddLog(VOS_TRACE_LEVEL_FATAL,
6939 "%s: Invalid device mode failed to set valid channel", __func__);
6940 return -EINVAL;
6941 }
6942 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306943 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006944}
6945
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306946static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
6947 struct net_device *dev,
6948 struct ieee80211_channel *chan,
6949 enum nl80211_channel_type channel_type
6950 )
6951{
6952 int ret;
6953
6954 vos_ssr_protect(__func__);
6955 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
6956 vos_ssr_unprotect(__func__);
6957
6958 return ret;
6959}
6960
Jeff Johnson295189b2012-06-20 16:38:30 -07006961#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
6962static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6963 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006964#else
6965static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6966 struct cfg80211_beacon_data *params,
6967 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05306968 enum nl80211_hidden_ssid hidden_ssid,
6969 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006970#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006971{
6972 tsap_Config_t *pConfig;
6973 beacon_data_t *pBeacon = NULL;
6974 struct ieee80211_mgmt *pMgmt_frame;
6975 v_U8_t *pIe=NULL;
6976 v_U16_t capab_info;
6977 eCsrAuthType RSNAuthType;
6978 eCsrEncryptionType RSNEncryptType;
6979 eCsrEncryptionType mcRSNEncryptType;
6980 int status = VOS_STATUS_SUCCESS;
6981 tpWLAN_SAPEventCB pSapEventCallback;
6982 hdd_hostapd_state_t *pHostapdState;
6983 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
6984 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306985 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006986 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306987 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006988 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08006989 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05306990 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07006991 v_BOOL_t MFPCapable = VOS_FALSE;
6992 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05306993 v_BOOL_t sapEnable11AC =
6994 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07006995 ENTER();
6996
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306997 iniConfig = pHddCtx->cfg_ini;
6998
Jeff Johnson295189b2012-06-20 16:38:30 -07006999 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
7000
7001 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
7002
7003 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
7004
7005 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
7006
7007 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
7008
7009 //channel is already set in the set_channel Call back
7010 //pConfig->channel = pCommitConfig->channel;
7011
7012 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307013 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07007014 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
7015
7016 pConfig->dtim_period = pBeacon->dtim_period;
7017
Arif Hussain6d2a3322013-11-17 19:50:10 -08007018 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07007019 pConfig->dtim_period);
7020
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08007021 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07007022 {
7023 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007024 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05307025 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
7026 {
7027 tANI_BOOLEAN restartNeeded;
7028 pConfig->ieee80211d = 1;
7029 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
7030 sme_setRegInfo(hHal, pConfig->countryCode);
7031 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
7032 }
7033 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07007034 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07007035 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007036 pConfig->ieee80211d = 1;
7037 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
7038 sme_setRegInfo(hHal, pConfig->countryCode);
7039 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07007040 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007041 else
7042 {
7043 pConfig->ieee80211d = 0;
7044 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307045 /*
7046 * If auto channel is configured i.e. channel is 0,
7047 * so skip channel validation.
7048 */
7049 if( AUTO_CHANNEL_SELECT != pConfig->channel )
7050 {
7051 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
7052 {
7053 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007054 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307055 return -EINVAL;
7056 }
7057 }
7058 else
7059 {
7060 if(1 != pHddCtx->is_dynamic_channel_range_set)
7061 {
7062 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
7063 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
7064 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
7065 }
7066 pHddCtx->is_dynamic_channel_range_set = 0;
7067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007068 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007069 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007070 {
7071 pConfig->ieee80211d = 0;
7072 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307073
7074#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7075 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7076 pConfig->authType = eSAP_OPEN_SYSTEM;
7077 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7078 pConfig->authType = eSAP_SHARED_KEY;
7079 else
7080 pConfig->authType = eSAP_AUTO_SWITCH;
7081#else
7082 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7083 pConfig->authType = eSAP_OPEN_SYSTEM;
7084 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7085 pConfig->authType = eSAP_SHARED_KEY;
7086 else
7087 pConfig->authType = eSAP_AUTO_SWITCH;
7088#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007089
7090 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307091
7092 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
7094
7095 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
7096
7097 /*Set wps station to configured*/
7098 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
7099
7100 if(pIe)
7101 {
7102 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
7103 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007104 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07007105 return -EINVAL;
7106 }
7107 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
7108 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007109 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07007110 /* Check 15 bit of WPS IE as it contain information for wps state
7111 * WPS state
7112 */
7113 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
7114 {
7115 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
7116 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
7117 {
7118 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
7119 }
7120 }
7121 }
7122 else
7123 {
7124 pConfig->wps_state = SAP_WPS_DISABLED;
7125 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307126 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07007127
c_hpothufe599e92014-06-16 11:38:55 +05307128 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7129 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7130 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
7131 eCSR_ENCRYPT_TYPE_NONE;
7132
Jeff Johnson295189b2012-06-20 16:38:30 -07007133 pConfig->RSNWPAReqIELength = 0;
7134 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307135 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007136 WLAN_EID_RSN);
7137 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307138 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007139 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7140 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7141 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307142 /* The actual processing may eventually be more extensive than
7143 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07007144 * by the app.
7145 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307146 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007147 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7148 &RSNEncryptType,
7149 &mcRSNEncryptType,
7150 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007151 &MFPCapable,
7152 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 pConfig->pRSNWPAReqIE[1]+2,
7154 pConfig->pRSNWPAReqIE );
7155
7156 if( VOS_STATUS_SUCCESS == status )
7157 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307158 /* Now copy over all the security attributes you have
7159 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007160 * */
7161 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7162 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7163 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7164 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307165 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007166 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007167 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7168 }
7169 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307170
Jeff Johnson295189b2012-06-20 16:38:30 -07007171 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7172 pBeacon->tail, pBeacon->tail_len);
7173
7174 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
7175 {
7176 if (pConfig->pRSNWPAReqIE)
7177 {
7178 /*Mixed mode WPA/WPA2*/
7179 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
7180 pConfig->RSNWPAReqIELength += pIe[1] + 2;
7181 }
7182 else
7183 {
7184 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7185 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7186 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307187 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007188 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7189 &RSNEncryptType,
7190 &mcRSNEncryptType,
7191 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007192 &MFPCapable,
7193 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007194 pConfig->pRSNWPAReqIE[1]+2,
7195 pConfig->pRSNWPAReqIE );
7196
7197 if( VOS_STATUS_SUCCESS == status )
7198 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307199 /* Now copy over all the security attributes you have
7200 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 * */
7202 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7203 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7204 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7205 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307206 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007207 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7209 }
7210 }
7211 }
7212
Jeff Johnson4416a782013-03-25 14:17:50 -07007213 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
7214 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
7215 return -EINVAL;
7216 }
7217
Jeff Johnson295189b2012-06-20 16:38:30 -07007218 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
7219
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007220#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 if (params->ssid != NULL)
7222 {
7223 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
7224 pConfig->SSIDinfo.ssid.length = params->ssid_len;
7225 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7226 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7227 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007228#else
7229 if (ssid != NULL)
7230 {
7231 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
7232 pConfig->SSIDinfo.ssid.length = ssid_len;
7233 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7234 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7235 }
7236#endif
7237
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307238 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07007239 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307240
Jeff Johnson295189b2012-06-20 16:38:30 -07007241 /* default value */
7242 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
7243 pConfig->num_accept_mac = 0;
7244 pConfig->num_deny_mac = 0;
7245
7246 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7247 pBeacon->tail, pBeacon->tail_len);
7248
7249 /* pIe for black list is following form:
7250 type : 1 byte
7251 length : 1 byte
7252 OUI : 4 bytes
7253 acl type : 1 byte
7254 no of mac addr in black list: 1 byte
7255 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307256 */
7257 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007258 {
7259 pConfig->SapMacaddr_acl = pIe[6];
7260 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007261 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007262 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307263 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
7264 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007265 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7266 for (i = 0; i < pConfig->num_deny_mac; i++)
7267 {
7268 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7269 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307270 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007271 }
7272 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7273 pBeacon->tail, pBeacon->tail_len);
7274
7275 /* pIe for white list is following form:
7276 type : 1 byte
7277 length : 1 byte
7278 OUI : 4 bytes
7279 acl type : 1 byte
7280 no of mac addr in white list: 1 byte
7281 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307282 */
7283 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007284 {
7285 pConfig->SapMacaddr_acl = pIe[6];
7286 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007287 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007288 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307289 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
7290 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007291 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7292 for (i = 0; i < pConfig->num_accept_mac; i++)
7293 {
7294 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7295 acl_entry++;
7296 }
7297 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307298
Jeff Johnson295189b2012-06-20 16:38:30 -07007299 wlan_hdd_set_sapHwmode(pHostapdAdapter);
7300
Jeff Johnsone7245742012-09-05 17:12:55 -07007301#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007302 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307303 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
7304 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05307305 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
7306 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007307 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
7308 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307309 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
7310 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07007311 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307312 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007313 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307314 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007315
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307316 /* If ACS disable and selected channel <= 14
7317 * OR
7318 * ACS enabled and ACS operating band is choosen as 2.4
7319 * AND
7320 * VHT in 2.4G Disabled
7321 * THEN
7322 * Fallback to 11N mode
7323 */
7324 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
7325 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05307326 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307327 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007328 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307329 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
7330 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007331 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
7332 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007333 }
7334#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307335
Jeff Johnson295189b2012-06-20 16:38:30 -07007336 // ht_capab is not what the name conveys,this is used for protection bitmap
7337 pConfig->ht_capab =
7338 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
7339
7340 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
7341 {
7342 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
7343 return -EINVAL;
7344 }
7345
7346 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307347 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07007348 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
7349 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307350 pConfig->obssProtEnabled =
7351 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07007352
Chet Lanctot8cecea22014-02-11 19:09:36 -08007353#ifdef WLAN_FEATURE_11W
7354 pConfig->mfpCapable = MFPCapable;
7355 pConfig->mfpRequired = MFPRequired;
7356 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
7357 pConfig->mfpCapable, pConfig->mfpRequired);
7358#endif
7359
Arif Hussain6d2a3322013-11-17 19:50:10 -08007360 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07007361 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007362 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
7363 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
7364 (int)pConfig->channel);
7365 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
7366 pConfig->SapHw_mode, pConfig->privacy,
7367 pConfig->authType);
7368 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
7369 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
7370 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
7371 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07007372
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307373 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007374 {
7375 //Bss already started. just return.
7376 //TODO Probably it should update some beacon params.
7377 hddLog( LOGE, "Bss Already started...Ignore the request");
7378 EXIT();
7379 return 0;
7380 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307381
Agarwal Ashish51325b52014-06-16 16:50:49 +05307382 if (vos_max_concurrent_connections_reached()) {
7383 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7384 return -EINVAL;
7385 }
7386
Jeff Johnson295189b2012-06-20 16:38:30 -07007387 pConfig->persona = pHostapdAdapter->device_mode;
7388
Peng Xu2446a892014-09-05 17:21:18 +05307389 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
7390 if ( NULL != psmeConfig)
7391 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307392 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05307393 sme_GetConfigParam(hHal, psmeConfig);
7394 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307395#ifdef WLAN_FEATURE_AP_HT40_24G
7396 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
7397 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
7398 && pHddCtx->cfg_ini->apHT40_24GEnabled)
7399 {
7400 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
7401 sme_UpdateConfig (hHal, psmeConfig);
7402 }
7403#endif
Peng Xu2446a892014-09-05 17:21:18 +05307404 vos_mem_free(psmeConfig);
7405 }
Peng Xuafc34e32014-09-25 13:23:55 +05307406 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05307407
Jeff Johnson295189b2012-06-20 16:38:30 -07007408 pSapEventCallback = hdd_hostapd_SAPEventCB;
7409 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
7410 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
7411 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007412 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007413 return -EINVAL;
7414 }
7415
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307416 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07007417 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
7418
7419 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307420
Jeff Johnson295189b2012-06-20 16:38:30 -07007421 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307422 {
7423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007424 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07007425 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007426 VOS_ASSERT(0);
7427 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307428
Jeff Johnson295189b2012-06-20 16:38:30 -07007429 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05307430 /* Initialize WMM configuation */
7431 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307432 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007433
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007434#ifdef WLAN_FEATURE_P2P_DEBUG
7435 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
7436 {
7437 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
7438 {
7439 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7440 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007441 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007442 }
7443 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
7444 {
7445 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7446 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007447 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007448 }
7449 }
7450#endif
7451
Jeff Johnson295189b2012-06-20 16:38:30 -07007452 pHostapdState->bCommit = TRUE;
7453 EXIT();
7454
7455 return 0;
7456}
7457
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007458#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307459static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307460 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007461 struct beacon_parameters *params)
7462{
7463 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307464 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307465 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007466
7467 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307468
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307469 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7470 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
7471 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307472 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
7473 hdd_device_modetoString(pAdapter->device_mode),
7474 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007475
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307476 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7477 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307478 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007479 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307480 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007481 }
7482
Agarwal Ashish51325b52014-06-16 16:50:49 +05307483 if (vos_max_concurrent_connections_reached()) {
7484 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7485 return -EINVAL;
7486 }
7487
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307488 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007489 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 )
7491 {
7492 beacon_data_t *old,*new;
7493
7494 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307495
Jeff Johnson295189b2012-06-20 16:38:30 -07007496 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307497 {
7498 hddLog(VOS_TRACE_LEVEL_WARN,
7499 FL("already beacon info added to session(%d)"),
7500 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007503
7504 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7505
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307506 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07007507 {
7508 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007509 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007510 return -EINVAL;
7511 }
7512
7513 pAdapter->sessionCtx.ap.beacon = new;
7514
7515 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7516 }
7517
7518 EXIT();
7519 return status;
7520}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307521
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307522static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
7523 struct net_device *dev,
7524 struct beacon_parameters *params)
7525{
7526 int ret;
7527
7528 vos_ssr_protect(__func__);
7529 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
7530 vos_ssr_unprotect(__func__);
7531
7532 return ret;
7533}
7534
7535static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007536 struct net_device *dev,
7537 struct beacon_parameters *params)
7538{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307539 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307540 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7541 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307542 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007543
7544 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307545
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307546 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7547 TRACE_CODE_HDD_CFG80211_SET_BEACON,
7548 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
7549 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7550 __func__, hdd_device_modetoString(pAdapter->device_mode),
7551 pAdapter->device_mode);
7552
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307553 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7554 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307555 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007556 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307557 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007558 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307559
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307560 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007561 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307562 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007563 {
7564 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307565
Jeff Johnson295189b2012-06-20 16:38:30 -07007566 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307567
Jeff Johnson295189b2012-06-20 16:38:30 -07007568 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307569 {
7570 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7571 FL("session(%d) old and new heads points to NULL"),
7572 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007573 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007575
7576 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7577
7578 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307579 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007580 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007581 return -EINVAL;
7582 }
7583
7584 pAdapter->sessionCtx.ap.beacon = new;
7585
7586 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7587 }
7588
7589 EXIT();
7590 return status;
7591}
7592
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307593static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
7594 struct net_device *dev,
7595 struct beacon_parameters *params)
7596{
7597 int ret;
7598
7599 vos_ssr_protect(__func__);
7600 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
7601 vos_ssr_unprotect(__func__);
7602
7603 return ret;
7604}
7605
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007606#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7607
7608#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307609static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007610 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007611#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307612static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007613 struct net_device *dev)
7614#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007615{
7616 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07007617 hdd_context_t *pHddCtx = NULL;
7618 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307619 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307620 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007621
7622 ENTER();
7623
7624 if (NULL == pAdapter)
7625 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307626 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007627 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007628 return -ENODEV;
7629 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007630
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307631 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7632 TRACE_CODE_HDD_CFG80211_STOP_AP,
7633 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307634 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7635 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307636 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007637 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307638 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07007639 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007640
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007641 pScanInfo = &pHddCtx->scan_info;
7642
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307643 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7644 __func__, hdd_device_modetoString(pAdapter->device_mode),
7645 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007646
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307647 ret = wlan_hdd_scan_abort(pAdapter);
7648
Girish Gowli4bf7a632014-06-12 13:42:11 +05307649 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07007650 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307651 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7652 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307653
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307654 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07007655 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7657 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08007658
Jeff Johnsone7245742012-09-05 17:12:55 -07007659 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307660 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07007661 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307662 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07007663 }
7664
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05307665 /* Delete all associated STAs before stopping AP/P2P GO */
7666 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05307667 hdd_hostapd_stop(dev);
7668
Jeff Johnson295189b2012-06-20 16:38:30 -07007669 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007670 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 )
7672 {
7673 beacon_data_t *old;
7674
7675 old = pAdapter->sessionCtx.ap.beacon;
7676
7677 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307678 {
7679 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7680 FL("session(%d) beacon data points to NULL"),
7681 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007682 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007684
Jeff Johnson295189b2012-06-20 16:38:30 -07007685 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007686
7687 mutex_lock(&pHddCtx->sap_lock);
7688 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7689 {
Jeff Johnson4416a782013-03-25 14:17:50 -07007690 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007691 {
7692 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7693
7694 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
7695
7696 if (!VOS_IS_STATUS_SUCCESS(status))
7697 {
7698 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007699 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007700 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307701 }
7702 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007703 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307704 /* BSS stopped, clear the active sessions for this device mode */
7705 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007706 }
7707 mutex_unlock(&pHddCtx->sap_lock);
7708
7709 if(status != VOS_STATUS_SUCCESS)
7710 {
7711 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007712 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007713 return -EINVAL;
7714 }
7715
Jeff Johnson4416a782013-03-25 14:17:50 -07007716 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007717 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
7718 ==eHAL_STATUS_FAILURE)
7719 {
7720 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007721 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007722 }
7723
Jeff Johnson4416a782013-03-25 14:17:50 -07007724 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007725 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7726 eANI_BOOLEAN_FALSE) )
7727 {
7728 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007729 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007730 }
7731
7732 // Reset WNI_CFG_PROBE_RSP Flags
7733 wlan_hdd_reset_prob_rspies(pAdapter);
7734
7735 pAdapter->sessionCtx.ap.beacon = NULL;
7736 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007737#ifdef WLAN_FEATURE_P2P_DEBUG
7738 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
7739 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
7740 {
7741 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
7742 "GO got removed");
7743 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
7744 }
7745#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007746 }
7747 EXIT();
7748 return status;
7749}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007750
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307751#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7752static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
7753 struct net_device *dev)
7754{
7755 int ret;
7756
7757 vos_ssr_protect(__func__);
7758 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
7759 vos_ssr_unprotect(__func__);
7760
7761 return ret;
7762}
7763#else
7764static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
7765 struct net_device *dev)
7766{
7767 int ret;
7768
7769 vos_ssr_protect(__func__);
7770 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
7771 vos_ssr_unprotect(__func__);
7772
7773 return ret;
7774}
7775#endif
7776
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007777#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
7778
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307779static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307780 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007781 struct cfg80211_ap_settings *params)
7782{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307783 hdd_adapter_t *pAdapter;
7784 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307785 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007786
7787 ENTER();
7788
Girish Gowlib143d7a2015-02-18 19:39:55 +05307789 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007790 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307791 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05307792 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307793 return -ENODEV;
7794 }
7795
7796 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7797 if (NULL == pAdapter)
7798 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307799 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307800 "%s: HDD adapter is Null", __func__);
7801 return -ENODEV;
7802 }
7803
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307804 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7805 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
7806 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307807 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
7808 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307809 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307810 "%s: HDD adapter magic is invalid", __func__);
7811 return -ENODEV;
7812 }
7813
7814 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307815 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307816 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307817 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307818 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307819 }
7820
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307821 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
7822 __func__, hdd_device_modetoString(pAdapter->device_mode),
7823 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307824
7825 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007826 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007827 )
7828 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307829 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007830
7831 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307832
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007833 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307834 {
7835 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7836 FL("already beacon info added to session(%d)"),
7837 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007838 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307839 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007840
Girish Gowlib143d7a2015-02-18 19:39:55 +05307841#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7842 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7843 &new,
7844 &params->beacon);
7845#else
7846 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7847 &new,
7848 &params->beacon,
7849 params->dtim_period);
7850#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007851
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307852 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007853 {
7854 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307855 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007856 return -EINVAL;
7857 }
7858 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08007859#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07007860 wlan_hdd_cfg80211_set_channel(wiphy, dev,
7861#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
7862 params->channel, params->channel_type);
7863#else
7864 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
7865#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08007866#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007867 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307868 params->ssid_len, params->hidden_ssid,
7869 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007870 }
7871
7872 EXIT();
7873 return status;
7874}
7875
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307876static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
7877 struct net_device *dev,
7878 struct cfg80211_ap_settings *params)
7879{
7880 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007881
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307882 vos_ssr_protect(__func__);
7883 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
7884 vos_ssr_unprotect(__func__);
7885
7886 return ret;
7887}
7888
7889static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007890 struct net_device *dev,
7891 struct cfg80211_beacon_data *params)
7892{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307893 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307894 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307895 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007896
7897 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307898
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307899 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7900 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
7901 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007902 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007903 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307904
7905 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7906 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307907 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007908 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307909 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007910 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007911
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307912 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007913 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307914 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007915 {
7916 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307917
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007918 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307919
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007920 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307921 {
7922 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7923 FL("session(%d) beacon data points to NULL"),
7924 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007925 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307926 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007927
7928 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
7929
7930 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307931 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007932 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007933 return -EINVAL;
7934 }
7935
7936 pAdapter->sessionCtx.ap.beacon = new;
7937
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307938 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
7939 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007940 }
7941
7942 EXIT();
7943 return status;
7944}
7945
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307946static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
7947 struct net_device *dev,
7948 struct cfg80211_beacon_data *params)
7949{
7950 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007951
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307952 vos_ssr_protect(__func__);
7953 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
7954 vos_ssr_unprotect(__func__);
7955
7956 return ret;
7957}
7958
7959#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007960
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307961static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007962 struct net_device *dev,
7963 struct bss_parameters *params)
7964{
7965 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307966 hdd_context_t *pHddCtx;
7967 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007968
7969 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307970
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307971 if (NULL == pAdapter)
7972 {
7973 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7974 "%s: HDD adapter is Null", __func__);
7975 return -ENODEV;
7976 }
7977 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307978 ret = wlan_hdd_validate_context(pHddCtx);
7979 if (0 != ret)
7980 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307981 return ret;
7982 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307983 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7984 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
7985 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307986 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7987 __func__, hdd_device_modetoString(pAdapter->device_mode),
7988 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007989
7990 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007991 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307992 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007993 {
7994 /* ap_isolate == -1 means that in change bss, upper layer doesn't
7995 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307996 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07007997 {
7998 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307999 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008000 }
8001
8002 EXIT();
8003 return 0;
8004}
8005
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308006static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
8007 struct net_device *dev,
8008 struct bss_parameters *params)
8009{
8010 int ret;
8011
8012 vos_ssr_protect(__func__);
8013 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
8014 vos_ssr_unprotect(__func__);
8015
8016 return ret;
8017}
Kiet Lam10841362013-11-01 11:36:50 +05308018/* FUNCTION: wlan_hdd_change_country_code_cd
8019* to wait for contry code completion
8020*/
8021void* wlan_hdd_change_country_code_cb(void *pAdapter)
8022{
8023 hdd_adapter_t *call_back_pAdapter = pAdapter;
8024 complete(&call_back_pAdapter->change_country_code);
8025 return NULL;
8026}
8027
Jeff Johnson295189b2012-06-20 16:38:30 -07008028/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308029 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07008030 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
8031 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308032int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008033 struct net_device *ndev,
8034 enum nl80211_iftype type,
8035 u32 *flags,
8036 struct vif_params *params
8037 )
8038{
8039 struct wireless_dev *wdev;
8040 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008041 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07008042 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008043 tCsrRoamProfile *pRoamProfile = NULL;
8044 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308045 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008046 eMib_dot11DesiredBssType connectedBssType;
8047 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308048 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008049
8050 ENTER();
8051
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308052 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008053 {
8054 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8055 "%s: Adapter context is null", __func__);
8056 return VOS_STATUS_E_FAILURE;
8057 }
8058
8059 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8060 if (!pHddCtx)
8061 {
8062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8063 "%s: HDD context is null", __func__);
8064 return VOS_STATUS_E_FAILURE;
8065 }
8066
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308067 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8068 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
8069 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308070 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308071 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07008072 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308073 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008074 }
8075
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308076 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8077 __func__, hdd_device_modetoString(pAdapter->device_mode),
8078 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008079
Agarwal Ashish51325b52014-06-16 16:50:49 +05308080 if (vos_max_concurrent_connections_reached()) {
8081 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
8082 return -EINVAL;
8083 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308084 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07008085 wdev = ndev->ieee80211_ptr;
8086
8087#ifdef WLAN_BTAMP_FEATURE
8088 if((NL80211_IFTYPE_P2P_CLIENT == type)||
8089 (NL80211_IFTYPE_ADHOC == type)||
8090 (NL80211_IFTYPE_AP == type)||
8091 (NL80211_IFTYPE_P2P_GO == type))
8092 {
8093 pHddCtx->isAmpAllowed = VOS_FALSE;
8094 // stop AMP traffic
8095 status = WLANBAP_StopAmp();
8096 if(VOS_STATUS_SUCCESS != status )
8097 {
8098 pHddCtx->isAmpAllowed = VOS_TRUE;
8099 hddLog(VOS_TRACE_LEVEL_FATAL,
8100 "%s: Failed to stop AMP", __func__);
8101 return -EINVAL;
8102 }
8103 }
8104#endif //WLAN_BTAMP_FEATURE
8105 /* Reset the current device mode bit mask*/
8106 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
8107
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05308108 /* Notify Mode change in case of concurrency.
8109 * Below function invokes TDLS teardown Functionality Since TDLS is
8110 * not Supported in case of concurrency i.e Once P2P session
8111 * is detected disable offchannel and teardown TDLS links
8112 */
8113 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
8114
Jeff Johnson295189b2012-06-20 16:38:30 -07008115 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008116 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07008117 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07008118 )
8119 {
8120 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008121 if (!pWextState)
8122 {
8123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8124 "%s: pWextState is null", __func__);
8125 return VOS_STATUS_E_FAILURE;
8126 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008127 pRoamProfile = &pWextState->roamProfile;
8128 LastBSSType = pRoamProfile->BSSType;
8129
8130 switch (type)
8131 {
8132 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008133 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008134 hddLog(VOS_TRACE_LEVEL_INFO,
8135 "%s: setting interface Type to INFRASTRUCTURE", __func__);
8136 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07008137#ifdef WLAN_FEATURE_11AC
8138 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
8139 {
8140 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
8141 }
8142#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308143 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07008144 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008145 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008146 //Check for sub-string p2p to confirm its a p2p interface
8147 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308148 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008149 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8150 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8151 }
8152 else
8153 {
8154 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008155 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008157 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05308158
Jeff Johnson295189b2012-06-20 16:38:30 -07008159 case NL80211_IFTYPE_ADHOC:
8160 hddLog(VOS_TRACE_LEVEL_INFO,
8161 "%s: setting interface Type to ADHOC", __func__);
8162 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
8163 pRoamProfile->phyMode =
8164 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07008165 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008166 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +05308167 hdd_set_ibss_ops( pAdapter );
8168 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +05308169
8170 status = hdd_sta_id_hash_attach(pAdapter);
8171 if (VOS_STATUS_SUCCESS != status) {
8172 hddLog(VOS_TRACE_LEVEL_ERROR,
8173 FL("Failed to initialize hash for IBSS"));
8174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008175 break;
8176
8177 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008178 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008179 {
8180 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8181 "%s: setting interface Type to %s", __func__,
8182 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
8183
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008184 //Cancel any remain on channel for GO mode
8185 if (NL80211_IFTYPE_P2P_GO == type)
8186 {
8187 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
8188 }
Mohit Khanna0f232092012-09-11 14:46:08 -07008189 if (NL80211_IFTYPE_AP == type)
8190 {
8191 /* As Loading WLAN Driver one interface being created for p2p device
8192 * address. This will take one HW STA and the max number of clients
8193 * that can connect to softAP will be reduced by one. so while changing
8194 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
8195 * interface as it is not required in SoftAP mode.
8196 */
8197
8198 // Get P2P Adapter
8199 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
8200
8201 if (pP2pAdapter)
8202 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05308203 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +05308204 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07008205 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
8206 }
8207 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05308208 //Disable IMPS & BMPS for SAP/GO
8209 if(VOS_STATUS_E_FAILURE ==
8210 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
8211 {
8212 //Fail to Exit BMPS
8213 VOS_ASSERT(0);
8214 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05308215
8216 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
8217
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308218#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07008219
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308220 /* A Mutex Lock is introduced while changing the mode to
8221 * protect the concurrent access for the Adapters by TDLS
8222 * module.
8223 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308224 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308225#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008226 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +05308227 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008228 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07008229 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8230 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308231#ifdef FEATURE_WLAN_TDLS
8232 mutex_unlock(&pHddCtx->tdls_lock);
8233#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008234 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
8235 (pConfig->apRandomBssidEnabled))
8236 {
8237 /* To meet Android requirements create a randomized
8238 MAC address of the form 02:1A:11:Fx:xx:xx */
8239 get_random_bytes(&ndev->dev_addr[3], 3);
8240 ndev->dev_addr[0] = 0x02;
8241 ndev->dev_addr[1] = 0x1A;
8242 ndev->dev_addr[2] = 0x11;
8243 ndev->dev_addr[3] |= 0xF0;
8244 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
8245 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08008246 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
8247 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008248 }
8249
Jeff Johnson295189b2012-06-20 16:38:30 -07008250 hdd_set_ap_ops( pAdapter->dev );
8251
Kiet Lam10841362013-11-01 11:36:50 +05308252 /* This is for only SAP mode where users can
8253 * control country through ini.
8254 * P2P GO follows station country code
8255 * acquired during the STA scanning. */
8256 if((NL80211_IFTYPE_AP == type) &&
8257 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
8258 {
8259 int status = 0;
8260 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
8261 "%s: setting country code from INI ", __func__);
8262 init_completion(&pAdapter->change_country_code);
8263 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
8264 (void *)(tSmeChangeCountryCallback)
8265 wlan_hdd_change_country_code_cb,
8266 pConfig->apCntryCode, pAdapter,
8267 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05308268 eSIR_FALSE,
8269 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05308270 if (eHAL_STATUS_SUCCESS == status)
8271 {
8272 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308273 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05308274 &pAdapter->change_country_code,
8275 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308276 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05308277 {
8278 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308279 FL("SME Timed out while setting country code %ld"),
8280 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08008281
8282 if (pHddCtx->isLogpInProgress)
8283 {
8284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8285 "%s: LOGP in Progress. Ignore!!!", __func__);
8286 return -EAGAIN;
8287 }
Kiet Lam10841362013-11-01 11:36:50 +05308288 }
8289 }
8290 else
8291 {
8292 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008293 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05308294 return -EINVAL;
8295 }
8296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008297 status = hdd_init_ap_mode(pAdapter);
8298 if(status != VOS_STATUS_SUCCESS)
8299 {
8300 hddLog(VOS_TRACE_LEVEL_FATAL,
8301 "%s: Error initializing the ap mode", __func__);
8302 return -EINVAL;
8303 }
8304 hdd_set_conparam(1);
8305
Nirav Shah7e3c8132015-06-22 23:51:42 +05308306 status = hdd_sta_id_hash_attach(pAdapter);
8307 if (VOS_STATUS_SUCCESS != status)
8308 {
8309 hddLog(VOS_TRACE_LEVEL_ERROR,
8310 FL("Failed to initialize hash for AP"));
8311 return -EINVAL;
8312 }
8313
Jeff Johnson295189b2012-06-20 16:38:30 -07008314 /*interface type changed update in wiphy structure*/
8315 if(wdev)
8316 {
8317 wdev->iftype = type;
8318 pHddCtx->change_iface = type;
8319 }
8320 else
8321 {
8322 hddLog(VOS_TRACE_LEVEL_ERROR,
8323 "%s: ERROR !!!! Wireless dev is NULL", __func__);
8324 return -EINVAL;
8325 }
8326 goto done;
8327 }
8328
8329 default:
8330 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8331 __func__);
8332 return -EOPNOTSUPP;
8333 }
8334 }
8335 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008336 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07008337 )
8338 {
8339 switch(type)
8340 {
8341 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008342 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008343 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05308344
8345 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308346#ifdef FEATURE_WLAN_TDLS
8347
8348 /* A Mutex Lock is introduced while changing the mode to
8349 * protect the concurrent access for the Adapters by TDLS
8350 * module.
8351 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308352 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308353#endif
c_hpothu002231a2015-02-05 14:58:51 +05308354 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008355 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008356 //Check for sub-string p2p to confirm its a p2p interface
8357 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008358 {
8359 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8360 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8361 }
8362 else
8363 {
8364 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008365 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008366 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008367 hdd_set_conparam(0);
8368 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
8370 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308371#ifdef FEATURE_WLAN_TDLS
8372 mutex_unlock(&pHddCtx->tdls_lock);
8373#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05308374 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008375 if( VOS_STATUS_SUCCESS != status )
8376 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07008377 /* In case of JB, for P2P-GO, only change interface will be called,
8378 * This is the right place to enable back bmps_imps()
8379 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308380 if (pHddCtx->hdd_wlan_suspended)
8381 {
8382 hdd_set_pwrparams(pHddCtx);
8383 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008384 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008385 goto done;
8386 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008387 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008388 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008389 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8390 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008391 goto done;
8392 default:
8393 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8394 __func__);
8395 return -EOPNOTSUPP;
8396
8397 }
8398
8399 }
8400 else
8401 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308402 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
8403 __func__, hdd_device_modetoString(pAdapter->device_mode),
8404 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008405 return -EOPNOTSUPP;
8406 }
8407
8408
8409 if(pRoamProfile)
8410 {
8411 if ( LastBSSType != pRoamProfile->BSSType )
8412 {
8413 /*interface type changed update in wiphy structure*/
8414 wdev->iftype = type;
8415
8416 /*the BSS mode changed, We need to issue disconnect
8417 if connected or in IBSS disconnect state*/
8418 if ( hdd_connGetConnectedBssType(
8419 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
8420 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
8421 {
8422 /*need to issue a disconnect to CSR.*/
8423 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8424 if( eHAL_STATUS_SUCCESS ==
8425 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8426 pAdapter->sessionId,
8427 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
8428 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308429 ret = wait_for_completion_interruptible_timeout(
8430 &pAdapter->disconnect_comp_var,
8431 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8432 if (ret <= 0)
8433 {
8434 hddLog(VOS_TRACE_LEVEL_ERROR,
8435 FL("wait on disconnect_comp_var failed %ld"), ret);
8436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008437 }
8438 }
8439 }
8440 }
8441
8442done:
8443 /*set bitmask based on updated value*/
8444 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07008445
8446 /* Only STA mode support TM now
8447 * all other mode, TM feature should be disabled */
8448 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
8449 (~VOS_STA & pHddCtx->concurrency_mode) )
8450 {
8451 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
8452 }
8453
Jeff Johnson295189b2012-06-20 16:38:30 -07008454#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308455 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05308456 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07008457 {
8458 //we are ok to do AMP
8459 pHddCtx->isAmpAllowed = VOS_TRUE;
8460 }
8461#endif //WLAN_BTAMP_FEATURE
8462 EXIT();
8463 return 0;
8464}
8465
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308466/*
8467 * FUNCTION: wlan_hdd_cfg80211_change_iface
8468 * wrapper function to protect the actual implementation from SSR.
8469 */
8470int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
8471 struct net_device *ndev,
8472 enum nl80211_iftype type,
8473 u32 *flags,
8474 struct vif_params *params
8475 )
8476{
8477 int ret;
8478
8479 vos_ssr_protect(__func__);
8480 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
8481 vos_ssr_unprotect(__func__);
8482
8483 return ret;
8484}
8485
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008486#ifdef FEATURE_WLAN_TDLS
8487static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
8488 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
8489{
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008490 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008491 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308492 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308493 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308494 hdd_adapter_t *pAdapter;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008495
8496 ENTER();
8497
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308498 if (!dev) {
8499 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
8500 return -EINVAL;
8501 }
8502
8503 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8504 if (!pAdapter) {
8505 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
8506 return -EINVAL;
8507 }
8508
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308509 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008510 {
8511 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8512 "Invalid arguments");
8513 return -EINVAL;
8514 }
Hoonki Lee27511902013-03-14 18:19:06 -07008515
8516 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
8517 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
8518 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308519 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -07008520 "%s: TDLS mode is disabled OR not enabled in FW."
8521 MAC_ADDRESS_STR " Request declined.",
8522 __func__, MAC_ADDR_ARRAY(mac));
8523 return -ENOTSUPP;
8524 }
8525
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008526 if (pHddCtx->isLogpInProgress)
8527 {
8528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8529 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05308530 wlan_hdd_tdls_set_link_status(pAdapter,
8531 mac,
8532 eTDLS_LINK_IDLE,
8533 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008534 return -EBUSY;
8535 }
8536
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308537 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05308538 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008539
8540 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308541 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008542 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
8543 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308544 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008545 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008546 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308547 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008548
8549 /* in add station, we accept existing valid staId if there is */
8550 if ((0 == update) &&
8551 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
8552 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008553 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308554 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008555 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008556 " link_status %d. staId %d. add station ignored.",
8557 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
8558 return 0;
8559 }
8560 /* in change station, we accept only when staId is valid */
8561 if ((1 == update) &&
8562 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
8563 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
8564 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308565 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008566 "%s: " MAC_ADDRESS_STR
8567 " link status %d. staId %d. change station %s.",
8568 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
8569 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
8570 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008571 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008572
8573 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05308574 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008575 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008576 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8577 "%s: " MAC_ADDRESS_STR
8578 " TDLS setup is ongoing. Request declined.",
8579 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07008580 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008581 }
8582
8583 /* first to check if we reached to maximum supported TDLS peer.
8584 TODO: for now, return -EPERM looks working fine,
8585 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308586 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
8587 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008588 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008589 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8590 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308591 " TDLS Max peer already connected. Request declined."
8592 " Num of peers (%d), Max allowed (%d).",
8593 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
8594 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008595 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008596 }
8597 else
8598 {
8599 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308600 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008601 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008602 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008603 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8604 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
8605 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008606 return -EPERM;
8607 }
8608 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008609 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05308610 wlan_hdd_tdls_set_link_status(pAdapter,
8611 mac,
8612 eTDLS_LINK_CONNECTING,
8613 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008614
Jeff Johnsond75fe012013-04-06 10:53:06 -07008615 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308616 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008617 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008619 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008620 if(StaParams->htcap_present)
8621 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008623 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008625 "ht_capa->extended_capabilities: %0x",
8626 StaParams->HTCap.extendedHtCapInfo);
8627 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008629 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008631 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008632 if(StaParams->vhtcap_present)
8633 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008635 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
8636 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
8637 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
8638 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008639 {
8640 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008641 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008642 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308643 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008644 "[%d]: %x ", i, StaParams->supported_rates[i]);
8645 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07008646 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308647 else if ((1 == update) && (NULL == StaParams))
8648 {
8649 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8650 "%s : update is true, but staParams is NULL. Error!", __func__);
8651 return -EPERM;
8652 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008653
8654 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
8655
8656 if (!update)
8657 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308658 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008659 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308660 if (ret != eHAL_STATUS_SUCCESS) {
8661 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to add TDLS peer STA"));
8662 return -EPERM;
8663 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008664 }
8665 else
8666 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308667 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008668 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308669 if (ret != eHAL_STATUS_SUCCESS) {
8670 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
8671 return -EPERM;
8672 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008673 }
8674
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308675 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008676 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
8677
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308678 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008679 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308681 "%s: timeout waiting for tdls add station indication %ld",
8682 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008683 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008684 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308685
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008686 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
8687 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008689 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008690 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008691 }
8692
8693 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008694
8695error:
Atul Mittal115287b2014-07-08 13:26:33 +05308696 wlan_hdd_tdls_set_link_status(pAdapter,
8697 mac,
8698 eTDLS_LINK_IDLE,
8699 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008700 return -EPERM;
8701
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008702}
8703#endif
8704
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308705static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008706 struct net_device *dev,
8707 u8 *mac,
8708 struct station_parameters *params)
8709{
8710 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308711 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308712 hdd_context_t *pHddCtx;
8713 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008714 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308715 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008716#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008717 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008718 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308719 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008720#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008721
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308722 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308723
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308724 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308725 if ((NULL == pAdapter))
8726 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308728 "invalid adapter ");
8729 return -EINVAL;
8730 }
8731
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308732 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8733 TRACE_CODE_HDD_CHANGE_STATION,
8734 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05308735 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308736
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308737 ret = wlan_hdd_validate_context(pHddCtx);
8738 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +05308739 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308740 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308741 }
8742
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308743 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8744
8745 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008746 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8748 "invalid HDD station context");
8749 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008751 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
8752
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008753 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
8754 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07008755 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008756 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07008757 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308758 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008759 WLANTL_STA_AUTHENTICATED);
8760
Gopichand Nakkala29149562013-05-10 21:43:41 +05308761 if (status != VOS_STATUS_SUCCESS)
8762 {
8763 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8764 "%s: Not able to change TL state to AUTHENTICATED", __func__);
8765 return -EINVAL;
8766 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008767 }
8768 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07008769 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
8770 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308771#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008772 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
8773 StaParams.capability = params->capability;
8774 StaParams.uapsd_queues = params->uapsd_queues;
8775 StaParams.max_sp = params->max_sp;
8776
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308777 /* Convert (first channel , number of channels) tuple to
8778 * the total list of channels. This goes with the assumption
8779 * that if the first channel is < 14, then the next channels
8780 * are an incremental of 1 else an incremental of 4 till the number
8781 * of channels.
8782 */
8783 if (0 != params->supported_channels_len) {
8784 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
8785 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
8786 {
8787 int wifi_chan_index;
8788 StaParams.supported_channels[j] = params->supported_channels[i];
8789 wifi_chan_index =
8790 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
8791 no_of_channels = params->supported_channels[i+1];
8792 for(k=1; k <= no_of_channels; k++)
8793 {
8794 StaParams.supported_channels[j+1] =
8795 StaParams.supported_channels[j] + wifi_chan_index;
8796 j+=1;
8797 }
8798 }
8799 StaParams.supported_channels_len = j;
8800 }
8801 vos_mem_copy(StaParams.supported_oper_classes,
8802 params->supported_oper_classes,
8803 params->supported_oper_classes_len);
8804 StaParams.supported_oper_classes_len =
8805 params->supported_oper_classes_len;
8806
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008807 if (0 != params->ext_capab_len)
8808 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
8809 sizeof(StaParams.extn_capability));
8810
8811 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008812 {
8813 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008814 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008815 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008816
8817 StaParams.supported_rates_len = params->supported_rates_len;
8818
8819 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
8820 * The supported_rates array , for all the structures propogating till Add Sta
8821 * to the firmware has to be modified , if the supplicant (ieee80211) is
8822 * modified to send more rates.
8823 */
8824
8825 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
8826 */
8827 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
8828 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
8829
8830 if (0 != StaParams.supported_rates_len) {
8831 int i = 0;
8832 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
8833 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008834 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008835 "Supported Rates with Length %d", StaParams.supported_rates_len);
8836 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008837 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008838 "[%d]: %0x", i, StaParams.supported_rates[i]);
8839 }
8840
8841 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008842 {
8843 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008844 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008845 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008846
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008847 if (0 != params->ext_capab_len ) {
8848 /*Define A Macro : TODO Sunil*/
8849 if ((1<<4) & StaParams.extn_capability[3]) {
8850 isBufSta = 1;
8851 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308852 /* TDLS Channel Switching Support */
8853 if ((1<<6) & StaParams.extn_capability[3]) {
8854 isOffChannelSupported = 1;
8855 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008856 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308857 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
8858 &StaParams, isBufSta,
8859 isOffChannelSupported);
8860
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308861 if (VOS_STATUS_SUCCESS != status) {
8862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8863 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
8864 return -EINVAL;
8865 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008866 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
8867
8868 if (VOS_STATUS_SUCCESS != status) {
8869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8870 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
8871 return -EINVAL;
8872 }
8873 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008874#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05308875 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008876 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008877 return status;
8878}
8879
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308880static int wlan_hdd_change_station(struct wiphy *wiphy,
8881 struct net_device *dev,
8882 u8 *mac,
8883 struct station_parameters *params)
8884{
8885 int ret;
8886
8887 vos_ssr_protect(__func__);
8888 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
8889 vos_ssr_unprotect(__func__);
8890
8891 return ret;
8892}
8893
Jeff Johnson295189b2012-06-20 16:38:30 -07008894/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308895 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008896 * This function is used to initialize the key information
8897 */
8898#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308899static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008900 struct net_device *ndev,
8901 u8 key_index, bool pairwise,
8902 const u8 *mac_addr,
8903 struct key_params *params
8904 )
8905#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308906static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008907 struct net_device *ndev,
8908 u8 key_index, const u8 *mac_addr,
8909 struct key_params *params
8910 )
8911#endif
8912{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008913 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07008914 tCsrRoamSetKey setKey;
8915 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308916 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008917 v_U32_t roamId= 0xFF;
8918 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008919 hdd_hostapd_state_t *pHostapdState;
8920 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008921 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308922 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008923
8924 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308925
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308926 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8927 TRACE_CODE_HDD_CFG80211_ADD_KEY,
8928 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308929 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8930 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308931 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008932 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308933 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008934 }
8935
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308936 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8937 __func__, hdd_device_modetoString(pAdapter->device_mode),
8938 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008939
8940 if (CSR_MAX_NUM_KEY <= key_index)
8941 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008942 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008943 key_index);
8944
8945 return -EINVAL;
8946 }
8947
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008948 if (CSR_MAX_KEY_LEN < params->key_len)
8949 {
8950 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
8951 params->key_len);
8952
8953 return -EINVAL;
8954 }
8955
8956 hddLog(VOS_TRACE_LEVEL_INFO,
8957 "%s: called with key index = %d & key length %d",
8958 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07008959
8960 /*extract key idx, key len and key*/
8961 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8962 setKey.keyId = key_index;
8963 setKey.keyLength = params->key_len;
8964 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
8965
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008966 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07008967 {
8968 case WLAN_CIPHER_SUITE_WEP40:
8969 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
8970 break;
8971
8972 case WLAN_CIPHER_SUITE_WEP104:
8973 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
8974 break;
8975
8976 case WLAN_CIPHER_SUITE_TKIP:
8977 {
8978 u8 *pKey = &setKey.Key[0];
8979 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
8980
8981 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
8982
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008983 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07008984
8985 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008986 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008987 |--------------|----------|----------|
8988 <---16bytes---><--8bytes--><--8bytes-->
8989
8990 */
8991 /*Sme expects the 32 bytes key to be in the below order
8992
8993 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008994 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008995 |--------------|----------|----------|
8996 <---16bytes---><--8bytes--><--8bytes-->
8997 */
8998 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008999 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07009000
9001 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009002 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009003
9004 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009005 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009006
9007
9008 break;
9009 }
9010
9011 case WLAN_CIPHER_SUITE_CCMP:
9012 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
9013 break;
9014
9015#ifdef FEATURE_WLAN_WAPI
9016 case WLAN_CIPHER_SUITE_SMS4:
9017 {
9018 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9019 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
9020 params->key, params->key_len);
9021 return 0;
9022 }
9023#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009024
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009025#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009026 case WLAN_CIPHER_SUITE_KRK:
9027 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
9028 break;
9029#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009030
9031#ifdef WLAN_FEATURE_11W
9032 case WLAN_CIPHER_SUITE_AES_CMAC:
9033 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07009034 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07009035#endif
9036
Jeff Johnson295189b2012-06-20 16:38:30 -07009037 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009038 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07009039 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309040 status = -EOPNOTSUPP;
9041 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009042 }
9043
9044 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
9045 __func__, setKey.encType);
9046
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009047 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07009048#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9049 (!pairwise)
9050#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009051 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07009052#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009053 )
9054 {
9055 /* set group key*/
9056 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9057 "%s- %d: setting Broadcast key",
9058 __func__, __LINE__);
9059 setKey.keyDirection = eSIR_RX_ONLY;
9060 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9061 }
9062 else
9063 {
9064 /* set pairwise key*/
9065 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9066 "%s- %d: setting pairwise key",
9067 __func__, __LINE__);
9068 setKey.keyDirection = eSIR_TX_RX;
9069 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9070 }
9071 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
9072 {
9073 setKey.keyDirection = eSIR_TX_RX;
9074 /*Set the group key*/
9075 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9076 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009077
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009078 if ( 0 != status )
9079 {
9080 hddLog(VOS_TRACE_LEVEL_ERROR,
9081 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309082 status = -EINVAL;
9083 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009084 }
9085 /*Save the keys here and call sme_RoamSetKey for setting
9086 the PTK after peer joins the IBSS network*/
9087 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
9088 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309089 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009090 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05309091 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
9092 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
9093 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009094 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009095 if( pHostapdState->bssState == BSS_START )
9096 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009097 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9098 vos_status = wlan_hdd_check_ula_done(pAdapter);
9099
9100 if ( vos_status != VOS_STATUS_SUCCESS )
9101 {
9102 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9103 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9104 __LINE__, vos_status );
9105
9106 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9107
9108 status = -EINVAL;
9109 goto end;
9110 }
9111
Jeff Johnson295189b2012-06-20 16:38:30 -07009112 status = WLANSAP_SetKeySta( pVosContext, &setKey);
9113
9114 if ( status != eHAL_STATUS_SUCCESS )
9115 {
9116 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9117 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9118 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309119 status = -EINVAL;
9120 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009121 }
9122 }
9123
9124 /* Saving WEP keys */
9125 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
9126 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
9127 {
9128 //Save the wep key in ap context. Issue setkey after the BSS is started.
9129 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9130 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
9131 }
9132 else
9133 {
9134 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009135 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009136 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
9137 }
9138 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009139 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9140 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009141 {
9142 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9143 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9144
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309145#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9146 if (!pairwise)
9147#else
9148 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9149#endif
9150 {
9151 /* set group key*/
9152 if (pHddStaCtx->roam_info.deferKeyComplete)
9153 {
9154 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9155 "%s- %d: Perform Set key Complete",
9156 __func__, __LINE__);
9157 hdd_PerformRoamSetKeyComplete(pAdapter);
9158 }
9159 }
9160
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
9162
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08009163 pWextState->roamProfile.Keys.defaultIndex = key_index;
9164
9165
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009166 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009167 params->key, params->key_len);
9168
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309169
Jeff Johnson295189b2012-06-20 16:38:30 -07009170 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9171
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309172 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009173 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309174 __func__, setKey.peerMac[0], setKey.peerMac[1],
9175 setKey.peerMac[2], setKey.peerMac[3],
9176 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009177 setKey.keyDirection);
9178
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009179 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +05309180
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009181 if ( vos_status != VOS_STATUS_SUCCESS )
9182 {
9183 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009184 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9185 __LINE__, vos_status );
9186
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009187 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009188
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009189 status = -EINVAL;
9190 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009191
9192 }
9193
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009194#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309195 /* The supplicant may attempt to set the PTK once pre-authentication
9196 is done. Save the key in the UMAC and include it in the ADD BSS
9197 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009198 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309199 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009200 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309201 hddLog(VOS_TRACE_LEVEL_INFO_MED,
9202 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309203 status = 0;
9204 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309205 }
9206 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
9207 {
9208 hddLog(VOS_TRACE_LEVEL_ERROR,
9209 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309210 status = -EINVAL;
9211 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009212 }
9213#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07009214
9215 /* issue set key request to SME*/
9216 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9217 pAdapter->sessionId, &setKey, &roamId );
9218
9219 if ( 0 != status )
9220 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309221 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009222 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
9223 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309224 status = -EINVAL;
9225 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009226 }
9227
9228
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309229 /* in case of IBSS as there was no information available about WEP keys during
9230 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07009231 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309232 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
9233 !( ( IW_AUTH_KEY_MGMT_802_1X
9234 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07009235 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
9236 )
9237 &&
9238 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
9239 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
9240 )
9241 )
9242 {
9243 setKey.keyDirection = eSIR_RX_ONLY;
9244 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9245
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309246 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009247 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309248 __func__, setKey.peerMac[0], setKey.peerMac[1],
9249 setKey.peerMac[2], setKey.peerMac[3],
9250 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009251 setKey.keyDirection);
9252
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309253 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009254 pAdapter->sessionId, &setKey, &roamId );
9255
9256 if ( 0 != status )
9257 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309258 hddLog(VOS_TRACE_LEVEL_ERROR,
9259 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009260 __func__, status);
9261 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309262 status = -EINVAL;
9263 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009264 }
9265 }
9266 }
9267
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309268end:
9269 /* Need to clear any trace of key value in the memory.
9270 * Thus zero out the memory even though it is local
9271 * variable.
9272 */
9273 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309274 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309275 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009276}
9277
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309278#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9279static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9280 struct net_device *ndev,
9281 u8 key_index, bool pairwise,
9282 const u8 *mac_addr,
9283 struct key_params *params
9284 )
9285#else
9286static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9287 struct net_device *ndev,
9288 u8 key_index, const u8 *mac_addr,
9289 struct key_params *params
9290 )
9291#endif
9292{
9293 int ret;
9294 vos_ssr_protect(__func__);
9295#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9296 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
9297 mac_addr, params);
9298#else
9299 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
9300 params);
9301#endif
9302 vos_ssr_unprotect(__func__);
9303
9304 return ret;
9305}
9306
Jeff Johnson295189b2012-06-20 16:38:30 -07009307/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309308 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009309 * This function is used to get the key information
9310 */
9311#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309312static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309313 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009314 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309315 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009316 const u8 *mac_addr, void *cookie,
9317 void (*callback)(void *cookie, struct key_params*)
9318 )
9319#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309320static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309321 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009322 struct net_device *ndev,
9323 u8 key_index, const u8 *mac_addr, void *cookie,
9324 void (*callback)(void *cookie, struct key_params*)
9325 )
9326#endif
9327{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309328 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309329 hdd_wext_state_t *pWextState = NULL;
9330 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009331 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309332 hdd_context_t *pHddCtx;
9333 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009334
9335 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309336
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309337 if (NULL == pAdapter)
9338 {
9339 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9340 "%s: HDD adapter is Null", __func__);
9341 return -ENODEV;
9342 }
9343
9344 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9345 ret = wlan_hdd_validate_context(pHddCtx);
9346 if (0 != ret)
9347 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309348 return ret;
9349 }
9350
9351 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9352 pRoamProfile = &(pWextState->roamProfile);
9353
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309354 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9355 __func__, hdd_device_modetoString(pAdapter->device_mode),
9356 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309357
Jeff Johnson295189b2012-06-20 16:38:30 -07009358 memset(&params, 0, sizeof(params));
9359
9360 if (CSR_MAX_NUM_KEY <= key_index)
9361 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309362 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07009363 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309364 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009365
9366 switch(pRoamProfile->EncryptionType.encryptionType[0])
9367 {
9368 case eCSR_ENCRYPT_TYPE_NONE:
9369 params.cipher = IW_AUTH_CIPHER_NONE;
9370 break;
9371
9372 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
9373 case eCSR_ENCRYPT_TYPE_WEP40:
9374 params.cipher = WLAN_CIPHER_SUITE_WEP40;
9375 break;
9376
9377 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
9378 case eCSR_ENCRYPT_TYPE_WEP104:
9379 params.cipher = WLAN_CIPHER_SUITE_WEP104;
9380 break;
9381
9382 case eCSR_ENCRYPT_TYPE_TKIP:
9383 params.cipher = WLAN_CIPHER_SUITE_TKIP;
9384 break;
9385
9386 case eCSR_ENCRYPT_TYPE_AES:
9387 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
9388 break;
9389
9390 default:
9391 params.cipher = IW_AUTH_CIPHER_NONE;
9392 break;
9393 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309394
c_hpothuaaf19692014-05-17 17:01:48 +05309395 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9396 TRACE_CODE_HDD_CFG80211_GET_KEY,
9397 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309398
Jeff Johnson295189b2012-06-20 16:38:30 -07009399 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
9400 params.seq_len = 0;
9401 params.seq = NULL;
9402 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
9403 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309404 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009405 return 0;
9406}
9407
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309408#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9409static int wlan_hdd_cfg80211_get_key(
9410 struct wiphy *wiphy,
9411 struct net_device *ndev,
9412 u8 key_index, bool pairwise,
9413 const u8 *mac_addr, void *cookie,
9414 void (*callback)(void *cookie, struct key_params*)
9415 )
9416#else
9417static int wlan_hdd_cfg80211_get_key(
9418 struct wiphy *wiphy,
9419 struct net_device *ndev,
9420 u8 key_index, const u8 *mac_addr, void *cookie,
9421 void (*callback)(void *cookie, struct key_params*)
9422 )
9423#endif
9424{
9425 int ret;
9426
9427 vos_ssr_protect(__func__);
9428#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9429 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
9430 mac_addr, cookie, callback);
9431#else
9432 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
9433 callback);
9434#endif
9435 vos_ssr_unprotect(__func__);
9436
9437 return ret;
9438}
9439
Jeff Johnson295189b2012-06-20 16:38:30 -07009440/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309441 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009442 * This function is used to delete the key information
9443 */
9444#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309445static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009446 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309447 u8 key_index,
9448 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009449 const u8 *mac_addr
9450 )
9451#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309452static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009453 struct net_device *ndev,
9454 u8 key_index,
9455 const u8 *mac_addr
9456 )
9457#endif
9458{
9459 int status = 0;
9460
9461 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309462 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009463 //it is observed that this is invalidating peer
9464 //key index whenever re-key is done. This is affecting data link.
9465 //It should be ok to ignore del_key.
9466#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309467 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
9468 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009469 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
9470 tCsrRoamSetKey setKey;
9471 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309472
Jeff Johnson295189b2012-06-20 16:38:30 -07009473 ENTER();
9474
9475 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
9476 __func__,pAdapter->device_mode);
9477
9478 if (CSR_MAX_NUM_KEY <= key_index)
9479 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309480 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009481 key_index);
9482
9483 return -EINVAL;
9484 }
9485
9486 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9487 setKey.keyId = key_index;
9488
9489 if (mac_addr)
9490 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9491 else
9492 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
9493
9494 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
9495
9496 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009497 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309498 )
9499 {
9500
9501 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07009502 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9503 if( pHostapdState->bssState == BSS_START)
9504 {
9505 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309506
Jeff Johnson295189b2012-06-20 16:38:30 -07009507 if ( status != eHAL_STATUS_SUCCESS )
9508 {
9509 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9510 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9511 __LINE__, status );
9512 }
9513 }
9514 }
9515 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309516 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07009517 )
9518 {
9519 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9520
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309521 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9522
9523 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009524 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309525 __func__, setKey.peerMac[0], setKey.peerMac[1],
9526 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07009527 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309528 if(pAdapter->sessionCtx.station.conn_info.connState ==
9529 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07009530 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309531 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009532 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309533
Jeff Johnson295189b2012-06-20 16:38:30 -07009534 if ( 0 != status )
9535 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309536 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009537 "%s: sme_RoamSetKey failure, returned %d",
9538 __func__, status);
9539 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9540 return -EINVAL;
9541 }
9542 }
9543 }
9544#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07009545 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009546 return status;
9547}
9548
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309549#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9550static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9551 struct net_device *ndev,
9552 u8 key_index,
9553 bool pairwise,
9554 const u8 *mac_addr
9555 )
9556#else
9557static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9558 struct net_device *ndev,
9559 u8 key_index,
9560 const u8 *mac_addr
9561 )
9562#endif
9563{
9564 int ret;
9565
9566 vos_ssr_protect(__func__);
9567#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9568 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
9569 mac_addr);
9570#else
9571 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
9572#endif
9573 vos_ssr_unprotect(__func__);
9574
9575 return ret;
9576}
9577
Jeff Johnson295189b2012-06-20 16:38:30 -07009578/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309579 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009580 * This function is used to set the default tx key index
9581 */
9582#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309583static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009584 struct net_device *ndev,
9585 u8 key_index,
9586 bool unicast, bool multicast)
9587#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309588static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009589 struct net_device *ndev,
9590 u8 key_index)
9591#endif
9592{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309593 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309594 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05309595 hdd_wext_state_t *pWextState;
9596 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309597 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009598
9599 ENTER();
9600
Gopichand Nakkala29149562013-05-10 21:43:41 +05309601 if ((NULL == pAdapter))
9602 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05309604 "invalid adapter");
9605 return -EINVAL;
9606 }
9607
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309608 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9609 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
9610 pAdapter->sessionId, key_index));
9611
Gopichand Nakkala29149562013-05-10 21:43:41 +05309612 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9613 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9614
9615 if ((NULL == pWextState) || (NULL == pHddStaCtx))
9616 {
9617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9618 "invalid Wext state or HDD context");
9619 return -EINVAL;
9620 }
9621
Arif Hussain6d2a3322013-11-17 19:50:10 -08009622 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009623 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309624
Jeff Johnson295189b2012-06-20 16:38:30 -07009625 if (CSR_MAX_NUM_KEY <= key_index)
9626 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309627 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009628 key_index);
9629
9630 return -EINVAL;
9631 }
9632
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309633 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9634 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309635 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009636 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309637 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009638 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309639
Jeff Johnson295189b2012-06-20 16:38:30 -07009640 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07009641 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309642 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009643 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05309644 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08009645 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309646 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08009647 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309649 {
9650 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07009651 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309652
Jeff Johnson295189b2012-06-20 16:38:30 -07009653 tCsrRoamSetKey setKey;
9654 v_U32_t roamId= 0xFF;
9655 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309656
9657 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009658 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309659
Jeff Johnson295189b2012-06-20 16:38:30 -07009660 Keys->defaultIndex = (u8)key_index;
9661 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9662 setKey.keyId = key_index;
9663 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309664
9665 vos_mem_copy(&setKey.Key[0],
9666 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009667 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309668
Gopichand Nakkala29149562013-05-10 21:43:41 +05309669 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309670
9671 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07009672 &pHddStaCtx->conn_info.bssId[0],
9673 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309674
Gopichand Nakkala29149562013-05-10 21:43:41 +05309675 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
9676 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
9677 eCSR_ENCRYPT_TYPE_WEP104)
9678 {
9679 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
9680 even though ap is configured for WEP-40 encryption. In this canse the key length
9681 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
9682 type(104) and switching encryption type to 40*/
9683 pWextState->roamProfile.EncryptionType.encryptionType[0] =
9684 eCSR_ENCRYPT_TYPE_WEP40;
9685 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
9686 eCSR_ENCRYPT_TYPE_WEP40;
9687 }
9688
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309689 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07009690 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309691
Jeff Johnson295189b2012-06-20 16:38:30 -07009692 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309693 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009694 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309695
Jeff Johnson295189b2012-06-20 16:38:30 -07009696 if ( 0 != status )
9697 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309698 hddLog(VOS_TRACE_LEVEL_ERROR,
9699 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009700 status);
9701 return -EINVAL;
9702 }
9703 }
9704 }
9705
9706 /* In SoftAp mode setting key direction for default mode */
9707 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
9708 {
9709 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
9710 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
9711 (eCSR_ENCRYPT_TYPE_AES !=
9712 pWextState->roamProfile.EncryptionType.encryptionType[0])
9713 )
9714 {
9715 /* Saving key direction for default key index to TX default */
9716 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9717 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
9718 }
9719 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309720 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009721 return status;
9722}
9723
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309724#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9725static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9726 struct net_device *ndev,
9727 u8 key_index,
9728 bool unicast, bool multicast)
9729#else
9730static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9731 struct net_device *ndev,
9732 u8 key_index)
9733#endif
9734{
9735 int ret;
9736 vos_ssr_protect(__func__);
9737#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9738 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
9739 multicast);
9740#else
9741 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
9742#endif
9743 vos_ssr_unprotect(__func__);
9744
9745 return ret;
9746}
9747
Jeff Johnson295189b2012-06-20 16:38:30 -07009748/*
9749 * FUNCTION: wlan_hdd_cfg80211_inform_bss
9750 * This function is used to inform the BSS details to nl80211 interface.
9751 */
9752static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
9753 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
9754{
9755 struct net_device *dev = pAdapter->dev;
9756 struct wireless_dev *wdev = dev->ieee80211_ptr;
9757 struct wiphy *wiphy = wdev->wiphy;
9758 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
9759 int chan_no;
9760 int ie_length;
9761 const char *ie;
9762 unsigned int freq;
9763 struct ieee80211_channel *chan;
9764 int rssi = 0;
9765 struct cfg80211_bss *bss = NULL;
9766
Jeff Johnson295189b2012-06-20 16:38:30 -07009767 if( NULL == pBssDesc )
9768 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009769 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009770 return bss;
9771 }
9772
9773 chan_no = pBssDesc->channelId;
9774 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
9775 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
9776
9777 if( NULL == ie )
9778 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009779 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009780 return bss;
9781 }
9782
9783#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
9784 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
9785 {
9786 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9787 }
9788 else
9789 {
9790 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9791 }
9792#else
9793 freq = ieee80211_channel_to_frequency(chan_no);
9794#endif
9795
9796 chan = __ieee80211_get_channel(wiphy, freq);
9797
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05309798 if (!chan) {
9799 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
9800 return NULL;
9801 }
9802
Abhishek Singhaee43942014-06-16 18:55:47 +05309803 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07009804
Abhishek Singhaee43942014-06-16 18:55:47 +05309805 return cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309806 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07009807 pBssDesc->capabilityInfo,
9808 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05309809 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07009810}
9811
9812
9813
9814/*
9815 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
9816 * This function is used to inform the BSS details to nl80211 interface.
9817 */
9818struct cfg80211_bss*
9819wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
9820 tSirBssDescription *bss_desc
9821 )
9822{
9823 /*
9824 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
9825 already exists in bss data base of cfg80211 for that particular BSS ID.
9826 Using cfg80211_inform_bss_frame to update the bss entry instead of
9827 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
9828 now there is no possibility to get the mgmt(probe response) frame from PE,
9829 converting bss_desc to ieee80211_mgmt(probe response) and passing to
9830 cfg80211_inform_bss_frame.
9831 */
9832 struct net_device *dev = pAdapter->dev;
9833 struct wireless_dev *wdev = dev->ieee80211_ptr;
9834 struct wiphy *wiphy = wdev->wiphy;
9835 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009836#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9837 qcom_ie_age *qie_age = NULL;
9838 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
9839#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009840 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009841#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009842 const char *ie =
9843 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
9844 unsigned int freq;
9845 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309846 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009847 struct cfg80211_bss *bss_status = NULL;
9848 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
9849 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07009850 hdd_context_t *pHddCtx;
9851 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07009852#ifdef WLAN_OPEN_SOURCE
9853 struct timespec ts;
9854#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009855
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309856
Wilson Yangf80a0542013-10-07 13:02:37 -07009857 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9858 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -07009859 if (0 != status)
9860 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009861 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009862 }
9863
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309864 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07009865 if (!mgmt)
9866 {
9867 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9868 "%s: memory allocation failed ", __func__);
9869 return NULL;
9870 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009871
Jeff Johnson295189b2012-06-20 16:38:30 -07009872 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07009873
9874#ifdef WLAN_OPEN_SOURCE
9875 /* Android does not want the timestamp from the frame.
9876 Instead it wants a monotonic increasing value */
9877 get_monotonic_boottime(&ts);
9878 mgmt->u.probe_resp.timestamp =
9879 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
9880#else
9881 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
9883 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07009884
9885#endif
9886
Jeff Johnson295189b2012-06-20 16:38:30 -07009887 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
9888 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009889
9890#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9891 /* GPS Requirement: need age ie per entry. Using vendor specific. */
9892 /* Assuming this is the last IE, copy at the end */
9893 ie_length -=sizeof(qcom_ie_age);
9894 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
9895 qie_age->element_id = QCOM_VENDOR_IE_ID;
9896 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
9897 qie_age->oui_1 = QCOM_OUI1;
9898 qie_age->oui_2 = QCOM_OUI2;
9899 qie_age->oui_3 = QCOM_OUI3;
9900 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
9901 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
9902#endif
9903
Jeff Johnson295189b2012-06-20 16:38:30 -07009904 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05309905 if (bss_desc->fProbeRsp)
9906 {
9907 mgmt->frame_control |=
9908 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
9909 }
9910 else
9911 {
9912 mgmt->frame_control |=
9913 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
9914 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009915
9916#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309917 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
9919 {
9920 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9921 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309922 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009923 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
9924
9925 {
9926 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9927 }
9928 else
9929 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309930 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
9931 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07009932 kfree(mgmt);
9933 return NULL;
9934 }
9935#else
9936 freq = ieee80211_channel_to_frequency(chan_no);
9937#endif
9938 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009939 /*when the band is changed on the fly using the GUI, three things are done
9940 * 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)
9941 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
9942 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
9943 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
9944 * and discards the channels correponding to previous band and calls back with zero bss results.
9945 * 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
9946 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
9947 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
9948 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
9949 * So drop the bss and continue to next bss.
9950 */
9951 if(chan == NULL)
9952 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309953 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07009954 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009955 return NULL;
9956 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +05309957 /*To keep the rssi icon of the connected AP in the scan window
9958 *and the rssi icon of the wireless networks in sync
9959 * */
9960 if (( eConnectionState_Associated ==
9961 pAdapter->sessionCtx.station.conn_info.connState ) &&
9962 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
9963 pAdapter->sessionCtx.station.conn_info.bssId,
9964 WNI_CFG_BSSID_LEN)) &&
9965 (pHddCtx->hdd_wlan_suspended == FALSE))
9966 {
9967 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
9968 rssi = (pAdapter->rssi * 100);
9969 }
9970 else
9971 {
9972 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
9973 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009974
Nirav Shah20ac06f2013-12-12 18:14:06 +05309975 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +05309976 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
9977 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +05309978
Jeff Johnson295189b2012-06-20 16:38:30 -07009979 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
9980 frame_len, rssi, GFP_KERNEL);
9981 kfree(mgmt);
9982 return bss_status;
9983}
9984
9985/*
9986 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
9987 * This function is used to update the BSS data base of CFG8011
9988 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309989struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07009990 tCsrRoamInfo *pRoamInfo
9991 )
9992{
9993 tCsrRoamConnectedProfile roamProfile;
9994 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9995 struct cfg80211_bss *bss = NULL;
9996
9997 ENTER();
9998
9999 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
10000 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
10001
10002 if (NULL != roamProfile.pBssDesc)
10003 {
Girish Gowlif4b68022014-08-28 23:18:57 +053010004 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10005 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010006
10007 if (NULL == bss)
10008 {
10009 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
10010 __func__);
10011 }
10012
10013 sme_RoamFreeConnectProfile(hHal, &roamProfile);
10014 }
10015 else
10016 {
10017 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
10018 __func__);
10019 }
10020 return bss;
10021}
10022
10023/*
10024 * FUNCTION: wlan_hdd_cfg80211_update_bss
10025 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010026static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
10027 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070010028 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010029{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010030 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010031 tCsrScanResultInfo *pScanResult;
10032 eHalStatus status = 0;
10033 tScanResultHandle pResult;
10034 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070010035 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010036 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070010037 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010038
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010039 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10040 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
10041 NO_SESSION, pAdapter->sessionId));
10042
Wilson Yangf80a0542013-10-07 13:02:37 -070010043 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10044
10045 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -070010046 {
Wilson Yangf80a0542013-10-07 13:02:37 -070010047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10048 "%s:LOGP in Progress. Ignore!!!",__func__);
10049 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010050 }
10051
Wilson Yangf80a0542013-10-07 13:02:37 -070010052
10053 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +053010054 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -070010055 {
10056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10057 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
10058 return VOS_STATUS_E_PERM;
10059 }
10060
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010061 if (pAdapter->request != NULL)
10062 {
10063 if ((pAdapter->request->n_ssids == 1)
10064 && (pAdapter->request->ssids != NULL)
10065 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
10066 is_p2p_scan = true;
10067 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010068 /*
10069 * start getting scan results and populate cgf80211 BSS database
10070 */
10071 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
10072
10073 /* no scan results */
10074 if (NULL == pResult)
10075 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010076 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
10077 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053010078 wlan_hdd_get_frame_logs(pAdapter,
10079 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070010080 return status;
10081 }
10082
10083 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
10084
10085 while (pScanResult)
10086 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010087 /*
10088 * cfg80211_inform_bss() is not updating ie field of bss entry, if
10089 * entry already exists in bss data base of cfg80211 for that
10090 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
10091 * bss entry instead of cfg80211_inform_bss, But this call expects
10092 * mgmt packet as input. As of now there is no possibility to get
10093 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070010094 * ieee80211_mgmt(probe response) and passing to c
10095 * fg80211_inform_bss_frame.
10096 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010097 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
10098 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
10099 {
10100 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Non P2P BSS skipped: =%s:"),
10101 pScanResult->ssId.ssId);
10102 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10103 continue; //Skip the non p2p bss entries
10104 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010105 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10106 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010107
Jeff Johnson295189b2012-06-20 16:38:30 -070010108
10109 if (NULL == bss_status)
10110 {
10111 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010112 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010113 }
10114 else
10115 {
Yue Maf49ba872013-08-19 12:04:25 -070010116 cfg80211_put_bss(
10117#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10118 wiphy,
10119#endif
10120 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010121 }
10122
10123 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10124 }
10125
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010126 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010127 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010128 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010129}
10130
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010131void
10132hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
10133{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010134 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080010135 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010136} /****** end hddPrintMacAddr() ******/
10137
10138void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010139hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010140{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010141 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010142 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010143 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
10144 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
10145 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010146} /****** end hddPrintPmkId() ******/
10147
10148//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
10149//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
10150
10151//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
10152//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
10153
10154#define dump_bssid(bssid) \
10155 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010156 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
10157 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010158 }
10159
10160#define dump_pmkid(pMac, pmkid) \
10161 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010162 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
10163 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010164 }
10165
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070010166#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010167/*
10168 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
10169 * This function is used to notify the supplicant of a new PMKSA candidate.
10170 */
10171int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010172 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010173 int index, bool preauth )
10174{
Jeff Johnsone7245742012-09-05 17:12:55 -070010175#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010176 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010177 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010178
10179 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070010180 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010181
10182 if( NULL == pRoamInfo )
10183 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010184 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010185 return -EINVAL;
10186 }
10187
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010188 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
10189 {
10190 dump_bssid(pRoamInfo->bssid);
10191 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010192 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010193 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010194#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010195 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010196}
10197#endif //FEATURE_WLAN_LFR
10198
Yue Maef608272013-04-08 23:09:17 -070010199#ifdef FEATURE_WLAN_LFR_METRICS
10200/*
10201 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
10202 * 802.11r/LFR metrics reporting function to report preauth initiation
10203 *
10204 */
10205#define MAX_LFR_METRICS_EVENT_LENGTH 100
10206VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
10207 tCsrRoamInfo *pRoamInfo)
10208{
10209 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10210 union iwreq_data wrqu;
10211
10212 ENTER();
10213
10214 if (NULL == pAdapter)
10215 {
10216 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10217 return VOS_STATUS_E_FAILURE;
10218 }
10219
10220 /* create the event */
10221 memset(&wrqu, 0, sizeof(wrqu));
10222 memset(metrics_notification, 0, sizeof(metrics_notification));
10223
10224 wrqu.data.pointer = metrics_notification;
10225 wrqu.data.length = scnprintf(metrics_notification,
10226 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
10227 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10228
10229 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10230
10231 EXIT();
10232
10233 return VOS_STATUS_SUCCESS;
10234}
10235
10236/*
10237 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
10238 * 802.11r/LFR metrics reporting function to report preauth completion
10239 * or failure
10240 */
10241VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
10242 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
10243{
10244 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10245 union iwreq_data wrqu;
10246
10247 ENTER();
10248
10249 if (NULL == pAdapter)
10250 {
10251 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10252 return VOS_STATUS_E_FAILURE;
10253 }
10254
10255 /* create the event */
10256 memset(&wrqu, 0, sizeof(wrqu));
10257 memset(metrics_notification, 0, sizeof(metrics_notification));
10258
10259 scnprintf(metrics_notification, sizeof(metrics_notification),
10260 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
10261 MAC_ADDR_ARRAY(pRoamInfo->bssid));
10262
10263 if (1 == preauth_status)
10264 strncat(metrics_notification, " TRUE", 5);
10265 else
10266 strncat(metrics_notification, " FALSE", 6);
10267
10268 wrqu.data.pointer = metrics_notification;
10269 wrqu.data.length = strlen(metrics_notification);
10270
10271 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10272
10273 EXIT();
10274
10275 return VOS_STATUS_SUCCESS;
10276}
10277
10278/*
10279 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
10280 * 802.11r/LFR metrics reporting function to report handover initiation
10281 *
10282 */
10283VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
10284 tCsrRoamInfo *pRoamInfo)
10285{
10286 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10287 union iwreq_data wrqu;
10288
10289 ENTER();
10290
10291 if (NULL == pAdapter)
10292 {
10293 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10294 return VOS_STATUS_E_FAILURE;
10295 }
10296
10297 /* create the event */
10298 memset(&wrqu, 0, sizeof(wrqu));
10299 memset(metrics_notification, 0, sizeof(metrics_notification));
10300
10301 wrqu.data.pointer = metrics_notification;
10302 wrqu.data.length = scnprintf(metrics_notification,
10303 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
10304 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10305
10306 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10307
10308 EXIT();
10309
10310 return VOS_STATUS_SUCCESS;
10311}
10312#endif
10313
Jeff Johnson295189b2012-06-20 16:38:30 -070010314/*
10315 * FUNCTION: hdd_cfg80211_scan_done_callback
10316 * scanning callback function, called after finishing scan
10317 *
10318 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010319static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070010320 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
10321{
10322 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010323 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070010324 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010325 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010326 struct cfg80211_scan_request *req = NULL;
10327 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010328 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010329 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010330 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010331 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010332
10333 ENTER();
10334
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010335 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053010336 if (NULL == pHddCtx) {
10337 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010338 goto allow_suspend;
10339 }
10340
10341 pScanInfo = &pHddCtx->scan_info;
10342
Jeff Johnson295189b2012-06-20 16:38:30 -070010343 hddLog(VOS_TRACE_LEVEL_INFO,
10344 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080010345 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010346 __func__, halHandle, pContext, (int) scanId, (int) status);
10347
Kiet Lamac06e2c2013-10-23 16:25:07 +053010348 pScanInfo->mScanPendingCounter = 0;
10349
Jeff Johnson295189b2012-06-20 16:38:30 -070010350 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010351 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070010352 &pScanInfo->scan_req_completion_event,
10353 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010354 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070010355 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010356 hddLog(VOS_TRACE_LEVEL_ERROR,
10357 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070010358 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010359 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010360 }
10361
Yue Maef608272013-04-08 23:09:17 -070010362 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010363 {
10364 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010365 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010366 }
10367
10368 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010369 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070010370 {
10371 hddLog(VOS_TRACE_LEVEL_INFO,
10372 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010373 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070010374 (int) scanId);
10375 }
10376
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010377 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010378 pAdapter);
10379
10380 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010381 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010382
10383
10384 /* If any client wait scan result through WEXT
10385 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010386 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070010387 {
10388 /* The other scan request waiting for current scan finish
10389 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010390 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010391 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010392 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070010393 }
10394 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010395 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010396 {
10397 struct net_device *dev = pAdapter->dev;
10398 union iwreq_data wrqu;
10399 int we_event;
10400 char *msg;
10401
10402 memset(&wrqu, '\0', sizeof(wrqu));
10403 we_event = SIOCGIWSCAN;
10404 msg = NULL;
10405 wireless_send_event(dev, we_event, &wrqu, msg);
10406 }
10407 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010408 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010409
10410 /* Get the Scan Req */
10411 req = pAdapter->request;
10412
10413 if (!req)
10414 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010415 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010416 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010417 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010418 }
10419
Jeff Johnson295189b2012-06-20 16:38:30 -070010420 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070010421 /* Scan is no longer pending */
10422 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010423
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010424 /* last_scan_timestamp is used to decide if new scan
10425 * is needed or not on station interface. If last station
10426 * scan time and new station scan time is less then
10427 * last_scan_timestamp ; driver will return cached scan.
10428 */
10429 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
10430 {
10431 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
10432
10433 if ( req->n_channels )
10434 {
10435 for (i = 0; i < req->n_channels ; i++ )
10436 {
10437 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
10438 }
10439 /* store no of channel scanned */
10440 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
10441 }
10442
10443 }
10444
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070010445 /*
10446 * cfg80211_scan_done informing NL80211 about completion
10447 * of scanning
10448 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010449 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
10450 {
10451 aborted = true;
10452 }
10453 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080010454 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070010455
Siddharth Bhal76972212014-10-15 16:22:51 +053010456 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
10457 /* Generate new random mac addr for next scan */
10458 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
10459 hdd_processSpoofMacAddrRequest(pHddCtx);
10460 }
10461
Jeff Johnsone7245742012-09-05 17:12:55 -070010462allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010463 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010464 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070010465
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010466 /* Acquire wakelock to handle the case where APP's tries to suspend
10467 * immediatly after the driver gets connect request(i.e after scan)
10468 * from supplicant, this result in app's is suspending and not able
10469 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010470 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010471
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010472#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010473 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010474#endif
10475
Jeff Johnson295189b2012-06-20 16:38:30 -070010476 EXIT();
10477 return 0;
10478}
10479
10480/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053010481 * FUNCTION: hdd_isConnectionInProgress
10482 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010483 *
10484 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010485v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010486{
10487 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10488 hdd_station_ctx_t *pHddStaCtx = NULL;
10489 hdd_adapter_t *pAdapter = NULL;
10490 VOS_STATUS status = 0;
10491 v_U8_t staId = 0;
10492 v_U8_t *staMac = NULL;
10493
c_hpothu9b781ba2013-12-30 20:57:45 +053010494 if (TRUE == pHddCtx->btCoexModeSet)
10495 {
10496 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053010497 FL("BTCoex Mode operation in progress"));
10498 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053010499 }
10500
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010501 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10502
10503 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10504 {
10505 pAdapter = pAdapterNode->pAdapter;
10506
10507 if( pAdapter )
10508 {
10509 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010510 "%s: Adapter with device mode %s (%d) exists",
10511 __func__, hdd_device_modetoString(pAdapter->device_mode),
10512 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010513 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053010514 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10515 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
10516 (eConnectionState_Connecting ==
10517 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
10518 {
10519 hddLog(VOS_TRACE_LEVEL_ERROR,
10520 "%s: %p(%d) Connection is in progress", __func__,
10521 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10522 return VOS_TRUE;
10523 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010524 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053010525 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010526 {
10527 hddLog(VOS_TRACE_LEVEL_ERROR,
10528 "%s: %p(%d) Reassociation is in progress", __func__,
10529 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10530 return VOS_TRUE;
10531 }
10532 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010533 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10534 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010535 {
10536 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10537 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010538 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010539 {
10540 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
10541 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010542 "%s: client " MAC_ADDRESS_STR
10543 " is in the middle of WPS/EAPOL exchange.", __func__,
10544 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010545 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010546 }
10547 }
10548 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
10549 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
10550 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010551 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10552 ptSapContext pSapCtx = NULL;
10553 pSapCtx = VOS_GET_SAP_CB(pVosContext);
10554 if(pSapCtx == NULL){
10555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10556 FL("psapCtx is NULL"));
10557 return VOS_FALSE;
10558 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010559 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
10560 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010561 if ((pSapCtx->aStaInfo[staId].isUsed) &&
10562 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010563 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010564 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010565
10566 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010567 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
10568 "middle of WPS/EAPOL exchange.", __func__,
10569 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010570 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010571 }
10572 }
10573 }
10574 }
10575 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10576 pAdapterNode = pNext;
10577 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053010578 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010579}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010580
10581/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010582 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070010583 * this scan respond to scan trigger and update cfg80211 scan database
10584 * later, scan dump command can be used to recieve scan results
10585 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010586int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010587#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10588 struct net_device *dev,
10589#endif
10590 struct cfg80211_scan_request *request)
10591{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010592 hdd_adapter_t *pAdapter = NULL;
10593 hdd_context_t *pHddCtx = NULL;
10594 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010595 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010596 tCsrScanRequest scanRequest;
10597 tANI_U8 *channelList = NULL, i;
10598 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010599 int status;
10600 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010601 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010602 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053010603 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010604 bool is_p2p_scan = false;
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010605 v_S7_t rssi=0;
10606 hdd_station_ctx_t *pHddStaCtx=NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010607
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010608#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
10609 struct net_device *dev = NULL;
10610 if (NULL == request)
10611 {
10612 hddLog(VOS_TRACE_LEVEL_ERROR,
10613 "%s: scan req param null", __func__);
10614 return -EINVAL;
10615 }
10616 dev = request->wdev->netdev;
10617#endif
10618
10619 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
10620 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
10621 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10622
Jeff Johnson295189b2012-06-20 16:38:30 -070010623 ENTER();
10624
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010625 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10626 __func__, hdd_device_modetoString(pAdapter->device_mode),
10627 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010628
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010629 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010630 if (0 != status)
10631 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010632 return status;
10633 }
10634
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010635 if (NULL == pwextBuf)
10636 {
10637 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
10638 __func__);
10639 return -EIO;
10640 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010641 cfg_param = pHddCtx->cfg_ini;
10642 pScanInfo = &pHddCtx->scan_info;
10643
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010644 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10645 if ( (pHddStaCtx != NULL) && (TRUE == hdd_connIsConnected(pHddStaCtx)))
10646 {
10647 wlan_hdd_get_roam_rssi(pAdapter, &rssi);
10648 hddLog(VOS_TRACE_LEVEL_INFO, FL("rssi: %d"), rssi);
10649 }
10650
Jeff Johnson295189b2012-06-20 16:38:30 -070010651#ifdef WLAN_BTAMP_FEATURE
10652 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010653 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070010654 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010655 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010656 "%s: No scanning when AMP is on", __func__);
10657 return -EOPNOTSUPP;
10658 }
10659#endif
10660 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010661 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010662 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010663 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010664 "%s: Not scanning on device_mode = %s (%d)",
10665 __func__, hdd_device_modetoString(pAdapter->device_mode),
10666 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010667 return -EOPNOTSUPP;
10668 }
10669
10670 if (TRUE == pScanInfo->mScanPending)
10671 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010672 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
10673 {
10674 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
10675 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010676 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010677 }
10678
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010679 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070010680 //Channel and action frame is pending
10681 //Otherwise Cancel Remain On Channel and allow Scan
10682 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010683 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070010684 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010685 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010686 return -EBUSY;
10687 }
10688
Jeff Johnson295189b2012-06-20 16:38:30 -070010689 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
10690 {
10691 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080010692 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010693 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010694 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010695 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
10696 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010697 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010698 "%s: MAX TM Level Scan not allowed", __func__);
10699 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010700 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010701 }
10702 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
10703
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010704 /* Check if scan is allowed at this point of time.
10705 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010706 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010707 {
10708 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
10709 return -EBUSY;
10710 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010711
Jeff Johnson295189b2012-06-20 16:38:30 -070010712 vos_mem_zero( &scanRequest, sizeof(scanRequest));
10713
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010714 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
10715 (int)request->n_ssids);
10716
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010717
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010718 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
10719 * Becasue of this, driver is assuming that this is not wildcard scan and so
10720 * is not aging out the scan results.
10721 */
10722 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070010723 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010724 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010725 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010726
10727 if ((request->ssids) && (0 < request->n_ssids))
10728 {
10729 tCsrSSIDInfo *SsidInfo;
10730 int j;
10731 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
10732 /* Allocate num_ssid tCsrSSIDInfo structure */
10733 SsidInfo = scanRequest.SSIDs.SSIDList =
10734 ( tCsrSSIDInfo *)vos_mem_malloc(
10735 request->n_ssids*sizeof(tCsrSSIDInfo));
10736
10737 if(NULL == scanRequest.SSIDs.SSIDList)
10738 {
10739 hddLog(VOS_TRACE_LEVEL_ERROR,
10740 "%s: memory alloc failed SSIDInfo buffer", __func__);
10741 return -ENOMEM;
10742 }
10743
10744 /* copy all the ssid's and their length */
10745 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
10746 {
10747 /* get the ssid length */
10748 SsidInfo->SSID.length = request->ssids[j].ssid_len;
10749 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
10750 SsidInfo->SSID.length);
10751 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
10752 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
10753 j, SsidInfo->SSID.ssId);
10754 }
10755 /* set the scan type to active */
10756 scanRequest.scanType = eSIR_ACTIVE_SCAN;
10757 }
10758 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070010759 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010760 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10761 TRACE_CODE_HDD_CFG80211_SCAN,
10762 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070010763 /* set the scan type to active */
10764 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010765 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010766 else
10767 {
10768 /*Set the scan type to default type, in this case it is ACTIVE*/
10769 scanRequest.scanType = pScanInfo->scan_mode;
10770 }
10771 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
10772 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070010773
10774 /* set BSSType to default type */
10775 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
10776
10777 /*TODO: scan the requested channels only*/
10778
10779 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010780 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070010781 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010782 hddLog(VOS_TRACE_LEVEL_WARN,
10783 "No of Scan Channels exceeded limit: %d", request->n_channels);
10784 request->n_channels = MAX_CHANNEL;
10785 }
10786
10787 hddLog(VOS_TRACE_LEVEL_INFO,
10788 "No of Scan Channels: %d", request->n_channels);
10789
10790
10791 if( request->n_channels )
10792 {
10793 char chList [(request->n_channels*5)+1];
10794 int len;
10795 channelList = vos_mem_malloc( request->n_channels );
10796 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053010797 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010798 hddLog(VOS_TRACE_LEVEL_ERROR,
10799 "%s: memory alloc failed channelList", __func__);
10800 status = -ENOMEM;
10801 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053010802 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010803
10804 for( i = 0, len = 0; i < request->n_channels ; i++ )
10805 {
10806 channelList[i] = request->channels[i]->hw_value;
10807 len += snprintf(chList+len, 5, "%d ", channelList[i]);
10808 }
10809
Nirav Shah20ac06f2013-12-12 18:14:06 +053010810 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010811 "Channel-List: %s ", chList);
10812 }
c_hpothu53512302014-04-15 18:49:53 +053010813
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010814 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
10815 scanRequest.ChannelInfo.ChannelList = channelList;
10816
10817 /* set requestType to full scan */
10818 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
10819
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010820 /* if there is back to back scan happening in driver with in
10821 * nDeferScanTimeInterval interval driver should defer new scan request
10822 * and should provide last cached scan results instead of new channel list.
10823 * This rule is not applicable if scan is p2p scan.
10824 * This condition will work only in case when last request no of channels
10825 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053010826 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053010827 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010828 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010829
Sushant Kaushik86592172015-04-27 16:35:03 +053010830 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
10831 /* if wps ie is NULL , then only defer scan */
10832 if ( pWpsIe == NULL &&
10833 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053010834 {
10835 if ( pScanInfo->last_scan_timestamp !=0 &&
10836 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
10837 {
10838 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
10839 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
10840 vos_mem_compare(pScanInfo->last_scan_channelList,
10841 channelList, pScanInfo->last_scan_numChannels))
10842 {
10843 hddLog(VOS_TRACE_LEVEL_WARN,
10844 " New and old station scan time differ is less then %u",
10845 pHddCtx->cfg_ini->nDeferScanTimeInterval);
10846
10847 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010848 pAdapter);
10849
Agarwal Ashish57e84372014-12-05 18:26:53 +053010850 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010851 "Return old cached scan as all channels and no of channels are same");
10852
Agarwal Ashish57e84372014-12-05 18:26:53 +053010853 if (0 > ret)
10854 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010855
Agarwal Ashish57e84372014-12-05 18:26:53 +053010856 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010857
10858 status = eHAL_STATUS_SUCCESS;
10859 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053010860 }
10861 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010862 }
10863
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010864 /* Flush the scan results(only p2p beacons) for STA scan and P2P
10865 * search (Flush on both full scan and social scan but not on single
10866 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
10867 */
10868
10869 /* Supplicant does single channel scan after 8-way handshake
10870 * and in that case driver shoudnt flush scan results. If
10871 * driver flushes the scan results here and unfortunately if
10872 * the AP doesnt respond to our probe req then association
10873 * fails which is not desired
10874 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010875 if ((request->n_ssids == 1)
10876 && (request->ssids != NULL)
10877 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
10878 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010879
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010880 if( is_p2p_scan ||
10881 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010882 {
10883 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
10884 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
10885 pAdapter->sessionId );
10886 }
10887
10888 if( request->ie_len )
10889 {
10890 /* save this for future association (join requires this) */
10891 /*TODO: Array needs to be converted to dynamic allocation,
10892 * as multiple ie.s can be sent in cfg80211_scan_request structure
10893 * CR 597966
10894 */
10895 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
10896 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
10897 pScanInfo->scanAddIE.length = request->ie_len;
10898
10899 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
10900 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10901 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010902 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053010903 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070010904 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010905 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
10906 memcpy( pwextBuf->roamProfile.addIEScan,
10907 request->ie, request->ie_len);
10908 }
10909 else
10910 {
10911 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
10912 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070010913 }
10914
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010915 }
10916 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
10917 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
10918
10919 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
10920 request->ie_len);
10921 if (pP2pIe != NULL)
10922 {
10923#ifdef WLAN_FEATURE_P2P_DEBUG
10924 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
10925 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
10926 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053010927 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010928 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
10929 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10930 "Go nego completed to Connection is started");
10931 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10932 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053010933 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010934 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
10935 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010936 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010937 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
10938 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10939 "Disconnected state to Connection is started");
10940 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10941 "for 4way Handshake");
10942 }
10943#endif
10944
10945 /* no_cck will be set during p2p find to disable 11b rates */
10946 if(TRUE == request->no_cck)
10947 {
10948 hddLog(VOS_TRACE_LEVEL_INFO,
10949 "%s: This is a P2P Search", __func__);
10950 scanRequest.p2pSearch = 1;
10951
10952 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053010953 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010954 /* set requestType to P2P Discovery */
10955 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
10956 }
10957
10958 /*
10959 Skip Dfs Channel in case of P2P Search
10960 if it is set in ini file
10961 */
10962 if(cfg_param->skipDfsChnlInP2pSearch)
10963 {
10964 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010965 }
10966 else
10967 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010968 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010969 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010970
Agarwal Ashish4f616132013-12-30 23:32:50 +053010971 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010972 }
10973 }
10974
10975 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
10976
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010977#ifdef FEATURE_WLAN_TDLS
10978 /* if tdls disagree scan right now, return immediately.
10979 tdls will schedule the scan when scan is allowed. (return SUCCESS)
10980 or will reject the scan if any TDLS is in progress. (return -EBUSY)
10981 */
10982 status = wlan_hdd_tdls_scan_callback (pAdapter,
10983 wiphy,
10984#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10985 dev,
10986#endif
10987 request);
10988 if(status <= 0)
10989 {
10990 if(!status)
10991 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
10992 "scan rejected %d", __func__, status);
10993 else
10994 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
10995 __func__, status);
10996
10997 return status;
10998 }
10999#endif
11000
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070011001 /* acquire the wakelock to avoid the apps suspend during the scan. To
11002 * address the following issues.
11003 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
11004 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
11005 * for long time, this result in apps running at full power for long time.
11006 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
11007 * be stuck in full power because of resume BMPS
11008 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011009 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070011010
Nirav Shah20ac06f2013-12-12 18:14:06 +053011011 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
11012 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011013 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
11014 scanRequest.requestType, scanRequest.scanType,
11015 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053011016 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
11017
Siddharth Bhal76972212014-10-15 16:22:51 +053011018 if (pHddCtx->spoofMacAddr.isEnabled)
11019 {
11020 hddLog(VOS_TRACE_LEVEL_INFO,
11021 "%s: MAC Spoofing enabled for current scan", __func__);
11022 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
11023 * to fill TxBds for probe request during current scan
11024 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011025 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053011026 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011027
11028 if(status != VOS_STATUS_SUCCESS)
11029 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011030 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011031 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053011032#ifdef FEATURE_WLAN_TDLS
11033 wlan_hdd_tdls_scan_done_callback(pAdapter);
11034#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011035 goto free_mem;
11036 }
Siddharth Bhal76972212014-10-15 16:22:51 +053011037 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053011038 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070011039 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011040 pAdapter->sessionId, &scanRequest, &scanId,
11041 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070011042
Jeff Johnson295189b2012-06-20 16:38:30 -070011043 if (eHAL_STATUS_SUCCESS != status)
11044 {
11045 hddLog(VOS_TRACE_LEVEL_ERROR,
11046 "%s: sme_ScanRequest returned error %d", __func__, status);
11047 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011048 if(eHAL_STATUS_RESOURCES == status)
11049 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053011050 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
11051 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011052 status = -EBUSY;
11053 } else {
11054 status = -EIO;
11055 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011056 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053011057
11058#ifdef FEATURE_WLAN_TDLS
11059 wlan_hdd_tdls_scan_done_callback(pAdapter);
11060#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011061 goto free_mem;
11062 }
11063
11064 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053011065 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011066 pAdapter->request = request;
11067 pScanInfo->scanId = scanId;
11068
11069 complete(&pScanInfo->scan_req_completion_event);
11070
11071free_mem:
11072 if( scanRequest.SSIDs.SSIDList )
11073 {
11074 vos_mem_free(scanRequest.SSIDs.SSIDList);
11075 }
11076
11077 if( channelList )
11078 vos_mem_free( channelList );
11079
11080 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011081 return status;
11082}
11083
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011084int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
11085#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11086 struct net_device *dev,
11087#endif
11088 struct cfg80211_scan_request *request)
11089{
11090 int ret;
11091
11092 vos_ssr_protect(__func__);
11093 ret = __wlan_hdd_cfg80211_scan(wiphy,
11094#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11095 dev,
11096#endif
11097 request);
11098 vos_ssr_unprotect(__func__);
11099
11100 return ret;
11101}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011102
11103void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
11104{
11105 v_U8_t iniDot11Mode =
11106 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
11107 eHddDot11Mode hddDot11Mode = iniDot11Mode;
11108
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011109 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
11110 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011111 switch ( iniDot11Mode )
11112 {
11113 case eHDD_DOT11_MODE_AUTO:
11114 case eHDD_DOT11_MODE_11ac:
11115 case eHDD_DOT11_MODE_11ac_ONLY:
11116#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053011117 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
11118 sme_IsFeatureSupportedByFW(DOT11AC) )
11119 hddDot11Mode = eHDD_DOT11_MODE_11ac;
11120 else
11121 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011122#else
11123 hddDot11Mode = eHDD_DOT11_MODE_11n;
11124#endif
11125 break;
11126 case eHDD_DOT11_MODE_11n:
11127 case eHDD_DOT11_MODE_11n_ONLY:
11128 hddDot11Mode = eHDD_DOT11_MODE_11n;
11129 break;
11130 default:
11131 hddDot11Mode = iniDot11Mode;
11132 break;
11133 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011134#ifdef WLAN_FEATURE_AP_HT40_24G
11135 if (operationChannel > SIR_11B_CHANNEL_END)
11136#endif
11137 {
11138 /* This call decides required channel bonding mode */
11139 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011140 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
11141 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011142 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011143}
11144
Jeff Johnson295189b2012-06-20 16:38:30 -070011145/*
11146 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011147 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011148 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011149int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011150 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070011151{
11152 int status = 0;
11153 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080011154 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011155 v_U32_t roamId;
11156 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070011157 eCsrAuthType RSNAuthType;
11158
11159 ENTER();
11160
11161 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080011162 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11163
11164 status = wlan_hdd_validate_context(pHddCtx);
11165 if (status)
11166 {
Yue Mae36e3552014-03-05 17:06:20 -080011167 return status;
11168 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011169
Jeff Johnson295189b2012-06-20 16:38:30 -070011170 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
11171 {
11172 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
11173 return -EINVAL;
11174 }
11175
11176 pRoamProfile = &pWextState->roamProfile;
11177
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011178 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070011179 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011180 hdd_station_ctx_t *pHddStaCtx;
11181 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011182
Siddharth Bhalda0d1622015-04-24 15:47:49 +053011183 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
11184
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011185 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070011186 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
11187 {
11188 /*QoS not enabled in cfg file*/
11189 pRoamProfile->uapsd_mask = 0;
11190 }
11191 else
11192 {
11193 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011194 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070011195 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
11196 }
11197
11198 pRoamProfile->SSIDs.numOfSSIDs = 1;
11199 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
11200 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011201 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070011202 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
11203 ssid, ssid_len);
11204
11205 if (bssid)
11206 {
11207 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
11208 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
11209 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011210 /* Save BSSID in seperate variable as well, as RoamProfile
11211 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070011212 case of join failure we should send valid BSSID to supplicant
11213 */
11214 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
11215 WNI_CFG_BSSID_LEN);
11216 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070011217 else
11218 {
11219 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
11220 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011221
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011222 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
11223 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011224 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
11225 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011226 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011227 /*set gen ie*/
11228 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
11229 /*set auth*/
11230 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
11231 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011232#ifdef FEATURE_WLAN_WAPI
11233 if (pAdapter->wapi_info.nWapiMode)
11234 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011235 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011236 switch (pAdapter->wapi_info.wapiAuthMode)
11237 {
11238 case WAPI_AUTH_MODE_PSK:
11239 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011240 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011241 pAdapter->wapi_info.wapiAuthMode);
11242 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
11243 break;
11244 }
11245 case WAPI_AUTH_MODE_CERT:
11246 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011247 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011248 pAdapter->wapi_info.wapiAuthMode);
11249 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
11250 break;
11251 }
11252 } // End of switch
11253 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
11254 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
11255 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011256 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011257 pRoamProfile->AuthType.numEntries = 1;
11258 pRoamProfile->EncryptionType.numEntries = 1;
11259 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11260 pRoamProfile->mcEncryptionType.numEntries = 1;
11261 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11262 }
11263 }
11264#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011265#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011266 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011267 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11268 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
11269 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011270 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
11271 sizeof (tSirGtkOffloadParams));
11272 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011273 }
11274#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011275 pRoamProfile->csrPersona = pAdapter->device_mode;
11276
Jeff Johnson32d95a32012-09-10 13:15:23 -070011277 if( operatingChannel )
11278 {
11279 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
11280 pRoamProfile->ChannelInfo.numOfChannels = 1;
11281 }
Chet Lanctot186b5732013-03-18 10:26:30 -070011282 else
11283 {
11284 pRoamProfile->ChannelInfo.ChannelList = NULL;
11285 pRoamProfile->ChannelInfo.numOfChannels = 0;
11286 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011287 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
11288 {
11289 hdd_select_cbmode(pAdapter,operatingChannel);
11290 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011291
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011292 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
11293 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011294 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011295 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011296 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
11297 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011298 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11299 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053011300 {
11301 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11302 "%s: Set HDD connState to eConnectionState_Connecting",
11303 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011304 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
11305 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053011306 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011307 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011308 pAdapter->sessionId, pRoamProfile, &roamId);
11309
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011310 if ((eHAL_STATUS_SUCCESS != status) &&
11311 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11312 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011313
11314 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011315 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
11316 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
11317 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011318 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011319 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011320 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011321
11322 pRoamProfile->ChannelInfo.ChannelList = NULL;
11323 pRoamProfile->ChannelInfo.numOfChannels = 0;
11324
Jeff Johnson295189b2012-06-20 16:38:30 -070011325 }
11326 else
11327 {
11328 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
11329 return -EINVAL;
11330 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080011331 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011332 return status;
11333}
11334
11335/*
11336 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
11337 * This function is used to set the authentication type (OPEN/SHARED).
11338 *
11339 */
11340static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
11341 enum nl80211_auth_type auth_type)
11342{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011343 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011344 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11345
11346 ENTER();
11347
11348 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011349 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070011350 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011351 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011352 hddLog(VOS_TRACE_LEVEL_INFO,
11353 "%s: set authentication type to AUTOSWITCH", __func__);
11354 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
11355 break;
11356
11357 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011358#ifdef WLAN_FEATURE_VOWIFI_11R
11359 case NL80211_AUTHTYPE_FT:
11360#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011361 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011362 "%s: set authentication type to OPEN", __func__);
11363 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11364 break;
11365
11366 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011367 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011368 "%s: set authentication type to SHARED", __func__);
11369 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
11370 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011371#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011372 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011373 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011374 "%s: set authentication type to CCKM WPA", __func__);
11375 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
11376 break;
11377#endif
11378
11379
11380 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011381 hddLog(VOS_TRACE_LEVEL_ERROR,
11382 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011383 auth_type);
11384 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
11385 return -EINVAL;
11386 }
11387
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011388 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011389 pHddStaCtx->conn_info.authType;
11390 return 0;
11391}
11392
11393/*
11394 * FUNCTION: wlan_hdd_set_akm_suite
11395 * This function is used to set the key mgmt type(PSK/8021x).
11396 *
11397 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011398static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011399 u32 key_mgmt
11400 )
11401{
11402 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11403 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053011404 /* Should be in ieee802_11_defs.h */
11405#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
11406#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070011407 /*set key mgmt type*/
11408 switch(key_mgmt)
11409 {
11410 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053011411 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011412#ifdef WLAN_FEATURE_VOWIFI_11R
11413 case WLAN_AKM_SUITE_FT_PSK:
11414#endif
11415 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070011416 __func__);
11417 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
11418 break;
11419
11420 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053011421 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011422#ifdef WLAN_FEATURE_VOWIFI_11R
11423 case WLAN_AKM_SUITE_FT_8021X:
11424#endif
11425 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011426 __func__);
11427 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11428 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011429#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011430#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
11431#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
11432 case WLAN_AKM_SUITE_CCKM:
11433 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
11434 __func__);
11435 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
11436 break;
11437#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070011438#ifndef WLAN_AKM_SUITE_OSEN
11439#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
11440 case WLAN_AKM_SUITE_OSEN:
11441 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
11442 __func__);
11443 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11444 break;
11445#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011446
11447 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011448 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011449 __func__, key_mgmt);
11450 return -EINVAL;
11451
11452 }
11453 return 0;
11454}
11455
11456/*
11457 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011458 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070011459 * (NONE/WEP40/WEP104/TKIP/CCMP).
11460 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011461static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
11462 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070011463 bool ucast
11464 )
11465{
11466 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011467 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011468 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11469
11470 ENTER();
11471
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011472 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011473 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011474 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070011475 __func__, cipher);
11476 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11477 }
11478 else
11479 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011480
Jeff Johnson295189b2012-06-20 16:38:30 -070011481 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011482 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011483 {
11484 case IW_AUTH_CIPHER_NONE:
11485 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11486 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011487
Jeff Johnson295189b2012-06-20 16:38:30 -070011488 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011489 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070011490 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011491
Jeff Johnson295189b2012-06-20 16:38:30 -070011492 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011493 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070011494 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011495
Jeff Johnson295189b2012-06-20 16:38:30 -070011496 case WLAN_CIPHER_SUITE_TKIP:
11497 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
11498 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011499
Jeff Johnson295189b2012-06-20 16:38:30 -070011500 case WLAN_CIPHER_SUITE_CCMP:
11501 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11502 break;
11503#ifdef FEATURE_WLAN_WAPI
11504 case WLAN_CIPHER_SUITE_SMS4:
11505 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
11506 break;
11507#endif
11508
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011509#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011510 case WLAN_CIPHER_SUITE_KRK:
11511 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
11512 break;
11513#endif
11514 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011515 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011516 __func__, cipher);
11517 return -EOPNOTSUPP;
11518 }
11519 }
11520
11521 if (ucast)
11522 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011523 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011524 __func__, encryptionType);
11525 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11526 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011527 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011528 encryptionType;
11529 }
11530 else
11531 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011532 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011533 __func__, encryptionType);
11534 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
11535 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
11536 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
11537 }
11538
11539 return 0;
11540}
11541
11542
11543/*
11544 * FUNCTION: wlan_hdd_cfg80211_set_ie
11545 * This function is used to parse WPA/RSN IE's.
11546 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011547int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
11548 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -070011549 size_t ie_len
11550 )
11551{
11552 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11553 u8 *genie = ie;
11554 v_U16_t remLen = ie_len;
11555#ifdef FEATURE_WLAN_WAPI
11556 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
11557 u16 *tmp;
11558 v_U16_t akmsuiteCount;
11559 int *akmlist;
11560#endif
11561 ENTER();
11562
11563 /* clear previous assocAddIE */
11564 pWextState->assocAddIE.length = 0;
11565 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011566 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011567
11568 while (remLen >= 2)
11569 {
11570 v_U16_t eLen = 0;
11571 v_U8_t elementId;
11572 elementId = *genie++;
11573 eLen = *genie++;
11574 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011575
Arif Hussain6d2a3322013-11-17 19:50:10 -080011576 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070011577 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011578
11579 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070011580 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011581 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011582 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 -070011583 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011584 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011585 "%s: Invalid WPA IE", __func__);
11586 return -EINVAL;
11587 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011588 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070011589 {
11590 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011591 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011592 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011593
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011594 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011595 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011596 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
11597 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011598 VOS_ASSERT(0);
11599 return -ENOMEM;
11600 }
11601 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11602 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11603 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011604
Jeff Johnson295189b2012-06-20 16:38:30 -070011605 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
11606 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11607 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11608 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011609 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
11610 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011611 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
11612 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11613 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
11614 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
11615 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
11616 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011617 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053011618 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070011619 {
11620 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011621 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011622 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011623
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011624 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011625 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011626 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11627 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011628 VOS_ASSERT(0);
11629 return -ENOMEM;
11630 }
11631 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11632 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11633 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011634
Jeff Johnson295189b2012-06-20 16:38:30 -070011635 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11636 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11637 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011638#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011639 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
11640 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011641 /*Consider WFD IE, only for P2P Client */
11642 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
11643 {
11644 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011645 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011646 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011647
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011648 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011649 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011650 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11651 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011652 VOS_ASSERT(0);
11653 return -ENOMEM;
11654 }
11655 // WFD IE is saved to Additional IE ; it should be accumulated to handle
11656 // WPS IE + P2P IE + WFD IE
11657 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11658 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011659
Jeff Johnson295189b2012-06-20 16:38:30 -070011660 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11661 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11662 }
11663#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011664 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011665 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011666 HS20_OUI_TYPE_SIZE)) )
11667 {
11668 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011669 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011670 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011671
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011672 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011673 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011674 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11675 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011676 VOS_ASSERT(0);
11677 return -ENOMEM;
11678 }
11679 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11680 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011681
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011682 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11683 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11684 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011685 /* Appending OSEN Information Element in Assiciation Request */
11686 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
11687 OSEN_OUI_TYPE_SIZE)) )
11688 {
11689 v_U16_t curAddIELen = pWextState->assocAddIE.length;
11690 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
11691 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011692
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011693 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011694 {
11695 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11696 "Need bigger buffer space");
11697 VOS_ASSERT(0);
11698 return -ENOMEM;
11699 }
11700 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11701 pWextState->assocAddIE.length += eLen + 2;
11702
11703 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
11704 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11705 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11706 }
11707
Abhishek Singh4322e622015-06-10 15:42:54 +053011708 /* Update only for WPA IE */
11709 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
11710 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011711
11712 /* populating as ADDIE in beacon frames */
11713 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11714 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
11715 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
11716 {
11717 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11718 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
11719 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11720 {
11721 hddLog(LOGE,
11722 "Coldn't pass "
11723 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
11724 }
11725 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
11726 else
11727 hddLog(LOGE,
11728 "Could not pass on "
11729 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
11730
11731 /* IBSS mode doesn't contain params->proberesp_ies still
11732 beaconIE's need to be populated in probe response frames */
11733 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
11734 {
11735 u16 rem_probe_resp_ie_len = eLen + 2;
11736 u8 probe_rsp_ie_len[3] = {0};
11737 u8 counter = 0;
11738
11739 /* Check Probe Resp Length if it is greater then 255 then
11740 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
11741 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
11742 not able Store More then 255 bytes into One Variable */
11743
11744 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
11745 {
11746 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
11747 {
11748 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
11749 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
11750 }
11751 else
11752 {
11753 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
11754 rem_probe_resp_ie_len = 0;
11755 }
11756 }
11757
11758 rem_probe_resp_ie_len = 0;
11759
11760 if (probe_rsp_ie_len[0] > 0)
11761 {
11762 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11763 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
11764 (tANI_U8*)(genie - 2),
11765 probe_rsp_ie_len[0], NULL,
11766 eANI_BOOLEAN_FALSE)
11767 == eHAL_STATUS_FAILURE)
11768 {
11769 hddLog(LOGE,
11770 "Could not pass"
11771 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
11772 }
11773 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
11774 }
11775
11776 if (probe_rsp_ie_len[1] > 0)
11777 {
11778 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11779 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
11780 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11781 probe_rsp_ie_len[1], NULL,
11782 eANI_BOOLEAN_FALSE)
11783 == eHAL_STATUS_FAILURE)
11784 {
11785 hddLog(LOGE,
11786 "Could not pass"
11787 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
11788 }
11789 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
11790 }
11791
11792 if (probe_rsp_ie_len[2] > 0)
11793 {
11794 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11795 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
11796 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11797 probe_rsp_ie_len[2], NULL,
11798 eANI_BOOLEAN_FALSE)
11799 == eHAL_STATUS_FAILURE)
11800 {
11801 hddLog(LOGE,
11802 "Could not pass"
11803 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
11804 }
11805 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
11806 }
11807
11808 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11809 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
11810 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11811 {
11812 hddLog(LOGE,
11813 "Could not pass"
11814 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
11815 }
11816 }
11817 else
11818 {
11819 // Reset WNI_CFG_PROBE_RSP Flags
11820 wlan_hdd_reset_prob_rspies(pAdapter);
11821
11822 hddLog(VOS_TRACE_LEVEL_INFO,
11823 "%s: No Probe Response IE received in set beacon",
11824 __func__);
11825 }
11826 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070011827 break;
11828 case DOT11F_EID_RSN:
11829 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
11830 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11831 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
11832 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
11833 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
11834 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053011835
11836 /* Appending Extended Capabilities with Interworking bit set
11837 * in Assoc Req.
11838 *
11839 * In assoc req this EXT Cap will only be taken into account if
11840 * interworkingService bit is set to 1. Currently
11841 * driver is only interested in interworkingService capability
11842 * from supplicant. If in future any other EXT Cap info is
11843 * required from supplicat, it needs to be handled while
11844 * sending Assoc Req in LIM.
11845 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011846 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011847 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011848 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011849 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011850 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011851
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011852 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011853 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011854 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11855 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011856 VOS_ASSERT(0);
11857 return -ENOMEM;
11858 }
11859 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11860 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011861
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011862 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11863 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11864 break;
11865 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011866#ifdef FEATURE_WLAN_WAPI
11867 case WLAN_EID_WAPI:
11868 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011869 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070011870 pAdapter->wapi_info.nWapiMode);
11871 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011872 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070011873 akmsuiteCount = WPA_GET_LE16(tmp);
11874 tmp = tmp + 1;
11875 akmlist = (int *)(tmp);
11876 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
11877 {
11878 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
11879 }
11880 else
11881 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011882 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070011883 VOS_ASSERT(0);
11884 return -EINVAL;
11885 }
11886
11887 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
11888 {
11889 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011890 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011891 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011892 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011893 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011894 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011895 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011896 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011897 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
11898 }
11899 break;
11900#endif
11901 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011902 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011903 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011904 /* when Unknown IE is received we should break and continue
11905 * to the next IE in the buffer instead we were returning
11906 * so changing this to break */
11907 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011908 }
11909 genie += eLen;
11910 remLen -= eLen;
11911 }
11912 EXIT();
11913 return 0;
11914}
11915
11916/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053011917 * FUNCTION: hdd_isWPAIEPresent
11918 * Parse the received IE to find the WPA IE
11919 *
11920 */
11921static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
11922{
11923 v_U8_t eLen = 0;
11924 v_U16_t remLen = ie_len;
11925 v_U8_t elementId = 0;
11926
11927 while (remLen >= 2)
11928 {
11929 elementId = *ie++;
11930 eLen = *ie++;
11931 remLen -= 2;
11932 if (eLen > remLen)
11933 {
11934 hddLog(VOS_TRACE_LEVEL_ERROR,
11935 "%s: IE length is wrong %d", __func__, eLen);
11936 return FALSE;
11937 }
11938 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
11939 {
11940 /* OUI - 0x00 0X50 0XF2
11941 WPA Information Element - 0x01
11942 WPA version - 0x01*/
11943 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
11944 return TRUE;
11945 }
11946 ie += eLen;
11947 remLen -= eLen;
11948 }
11949 return FALSE;
11950}
11951
11952/*
Jeff Johnson295189b2012-06-20 16:38:30 -070011953 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011954 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070011955 * parameters during connect operation.
11956 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011957int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011958 struct cfg80211_connect_params *req
11959 )
11960{
11961 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011962 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011963 ENTER();
11964
11965 /*set wpa version*/
11966 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11967
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011968 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011969 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053011970 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011971 {
11972 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
11973 }
11974 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
11975 {
11976 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
11977 }
11978 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011979
11980 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011981 pWextState->wpaVersion);
11982
11983 /*set authentication type*/
11984 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
11985
11986 if (0 > status)
11987 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011988 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011989 "%s: failed to set authentication type ", __func__);
11990 return status;
11991 }
11992
11993 /*set key mgmt type*/
11994 if (req->crypto.n_akm_suites)
11995 {
11996 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
11997 if (0 > status)
11998 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011999 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070012000 __func__);
12001 return status;
12002 }
12003 }
12004
12005 /*set pairwise cipher type*/
12006 if (req->crypto.n_ciphers_pairwise)
12007 {
12008 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
12009 req->crypto.ciphers_pairwise[0], true);
12010 if (0 > status)
12011 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012012 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012013 "%s: failed to set unicast cipher type", __func__);
12014 return status;
12015 }
12016 }
12017 else
12018 {
12019 /*Reset previous cipher suite to none*/
12020 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
12021 if (0 > status)
12022 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012023 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012024 "%s: failed to set unicast cipher type", __func__);
12025 return status;
12026 }
12027 }
12028
12029 /*set group cipher type*/
12030 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
12031 false);
12032
12033 if (0 > status)
12034 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012035 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070012036 __func__);
12037 return status;
12038 }
12039
Chet Lanctot186b5732013-03-18 10:26:30 -070012040#ifdef WLAN_FEATURE_11W
12041 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
12042#endif
12043
Jeff Johnson295189b2012-06-20 16:38:30 -070012044 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
12045 if (req->ie_len)
12046 {
12047 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
12048 if ( 0 > status)
12049 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012050 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012051 __func__);
12052 return status;
12053 }
12054 }
12055
12056 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012057 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012058 {
12059 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
12060 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
12061 )
12062 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012063 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070012064 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
12065 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012066 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012067 __func__);
12068 return -EOPNOTSUPP;
12069 }
12070 else
12071 {
12072 u8 key_len = req->key_len;
12073 u8 key_idx = req->key_idx;
12074
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012075 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012076 && (CSR_MAX_NUM_KEY > key_idx)
12077 )
12078 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012079 hddLog(VOS_TRACE_LEVEL_INFO,
12080 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012081 __func__, key_idx, key_len);
12082 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012083 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012084 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012085 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070012086 (u8)key_len;
12087 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
12088 }
12089 }
12090 }
12091 }
12092
12093 return status;
12094}
12095
12096/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012097 * FUNCTION: wlan_hdd_try_disconnect
12098 * This function is used to disconnect from previous
12099 * connection
12100 */
12101static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
12102{
12103 long ret = 0;
12104 hdd_station_ctx_t *pHddStaCtx;
12105 eMib_dot11DesiredBssType connectedBssType;
12106
12107 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12108
12109 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
12110
12111 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
12112 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
12113 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
12114 {
12115 /* Issue disconnect to CSR */
12116 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12117 if( eHAL_STATUS_SUCCESS ==
12118 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12119 pAdapter->sessionId,
12120 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
12121 {
12122 ret = wait_for_completion_interruptible_timeout(
12123 &pAdapter->disconnect_comp_var,
12124 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12125 if (0 >= ret)
12126 {
12127 hddLog(LOGE, FL("Failed to receive disconnect event"));
12128 return -EALREADY;
12129 }
12130 }
12131 }
12132 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
12133 {
12134 ret = wait_for_completion_interruptible_timeout(
12135 &pAdapter->disconnect_comp_var,
12136 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12137 if (0 >= ret)
12138 {
12139 hddLog(LOGE, FL("Failed to receive disconnect event"));
12140 return -EALREADY;
12141 }
12142 }
12143
12144 return 0;
12145}
12146
12147/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053012148 * FUNCTION: __wlan_hdd_cfg80211_connect
12149 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070012150 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012151static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012152 struct net_device *ndev,
12153 struct cfg80211_connect_params *req
12154 )
12155{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012156 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012157 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012158 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053012159 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012160
12161 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012162
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012163 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12164 TRACE_CODE_HDD_CFG80211_CONNECT,
12165 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012166 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012167 "%s: device_mode = %s (%d)", __func__,
12168 hdd_device_modetoString(pAdapter->device_mode),
12169 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012170
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012171 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012172 if (!pHddCtx)
12173 {
12174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12175 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053012176 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012177 }
12178
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012179 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012180 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012181 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012182 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012183 }
12184
Agarwal Ashish51325b52014-06-16 16:50:49 +053012185 if (vos_max_concurrent_connections_reached()) {
12186 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12187 return -ECONNREFUSED;
12188 }
12189
Jeff Johnson295189b2012-06-20 16:38:30 -070012190#ifdef WLAN_BTAMP_FEATURE
12191 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012192 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070012193 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012194 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012195 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080012196 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012197 }
12198#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012199
12200 //If Device Mode is Station Concurrent Sessions Exit BMps
12201 //P2P Mode will be taken care in Open/close adapter
12202 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012203 (vos_concurrent_open_sessions_running())) {
12204 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
12205 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012206 }
12207
12208 /*Try disconnecting if already in connected state*/
12209 status = wlan_hdd_try_disconnect(pAdapter);
12210 if ( 0 > status)
12211 {
12212 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12213 " connection"));
12214 return -EALREADY;
12215 }
12216
Jeff Johnson295189b2012-06-20 16:38:30 -070012217 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012218 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070012219
12220 if ( 0 > status)
12221 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012222 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070012223 __func__);
12224 return status;
12225 }
Mohit Khanna765234a2012-09-11 15:08:35 -070012226 if ( req->channel )
12227 {
12228 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
12229 req->ssid_len, req->bssid,
12230 req->channel->hw_value);
12231 }
12232 else
12233 {
12234 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012235 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070012236 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012237
Sushant Kaushikd7083982015-03-18 14:33:24 +053012238 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012239 {
12240 //ReEnable BMPS if disabled
12241 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
12242 (NULL != pHddCtx))
12243 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012244 if (pHddCtx->hdd_wlan_suspended)
12245 {
12246 hdd_set_pwrparams(pHddCtx);
12247 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012248 //ReEnable Bmps and Imps back
12249 hdd_enable_bmps_imps(pHddCtx);
12250 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053012251 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012252 return status;
12253 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012254 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012255 EXIT();
12256 return status;
12257}
12258
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012259static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
12260 struct net_device *ndev,
12261 struct cfg80211_connect_params *req)
12262{
12263 int ret;
12264 vos_ssr_protect(__func__);
12265 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
12266 vos_ssr_unprotect(__func__);
12267
12268 return ret;
12269}
Jeff Johnson295189b2012-06-20 16:38:30 -070012270
12271/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012272 * FUNCTION: wlan_hdd_disconnect
12273 * This function is used to issue a disconnect request to SME
12274 */
12275int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
12276{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012277 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012278 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012279 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012280 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012281
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012282 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012283
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012284 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012285 if (0 != status)
12286 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012287 return status;
12288 }
12289
Sushant Kaushikb4834d22015-07-15 15:29:05 +053012290 if (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)
12291 {
12292 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
12293 pAdapter->sessionId);
12294 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012295 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012296
Agarwal Ashish47d18112014-08-04 19:55:07 +053012297 /* Need to apply spin lock before decreasing active sessions
12298 * as there can be chance for double decrement if context switch
12299 * Calls hdd_DisConnectHandler.
12300 */
12301
12302 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012303 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
12304 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012305 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
12306 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053012307 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
12308 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012309
Abhishek Singhf4669da2014-05-26 15:07:49 +053012310 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053012311 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
12312
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012313 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012314
Mihir Shete182a0b22014-08-18 16:08:48 +053012315 /*
12316 * stop tx queues before deleting STA/BSS context from the firmware.
12317 * tx has to be disabled because the firmware can get busy dropping
12318 * the tx frames after BSS/STA has been deleted and will not send
12319 * back a response resulting in WDI timeout
12320 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053012321 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053012322 netif_tx_disable(pAdapter->dev);
12323 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012324
Mihir Shete182a0b22014-08-18 16:08:48 +053012325 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012326 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12327 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012328 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
12329 {
12330 hddLog(VOS_TRACE_LEVEL_INFO,
12331 FL("status = %d, already disconnected"),
12332 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012333
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012334 }
12335 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012336 {
12337 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012338 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012339 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012340 result = -EINVAL;
12341 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012342 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012343 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012344 &pAdapter->disconnect_comp_var,
12345 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012346 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012347 {
12348 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012349 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012350 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012351 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012352 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012353 {
12354 hddLog(VOS_TRACE_LEVEL_ERROR,
12355 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012356 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012357 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012358disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012359 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12360 FL("Set HDD connState to eConnectionState_NotConnected"));
12361 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
12362
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012363 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012364 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012365}
12366
12367
12368/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012369 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070012370 * This function is used to issue a disconnect request to SME
12371 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012372static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012373 struct net_device *dev,
12374 u16 reason
12375 )
12376{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012377 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012378 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012379 tCsrRoamProfile *pRoamProfile;
12380 hdd_station_ctx_t *pHddStaCtx;
12381 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012382#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012383 tANI_U8 staIdx;
12384#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012385
Jeff Johnson295189b2012-06-20 16:38:30 -070012386 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012387
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012388 if (!pAdapter) {
12389 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
12390 return -EINVAL;
12391 }
12392
12393 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12394 if (!pHddStaCtx) {
12395 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
12396 return -EINVAL;
12397 }
12398
12399 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12400 status = wlan_hdd_validate_context(pHddCtx);
12401 if (0 != status)
12402 {
12403 return status;
12404 }
12405
12406 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
12407
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012408 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12409 TRACE_CODE_HDD_CFG80211_DISCONNECT,
12410 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012411 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
12412 __func__, hdd_device_modetoString(pAdapter->device_mode),
12413 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012414
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012415 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
12416 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070012417
Jeff Johnson295189b2012-06-20 16:38:30 -070012418 if (NULL != pRoamProfile)
12419 {
12420 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012421 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
12422 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070012423 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012424 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070012425 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012426 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012427 switch(reason)
12428 {
12429 case WLAN_REASON_MIC_FAILURE:
12430 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
12431 break;
12432
12433 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
12434 case WLAN_REASON_DISASSOC_AP_BUSY:
12435 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
12436 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
12437 break;
12438
12439 case WLAN_REASON_PREV_AUTH_NOT_VALID:
12440 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053012441 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070012442 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
12443 break;
12444
Jeff Johnson295189b2012-06-20 16:38:30 -070012445 default:
12446 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
12447 break;
12448 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012449 pScanInfo = &pHddCtx->scan_info;
12450 if (pScanInfo->mScanPending)
12451 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012452 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012453 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053012454 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012455 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012456 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012457
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012458#ifdef FEATURE_WLAN_TDLS
12459 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012460 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012461 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012462 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
12463 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012464 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012465 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012466 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012467 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012468 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012469 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012470 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012471 status = sme_DeleteTdlsPeerSta(
12472 WLAN_HDD_GET_HAL_CTX(pAdapter),
12473 pAdapter->sessionId,
12474 mac);
12475 if (status != eHAL_STATUS_SUCCESS) {
12476 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
12477 return -EPERM;
12478 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012479 }
12480 }
12481#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012482 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012483 status = wlan_hdd_disconnect(pAdapter, reasonCode);
12484 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070012485 {
12486 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012487 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012488 __func__, (int)status );
12489 return -EINVAL;
12490 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012491 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012492 else
12493 {
12494 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
12495 "called while in %d state", __func__,
12496 pHddStaCtx->conn_info.connState);
12497 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012498 }
12499 else
12500 {
12501 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
12502 }
12503
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012504 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012505 return status;
12506}
12507
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012508static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
12509 struct net_device *dev,
12510 u16 reason
12511 )
12512{
12513 int ret;
12514 vos_ssr_protect(__func__);
12515 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
12516 vos_ssr_unprotect(__func__);
12517
12518 return ret;
12519}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012520
Jeff Johnson295189b2012-06-20 16:38:30 -070012521/*
12522 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012523 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012524 * settings in IBSS mode.
12525 */
12526static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012527 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012528 struct cfg80211_ibss_params *params
12529 )
12530{
12531 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012532 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012533 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
12534 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012535
Jeff Johnson295189b2012-06-20 16:38:30 -070012536 ENTER();
12537
12538 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070012539 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070012540
12541 if (params->ie_len && ( NULL != params->ie) )
12542 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012543 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12544 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012545 {
12546 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12547 encryptionType = eCSR_ENCRYPT_TYPE_AES;
12548 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012549 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012550 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012551 tDot11fIEWPA dot11WPAIE;
12552 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012553 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012554
Wilson Yang00256342013-10-10 23:13:38 -070012555 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012556 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12557 params->ie_len, DOT11F_EID_WPA);
12558 if ( NULL != ie )
12559 {
12560 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12561 // Unpack the WPA IE
12562 //Skip past the EID byte and length byte - and four byte WiFi OUI
12563 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
12564 &ie[2+4],
12565 ie[1] - 4,
12566 &dot11WPAIE);
12567 /*Extract the multicast cipher, the encType for unicast
12568 cipher for wpa-none is none*/
12569 encryptionType =
12570 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
12571 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012572 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012573
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
12575
12576 if (0 > status)
12577 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012578 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012579 __func__);
12580 return status;
12581 }
12582 }
12583
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012584 pWextState->roamProfile.AuthType.authType[0] =
12585 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012586 eCSR_AUTH_TYPE_OPEN_SYSTEM;
12587
12588 if (params->privacy)
12589 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012590 /* Security enabled IBSS, At this time there is no information available
12591 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070012592 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012593 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070012594 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012595 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070012596 *enable privacy bit in beacons */
12597
12598 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
12599 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012600 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
12601 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012602 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
12603 pWextState->roamProfile.EncryptionType.numEntries = 1;
12604 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012605 return status;
12606}
12607
12608/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012609 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012610 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012611 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012612static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012613 struct net_device *dev,
12614 struct cfg80211_ibss_params *params
12615 )
12616{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012617 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012618 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12619 tCsrRoamProfile *pRoamProfile;
12620 int status;
krunal sonie9002db2013-11-25 14:24:17 -080012621 bool alloc_bssid = VOS_FALSE;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012622 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12623 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012624
12625 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012626
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012627 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12628 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
12629 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012630 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012631 "%s: device_mode = %s (%d)", __func__,
12632 hdd_device_modetoString(pAdapter->device_mode),
12633 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012634
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012635 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012636 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012637 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012638 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012639 }
12640
12641 if (NULL == pWextState)
12642 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012643 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012644 __func__);
12645 return -EIO;
12646 }
12647
Agarwal Ashish51325b52014-06-16 16:50:49 +053012648 if (vos_max_concurrent_connections_reached()) {
12649 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12650 return -ECONNREFUSED;
12651 }
12652
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012653 /*Try disconnecting if already in connected state*/
12654 status = wlan_hdd_try_disconnect(pAdapter);
12655 if ( 0 > status)
12656 {
12657 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12658 " IBSS connection"));
12659 return -EALREADY;
12660 }
12661
Jeff Johnson295189b2012-06-20 16:38:30 -070012662 pRoamProfile = &pWextState->roamProfile;
12663
12664 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
12665 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012666 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012667 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012668 return -EINVAL;
12669 }
12670
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012671 /* BSSID is provided by upper layers hence no need to AUTO generate */
12672 if (NULL != params->bssid) {
12673 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12674 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
12675 hddLog (VOS_TRACE_LEVEL_ERROR,
12676 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12677 return -EIO;
12678 }
12679 }
krunal sonie9002db2013-11-25 14:24:17 -080012680 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
12681 {
12682 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12683 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
12684 {
12685 hddLog (VOS_TRACE_LEVEL_ERROR,
12686 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12687 return -EIO;
12688 }
Sachin Ahuja46ff4912015-03-23 22:48:43 +053012689 params->bssid = vos_mem_malloc(VOS_MAC_ADDR_SIZE);
krunal sonie9002db2013-11-25 14:24:17 -080012690 if (!params->bssid)
12691 {
12692 hddLog (VOS_TRACE_LEVEL_ERROR,
12693 "%s:Failed memory allocation", __func__);
12694 return -EIO;
12695 }
12696 vos_mem_copy((v_U8_t *)params->bssid,
12697 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
12698 VOS_MAC_ADDR_SIZE);
12699 alloc_bssid = VOS_TRUE;
12700 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012701
Jeff Johnson295189b2012-06-20 16:38:30 -070012702 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070012703 if (NULL !=
12704#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12705 params->chandef.chan)
12706#else
12707 params->channel)
12708#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012709 {
12710 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012711 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12712 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
12713 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12714 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012715
12716 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012717 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070012718 ieee80211_frequency_to_channel(
12719#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12720 params->chandef.chan->center_freq);
12721#else
12722 params->channel->center_freq);
12723#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012724
12725 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
12726 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070012727 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012728 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
12729 __func__);
12730 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070012731 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012732
12733 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012734 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012735 if (channelNum == validChan[indx])
12736 {
12737 break;
12738 }
12739 }
12740 if (indx >= numChans)
12741 {
12742 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012743 __func__, channelNum);
12744 return -EINVAL;
12745 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012746 /* Set the Operational Channel */
12747 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
12748 channelNum);
12749 pRoamProfile->ChannelInfo.numOfChannels = 1;
12750 pHddStaCtx->conn_info.operationChannel = channelNum;
12751 pRoamProfile->ChannelInfo.ChannelList =
12752 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070012753 }
12754
12755 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012756 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070012757 if (status < 0)
12758 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012759 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070012760 __func__);
12761 return status;
12762 }
12763
12764 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012765 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012766 params->ssid_len, params->bssid,
12767 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070012768
12769 if (0 > status)
12770 {
12771 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
12772 return status;
12773 }
12774
krunal sonie9002db2013-11-25 14:24:17 -080012775 if (NULL != params->bssid &&
12776 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
12777 alloc_bssid == VOS_TRUE)
12778 {
12779 vos_mem_free(params->bssid);
12780 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012781 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012782 return 0;
12783}
12784
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012785static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
12786 struct net_device *dev,
12787 struct cfg80211_ibss_params *params
12788 )
12789{
12790 int ret = 0;
12791
12792 vos_ssr_protect(__func__);
12793 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
12794 vos_ssr_unprotect(__func__);
12795
12796 return ret;
12797}
12798
Jeff Johnson295189b2012-06-20 16:38:30 -070012799/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012800 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012801 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012802 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012803static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012804 struct net_device *dev
12805 )
12806{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012807 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012808 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12809 tCsrRoamProfile *pRoamProfile;
12810 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012811 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012812
12813 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012814
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012815 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12816 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
12817 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012818 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012819 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012820 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012821 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012822 }
12823
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012824 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
12825 hdd_device_modetoString(pAdapter->device_mode),
12826 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012827 if (NULL == pWextState)
12828 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012829 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012830 __func__);
12831 return -EIO;
12832 }
12833
12834 pRoamProfile = &pWextState->roamProfile;
12835
12836 /* Issue disconnect only if interface type is set to IBSS */
12837 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
12838 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012839 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070012840 __func__);
12841 return -EINVAL;
12842 }
12843
12844 /* Issue Disconnect request */
12845 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12846 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
12847 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
12848
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012849 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012850 return 0;
12851}
12852
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012853static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
12854 struct net_device *dev
12855 )
12856{
12857 int ret = 0;
12858
12859 vos_ssr_protect(__func__);
12860 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
12861 vos_ssr_unprotect(__func__);
12862
12863 return ret;
12864}
12865
Jeff Johnson295189b2012-06-20 16:38:30 -070012866/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012867 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070012868 * This function is used to set the phy parameters
12869 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
12870 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012871static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012872 u32 changed)
12873{
12874 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
12875 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012876 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012877
12878 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012879
12880 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012881 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
12882 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012883
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012884 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012885 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012886 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012887 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012888 }
12889
Jeff Johnson295189b2012-06-20 16:38:30 -070012890 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
12891 {
12892 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
12893 WNI_CFG_RTS_THRESHOLD_STAMAX :
12894 wiphy->rts_threshold;
12895
12896 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012897 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070012898 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012899 hddLog(VOS_TRACE_LEVEL_ERROR,
12900 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012901 __func__, rts_threshold);
12902 return -EINVAL;
12903 }
12904
12905 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
12906 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012907 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012908 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012909 hddLog(VOS_TRACE_LEVEL_ERROR,
12910 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012911 __func__, rts_threshold);
12912 return -EIO;
12913 }
12914
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012915 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012916 rts_threshold);
12917 }
12918
12919 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
12920 {
12921 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
12922 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
12923 wiphy->frag_threshold;
12924
12925 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012926 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012927 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012928 hddLog(VOS_TRACE_LEVEL_ERROR,
12929 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012930 frag_threshold);
12931 return -EINVAL;
12932 }
12933
12934 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
12935 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012936 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012937 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012938 hddLog(VOS_TRACE_LEVEL_ERROR,
12939 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012940 __func__, frag_threshold);
12941 return -EIO;
12942 }
12943
12944 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
12945 frag_threshold);
12946 }
12947
12948 if ((changed & WIPHY_PARAM_RETRY_SHORT)
12949 || (changed & WIPHY_PARAM_RETRY_LONG))
12950 {
12951 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
12952 wiphy->retry_short :
12953 wiphy->retry_long;
12954
12955 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
12956 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
12957 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012958 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012959 __func__, retry_value);
12960 return -EINVAL;
12961 }
12962
12963 if (changed & WIPHY_PARAM_RETRY_SHORT)
12964 {
12965 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
12966 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012967 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012968 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012969 hddLog(VOS_TRACE_LEVEL_ERROR,
12970 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012971 __func__, retry_value);
12972 return -EIO;
12973 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012974 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012975 __func__, retry_value);
12976 }
12977 else if (changed & WIPHY_PARAM_RETRY_SHORT)
12978 {
12979 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
12980 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012981 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012982 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012983 hddLog(VOS_TRACE_LEVEL_ERROR,
12984 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012985 __func__, retry_value);
12986 return -EIO;
12987 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012988 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012989 __func__, retry_value);
12990 }
12991 }
12992
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012993 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012994 return 0;
12995}
12996
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012997static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
12998 u32 changed)
12999{
13000 int ret;
13001
13002 vos_ssr_protect(__func__);
13003 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
13004 vos_ssr_unprotect(__func__);
13005
13006 return ret;
13007}
13008
Jeff Johnson295189b2012-06-20 16:38:30 -070013009/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013010 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013011 * This function is used to set the txpower
13012 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013013static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013014#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13015 struct wireless_dev *wdev,
13016#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013017#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013018 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013019#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013020 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013021#endif
13022 int dbm)
13023{
13024 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013025 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013026 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
13027 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013028 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013029
13030 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013031
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013032 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13033 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
13034 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013035 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013036 if (0 != status)
13037 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013038 return status;
13039 }
13040
13041 hHal = pHddCtx->hHal;
13042
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013043 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
13044 dbm, ccmCfgSetCallback,
13045 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013046 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013047 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013048 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
13049 return -EIO;
13050 }
13051
13052 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
13053 dbm);
13054
13055 switch(type)
13056 {
13057 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
13058 /* Fall through */
13059 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
13060 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
13061 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013062 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
13063 __func__);
13064 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070013065 }
13066 break;
13067 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013068 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070013069 __func__);
13070 return -EOPNOTSUPP;
13071 break;
13072 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013073 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
13074 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070013075 return -EIO;
13076 }
13077
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013078 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013079 return 0;
13080}
13081
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013082static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
13083#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13084 struct wireless_dev *wdev,
13085#endif
13086#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13087 enum tx_power_setting type,
13088#else
13089 enum nl80211_tx_power_setting type,
13090#endif
13091 int dbm)
13092{
13093 int ret;
13094 vos_ssr_protect(__func__);
13095 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
13096#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13097 wdev,
13098#endif
13099#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13100 type,
13101#else
13102 type,
13103#endif
13104 dbm);
13105 vos_ssr_unprotect(__func__);
13106
13107 return ret;
13108}
13109
Jeff Johnson295189b2012-06-20 16:38:30 -070013110/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013111 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013112 * This function is used to read the txpower
13113 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013114static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013115#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13116 struct wireless_dev *wdev,
13117#endif
13118 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070013119{
13120
13121 hdd_adapter_t *pAdapter;
13122 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013123 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013124
Jeff Johnsone7245742012-09-05 17:12:55 -070013125 ENTER();
13126
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013127 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013128 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013129 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013130 *dbm = 0;
13131 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013132 }
13133
Jeff Johnson295189b2012-06-20 16:38:30 -070013134 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
13135 if (NULL == pAdapter)
13136 {
13137 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
13138 return -ENOENT;
13139 }
13140
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053013141 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13142 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
13143 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070013144 wlan_hdd_get_classAstats(pAdapter);
13145 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
13146
Jeff Johnsone7245742012-09-05 17:12:55 -070013147 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013148 return 0;
13149}
13150
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013151static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
13152#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13153 struct wireless_dev *wdev,
13154#endif
13155 int *dbm)
13156{
13157 int ret;
13158
13159 vos_ssr_protect(__func__);
13160 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
13161#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13162 wdev,
13163#endif
13164 dbm);
13165 vos_ssr_unprotect(__func__);
13166
13167 return ret;
13168}
13169
13170
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013171static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070013172 u8* mac, struct station_info *sinfo)
13173{
13174 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13175 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13176 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053013177 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013178
13179 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
13180 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070013181
13182 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
13183 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
13184 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
13185 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
13186 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
13187 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
13188 tANI_U16 maxRate = 0;
13189 tANI_U16 myRate;
13190 tANI_U16 currentRate = 0;
13191 tANI_U8 maxSpeedMCS = 0;
13192 tANI_U8 maxMCSIdx = 0;
13193 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053013194 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013195 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013196 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013197
Leo Chang6f8870f2013-03-26 18:11:36 -070013198#ifdef WLAN_FEATURE_11AC
13199 tANI_U32 vht_mcs_map;
13200 eDataRate11ACMaxMcs vhtMaxMcs;
13201#endif /* WLAN_FEATURE_11AC */
13202
Jeff Johnsone7245742012-09-05 17:12:55 -070013203 ENTER();
13204
Jeff Johnson295189b2012-06-20 16:38:30 -070013205 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
13206 (0 == ssidlen))
13207 {
13208 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
13209 " Invalid ssidlen, %d", __func__, ssidlen);
13210 /*To keep GUI happy*/
13211 return 0;
13212 }
13213
Mukul Sharma811205f2014-07-09 21:07:30 +053013214 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
13215 {
13216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13217 "%s: Roaming in progress, so unable to proceed this request", __func__);
13218 return 0;
13219 }
13220
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013221 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013222 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013223 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013224 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013225 }
13226
Jeff Johnson295189b2012-06-20 16:38:30 -070013227
Kiet Lam3b17fc82013-09-27 05:24:08 +053013228 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
13229 sinfo->filled |= STATION_INFO_SIGNAL;
13230
c_hpothu09f19542014-05-30 21:53:31 +053013231 wlan_hdd_get_station_stats(pAdapter);
13232 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
13233
13234 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053013235 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
13236 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053013237 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053013238 {
13239 rate_flags = pAdapter->maxRateFlags;
13240 }
c_hpothu44ff4e02014-05-08 00:13:57 +053013241
Jeff Johnson295189b2012-06-20 16:38:30 -070013242 //convert to the UI units of 100kbps
13243 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
13244
13245#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070013246 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 -070013247 sinfo->signal,
13248 pCfg->reportMaxLinkSpeed,
13249 myRate,
13250 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013251 (int) pCfg->linkSpeedRssiMid,
13252 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070013253 (int) rate_flags,
13254 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013255#endif //LINKSPEED_DEBUG_ENABLED
13256
13257 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
13258 {
13259 // we do not want to necessarily report the current speed
13260 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
13261 {
13262 // report the max possible speed
13263 rssidx = 0;
13264 }
13265 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
13266 {
13267 // report the max possible speed with RSSI scaling
13268 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
13269 {
13270 // report the max possible speed
13271 rssidx = 0;
13272 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013273 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070013274 {
13275 // report middle speed
13276 rssidx = 1;
13277 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013278 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
13279 {
13280 // report middle speed
13281 rssidx = 2;
13282 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013283 else
13284 {
13285 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013286 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070013287 }
13288 }
13289 else
13290 {
13291 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
13292 hddLog(VOS_TRACE_LEVEL_ERROR,
13293 "%s: Invalid value for reportMaxLinkSpeed: %u",
13294 __func__, pCfg->reportMaxLinkSpeed);
13295 rssidx = 0;
13296 }
13297
13298 maxRate = 0;
13299
13300 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013301 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
13302 OperationalRates, &ORLeng))
13303 {
13304 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13305 /*To keep GUI happy*/
13306 return 0;
13307 }
13308
Jeff Johnson295189b2012-06-20 16:38:30 -070013309 for (i = 0; i < ORLeng; i++)
13310 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013311 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013312 {
13313 /* Validate Rate Set */
13314 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
13315 {
13316 currentRate = supported_data_rate[j].supported_rate[rssidx];
13317 break;
13318 }
13319 }
13320 /* Update MAX rate */
13321 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13322 }
13323
13324 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013325 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
13326 ExtendedRates, &ERLeng))
13327 {
13328 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13329 /*To keep GUI happy*/
13330 return 0;
13331 }
13332
Jeff Johnson295189b2012-06-20 16:38:30 -070013333 for (i = 0; i < ERLeng; i++)
13334 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013335 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013336 {
13337 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
13338 {
13339 currentRate = supported_data_rate[j].supported_rate[rssidx];
13340 break;
13341 }
13342 }
13343 /* Update MAX rate */
13344 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13345 }
c_hpothu79aab322014-07-14 21:11:01 +053013346
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013347 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053013348 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013349 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053013350 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070013351 {
c_hpothu79aab322014-07-14 21:11:01 +053013352 if (rate_flags & eHAL_TX_RATE_VHT80)
13353 mode = 2;
13354 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
13355 mode = 1;
13356 else
13357 mode = 0;
13358
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013359 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
13360 MCSRates, &MCSLeng))
13361 {
13362 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13363 /*To keep GUI happy*/
13364 return 0;
13365 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013366 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070013367#ifdef WLAN_FEATURE_11AC
13368 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013369 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070013370 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013371 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013372 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070013373 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070013374 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013375 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013376 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013377 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070013378 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013379 maxMCSIdx = 7;
13380 }
13381 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
13382 {
13383 maxMCSIdx = 8;
13384 }
13385 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
13386 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013387 //VHT20 is supporting 0~8
13388 if (rate_flags & eHAL_TX_RATE_VHT20)
13389 maxMCSIdx = 8;
13390 else
13391 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070013392 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013393
c_hpothu79aab322014-07-14 21:11:01 +053013394 if (0 != rssidx)/*check for scaled */
13395 {
13396 //get middle rate MCS index if rssi=1/2
13397 for (i=0; i <= maxMCSIdx; i++)
13398 {
13399 if (sinfo->signal <= rssiMcsTbl[mode][i])
13400 {
13401 maxMCSIdx = i;
13402 break;
13403 }
13404 }
13405 }
13406
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013407 if (rate_flags & eHAL_TX_RATE_VHT80)
13408 {
13409 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
13410 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
13411 }
13412 else if (rate_flags & eHAL_TX_RATE_VHT40)
13413 {
13414 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
13415 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
13416 }
13417 else if (rate_flags & eHAL_TX_RATE_VHT20)
13418 {
13419 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
13420 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
13421 }
13422
Leo Chang6f8870f2013-03-26 18:11:36 -070013423 maxSpeedMCS = 1;
13424 if (currentRate > maxRate)
13425 {
13426 maxRate = currentRate;
13427 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013428
Leo Chang6f8870f2013-03-26 18:11:36 -070013429 }
13430 else
13431#endif /* WLAN_FEATURE_11AC */
13432 {
13433 if (rate_flags & eHAL_TX_RATE_HT40)
13434 {
13435 rateFlag |= 1;
13436 }
13437 if (rate_flags & eHAL_TX_RATE_SGI)
13438 {
13439 rateFlag |= 2;
13440 }
13441
Girish Gowli01abcee2014-07-31 20:18:55 +053013442 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053013443 if (rssidx == 1 || rssidx == 2)
13444 {
13445 //get middle rate MCS index if rssi=1/2
13446 for (i=0; i <= 7; i++)
13447 {
13448 if (sinfo->signal <= rssiMcsTbl[mode][i])
13449 {
13450 temp = i+1;
13451 break;
13452 }
13453 }
13454 }
c_hpothu79aab322014-07-14 21:11:01 +053013455
13456 for (i = 0; i < MCSLeng; i++)
13457 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013458 for (j = 0; j < temp; j++)
13459 {
13460 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
13461 {
13462 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013463 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013464 break;
13465 }
13466 }
13467 if ((j < temp) && (currentRate > maxRate))
13468 {
13469 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070013470 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013471 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013472 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013473 }
13474 }
13475
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013476 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
13477 {
13478 maxRate = myRate;
13479 maxSpeedMCS = 1;
13480 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13481 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013482 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053013483 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070013484 {
13485 maxRate = myRate;
13486 if (rate_flags & eHAL_TX_RATE_LEGACY)
13487 {
13488 maxSpeedMCS = 0;
13489 }
13490 else
13491 {
13492 maxSpeedMCS = 1;
13493 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13494 }
13495 }
13496
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013497 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070013498 {
13499 sinfo->txrate.legacy = maxRate;
13500#ifdef LINKSPEED_DEBUG_ENABLED
13501 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
13502#endif //LINKSPEED_DEBUG_ENABLED
13503 }
13504 else
13505 {
13506 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070013507#ifdef WLAN_FEATURE_11AC
13508 sinfo->txrate.nss = 1;
13509 if (rate_flags & eHAL_TX_RATE_VHT80)
13510 {
13511 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013512 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070013513 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013514 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070013515 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013516 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13517 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13518 }
13519 else if (rate_flags & eHAL_TX_RATE_VHT20)
13520 {
13521 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13522 }
13523#endif /* WLAN_FEATURE_11AC */
13524 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
13525 {
13526 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13527 if (rate_flags & eHAL_TX_RATE_HT40)
13528 {
13529 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13530 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013531 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013532 if (rate_flags & eHAL_TX_RATE_SGI)
13533 {
13534 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13535 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013536
Jeff Johnson295189b2012-06-20 16:38:30 -070013537#ifdef LINKSPEED_DEBUG_ENABLED
13538 pr_info("Reporting MCS rate %d flags %x\n",
13539 sinfo->txrate.mcs,
13540 sinfo->txrate.flags );
13541#endif //LINKSPEED_DEBUG_ENABLED
13542 }
13543 }
13544 else
13545 {
13546 // report current rate instead of max rate
13547
13548 if (rate_flags & eHAL_TX_RATE_LEGACY)
13549 {
13550 //provide to the UI in units of 100kbps
13551 sinfo->txrate.legacy = myRate;
13552#ifdef LINKSPEED_DEBUG_ENABLED
13553 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
13554#endif //LINKSPEED_DEBUG_ENABLED
13555 }
13556 else
13557 {
13558 //must be MCS
13559 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013560#ifdef WLAN_FEATURE_11AC
13561 sinfo->txrate.nss = 1;
13562 if (rate_flags & eHAL_TX_RATE_VHT80)
13563 {
13564 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13565 }
13566 else
13567#endif /* WLAN_FEATURE_11AC */
13568 {
13569 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13570 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013571 if (rate_flags & eHAL_TX_RATE_SGI)
13572 {
13573 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13574 }
13575 if (rate_flags & eHAL_TX_RATE_HT40)
13576 {
13577 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13578 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013579#ifdef WLAN_FEATURE_11AC
13580 else if (rate_flags & eHAL_TX_RATE_VHT80)
13581 {
13582 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
13583 }
13584#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070013585#ifdef LINKSPEED_DEBUG_ENABLED
13586 pr_info("Reporting actual MCS rate %d flags %x\n",
13587 sinfo->txrate.mcs,
13588 sinfo->txrate.flags );
13589#endif //LINKSPEED_DEBUG_ENABLED
13590 }
13591 }
13592 sinfo->filled |= STATION_INFO_TX_BITRATE;
13593
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013594 sinfo->tx_packets =
13595 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
13596 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
13597 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
13598 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
13599
13600 sinfo->tx_retries =
13601 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
13602 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
13603 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
13604 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
13605
13606 sinfo->tx_failed =
13607 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
13608 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
13609 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
13610 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
13611
13612 sinfo->filled |=
13613 STATION_INFO_TX_PACKETS |
13614 STATION_INFO_TX_RETRIES |
13615 STATION_INFO_TX_FAILED;
13616
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013617 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13618 TRACE_CODE_HDD_CFG80211_GET_STA,
13619 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013620 EXIT();
13621 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013622}
13623
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013624static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13625 u8* mac, struct station_info *sinfo)
13626{
13627 int ret;
13628
13629 vos_ssr_protect(__func__);
13630 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
13631 vos_ssr_unprotect(__func__);
13632
13633 return ret;
13634}
13635
13636static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070013637 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070013638{
13639 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013640 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013641 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013642 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013643
Jeff Johnsone7245742012-09-05 17:12:55 -070013644 ENTER();
13645
Jeff Johnson295189b2012-06-20 16:38:30 -070013646 if (NULL == pAdapter)
13647 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013648 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013649 return -ENODEV;
13650 }
13651
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013652 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13653 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
13654 pAdapter->sessionId, timeout));
13655
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013656 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013657 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013658 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013659 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013660 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013661 }
13662
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013663 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
13664 (TRUE == pHddCtx->hdd_wlan_suspended) &&
13665 (pHddCtx->cfg_ini->fhostArpOffload) &&
13666 (eConnectionState_Associated ==
13667 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13668 {
Amar Singhald53568e2013-09-26 11:03:45 -070013669
13670 hddLog(VOS_TRACE_LEVEL_INFO,
13671 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053013672 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013673 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13674 {
13675 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013676 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013677 __func__, vos_status);
13678 }
13679 }
13680
Jeff Johnson295189b2012-06-20 16:38:30 -070013681 /**The get power cmd from the supplicant gets updated by the nl only
13682 *on successful execution of the function call
13683 *we are oppositely mapped w.r.t mode in the driver
13684 **/
13685 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
13686
13687 if (VOS_STATUS_E_FAILURE == vos_status)
13688 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013689 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13690 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013691 return -EINVAL;
13692 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013693 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013694 return 0;
13695}
13696
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013697static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
13698 struct net_device *dev, bool mode, int timeout)
13699{
13700 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013701
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013702 vos_ssr_protect(__func__);
13703 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
13704 vos_ssr_unprotect(__func__);
13705
13706 return ret;
13707}
Jeff Johnson295189b2012-06-20 16:38:30 -070013708#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013709static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
13710 struct net_device *netdev,
13711 u8 key_index)
13712{
13713 ENTER();
13714 return 0;
13715}
13716
Jeff Johnson295189b2012-06-20 16:38:30 -070013717static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013718 struct net_device *netdev,
13719 u8 key_index)
13720{
13721 int ret;
13722 vos_ssr_protect(__func__);
13723 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
13724 vos_ssr_unprotect(__func__);
13725 return ret;
13726}
13727#endif //LINUX_VERSION_CODE
13728
13729#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13730static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13731 struct net_device *dev,
13732 struct ieee80211_txq_params *params)
13733{
13734 ENTER();
13735 return 0;
13736}
13737#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13738static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13739 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013740{
Jeff Johnsone7245742012-09-05 17:12:55 -070013741 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070013742 return 0;
13743}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013744#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070013745
13746#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13747static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013748 struct net_device *dev,
13749 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013750{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013751 int ret;
13752
13753 vos_ssr_protect(__func__);
13754 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
13755 vos_ssr_unprotect(__func__);
13756 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013757}
13758#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13759static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
13760 struct ieee80211_txq_params *params)
13761{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013762 int ret;
13763
13764 vos_ssr_protect(__func__);
13765 ret = __wlan_hdd_set_txq_params(wiphy, params);
13766 vos_ssr_unprotect(__func__);
13767 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013768}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013769#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013770
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013771static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013772 struct net_device *dev,
13773 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070013774{
13775 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013776 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013777 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013778 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013779 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013780 v_CONTEXT_t pVosContext = NULL;
13781 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013782
Jeff Johnsone7245742012-09-05 17:12:55 -070013783 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013784
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013785 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070013786 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013787 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013788 return -EINVAL;
13789 }
13790
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013791 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13792 TRACE_CODE_HDD_CFG80211_DEL_STA,
13793 pAdapter->sessionId, pAdapter->device_mode));
13794
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013795 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13796 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013797 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013798 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013799 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013800 }
13801
Jeff Johnson295189b2012-06-20 16:38:30 -070013802 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013803 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013804 )
13805 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013806 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13807 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13808 if(pSapCtx == NULL){
13809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13810 FL("psapCtx is NULL"));
13811 return -ENOENT;
13812 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013813 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070013814 {
13815 v_U16_t i;
13816 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
13817 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013818 if ((pSapCtx->aStaInfo[i].isUsed) &&
13819 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070013820 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013821 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013822 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013823 ETHER_ADDR_LEN);
13824
Jeff Johnson295189b2012-06-20 16:38:30 -070013825 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013826 "%s: Delete STA with MAC::"
13827 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013828 __func__,
13829 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
13830 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070013831 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013832 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013833 }
13834 }
13835 }
13836 else
13837 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013838
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013839 vos_status = hdd_softap_GetStaId(pAdapter,
13840 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013841 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13842 {
13843 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013844 "%s: Skip this DEL STA as this is not used::"
13845 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013846 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013847 return -ENOENT;
13848 }
13849
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013850 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013851 {
13852 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013853 "%s: Skip this DEL STA as deauth is in progress::"
13854 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013855 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013856 return -ENOENT;
13857 }
13858
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013859 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013860
Jeff Johnson295189b2012-06-20 16:38:30 -070013861 hddLog(VOS_TRACE_LEVEL_INFO,
13862 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013863 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013864 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013865 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013866
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013867 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013868 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13869 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013870 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013871 hddLog(VOS_TRACE_LEVEL_INFO,
13872 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013873 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013874 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013875 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013876 return -ENOENT;
13877 }
13878
Jeff Johnson295189b2012-06-20 16:38:30 -070013879 }
13880 }
13881
13882 EXIT();
13883
13884 return 0;
13885}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013886
13887#ifdef CFG80211_DEL_STA_V2
13888static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13889 struct net_device *dev,
13890 struct station_del_parameters *param)
13891#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013892static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13893 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013894#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013895{
13896 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013897 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070013898
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013899 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013900
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013901#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013902 if (NULL == param) {
13903 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013904 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013905 return -EINVAL;
13906 }
13907
13908 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
13909 param->subtype, &delStaParams);
13910
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013911#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053013912 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013913 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013914#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013915 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
13916
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013917 vos_ssr_unprotect(__func__);
13918
13919 return ret;
13920}
13921
13922static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013923 struct net_device *dev, u8 *mac, struct station_parameters *params)
13924{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013925 hdd_adapter_t *pAdapter;
13926 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013927 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013928#ifdef FEATURE_WLAN_TDLS
13929 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013930
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013931 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013932
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013933 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13934 if (NULL == pAdapter)
13935 {
13936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13937 "%s: Adapter is NULL",__func__);
13938 return -EINVAL;
13939 }
13940 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13941 status = wlan_hdd_validate_context(pHddCtx);
13942 if (0 != status)
13943 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013944 return status;
13945 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013946
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013947 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13948 TRACE_CODE_HDD_CFG80211_ADD_STA,
13949 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013950 mask = params->sta_flags_mask;
13951
13952 set = params->sta_flags_set;
13953
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053013954 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013955 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
13956 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013957
13958 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
13959 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013960 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013961 }
13962 }
13963#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013964 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013965 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013966}
13967
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013968static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
13969 struct net_device *dev, u8 *mac, struct station_parameters *params)
13970{
13971 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013972
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013973 vos_ssr_protect(__func__);
13974 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
13975 vos_ssr_unprotect(__func__);
13976
13977 return ret;
13978}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013979#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070013980
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013981static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070013982 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013983{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013984 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13985 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013986 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013987 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013988 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013989 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070013990
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013991 ENTER();
13992
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013993 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013994 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013995 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013996 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013997 return -EINVAL;
13998 }
13999
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014000 if (!pmksa) {
14001 hddLog(LOGE, FL("pmksa is NULL"));
14002 return -EINVAL;
14003 }
14004
14005 if (!pmksa->bssid || !pmksa->pmkid) {
14006 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
14007 pmksa->bssid, pmksa->pmkid);
14008 return -EINVAL;
14009 }
14010
14011 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
14012 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14013
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014014 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14015 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014016 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014017 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014018 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014019 }
14020
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014021 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014022 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14023
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014024 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
14025 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014026
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014027 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014028 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014029 &pmk_id, 1, FALSE);
14030
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014031 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14032 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
14033 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014034
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014035 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014036 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014037}
14038
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014039static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
14040 struct cfg80211_pmksa *pmksa)
14041{
14042 int ret;
14043
14044 vos_ssr_protect(__func__);
14045 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
14046 vos_ssr_unprotect(__func__);
14047
14048 return ret;
14049}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014050
Wilson Yang6507c4e2013-10-01 20:11:19 -070014051
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014052static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070014053 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014054{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014055 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14056 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014057 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014058 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014059
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014060 ENTER();
14061
Wilson Yang6507c4e2013-10-01 20:11:19 -070014062 /* Validate pAdapter */
14063 if (NULL == pAdapter)
14064 {
14065 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
14066 return -EINVAL;
14067 }
14068
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014069 if (!pmksa) {
14070 hddLog(LOGE, FL("pmksa is NULL"));
14071 return -EINVAL;
14072 }
14073
14074 if (!pmksa->bssid) {
14075 hddLog(LOGE, FL("pmksa->bssid is NULL"));
14076 return -EINVAL;
14077 }
14078
Kiet Lam98c46a12014-10-31 15:34:57 -070014079 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
14080 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14081
Wilson Yang6507c4e2013-10-01 20:11:19 -070014082 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14083 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014084 if (0 != status)
14085 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014086 return status;
14087 }
14088
14089 /*Retrieve halHandle*/
14090 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14091
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014092 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14093 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
14094 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014095 /* Delete the PMKID CSR cache */
14096 if (eHAL_STATUS_SUCCESS !=
14097 sme_RoamDelPMKIDfromCache(halHandle,
14098 pAdapter->sessionId, pmksa->bssid, FALSE)) {
14099 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
14100 MAC_ADDR_ARRAY(pmksa->bssid));
14101 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014102 }
14103
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014104 EXIT();
14105 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014106}
14107
Wilson Yang6507c4e2013-10-01 20:11:19 -070014108
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014109static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
14110 struct cfg80211_pmksa *pmksa)
14111{
14112 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014113
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014114 vos_ssr_protect(__func__);
14115 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
14116 vos_ssr_unprotect(__func__);
14117
14118 return ret;
14119
14120}
14121
14122static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014123{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014124 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14125 tHalHandle halHandle;
14126 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014127 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014128
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014129 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070014130
14131 /* Validate pAdapter */
14132 if (NULL == pAdapter)
14133 {
14134 hddLog(VOS_TRACE_LEVEL_ERROR,
14135 "%s: Invalid Adapter" ,__func__);
14136 return -EINVAL;
14137 }
14138
14139 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14140 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014141 if (0 != status)
14142 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014143 return status;
14144 }
14145
14146 /*Retrieve halHandle*/
14147 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14148
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014149 /* Flush the PMKID cache in CSR */
14150 if (eHAL_STATUS_SUCCESS !=
14151 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
14152 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
14153 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014154 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014155 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080014156 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014157}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014158
14159static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
14160{
14161 int ret;
14162
14163 vos_ssr_protect(__func__);
14164 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
14165 vos_ssr_unprotect(__func__);
14166
14167 return ret;
14168}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014169#endif
14170
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014171#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014172static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14173 struct net_device *dev,
14174 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014175{
14176 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14177 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014178 hdd_context_t *pHddCtx;
14179 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014180
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014181 ENTER();
14182
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014183 if (NULL == pAdapter)
14184 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014185 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014186 return -ENODEV;
14187 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014188 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14189 ret = wlan_hdd_validate_context(pHddCtx);
14190 if (0 != ret)
14191 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014192 return ret;
14193 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014194 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014195 if (NULL == pHddStaCtx)
14196 {
14197 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
14198 return -EINVAL;
14199 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014200
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014201 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14202 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
14203 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014204 // Added for debug on reception of Re-assoc Req.
14205 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
14206 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014207 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014208 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080014209 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014210 }
14211
14212#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080014213 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014214 ftie->ie_len);
14215#endif
14216
14217 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014218 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14219 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014220 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014221
14222 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014223 return 0;
14224}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014225
14226static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14227 struct net_device *dev,
14228 struct cfg80211_update_ft_ies_params *ftie)
14229{
14230 int ret;
14231
14232 vos_ssr_protect(__func__);
14233 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
14234 vos_ssr_unprotect(__func__);
14235
14236 return ret;
14237}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014238#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014239
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014240#ifdef FEATURE_WLAN_SCAN_PNO
14241
14242void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
14243 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
14244{
14245 int ret;
14246 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
14247 hdd_context_t *pHddCtx;
14248
Nirav Shah80830bf2013-12-31 16:35:12 +053014249 ENTER();
14250
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014251 if (NULL == pAdapter)
14252 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014253 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014254 "%s: HDD adapter is Null", __func__);
14255 return ;
14256 }
14257
14258 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14259 if (NULL == pHddCtx)
14260 {
14261 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14262 "%s: HDD context is Null!!!", __func__);
14263 return ;
14264 }
14265
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014266 spin_lock(&pHddCtx->schedScan_lock);
14267 if (TRUE == pHddCtx->isWiphySuspended)
14268 {
14269 pHddCtx->isSchedScanUpdatePending = TRUE;
14270 spin_unlock(&pHddCtx->schedScan_lock);
14271 hddLog(VOS_TRACE_LEVEL_INFO,
14272 "%s: Update cfg80211 scan database after it resume", __func__);
14273 return ;
14274 }
14275 spin_unlock(&pHddCtx->schedScan_lock);
14276
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014277 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
14278
14279 if (0 > ret)
14280 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
14281
14282 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014283 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14284 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014285}
14286
14287/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014288 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014289 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014290 */
14291static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
14292{
14293 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
14294 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014295 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014296 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14297 int status = 0;
14298 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
14299
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014300 /* The current firmware design does not allow PNO during any
14301 * active sessions. Hence, determine the active sessions
14302 * and return a failure.
14303 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014304 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
14305 {
14306 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014307 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014308
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014309 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
14310 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
14311 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
14312 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
14313 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053014314 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014315 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014316 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014317 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014318 }
14319 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14320 pAdapterNode = pNext;
14321 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014322 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014323}
14324
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014325void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
14326{
14327 hdd_adapter_t *pAdapter = callbackContext;
14328 hdd_context_t *pHddCtx;
14329
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014330 ENTER();
14331
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014332 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
14333 {
14334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14335 FL("Invalid adapter or adapter has invalid magic"));
14336 return;
14337 }
14338
14339 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14340 if (0 != wlan_hdd_validate_context(pHddCtx))
14341 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014342 return;
14343 }
14344
c_hpothub53c45d2014-08-18 16:53:14 +053014345 if (VOS_STATUS_SUCCESS != status)
14346 {
14347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014348 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053014349 pHddCtx->isPnoEnable = FALSE;
14350 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014351
14352 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
14353 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014354 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014355}
14356
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014357/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014358 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
14359 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014360 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014361static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014362 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14363{
14364 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014365 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014366 hdd_context_t *pHddCtx;
14367 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014368 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053014369 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
14370 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014371 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14372 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014373 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014374 hdd_config_t *pConfig = NULL;
14375 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014376
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014377 ENTER();
14378
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014379 if (NULL == pAdapter)
14380 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014382 "%s: HDD adapter is Null", __func__);
14383 return -ENODEV;
14384 }
14385
14386 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014387 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014388
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014389 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014390 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014391 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014392 }
14393
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014394 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014395 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14396 if (NULL == hHal)
14397 {
14398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14399 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014400 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014401 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014402 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14403 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
14404 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053014405 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014406 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053014407 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014408 {
14409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14410 "%s: aborting the existing scan is unsuccessfull", __func__);
14411 return -EBUSY;
14412 }
14413
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014414 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014415 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014417 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014418 return -EBUSY;
14419 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014420
c_hpothu37f21312014-04-09 21:49:54 +053014421 if (TRUE == pHddCtx->isPnoEnable)
14422 {
14423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14424 FL("already PNO is enabled"));
14425 return -EBUSY;
14426 }
c_hpothu225aa7c2014-10-22 17:45:13 +053014427
14428 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
14429 {
14430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14431 "%s: abort ROC failed ", __func__);
14432 return -EBUSY;
14433 }
14434
c_hpothu37f21312014-04-09 21:49:54 +053014435 pHddCtx->isPnoEnable = TRUE;
14436
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014437 pnoRequest.enable = 1; /*Enable PNO */
14438 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014439
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014440 if (( !pnoRequest.ucNetworksCount ) ||
14441 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014442 {
14443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014444 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014445 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014446 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014447 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014448 goto error;
14449 }
14450
14451 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
14452 {
14453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014454 "%s: Incorrect number of channels %d",
14455 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014456 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014457 goto error;
14458 }
14459
14460 /* Framework provides one set of channels(all)
14461 * common for all saved profile */
14462 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14463 channels_allowed, &num_channels_allowed))
14464 {
14465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14466 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014467 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014468 goto error;
14469 }
14470 /* Checking each channel against allowed channel list */
14471 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053014472 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014473 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014474 char chList [(request->n_channels*5)+1];
14475 int len;
14476 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014477 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014478 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014479 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014480 if (request->channels[i]->hw_value == channels_allowed[indx])
14481 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014482 if ((!pConfig->enableDFSPnoChnlScan) &&
14483 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
14484 {
14485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14486 "%s : Dropping DFS channel : %d",
14487 __func__,channels_allowed[indx]);
14488 num_ignore_dfs_ch++;
14489 break;
14490 }
14491
Nirav Shah80830bf2013-12-31 16:35:12 +053014492 valid_ch[num_ch++] = request->channels[i]->hw_value;
14493 len += snprintf(chList+len, 5, "%d ",
14494 request->channels[i]->hw_value);
14495 break ;
14496 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014497 }
14498 }
Nirav Shah80830bf2013-12-31 16:35:12 +053014499 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014500
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014501 /*If all channels are DFS and dropped, then ignore the PNO request*/
14502 if (num_ignore_dfs_ch == request->n_channels)
14503 {
14504 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14505 "%s : All requested channels are DFS channels", __func__);
14506 ret = -EINVAL;
14507 goto error;
14508 }
14509 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014510
14511 pnoRequest.aNetworks =
14512 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14513 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014514 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014515 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14516 FL("failed to allocate memory aNetworks %u"),
14517 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14518 goto error;
14519 }
14520 vos_mem_zero(pnoRequest.aNetworks,
14521 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14522
14523 /* Filling per profile params */
14524 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
14525 {
14526 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014527 request->match_sets[i].ssid.ssid_len;
14528
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014529 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
14530 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014531 {
14532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014533 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014534 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014535 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014536 goto error;
14537 }
14538
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014539 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014540 request->match_sets[i].ssid.ssid,
14541 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14543 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014544 i, pnoRequest.aNetworks[i].ssId.ssId);
14545 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
14546 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
14547 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014548
14549 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014550 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
14551 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014552
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014553 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014554 }
14555
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014556 for (i = 0; i < request->n_ssids; i++)
14557 {
14558 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014559 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014560 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014561 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014562 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014563 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014564 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014565 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014566 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014567 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014568 break;
14569 }
14570 j++;
14571 }
14572 }
14573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14574 "Number of hidden networks being Configured = %d",
14575 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080014577 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014578
14579 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14580 if (pnoRequest.p24GProbeTemplate == NULL)
14581 {
14582 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14583 FL("failed to allocate memory p24GProbeTemplate %u"),
14584 SIR_PNO_MAX_PB_REQ_SIZE);
14585 goto error;
14586 }
14587
14588 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14589 if (pnoRequest.p5GProbeTemplate == NULL)
14590 {
14591 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14592 FL("failed to allocate memory p5GProbeTemplate %u"),
14593 SIR_PNO_MAX_PB_REQ_SIZE);
14594 goto error;
14595 }
14596
14597 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14598 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14599
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053014600 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
14601 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014602 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014603 pnoRequest.us24GProbeTemplateLen = request->ie_len;
14604 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
14605 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014606
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014607 pnoRequest.us5GProbeTemplateLen = request->ie_len;
14608 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
14609 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014610 }
14611
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014612 /* Driver gets only one time interval which is hardcoded in
14613 * supplicant for 10000ms. Taking power consumption into account 6 timers
14614 * will be used, Timervalue is increased exponentially i.e 10,20,40,
14615 * 80,160,320 secs. And number of scan cycle for each timer
14616 * is configurable through INI param gPNOScanTimerRepeatValue.
14617 * If it is set to 0 only one timer will be used and PNO scan cycle
14618 * will be repeated after each interval specified by supplicant
14619 * till PNO is disabled.
14620 */
14621 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014622 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014623 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014624 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014625 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
14626
14627 tempInterval = (request->interval)/1000;
14628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14629 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
14630 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014631 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014632 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014633 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014634 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014635 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014636 tempInterval *= 2;
14637 }
14638 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014639 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014640
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014641 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014642
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014643 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014644 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
14645 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014646 pAdapter->pno_req_status = 0;
14647
Nirav Shah80830bf2013-12-31 16:35:12 +053014648 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14649 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014650 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
14651 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053014652
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014653 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014654 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014655 hdd_cfg80211_sched_scan_done_callback, pAdapter);
14656 if (eHAL_STATUS_SUCCESS != status)
14657 {
14658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014659 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014660 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014661 goto error;
14662 }
14663
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014664 ret = wait_for_completion_timeout(
14665 &pAdapter->pno_comp_var,
14666 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
14667 if (0 >= ret)
14668 {
14669 // Did not receive the response for PNO enable in time.
14670 // Assuming the PNO enable was success.
14671 // Returning error from here, because we timeout, results
14672 // in side effect of Wifi (Wifi Setting) not to work.
14673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14674 FL("Timed out waiting for PNO to be Enabled"));
14675 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014676 }
14677
14678 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053014679 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014680
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014681error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14683 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053014684 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014685 if (pnoRequest.aNetworks)
14686 vos_mem_free(pnoRequest.aNetworks);
14687 if (pnoRequest.p24GProbeTemplate)
14688 vos_mem_free(pnoRequest.p24GProbeTemplate);
14689 if (pnoRequest.p5GProbeTemplate)
14690 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014691
14692 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014693 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014694}
14695
14696/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014697 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
14698 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014699 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014700static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
14701 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14702{
14703 int ret;
14704
14705 vos_ssr_protect(__func__);
14706 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
14707 vos_ssr_unprotect(__func__);
14708
14709 return ret;
14710}
14711
14712/*
14713 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
14714 * Function to disable PNO
14715 */
14716static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014717 struct net_device *dev)
14718{
14719 eHalStatus status = eHAL_STATUS_FAILURE;
14720 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14721 hdd_context_t *pHddCtx;
14722 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014723 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014724 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014725
14726 ENTER();
14727
14728 if (NULL == pAdapter)
14729 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014730 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014731 "%s: HDD adapter is Null", __func__);
14732 return -ENODEV;
14733 }
14734
14735 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014736
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014737 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014738 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014739 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014740 "%s: HDD context is Null", __func__);
14741 return -ENODEV;
14742 }
14743
14744 /* The return 0 is intentional when isLogpInProgress and
14745 * isLoadUnloadInProgress. We did observe a crash due to a return of
14746 * failure in sched_scan_stop , especially for a case where the unload
14747 * of the happens at the same time. The function __cfg80211_stop_sched_scan
14748 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
14749 * success. If it returns a failure , then its next invocation due to the
14750 * clean up of the second interface will have the dev pointer corresponding
14751 * to the first one leading to a crash.
14752 */
14753 if (pHddCtx->isLogpInProgress)
14754 {
14755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14756 "%s: LOGP in Progress. Ignore!!!", __func__);
14757 return ret;
14758 }
14759
Mihir Shete18156292014-03-11 15:38:30 +053014760 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014761 {
14762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14763 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14764 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014765 }
14766
14767 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14768 if (NULL == hHal)
14769 {
14770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14771 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014772 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014773 }
14774
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014775 pnoRequest.enable = 0; /* Disable PNO */
14776 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014777
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014778 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14779 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
14780 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014781 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014782 pAdapter->sessionId,
14783 NULL, pAdapter);
14784 if (eHAL_STATUS_SUCCESS != status)
14785 {
14786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14787 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014788 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014789 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014790 }
c_hpothu37f21312014-04-09 21:49:54 +053014791 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014792
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014793error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014794 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014795 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014796
14797 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014798 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014799}
14800
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014801/*
14802 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
14803 * NL interface to disable PNO
14804 */
14805static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
14806 struct net_device *dev)
14807{
14808 int ret;
14809
14810 vos_ssr_protect(__func__);
14811 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
14812 vos_ssr_unprotect(__func__);
14813
14814 return ret;
14815}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014816#endif /*FEATURE_WLAN_SCAN_PNO*/
14817
14818
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014819#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014820#if TDLS_MGMT_VERSION2
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014821static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014822 u8 *peer, u8 action_code, u8 dialog_token,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014823 u16 status_code, u32 peer_capability, const u8 *buf, size_t len)
14824#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014825static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014826 u8 *peer, u8 action_code, u8 dialog_token,
14827 u16 status_code, const u8 *buf, size_t len)
14828#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014829{
14830
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014831 hdd_adapter_t *pAdapter;
14832 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014833 u8 peerMac[6];
14834 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070014835 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080014836 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070014837 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014838 int ret;
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014839#if !(TDLS_MGMT_VERSION2)
14840 u32 peer_capability = 0;
14841#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014842 tANI_U16 numCurrTdlsPeers;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014843
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014844 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14845 if (NULL == pAdapter)
14846 {
14847 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14848 "%s: Adapter is NULL",__func__);
14849 return -EINVAL;
14850 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014851 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14852 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
14853 pAdapter->sessionId, action_code));
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014854 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014855 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014856 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014857 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014858 "Invalid arguments");
14859 return -EINVAL;
14860 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014861 if (pHddCtx->isLogpInProgress)
14862 {
14863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14864 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053014865 wlan_hdd_tdls_set_link_status(pAdapter,
14866 peer,
14867 eTDLS_LINK_IDLE,
14868 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014869 return -EBUSY;
14870 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014871 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
14872 {
14873 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14874 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14875 return -EAGAIN;
14876 }
Hoonki Lee27511902013-03-14 18:19:06 -070014877 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014878 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014879 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070014880 "%s: TDLS mode is disabled OR not enabled in FW."
14881 MAC_ADDRESS_STR " action %d declined.",
14882 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014883 return -ENOTSUPP;
14884 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014885
Hoonki Lee27511902013-03-14 18:19:06 -070014886 /* other than teardown frame, other mgmt frames are not sent if disabled */
14887 if (SIR_MAC_TDLS_TEARDOWN != action_code)
14888 {
14889 /* if tdls_mode is disabled to respond to peer's request */
14890 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
14891 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014892 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070014893 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014894 " TDLS mode is disabled. action %d declined.",
14895 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070014896
14897 return -ENOTSUPP;
14898 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053014899
14900 if (vos_max_concurrent_connections_reached())
14901 {
14902 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
14903 return -EINVAL;
14904 }
Hoonki Lee27511902013-03-14 18:19:06 -070014905 }
14906
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014907 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
14908 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053014909 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014910 {
14911 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014912 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014913 " TDLS setup is ongoing. action %d declined.",
14914 __func__, MAC_ADDR_ARRAY(peer), action_code);
14915 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014916 }
14917 }
14918
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014919 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
14920 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080014921 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014922 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
14923 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080014924 {
14925 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
14926 we return error code at 'add_station()'. Hence we have this
14927 check again in addtion to add_station().
14928 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014929 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080014930 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014931 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14932 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014933 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
14934 __func__, MAC_ADDR_ARRAY(peer), action_code,
14935 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053014936 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080014937 }
14938 else
14939 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014940 /* maximum reached. tweak to send error code to peer and return
14941 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080014942 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014943 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14944 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014945 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
14946 __func__, MAC_ADDR_ARRAY(peer), status_code,
14947 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070014948 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014949 /* fall through to send setup resp with failure status
14950 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080014951 }
14952 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014953 else
14954 {
14955 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053014956 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014957 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014958 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014959 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014960 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
14961 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014962 return -EPERM;
14963 }
14964 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014965 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014966 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014967
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014968 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053014969 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014970 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
14971 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014972
Hoonki Leea34dd892013-02-05 22:56:02 -080014973 /*Except teardown responder will not be used so just make 0*/
14974 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014975 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080014976 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014977
14978 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053014979 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014980
14981 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
14982 responder = pTdlsPeer->is_responder;
14983 else
Hoonki Leea34dd892013-02-05 22:56:02 -080014984 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014985 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053014986 "%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 -070014987 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
14988 dialog_token, status_code, len);
14989 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080014990 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014991 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014992
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014993 /* For explicit trigger of DIS_REQ come out of BMPS for
14994 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070014995 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014996 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
14997 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070014998 {
14999 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
15000 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015001 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015002 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015003 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
15004 if (status != VOS_STATUS_SUCCESS) {
15005 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
15006 }
Hoonki Lee14621352013-04-16 17:51:19 -070015007 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015008 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
15009 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED)) {
15010 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
15011 }
15012 }
Hoonki Lee14621352013-04-16 17:51:19 -070015013 }
15014
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015015 /* make sure doesn't call send_mgmt() while it is pending */
15016 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
15017 {
15018 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015019 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015020 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015021 ret = -EBUSY;
15022 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015023 }
15024
15025 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015026 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
15027
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015028 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053015029 peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015030
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015031 if (VOS_STATUS_SUCCESS != status)
15032 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15034 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015035 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015036 ret = -EINVAL;
15037 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015038 }
15039
Hoonki Leed37cbb32013-04-20 00:31:14 -070015040 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
15041 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
15042
15043 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015044 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070015045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070015046 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070015047 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015048 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080015049
15050 if (pHddCtx->isLogpInProgress)
15051 {
15052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15053 "%s: LOGP in Progress. Ignore!!!", __func__);
15054 return -EAGAIN;
15055 }
15056
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015057 ret = -EINVAL;
15058 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015059 }
15060
Gopichand Nakkala05922802013-03-14 12:23:19 -070015061 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070015062 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015063 ret = max_sta_failed;
15064 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070015065 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015066
Hoonki Leea34dd892013-02-05 22:56:02 -080015067 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
15068 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015069 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE)) {
15070 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15071 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015072 }
15073 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
15074 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015075 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE)) {
15076 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15077 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015078 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015079
15080 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015081
15082tx_failed:
15083 /* add_station will be called before sending TDLS_SETUP_REQ and
15084 * TDLS_SETUP_RSP and as part of add_station driver will enable
15085 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
15086 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
15087 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
15088 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
15089 */
15090
15091 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
15092 (SIR_MAC_TDLS_SETUP_RSP == action_code))
15093 wlan_hdd_tdls_check_bmps(pAdapter);
15094 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015095}
15096
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015097#if TDLS_MGMT_VERSION2
15098static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15099 u8 *peer, u8 action_code, u8 dialog_token,
15100 u16 status_code, u32 peer_capability,
15101 const u8 *buf, size_t len)
15102#else
15103static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15104 u8 *peer, u8 action_code, u8 dialog_token,
15105 u16 status_code, const u8 *buf, size_t len)
15106#endif
15107{
15108 int ret;
15109
15110 vos_ssr_protect(__func__);
15111#if TDLS_MGMT_VERSION2
15112 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, dialog_token,
15113 status_code, peer_capability, buf, len);
15114#else
15115 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, dialog_token,
15116 status_code, buf, len);
15117#endif
15118 vos_ssr_unprotect(__func__);
15119
15120 return ret;
15121}
Atul Mittal115287b2014-07-08 13:26:33 +053015122
15123int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
15124 u8 *peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015125 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053015126 cfg80211_exttdls_callback callback)
15127{
15128
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015129 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053015130 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015131 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053015132 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15133 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
15134 __func__, MAC_ADDR_ARRAY(peer));
15135
15136 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15137 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15138
15139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015140 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15141 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15142 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015143 return -ENOTSUPP;
15144 }
15145
15146 /* To cater the requirement of establishing the TDLS link
15147 * irrespective of the data traffic , get an entry of TDLS peer.
15148 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015149 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015150 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
15151 if (pTdlsPeer == NULL) {
15152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15153 "%s: peer " MAC_ADDRESS_STR " not existing",
15154 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015155 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015156 return -EINVAL;
15157 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015158 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015159
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015160 /* check FW TDLS Off Channel capability */
15161 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015162 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015163 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015164 {
15165 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
15166 pTdlsPeer->peerParams.global_operating_class =
15167 tdls_peer_params->global_operating_class;
15168 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
15169 pTdlsPeer->peerParams.min_bandwidth_kbps =
15170 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015171 /* check configured channel is valid, non dfs and
15172 * not current operating channel */
15173 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
15174 tdls_peer_params->channel)) &&
15175 (pHddStaCtx) &&
15176 (tdls_peer_params->channel !=
15177 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015178 {
15179 pTdlsPeer->isOffChannelConfigured = TRUE;
15180 }
15181 else
15182 {
15183 pTdlsPeer->isOffChannelConfigured = FALSE;
15184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15185 "%s: Configured Tdls Off Channel is not valid", __func__);
15186
15187 }
15188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015189 "%s: tdls_off_channel %d isOffChannelConfigured %d "
15190 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015191 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015192 pTdlsPeer->isOffChannelConfigured,
15193 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015194 }
15195 else
15196 {
15197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015198 "%s: TDLS off channel FW capability %d, "
15199 "host capab %d or Invalid TDLS Peer Params", __func__,
15200 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
15201 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015202 }
15203
Atul Mittal115287b2014-07-08 13:26:33 +053015204 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
15205
15206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15207 " %s TDLS Add Force Peer Failed",
15208 __func__);
15209 return -EINVAL;
15210 }
15211 /*EXT TDLS*/
15212
15213 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
15214 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15215 " %s TDLS set callback Failed",
15216 __func__);
15217 return -EINVAL;
15218 }
15219
15220 return(0);
15221
15222}
15223
15224int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter, u8 *peer)
15225{
15226
15227 hddTdlsPeer_t *pTdlsPeer;
15228 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15230 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
15231 __func__, MAC_ADDR_ARRAY(peer));
15232
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015233 if (0 != wlan_hdd_validate_context(pHddCtx)) {
15234 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
15235 return -EINVAL;
15236 }
15237
Atul Mittal115287b2014-07-08 13:26:33 +053015238 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15239 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15240
15241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015242 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15243 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15244 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015245 return -ENOTSUPP;
15246 }
15247
15248
15249 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15250
15251 if ( NULL == pTdlsPeer ) {
15252 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015253 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053015254 __func__, MAC_ADDR_ARRAY(peer));
15255 return -EINVAL;
15256 }
15257 else {
15258 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
15259 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015260 /* if channel switch is configured, reset
15261 the channel for this peer */
15262 if (TRUE == pTdlsPeer->isOffChannelConfigured)
15263 {
15264 pTdlsPeer->peerParams.channel = 0;
15265 pTdlsPeer->isOffChannelConfigured = FALSE;
15266 }
Atul Mittal115287b2014-07-08 13:26:33 +053015267 }
15268
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015269 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
15270 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053015271 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015272 }
Atul Mittal115287b2014-07-08 13:26:33 +053015273
15274 /*EXT TDLS*/
15275
15276 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
15277
15278 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15279 " %s TDLS set callback Failed",
15280 __func__);
15281 return -EINVAL;
15282 }
15283 return(0);
15284
15285}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015286static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015287 u8 *peer, enum nl80211_tdls_operation oper)
15288{
15289 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15290 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015291 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015292 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015293
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015294 ENTER();
15295
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015296 if (!pAdapter) {
15297 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15298 return -EINVAL;
15299 }
15300
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015301 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15302 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
15303 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015304 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015305 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015306 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070015307 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015308 return -EINVAL;
15309 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015310
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015311 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015312 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015313 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015314 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015315 }
15316
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015317
15318 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015319 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015320 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015321 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015322 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
15323 "Cannot process TDLS commands",
15324 pHddCtx->cfg_ini->fEnableTDLSSupport,
15325 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015326 return -ENOTSUPP;
15327 }
15328
15329 switch (oper) {
15330 case NL80211_TDLS_ENABLE_LINK:
15331 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015332 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015333 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015334 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053015335 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015336 tANI_U16 numCurrTdlsPeers = 0;
15337 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015338 tANI_U8 suppChannelLen = 0;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015339
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15341 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
15342 __func__, MAC_ADDR_ARRAY(peer));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015343 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015344 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015345 if ( NULL == pTdlsPeer ) {
15346 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15347 " (oper %d) not exsting. ignored",
15348 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15349 return -EINVAL;
15350 }
15351
15352 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15353 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15354 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15355 "NL80211_TDLS_ENABLE_LINK");
15356
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070015357 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
15358 {
15359 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
15360 MAC_ADDRESS_STR " failed",
15361 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
15362 return -EINVAL;
15363 }
15364
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015365 /* before starting tdls connection, set tdls
15366 * off channel established status to default value */
15367 pTdlsPeer->isOffChannelEstablished = FALSE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015368 /* TDLS Off Channel, Disable tdls channel switch,
15369 when there are more than one tdls link */
15370 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053015371 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015372 {
15373 /* get connected peer and send disable tdls off chan */
15374 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015375 if ((connPeer) &&
15376 (connPeer->isOffChannelSupported == TRUE) &&
15377 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015378 {
15379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15380 "%s: More then one peer connected, Disable "
15381 "TDLS channel switch", __func__);
15382
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015383 connPeer->isOffChannelEstablished = FALSE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015384 ret = sme_SendTdlsChanSwitchReq(
15385 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015386 pAdapter->sessionId,
15387 connPeer->peerMac,
15388 connPeer->peerParams.channel,
15389 TDLS_OFF_CHANNEL_BW_OFFSET,
15390 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015391 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015392 hddLog(VOS_TRACE_LEVEL_ERROR,
15393 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015394 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015395 }
15396 else
15397 {
15398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15399 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015400 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015401 "isOffChannelConfigured %d",
15402 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015403 (connPeer ? (connPeer->isOffChannelSupported)
15404 : -1),
15405 (connPeer ? (connPeer->isOffChannelConfigured)
15406 : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015407 }
15408 }
15409
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015410 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015411 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015412 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053015413
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015414 if (0 != wlan_hdd_tdls_get_link_establish_params(
15415 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015416 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015417 return -EINVAL;
15418 }
15419 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015420
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015421 ret = sme_SendTdlsLinkEstablishParams(
15422 WLAN_HDD_GET_HAL_CTX(pAdapter),
15423 pAdapter->sessionId, peer,
15424 &tdlsLinkEstablishParams);
15425 if (ret != VOS_STATUS_SUCCESS) {
15426 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
15427 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015428 /* Send TDLS peer UAPSD capabilities to the firmware and
15429 * register with the TL on after the response for this operation
15430 * is received .
15431 */
15432 ret = wait_for_completion_interruptible_timeout(
15433 &pAdapter->tdls_link_establish_req_comp,
15434 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
15435 if (ret <= 0)
15436 {
15437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015438 FL("Link Establish Request Failed Status %ld"),
15439 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015440 return -EINVAL;
15441 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015442 }
Atul Mittal115287b2014-07-08 13:26:33 +053015443 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15444 eTDLS_LINK_CONNECTED,
15445 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015446 staDesc.ucSTAId = pTdlsPeer->staId;
15447 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015448 ret = WLANTL_UpdateTdlsSTAClient(
15449 pHddCtx->pvosContext,
15450 &staDesc);
15451 if (ret != VOS_STATUS_SUCCESS) {
15452 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
15453 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053015454
Gopichand Nakkala471708b2013-06-04 20:03:01 +053015455 /* Mark TDLS client Authenticated .*/
15456 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
15457 pTdlsPeer->staId,
15458 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015459 if (VOS_STATUS_SUCCESS == status)
15460 {
Hoonki Lee14621352013-04-16 17:51:19 -070015461 if (pTdlsPeer->is_responder == 0)
15462 {
15463 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
15464
15465 wlan_hdd_tdls_timer_restart(pAdapter,
15466 &pTdlsPeer->initiatorWaitTimeoutTimer,
15467 WAIT_TIME_TDLS_INITIATOR);
15468 /* suspend initiator TX until it receives direct packet from the
15469 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015470 ret = WLANTL_SuspendDataTx(
15471 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15472 &staId, NULL);
15473 if (ret != VOS_STATUS_SUCCESS) {
15474 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
15475 }
Hoonki Lee14621352013-04-16 17:51:19 -070015476 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015477
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015478 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015479 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015480 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015481 suppChannelLen =
15482 tdlsLinkEstablishParams.supportedChannelsLen;
15483
15484 if ((suppChannelLen > 0) &&
15485 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
15486 {
15487 tANI_U8 suppPeerChannel = 0;
15488 int i = 0;
15489 for (i = 0U; i < suppChannelLen; i++)
15490 {
15491 suppPeerChannel =
15492 tdlsLinkEstablishParams.supportedChannels[i];
15493
15494 pTdlsPeer->isOffChannelSupported = FALSE;
15495 if (suppPeerChannel ==
15496 pTdlsPeer->peerParams.channel)
15497 {
15498 pTdlsPeer->isOffChannelSupported = TRUE;
15499 break;
15500 }
15501 }
15502 }
15503 else
15504 {
15505 pTdlsPeer->isOffChannelSupported = FALSE;
15506 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015507 }
15508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15509 "%s: TDLS channel switch request for channel "
15510 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015511 "%d isOffChannelSupported %d", __func__,
15512 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015513 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015514 suppChannelLen,
15515 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015516
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015517 /* TDLS Off Channel, Enable tdls channel switch,
15518 when their is only one tdls link and it supports */
15519 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15520 if ((numCurrTdlsPeers == 1) &&
15521 (TRUE == pTdlsPeer->isOffChannelSupported) &&
15522 (TRUE == pTdlsPeer->isOffChannelConfigured))
15523 {
15524 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15525 "%s: Send TDLS channel switch request for channel %d",
15526 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015527
15528 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015529 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
15530 pAdapter->sessionId,
15531 pTdlsPeer->peerMac,
15532 pTdlsPeer->peerParams.channel,
15533 TDLS_OFF_CHANNEL_BW_OFFSET,
15534 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015535 if (ret != VOS_STATUS_SUCCESS) {
15536 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
15537 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015538 }
15539 else
15540 {
15541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15542 "%s: TDLS channel switch request not sent"
15543 " numCurrTdlsPeers %d "
15544 "isOffChannelSupported %d "
15545 "isOffChannelConfigured %d",
15546 __func__, numCurrTdlsPeers,
15547 pTdlsPeer->isOffChannelSupported,
15548 pTdlsPeer->isOffChannelConfigured);
15549 }
15550
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015551 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015552 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015553
15554 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015555 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
15556 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015557 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015558 int ac;
15559 uint8 ucAc[4] = { WLANTL_AC_VO,
15560 WLANTL_AC_VI,
15561 WLANTL_AC_BK,
15562 WLANTL_AC_BE };
15563 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
15564 for(ac=0; ac < 4; ac++)
15565 {
15566 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15567 pTdlsPeer->staId, ucAc[ac],
15568 tlTid[ac], tlTid[ac], 0, 0,
15569 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015570 if (status != VOS_STATUS_SUCCESS) {
15571 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
15572 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015573 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015574 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015575 }
15576
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015577 }
15578 break;
15579 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080015580 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015581 tANI_U16 numCurrTdlsPeers = 0;
15582 hddTdlsPeer_t *connPeer = NULL;
15583
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15585 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
15586 __func__, MAC_ADDR_ARRAY(peer));
15587
Sunil Dutt41de4e22013-11-14 18:09:02 +053015588 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15589
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015590
Sunil Dutt41de4e22013-11-14 18:09:02 +053015591 if ( NULL == pTdlsPeer ) {
15592 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15593 " (oper %d) not exsting. ignored",
15594 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15595 return -EINVAL;
15596 }
15597
15598 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15599 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15600 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15601 "NL80211_TDLS_DISABLE_LINK");
15602
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015603 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080015604 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015605 long status;
15606
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015607 /* set tdls off channel status to false for this peer */
15608 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053015609 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15610 eTDLS_LINK_TEARING,
15611 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
15612 eTDLS_LINK_UNSPECIFIED:
15613 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015614 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
15615
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015616 status = sme_DeleteTdlsPeerSta(
15617 WLAN_HDD_GET_HAL_CTX(pAdapter),
15618 pAdapter->sessionId, peer );
15619 if (status != VOS_STATUS_SUCCESS) {
15620 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15621 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015622
15623 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
15624 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053015625 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053015626 eTDLS_LINK_IDLE,
15627 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015628 if (status <= 0)
15629 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15631 "%s: Del station failed status %ld",
15632 __func__, status);
15633 return -EPERM;
15634 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015635
15636 /* TDLS Off Channel, Enable tdls channel switch,
15637 when their is only one tdls link and it supports */
15638 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15639 if (numCurrTdlsPeers == 1)
15640 {
15641 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15642 if ((connPeer) &&
15643 (connPeer->isOffChannelSupported == TRUE) &&
15644 (connPeer->isOffChannelConfigured == TRUE))
15645 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015646 connPeer->isOffChannelEstablished = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015647 status = sme_SendTdlsChanSwitchReq(
15648 WLAN_HDD_GET_HAL_CTX(pAdapter),
15649 pAdapter->sessionId,
15650 connPeer->peerMac,
15651 connPeer->peerParams.channel,
15652 TDLS_OFF_CHANNEL_BW_OFFSET,
15653 TDLS_CHANNEL_SWITCH_ENABLE);
15654 if (status != VOS_STATUS_SUCCESS) {
15655 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
15656 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015657 }
15658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15659 "%s: TDLS channel switch "
15660 "isOffChannelSupported %d "
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015661 "isOffChannelConfigured %d "
15662 "isOffChannelEstablished %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015663 __func__,
15664 (connPeer ? connPeer->isOffChannelSupported : -1),
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015665 (connPeer ? connPeer->isOffChannelConfigured : -1),
15666 (connPeer ? connPeer->isOffChannelEstablished : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015667 }
15668 else
15669 {
15670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15671 "%s: TDLS channel switch request not sent "
15672 "numCurrTdlsPeers %d ",
15673 __func__, numCurrTdlsPeers);
15674 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015675 }
15676 else
15677 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15679 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080015680 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015681 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015682 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015683 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015684 {
Atul Mittal115287b2014-07-08 13:26:33 +053015685 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015686
Atul Mittal115287b2014-07-08 13:26:33 +053015687 if (0 != status)
15688 {
15689 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015690 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053015691 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015692 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053015693 break;
15694 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015695 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015696 {
Atul Mittal115287b2014-07-08 13:26:33 +053015697 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
15698 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015699 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053015700 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015701
Atul Mittal115287b2014-07-08 13:26:33 +053015702 if (0 != status)
15703 {
15704 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015705 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053015706 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053015707 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053015708 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015709 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015710 case NL80211_TDLS_DISCOVERY_REQ:
15711 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015713 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015714 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015715 return -ENOTSUPP;
15716 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15718 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015719 return -ENOTSUPP;
15720 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015721
15722 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015723 return 0;
15724}
Chilam NG571c65a2013-01-19 12:27:36 +053015725
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015726static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
15727 u8 *peer, enum nl80211_tdls_operation oper)
15728{
15729 int ret;
15730
15731 vos_ssr_protect(__func__);
15732 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
15733 vos_ssr_unprotect(__func__);
15734
15735 return ret;
15736}
15737
Chilam NG571c65a2013-01-19 12:27:36 +053015738int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
15739 struct net_device *dev, u8 *peer)
15740{
Arif Hussaina7c8e412013-11-20 11:06:42 -080015741 hddLog(VOS_TRACE_LEVEL_INFO,
15742 "tdls send discover req: "MAC_ADDRESS_STR,
15743 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053015744
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015745#if TDLS_MGMT_VERSION2
15746 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15747 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
15748#else
Chilam NG571c65a2013-01-19 12:27:36 +053015749 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15750 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015751#endif
Chilam NG571c65a2013-01-19 12:27:36 +053015752}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015753#endif
15754
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015755#ifdef WLAN_FEATURE_GTK_OFFLOAD
15756/*
15757 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
15758 * Callback rountine called upon receiving response for
15759 * get offload info
15760 */
15761void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
15762 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
15763{
15764
15765 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015766 tANI_U8 tempReplayCounter[8];
15767 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015768
15769 ENTER();
15770
15771 if (NULL == pAdapter)
15772 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053015773 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015774 "%s: HDD adapter is Null", __func__);
15775 return ;
15776 }
15777
15778 if (NULL == pGtkOffloadGetInfoRsp)
15779 {
15780 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15781 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
15782 return ;
15783 }
15784
15785 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
15786 {
15787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15788 "%s: wlan Failed to get replay counter value",
15789 __func__);
15790 return ;
15791 }
15792
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015793 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15794 /* Update replay counter */
15795 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
15796 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
15797
15798 {
15799 /* changing from little to big endian since supplicant
15800 * works on big endian format
15801 */
15802 int i;
15803 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
15804
15805 for (i = 0; i < 8; i++)
15806 {
15807 tempReplayCounter[7-i] = (tANI_U8)p[i];
15808 }
15809 }
15810
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015811 /* Update replay counter to NL */
15812 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015813 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015814}
15815
15816/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015817 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015818 * This function is used to offload GTK rekeying job to the firmware.
15819 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015820int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015821 struct cfg80211_gtk_rekey_data *data)
15822{
15823 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15824 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
15825 hdd_station_ctx_t *pHddStaCtx;
15826 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015827 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015828 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015829 eHalStatus status = eHAL_STATUS_FAILURE;
15830
15831 ENTER();
15832
15833 if (NULL == pAdapter)
15834 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015835 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015836 "%s: HDD adapter is Null", __func__);
15837 return -ENODEV;
15838 }
15839
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015840 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15841 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
15842 pAdapter->sessionId, pAdapter->device_mode));
15843
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015844 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015845 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015846 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015847 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015848 }
15849
15850 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15851 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
15852 if (NULL == hHal)
15853 {
15854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15855 "%s: HAL context is Null!!!", __func__);
15856 return -EAGAIN;
15857 }
15858
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015859 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
15860 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
15861 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
15862 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015863 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015864 {
15865 /* changing from big to little endian since driver
15866 * works on little endian format
15867 */
15868 tANI_U8 *p =
15869 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
15870 int i;
15871
15872 for (i = 0; i < 8; i++)
15873 {
15874 p[7-i] = data->replay_ctr[i];
15875 }
15876 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015877
15878 if (TRUE == pHddCtx->hdd_wlan_suspended)
15879 {
15880 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015881 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
15882 sizeof (tSirGtkOffloadParams));
15883 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015884 pAdapter->sessionId);
15885
15886 if (eHAL_STATUS_SUCCESS != status)
15887 {
15888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15889 "%s: sme_SetGTKOffload failed, returned %d",
15890 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053015891
15892 /* Need to clear any trace of key value in the memory.
15893 * Thus zero out the memory even though it is local
15894 * variable.
15895 */
15896 vos_mem_zero(&hddGtkOffloadReqParams,
15897 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015898 return status;
15899 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15901 "%s: sme_SetGTKOffload successfull", __func__);
15902 }
15903 else
15904 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015905 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15906 "%s: wlan not suspended GTKOffload request is stored",
15907 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015908 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015909
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053015910 /* Need to clear any trace of key value in the memory.
15911 * Thus zero out the memory even though it is local
15912 * variable.
15913 */
15914 vos_mem_zero(&hddGtkOffloadReqParams,
15915 sizeof(hddGtkOffloadReqParams));
15916
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015917 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015918 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015919}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015920
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015921int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
15922 struct cfg80211_gtk_rekey_data *data)
15923{
15924 int ret;
15925
15926 vos_ssr_protect(__func__);
15927 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
15928 vos_ssr_unprotect(__func__);
15929
15930 return ret;
15931}
15932#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015933/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015934 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015935 * This function is used to set access control policy
15936 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015937static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
15938 struct net_device *dev,
15939 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015940{
15941 int i;
15942 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15943 hdd_hostapd_state_t *pHostapdState;
15944 tsap_Config_t *pConfig;
15945 v_CONTEXT_t pVosContext = NULL;
15946 hdd_context_t *pHddCtx;
15947 int status;
15948
15949 ENTER();
15950
15951 if (NULL == pAdapter)
15952 {
15953 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15954 "%s: HDD adapter is Null", __func__);
15955 return -ENODEV;
15956 }
15957
15958 if (NULL == params)
15959 {
15960 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15961 "%s: params is Null", __func__);
15962 return -EINVAL;
15963 }
15964
15965 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15966 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015967 if (0 != status)
15968 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015969 return status;
15970 }
15971
15972 pVosContext = pHddCtx->pvosContext;
15973 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
15974
15975 if (NULL == pHostapdState)
15976 {
15977 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15978 "%s: pHostapdState is Null", __func__);
15979 return -EINVAL;
15980 }
15981
15982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
15983 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053015984 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15985 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
15986 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015987
15988 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
15989 {
15990 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
15991
15992 /* default value */
15993 pConfig->num_accept_mac = 0;
15994 pConfig->num_deny_mac = 0;
15995
15996 /**
15997 * access control policy
15998 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
15999 * listed in hostapd.deny file.
16000 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
16001 * listed in hostapd.accept file.
16002 */
16003 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
16004 {
16005 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
16006 }
16007 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
16008 {
16009 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
16010 }
16011 else
16012 {
16013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16014 "%s:Acl Policy : %d is not supported",
16015 __func__, params->acl_policy);
16016 return -ENOTSUPP;
16017 }
16018
16019 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
16020 {
16021 pConfig->num_accept_mac = params->n_acl_entries;
16022 for (i = 0; i < params->n_acl_entries; i++)
16023 {
16024 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16025 "** Add ACL MAC entry %i in WhiletList :"
16026 MAC_ADDRESS_STR, i,
16027 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16028
16029 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
16030 sizeof(qcmacaddr));
16031 }
16032 }
16033 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
16034 {
16035 pConfig->num_deny_mac = params->n_acl_entries;
16036 for (i = 0; i < params->n_acl_entries; i++)
16037 {
16038 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16039 "** Add ACL MAC entry %i in BlackList :"
16040 MAC_ADDRESS_STR, i,
16041 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16042
16043 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
16044 sizeof(qcmacaddr));
16045 }
16046 }
16047
16048 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
16049 {
16050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16051 "%s: SAP Set Mac Acl fail", __func__);
16052 return -EINVAL;
16053 }
16054 }
16055 else
16056 {
16057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053016058 "%s: Invalid device_mode = %s (%d)",
16059 __func__, hdd_device_modetoString(pAdapter->device_mode),
16060 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016061 return -EINVAL;
16062 }
16063
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016064 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016065 return 0;
16066}
16067
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016068static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16069 struct net_device *dev,
16070 const struct cfg80211_acl_data *params)
16071{
16072 int ret;
16073 vos_ssr_protect(__func__);
16074 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
16075 vos_ssr_unprotect(__func__);
16076
16077 return ret;
16078}
16079
Leo Chang9056f462013-08-01 19:21:11 -070016080#ifdef WLAN_NL80211_TESTMODE
16081#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070016082void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070016083(
16084 void *pAdapter,
16085 void *indCont
16086)
16087{
Leo Changd9df8aa2013-09-26 13:32:26 -070016088 tSirLPHBInd *lphbInd;
16089 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053016090 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070016091
16092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016093 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070016094
c_hpothu73f35e62014-04-18 13:40:08 +053016095 if (pAdapter == NULL)
16096 {
16097 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16098 "%s: pAdapter is NULL\n",__func__);
16099 return;
16100 }
16101
Leo Chang9056f462013-08-01 19:21:11 -070016102 if (NULL == indCont)
16103 {
16104 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016105 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070016106 return;
16107 }
16108
c_hpothu73f35e62014-04-18 13:40:08 +053016109 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070016110 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070016111 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053016112 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070016113 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070016114 GFP_ATOMIC);
16115 if (!skb)
16116 {
16117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16118 "LPHB timeout, NL buffer alloc fail");
16119 return;
16120 }
16121
Leo Changac3ba772013-10-07 09:47:04 -070016122 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070016123 {
16124 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16125 "WLAN_HDD_TM_ATTR_CMD put fail");
16126 goto nla_put_failure;
16127 }
Leo Changac3ba772013-10-07 09:47:04 -070016128 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070016129 {
16130 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16131 "WLAN_HDD_TM_ATTR_TYPE put fail");
16132 goto nla_put_failure;
16133 }
Leo Changac3ba772013-10-07 09:47:04 -070016134 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070016135 sizeof(tSirLPHBInd), lphbInd))
16136 {
16137 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16138 "WLAN_HDD_TM_ATTR_DATA put fail");
16139 goto nla_put_failure;
16140 }
Leo Chang9056f462013-08-01 19:21:11 -070016141 cfg80211_testmode_event(skb, GFP_ATOMIC);
16142 return;
16143
16144nla_put_failure:
16145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16146 "NLA Put fail");
16147 kfree_skb(skb);
16148
16149 return;
16150}
16151#endif /* FEATURE_WLAN_LPHB */
16152
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016153static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070016154{
16155 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
16156 int err = 0;
16157#ifdef FEATURE_WLAN_LPHB
16158 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070016159 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016160
16161 ENTER();
16162
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016163 err = wlan_hdd_validate_context(pHddCtx);
16164 if (0 != err)
16165 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016166 return err;
16167 }
Leo Chang9056f462013-08-01 19:21:11 -070016168#endif /* FEATURE_WLAN_LPHB */
16169
16170 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
16171 if (err)
16172 {
16173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16174 "%s Testmode INV ATTR", __func__);
16175 return err;
16176 }
16177
16178 if (!tb[WLAN_HDD_TM_ATTR_CMD])
16179 {
16180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16181 "%s Testmode INV CMD", __func__);
16182 return -EINVAL;
16183 }
16184
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016185 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16186 TRACE_CODE_HDD_CFG80211_TESTMODE,
16187 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070016188 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
16189 {
16190#ifdef FEATURE_WLAN_LPHB
16191 /* Low Power Heartbeat configuration request */
16192 case WLAN_HDD_TM_CMD_WLAN_HB:
16193 {
16194 int buf_len;
16195 void *buf;
16196 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080016197 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070016198
16199 if (!tb[WLAN_HDD_TM_ATTR_DATA])
16200 {
16201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16202 "%s Testmode INV DATA", __func__);
16203 return -EINVAL;
16204 }
16205
16206 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
16207 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080016208
16209 hb_params_temp =(tSirLPHBReq *)buf;
16210 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
16211 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
16212 return -EINVAL;
16213
Leo Chang9056f462013-08-01 19:21:11 -070016214 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
16215 if (NULL == hb_params)
16216 {
16217 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16218 "%s Request Buffer Alloc Fail", __func__);
16219 return -EINVAL;
16220 }
16221
16222 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070016223 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
16224 hb_params,
16225 wlan_hdd_cfg80211_lphb_ind_handler);
16226 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070016227 {
Leo Changd9df8aa2013-09-26 13:32:26 -070016228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16229 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070016230 vos_mem_free(hb_params);
16231 }
Leo Chang9056f462013-08-01 19:21:11 -070016232 return 0;
16233 }
16234#endif /* FEATURE_WLAN_LPHB */
16235 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16237 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070016238 return -EOPNOTSUPP;
16239 }
16240
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016241 EXIT();
16242 return err;
Leo Chang9056f462013-08-01 19:21:11 -070016243}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016244
16245static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
16246{
16247 int ret;
16248
16249 vos_ssr_protect(__func__);
16250 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
16251 vos_ssr_unprotect(__func__);
16252
16253 return ret;
16254}
Leo Chang9056f462013-08-01 19:21:11 -070016255#endif /* CONFIG_NL80211_TESTMODE */
16256
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016257static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016258 struct net_device *dev,
16259 int idx, struct survey_info *survey)
16260{
16261 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16262 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053016263 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016264 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053016265 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016266 v_S7_t snr,rssi;
16267 int status, i, j, filled = 0;
16268
16269 ENTER();
16270
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016271 if (NULL == pAdapter)
16272 {
16273 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16274 "%s: HDD adapter is Null", __func__);
16275 return -ENODEV;
16276 }
16277
16278 if (NULL == wiphy)
16279 {
16280 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16281 "%s: wiphy is Null", __func__);
16282 return -ENODEV;
16283 }
16284
16285 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16286 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016287 if (0 != status)
16288 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016289 return status;
16290 }
16291
Mihir Sheted9072e02013-08-21 17:02:29 +053016292 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16293
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016294 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053016295 0 != pAdapter->survey_idx ||
16296 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016297 {
16298 /* The survey dump ops when implemented completely is expected to
16299 * return a survey of all channels and the ops is called by the
16300 * kernel with incremental values of the argument 'idx' till it
16301 * returns -ENONET. But we can only support the survey for the
16302 * operating channel for now. survey_idx is used to track
16303 * that the ops is called only once and then return -ENONET for
16304 * the next iteration
16305 */
16306 pAdapter->survey_idx = 0;
16307 return -ENONET;
16308 }
16309
Mukul Sharma9d5233b2015-06-11 20:28:20 +053016310 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
16311 {
16312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16313 "%s: Roaming in progress, hence return ", __func__);
16314 return -ENONET;
16315 }
16316
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016317 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16318
16319 wlan_hdd_get_snr(pAdapter, &snr);
16320 wlan_hdd_get_rssi(pAdapter, &rssi);
16321
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016322 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16323 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
16324 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016325 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
16326 hdd_wlan_get_freq(channel, &freq);
16327
16328
16329 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
16330 {
16331 if (NULL == wiphy->bands[i])
16332 {
16333 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
16334 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
16335 continue;
16336 }
16337
16338 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
16339 {
16340 struct ieee80211_supported_band *band = wiphy->bands[i];
16341
16342 if (band->channels[j].center_freq == (v_U16_t)freq)
16343 {
16344 survey->channel = &band->channels[j];
16345 /* The Rx BDs contain SNR values in dB for the received frames
16346 * while the supplicant expects noise. So we calculate and
16347 * return the value of noise (dBm)
16348 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
16349 */
16350 survey->noise = rssi - snr;
16351 survey->filled = SURVEY_INFO_NOISE_DBM;
16352 filled = 1;
16353 }
16354 }
16355 }
16356
16357 if (filled)
16358 pAdapter->survey_idx = 1;
16359 else
16360 {
16361 pAdapter->survey_idx = 0;
16362 return -ENONET;
16363 }
16364
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016365 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016366 return 0;
16367}
16368
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016369static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
16370 struct net_device *dev,
16371 int idx, struct survey_info *survey)
16372{
16373 int ret;
16374
16375 vos_ssr_protect(__func__);
16376 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
16377 vos_ssr_unprotect(__func__);
16378
16379 return ret;
16380}
16381
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016382/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016383 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016384 * this is called when cfg80211 driver resume
16385 * driver updates latest sched_scan scan result(if any) to cfg80211 database
16386 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016387int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016388{
16389 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16390 hdd_adapter_t *pAdapter;
16391 hdd_adapter_list_node_t *pAdapterNode, *pNext;
16392 VOS_STATUS status = VOS_STATUS_SUCCESS;
16393
16394 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016395
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016396 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016397 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016398 return 0;
16399 }
16400
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016401 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
16402 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016403 spin_lock(&pHddCtx->schedScan_lock);
16404 pHddCtx->isWiphySuspended = FALSE;
16405 if (TRUE != pHddCtx->isSchedScanUpdatePending)
16406 {
16407 spin_unlock(&pHddCtx->schedScan_lock);
16408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16409 "%s: Return resume is not due to PNO indication", __func__);
16410 return 0;
16411 }
16412 // Reset flag to avoid updatating cfg80211 data old results again
16413 pHddCtx->isSchedScanUpdatePending = FALSE;
16414 spin_unlock(&pHddCtx->schedScan_lock);
16415
16416 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
16417
16418 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
16419 {
16420 pAdapter = pAdapterNode->pAdapter;
16421 if ( (NULL != pAdapter) &&
16422 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
16423 {
16424 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016425 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16427 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016428 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016429 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016430 {
16431 /* Acquire wakelock to handle the case where APP's tries to
16432 * suspend immediately after updating the scan results. Whis
16433 * results in app's is in suspended state and not able to
16434 * process the connect request to AP
16435 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053016436 hdd_prevent_suspend_timeout(2000,
16437 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016438 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016439 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016440
16441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16442 "%s : cfg80211 scan result database updated", __func__);
16443
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016444 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016445 return 0;
16446
16447 }
16448 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16449 pAdapterNode = pNext;
16450 }
16451
16452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16453 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016454 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016455 return 0;
16456}
16457
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016458int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
16459{
16460 int ret;
16461
16462 vos_ssr_protect(__func__);
16463 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
16464 vos_ssr_unprotect(__func__);
16465
16466 return ret;
16467}
16468
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016469/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016470 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016471 * this is called when cfg80211 driver suspends
16472 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016473int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016474 struct cfg80211_wowlan *wow)
16475{
16476 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016477 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016478
16479 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016480
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016481 ret = wlan_hdd_validate_context(pHddCtx);
16482 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016483 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016484 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016485 }
16486
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016487
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016488 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16489 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
16490 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016491 pHddCtx->isWiphySuspended = TRUE;
16492
16493 EXIT();
16494
16495 return 0;
16496}
16497
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016498int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
16499 struct cfg80211_wowlan *wow)
16500{
16501 int ret;
16502
16503 vos_ssr_protect(__func__);
16504 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
16505 vos_ssr_unprotect(__func__);
16506
16507 return ret;
16508}
Jeff Johnson295189b2012-06-20 16:38:30 -070016509/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016510static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070016511{
16512 .add_virtual_intf = wlan_hdd_add_virtual_intf,
16513 .del_virtual_intf = wlan_hdd_del_virtual_intf,
16514 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
16515 .change_station = wlan_hdd_change_station,
16516#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
16517 .add_beacon = wlan_hdd_cfg80211_add_beacon,
16518 .del_beacon = wlan_hdd_cfg80211_del_beacon,
16519 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016520#else
16521 .start_ap = wlan_hdd_cfg80211_start_ap,
16522 .change_beacon = wlan_hdd_cfg80211_change_beacon,
16523 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070016524#endif
16525 .change_bss = wlan_hdd_cfg80211_change_bss,
16526 .add_key = wlan_hdd_cfg80211_add_key,
16527 .get_key = wlan_hdd_cfg80211_get_key,
16528 .del_key = wlan_hdd_cfg80211_del_key,
16529 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016530#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070016531 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016532#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016533 .scan = wlan_hdd_cfg80211_scan,
16534 .connect = wlan_hdd_cfg80211_connect,
16535 .disconnect = wlan_hdd_cfg80211_disconnect,
16536 .join_ibss = wlan_hdd_cfg80211_join_ibss,
16537 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
16538 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
16539 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
16540 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070016541 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
16542 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053016543 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070016544#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16545 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
16546 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
16547 .set_txq_params = wlan_hdd_set_txq_params,
16548#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016549 .get_station = wlan_hdd_cfg80211_get_station,
16550 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
16551 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016552 .add_station = wlan_hdd_cfg80211_add_station,
16553#ifdef FEATURE_WLAN_LFR
16554 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
16555 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
16556 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
16557#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016558#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
16559 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
16560#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016561#ifdef FEATURE_WLAN_TDLS
16562 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
16563 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
16564#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016565#ifdef WLAN_FEATURE_GTK_OFFLOAD
16566 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
16567#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016568#ifdef FEATURE_WLAN_SCAN_PNO
16569 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
16570 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
16571#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016572 .resume = wlan_hdd_cfg80211_resume_wlan,
16573 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016574 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070016575#ifdef WLAN_NL80211_TESTMODE
16576 .testmode_cmd = wlan_hdd_cfg80211_testmode,
16577#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016578 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070016579};
16580