blob: 7110c4b0017129de9a532ce1120bea8385e52cf5 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +053026 *
Kiet Lamaa8e15a2014-02-11 23:30:06 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Kiet Lama7f454d2014-07-24 12:04:06 -070030
31
Jeff Johnson295189b2012-06-20 16:38:30 -070032/**========================================================================
33
34 \file wlan_hdd_cfg80211.c
35
36 \brief WLAN Host Device Driver implementation
37
Jeff Johnson295189b2012-06-20 16:38:30 -070038 ========================================================================*/
39
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070040/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070041
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070042 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070043
44
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070045 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070047
48
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070049 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070050
51
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070052 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070053 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070054 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070055
56 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070057 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070058 ==========================================================================*/
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060
61#include <linux/version.h>
62#include <linux/module.h>
63#include <linux/kernel.h>
64#include <linux/init.h>
65#include <linux/wireless.h>
66#include <wlan_hdd_includes.h>
67#include <net/arp.h>
68#include <net/cfg80211.h>
69#include <linux/wireless.h>
70#include <wlan_hdd_wowl.h>
71#include <aniGlobal.h>
72#include "ccmApi.h"
73#include "sirParams.h"
74#include "dot11f.h"
75#include "wlan_hdd_assoc.h"
76#include "wlan_hdd_wext.h"
77#include "sme_Api.h"
78#include "wlan_hdd_p2p.h"
79#include "wlan_hdd_cfg80211.h"
80#include "wlan_hdd_hostapd.h"
81#include "sapInternal.h"
82#include "wlan_hdd_softap_tx_rx.h"
83#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053084#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053085#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053086#include "wlan_hdd_trace.h"
87#include "vos_types.h"
88#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070089#ifdef WLAN_BTAMP_FEATURE
90#include "bap_hdd_misc.h"
91#endif
92#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080093#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053094#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053095#include "wlan_qct_wda.h"
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053096#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070097#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070098
99#define g_mode_rates_size (12)
100#define a_mode_rates_size (8)
101#define FREQ_BASE_80211G (2407)
102#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700103#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530104#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800106 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
108#define HDD2GHZCHAN(freq, chan, flag) { \
109 .band = IEEE80211_BAND_2GHZ, \
110 .center_freq = (freq), \
111 .hw_value = (chan),\
112 .flags = (flag), \
113 .max_antenna_gain = 0 ,\
114 .max_power = 30, \
115}
116
117#define HDD5GHZCHAN(freq, chan, flag) { \
118 .band = IEEE80211_BAND_5GHZ, \
119 .center_freq = (freq), \
120 .hw_value = (chan),\
121 .flags = (flag), \
122 .max_antenna_gain = 0 ,\
123 .max_power = 30, \
124}
125
126#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
127{\
128 .bitrate = rate, \
129 .hw_value = rate_id, \
130 .flags = flag, \
131}
132
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530133#ifdef WLAN_FEATURE_VOWIFI_11R
134#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
135#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
136#endif
137
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530138#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530139#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530140
Sunil Duttc69bccb2014-05-26 21:30:20 +0530141#ifdef WLAN_FEATURE_LINK_LAYER_STATS
142/*
143 * Used to allocate the size of 4096 for the link layer stats.
144 * The size of 4096 is considered assuming that all data per
145 * respective event fit with in the limit.Please take a call
146 * on the limit based on the data requirements on link layer
147 * statistics.
148 */
149#define LL_STATS_EVENT_BUF_SIZE 4096
150#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530151#ifdef WLAN_FEATURE_EXTSCAN
152/*
153 * Used to allocate the size of 4096 for the EXTScan NL data.
154 * The size of 4096 is considered assuming that all data per
155 * respective event fit with in the limit.Please take a call
156 * on the limit based on the data requirements.
157 */
158
159#define EXTSCAN_EVENT_BUF_SIZE 4096
160#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
161#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530162
Atul Mittal115287b2014-07-08 13:26:33 +0530163/*EXT TDLS*/
164/*
165 * Used to allocate the size of 4096 for the TDLS.
166 * The size of 4096 is considered assuming that all data per
167 * respective event fit with in the limit.Please take a call
168 * on the limit based on the data requirements on link layer
169 * statistics.
170 */
171#define EXTTDLS_EVENT_BUF_SIZE 4096
172
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530173static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700174{
175 WLAN_CIPHER_SUITE_WEP40,
176 WLAN_CIPHER_SUITE_WEP104,
177 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800178#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700179#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
180 WLAN_CIPHER_SUITE_KRK,
181 WLAN_CIPHER_SUITE_CCMP,
182#else
183 WLAN_CIPHER_SUITE_CCMP,
184#endif
185#ifdef FEATURE_WLAN_WAPI
186 WLAN_CIPHER_SUITE_SMS4,
187#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700188#ifdef WLAN_FEATURE_11W
189 WLAN_CIPHER_SUITE_AES_CMAC,
190#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700191};
192
193static inline int is_broadcast_ether_addr(const u8 *addr)
194{
195 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
196 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
197}
198
199static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530200{
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 HDD2GHZCHAN(2412, 1, 0) ,
202 HDD2GHZCHAN(2417, 2, 0) ,
203 HDD2GHZCHAN(2422, 3, 0) ,
204 HDD2GHZCHAN(2427, 4, 0) ,
205 HDD2GHZCHAN(2432, 5, 0) ,
206 HDD2GHZCHAN(2437, 6, 0) ,
207 HDD2GHZCHAN(2442, 7, 0) ,
208 HDD2GHZCHAN(2447, 8, 0) ,
209 HDD2GHZCHAN(2452, 9, 0) ,
210 HDD2GHZCHAN(2457, 10, 0) ,
211 HDD2GHZCHAN(2462, 11, 0) ,
212 HDD2GHZCHAN(2467, 12, 0) ,
213 HDD2GHZCHAN(2472, 13, 0) ,
214 HDD2GHZCHAN(2484, 14, 0) ,
215};
216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
218{
219 HDD2GHZCHAN(2412, 1, 0) ,
220 HDD2GHZCHAN(2437, 6, 0) ,
221 HDD2GHZCHAN(2462, 11, 0) ,
222};
Jeff Johnson295189b2012-06-20 16:38:30 -0700223
224static struct ieee80211_channel hdd_channels_5_GHZ[] =
225{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700226 HDD5GHZCHAN(4920, 240, 0) ,
227 HDD5GHZCHAN(4940, 244, 0) ,
228 HDD5GHZCHAN(4960, 248, 0) ,
229 HDD5GHZCHAN(4980, 252, 0) ,
230 HDD5GHZCHAN(5040, 208, 0) ,
231 HDD5GHZCHAN(5060, 212, 0) ,
232 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 HDD5GHZCHAN(5180, 36, 0) ,
234 HDD5GHZCHAN(5200, 40, 0) ,
235 HDD5GHZCHAN(5220, 44, 0) ,
236 HDD5GHZCHAN(5240, 48, 0) ,
237 HDD5GHZCHAN(5260, 52, 0) ,
238 HDD5GHZCHAN(5280, 56, 0) ,
239 HDD5GHZCHAN(5300, 60, 0) ,
240 HDD5GHZCHAN(5320, 64, 0) ,
241 HDD5GHZCHAN(5500,100, 0) ,
242 HDD5GHZCHAN(5520,104, 0) ,
243 HDD5GHZCHAN(5540,108, 0) ,
244 HDD5GHZCHAN(5560,112, 0) ,
245 HDD5GHZCHAN(5580,116, 0) ,
246 HDD5GHZCHAN(5600,120, 0) ,
247 HDD5GHZCHAN(5620,124, 0) ,
248 HDD5GHZCHAN(5640,128, 0) ,
249 HDD5GHZCHAN(5660,132, 0) ,
250 HDD5GHZCHAN(5680,136, 0) ,
251 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800252#ifdef FEATURE_WLAN_CH144
253 HDD5GHZCHAN(5720,144, 0) ,
254#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 HDD5GHZCHAN(5745,149, 0) ,
256 HDD5GHZCHAN(5765,153, 0) ,
257 HDD5GHZCHAN(5785,157, 0) ,
258 HDD5GHZCHAN(5805,161, 0) ,
259 HDD5GHZCHAN(5825,165, 0) ,
260};
261
262static struct ieee80211_rate g_mode_rates[] =
263{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530264 HDD_G_MODE_RATETAB(10, 0x1, 0),
265 HDD_G_MODE_RATETAB(20, 0x2, 0),
266 HDD_G_MODE_RATETAB(55, 0x4, 0),
267 HDD_G_MODE_RATETAB(110, 0x8, 0),
268 HDD_G_MODE_RATETAB(60, 0x10, 0),
269 HDD_G_MODE_RATETAB(90, 0x20, 0),
270 HDD_G_MODE_RATETAB(120, 0x40, 0),
271 HDD_G_MODE_RATETAB(180, 0x80, 0),
272 HDD_G_MODE_RATETAB(240, 0x100, 0),
273 HDD_G_MODE_RATETAB(360, 0x200, 0),
274 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530276};
Jeff Johnson295189b2012-06-20 16:38:30 -0700277
278static struct ieee80211_rate a_mode_rates[] =
279{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530280 HDD_G_MODE_RATETAB(60, 0x10, 0),
281 HDD_G_MODE_RATETAB(90, 0x20, 0),
282 HDD_G_MODE_RATETAB(120, 0x40, 0),
283 HDD_G_MODE_RATETAB(180, 0x80, 0),
284 HDD_G_MODE_RATETAB(240, 0x100, 0),
285 HDD_G_MODE_RATETAB(360, 0x200, 0),
286 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 HDD_G_MODE_RATETAB(540, 0x800, 0),
288};
289
290static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
291{
292 .channels = hdd_channels_2_4_GHZ,
293 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
294 .band = IEEE80211_BAND_2GHZ,
295 .bitrates = g_mode_rates,
296 .n_bitrates = g_mode_rates_size,
297 .ht_cap.ht_supported = 1,
298 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
299 | IEEE80211_HT_CAP_GRN_FLD
300 | IEEE80211_HT_CAP_DSSSCCK40
301 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
302 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
303 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
304 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
305 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
306 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
307};
308
Jeff Johnson295189b2012-06-20 16:38:30 -0700309static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
310{
311 .channels = hdd_social_channels_2_4_GHZ,
312 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
313 .band = IEEE80211_BAND_2GHZ,
314 .bitrates = g_mode_rates,
315 .n_bitrates = g_mode_rates_size,
316 .ht_cap.ht_supported = 1,
317 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
318 | IEEE80211_HT_CAP_GRN_FLD
319 | IEEE80211_HT_CAP_DSSSCCK40
320 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
321 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
322 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
323 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
324 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
325 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
326};
Jeff Johnson295189b2012-06-20 16:38:30 -0700327
328static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
329{
330 .channels = hdd_channels_5_GHZ,
331 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
332 .band = IEEE80211_BAND_5GHZ,
333 .bitrates = a_mode_rates,
334 .n_bitrates = a_mode_rates_size,
335 .ht_cap.ht_supported = 1,
336 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
337 | IEEE80211_HT_CAP_GRN_FLD
338 | IEEE80211_HT_CAP_DSSSCCK40
339 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
340 | IEEE80211_HT_CAP_SGI_40
341 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
342 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
343 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
344 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
345 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
346 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
347};
348
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530349/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700350 TX/RX direction for each kind of interface */
351static const struct ieee80211_txrx_stypes
352wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
353 [NL80211_IFTYPE_STATION] = {
354 .tx = 0xffff,
355 .rx = BIT(SIR_MAC_MGMT_ACTION) |
356 BIT(SIR_MAC_MGMT_PROBE_REQ),
357 },
358 [NL80211_IFTYPE_AP] = {
359 .tx = 0xffff,
360 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
361 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
362 BIT(SIR_MAC_MGMT_PROBE_REQ) |
363 BIT(SIR_MAC_MGMT_DISASSOC) |
364 BIT(SIR_MAC_MGMT_AUTH) |
365 BIT(SIR_MAC_MGMT_DEAUTH) |
366 BIT(SIR_MAC_MGMT_ACTION),
367 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700368 [NL80211_IFTYPE_ADHOC] = {
369 .tx = 0xffff,
370 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
371 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
372 BIT(SIR_MAC_MGMT_PROBE_REQ) |
373 BIT(SIR_MAC_MGMT_DISASSOC) |
374 BIT(SIR_MAC_MGMT_AUTH) |
375 BIT(SIR_MAC_MGMT_DEAUTH) |
376 BIT(SIR_MAC_MGMT_ACTION),
377 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 [NL80211_IFTYPE_P2P_CLIENT] = {
379 .tx = 0xffff,
380 .rx = BIT(SIR_MAC_MGMT_ACTION) |
381 BIT(SIR_MAC_MGMT_PROBE_REQ),
382 },
383 [NL80211_IFTYPE_P2P_GO] = {
384 /* This is also same as for SoftAP */
385 .tx = 0xffff,
386 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
387 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
388 BIT(SIR_MAC_MGMT_PROBE_REQ) |
389 BIT(SIR_MAC_MGMT_DISASSOC) |
390 BIT(SIR_MAC_MGMT_AUTH) |
391 BIT(SIR_MAC_MGMT_DEAUTH) |
392 BIT(SIR_MAC_MGMT_ACTION),
393 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700394};
395
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800396#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800397static const struct ieee80211_iface_limit
398wlan_hdd_iface_limit[] = {
399 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800400 /* max = 3 ; Our driver create two interfaces during driver init
401 * wlan0 and p2p0 interfaces. p2p0 is considered as station
402 * interface until a group is formed. In JB architecture, once the
403 * group is formed, interface type of p2p0 is changed to P2P GO or
404 * Client.
405 * When supplicant remove the group, it first issue a set interface
406 * cmd to change the mode back to Station. In JB this works fine as
407 * we advertize two station type interface during driver init.
408 * Some vendors create separate interface for P2P GO/Client,
409 * after group formation(Third one). But while group remove
410 * supplicant first tries to change the mode(3rd interface) to STATION
411 * But as we advertized only two sta type interfaces nl80211 was
412 * returning error for the third one which was leading to failure in
413 * delete interface. Ideally while removing the group, supplicant
414 * should not try to change the 3rd interface mode to Station type.
415 * Till we get a fix in wpa_supplicant, we advertize max STA
416 * interface type to 3
417 */
418 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800419 .types = BIT(NL80211_IFTYPE_STATION),
420 },
421 {
422 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700423 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800424 },
425 {
426 .max = 1,
427 .types = BIT(NL80211_IFTYPE_P2P_GO) |
428 BIT(NL80211_IFTYPE_P2P_CLIENT),
429 },
430};
431
432/* By default, only single channel concurrency is allowed */
433static struct ieee80211_iface_combination
434wlan_hdd_iface_combination = {
435 .limits = wlan_hdd_iface_limit,
436 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800437 /*
438 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
439 * and p2p0 interfaces during driver init
440 * Some vendors create separate interface for P2P operations.
441 * wlan0: STA interface
442 * p2p0: P2P Device interface, action frames goes
443 * through this interface.
444 * p2p-xx: P2P interface, After GO negotiation this interface is
445 * created for p2p operations(GO/CLIENT interface).
446 */
447 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800448 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
449 .beacon_int_infra_match = false,
450};
451#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800452
Jeff Johnson295189b2012-06-20 16:38:30 -0700453static struct cfg80211_ops wlan_hdd_cfg80211_ops;
454
455/* Data rate 100KBPS based on IE Index */
456struct index_data_rate_type
457{
458 v_U8_t beacon_rate_index;
459 v_U16_t supported_rate[4];
460};
461
462/* 11B, 11G Rate table include Basic rate and Extended rate
463 The IDX field is the rate index
464 The HI field is the rate when RSSI is strong or being ignored
465 (in this case we report actual rate)
466 The MID field is the rate when RSSI is moderate
467 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
468 The LO field is the rate when RSSI is low
469 (in this case we don't report rates, actual current rate used)
470 */
471static const struct
472{
473 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700474 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700475} supported_data_rate[] =
476{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700477/* IDX HI HM LM LO (RSSI-based index */
478 {2, { 10, 10, 10, 0}},
479 {4, { 20, 20, 10, 0}},
480 {11, { 55, 20, 10, 0}},
481 {12, { 60, 55, 20, 0}},
482 {18, { 90, 55, 20, 0}},
483 {22, {110, 55, 20, 0}},
484 {24, {120, 90, 60, 0}},
485 {36, {180, 120, 60, 0}},
486 {44, {220, 180, 60, 0}},
487 {48, {240, 180, 90, 0}},
488 {66, {330, 180, 90, 0}},
489 {72, {360, 240, 90, 0}},
490 {96, {480, 240, 120, 0}},
491 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700492};
493
494/* MCS Based rate table */
495static struct index_data_rate_type supported_mcs_rate[] =
496{
497/* MCS L20 L40 S20 S40 */
498 {0, {65, 135, 72, 150}},
499 {1, {130, 270, 144, 300}},
500 {2, {195, 405, 217, 450}},
501 {3, {260, 540, 289, 600}},
502 {4, {390, 810, 433, 900}},
503 {5, {520, 1080, 578, 1200}},
504 {6, {585, 1215, 650, 1350}},
505 {7, {650, 1350, 722, 1500}}
506};
507
Leo Chang6f8870f2013-03-26 18:11:36 -0700508#ifdef WLAN_FEATURE_11AC
509
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530510#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700511
512struct index_vht_data_rate_type
513{
514 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530515 v_U16_t supported_VHT80_rate[2];
516 v_U16_t supported_VHT40_rate[2];
517 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700518};
519
520typedef enum
521{
522 DATA_RATE_11AC_MAX_MCS_7,
523 DATA_RATE_11AC_MAX_MCS_8,
524 DATA_RATE_11AC_MAX_MCS_9,
525 DATA_RATE_11AC_MAX_MCS_NA
526} eDataRate11ACMaxMcs;
527
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530528/* SSID broadcast type */
529typedef enum eSSIDBcastType
530{
531 eBCAST_UNKNOWN = 0,
532 eBCAST_NORMAL = 1,
533 eBCAST_HIDDEN = 2,
534} tSSIDBcastType;
535
Leo Chang6f8870f2013-03-26 18:11:36 -0700536/* MCS Based VHT rate table */
537static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
538{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530539/* MCS L80 S80 L40 S40 L20 S40*/
540 {0, {293, 325}, {135, 150}, {65, 72}},
541 {1, {585, 650}, {270, 300}, {130, 144}},
542 {2, {878, 975}, {405, 450}, {195, 217}},
543 {3, {1170, 1300}, {540, 600}, {260, 289}},
544 {4, {1755, 1950}, {810, 900}, {390, 433}},
545 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
546 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
547 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
548 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
549 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700550};
551#endif /* WLAN_FEATURE_11AC */
552
c_hpothu79aab322014-07-14 21:11:01 +0530553/*array index points to MCS and array value points respective rssi*/
554static int rssiMcsTbl[][10] =
555{
556/*MCS 0 1 2 3 4 5 6 7 8 9*/
557 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
558 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
559 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
560};
561
Jeff Johnson295189b2012-06-20 16:38:30 -0700562extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530563#ifdef FEATURE_WLAN_SCAN_PNO
564static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
565#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700566
Leo Chang9056f462013-08-01 19:21:11 -0700567#ifdef WLAN_NL80211_TESTMODE
568enum wlan_hdd_tm_attr
569{
570 WLAN_HDD_TM_ATTR_INVALID = 0,
571 WLAN_HDD_TM_ATTR_CMD = 1,
572 WLAN_HDD_TM_ATTR_DATA = 2,
573 WLAN_HDD_TM_ATTR_TYPE = 3,
574 /* keep last */
575 WLAN_HDD_TM_ATTR_AFTER_LAST,
576 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
577};
578
579enum wlan_hdd_tm_cmd
580{
581 WLAN_HDD_TM_CMD_WLAN_HB = 1,
582};
583
584#define WLAN_HDD_TM_DATA_MAX_LEN 5000
585
586static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
587{
588 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
589 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
590 .len = WLAN_HDD_TM_DATA_MAX_LEN },
591};
592#endif /* WLAN_NL80211_TESTMODE */
593
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800594#ifdef FEATURE_WLAN_CH_AVOID
595/*
596 * FUNCTION: wlan_hdd_send_avoid_freq_event
597 * This is called when wlan driver needs to send vendor specific
598 * avoid frequency range event to userspace
599 */
600int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
601 tHddAvoidFreqList *pAvoidFreqList)
602{
603 struct sk_buff *vendor_event;
604
605 ENTER();
606
607 if (!pHddCtx)
608 {
609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
610 "%s: HDD context is null", __func__);
611 return -1;
612 }
613
614 if (!pAvoidFreqList)
615 {
616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
617 "%s: pAvoidFreqList is null", __func__);
618 return -1;
619 }
620
621 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530622#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
623 NULL,
624#endif
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800625 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530626 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800627 GFP_KERNEL);
628 if (!vendor_event)
629 {
630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
631 "%s: cfg80211_vendor_event_alloc failed", __func__);
632 return -1;
633 }
634
635 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
636 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
637
638 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
639
640 EXIT();
641 return 0;
642}
643#endif /* FEATURE_WLAN_CH_AVOID */
644
Srinivas Dasari030bad32015-02-18 23:23:54 +0530645/*
646 * FUNCTION: __wlan_hdd_cfg80211_nan_request
647 * This is called when wlan driver needs to send vendor specific
648 * nan request event.
649 */
650static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
651 struct wireless_dev *wdev,
652 const void *data, int data_len)
653{
654 tNanRequestReq nan_req;
655 VOS_STATUS status;
656 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530657 struct net_device *dev = wdev->netdev;
658 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
659 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530660 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
661
662 if (0 == data_len)
663 {
664 hddLog(VOS_TRACE_LEVEL_ERROR,
665 FL("NAN - Invalid Request, length = 0"));
666 return ret_val;
667 }
668
669 if (NULL == data)
670 {
671 hddLog(VOS_TRACE_LEVEL_ERROR,
672 FL("NAN - Invalid Request, data is NULL"));
673 return ret_val;
674 }
675
676 status = wlan_hdd_validate_context(pHddCtx);
677 if (0 != status)
678 {
679 hddLog(VOS_TRACE_LEVEL_ERROR,
680 FL("HDD context is not valid"));
681 return -EINVAL;
682 }
683
684 hddLog(LOG1, FL("Received NAN command"));
685 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
686 (tANI_U8 *)data, data_len);
687
688 /* check the NAN Capability */
689 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
690 {
691 hddLog(VOS_TRACE_LEVEL_ERROR,
692 FL("NAN is not supported by Firmware"));
693 return -EINVAL;
694 }
695
696 nan_req.request_data_len = data_len;
697 nan_req.request_data = data;
698
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530699 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530700 if (VOS_STATUS_SUCCESS == status)
701 {
702 ret_val = 0;
703 }
704 return ret_val;
705}
706
707/*
708 * FUNCTION: wlan_hdd_cfg80211_nan_request
709 * Wrapper to protect the nan vendor command from ssr
710 */
711static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
712 struct wireless_dev *wdev,
713 const void *data, int data_len)
714{
715 int ret;
716
717 vos_ssr_protect(__func__);
718 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
719 vos_ssr_unprotect(__func__);
720
721 return ret;
722}
723
724/*
725 * FUNCTION: wlan_hdd_cfg80211_nan_callback
726 * This is a callback function and it gets called
727 * when we need to report nan response event to
728 * upper layers.
729 */
730static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
731{
732 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
733 struct sk_buff *vendor_event;
734 int status;
735 tSirNanEvent *data;
736
737 ENTER();
738 if (NULL == msg)
739 {
740 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
741 FL(" msg received here is null"));
742 return;
743 }
744 data = msg;
745
746 status = wlan_hdd_validate_context(pHddCtx);
747
748 if (0 != status)
749 {
750 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
751 FL("HDD context is not valid"));
752 return;
753 }
754
755 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530756#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
757 NULL,
758#endif
Srinivas Dasari030bad32015-02-18 23:23:54 +0530759 data->event_data_len +
760 NLMSG_HDRLEN,
761 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
762 GFP_KERNEL);
763
764 if (!vendor_event)
765 {
766 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
767 FL("cfg80211_vendor_event_alloc failed"));
768 return;
769 }
770 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
771 data->event_data_len, data->event_data))
772 {
773 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
774 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
775 kfree_skb(vendor_event);
776 return;
777 }
778 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
779 EXIT();
780}
781
782/*
783 * FUNCTION: wlan_hdd_cfg80211_nan_init
784 * This function is called to register the callback to sme layer
785 */
786inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
787{
788 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
789}
790
791
Sunil Duttc69bccb2014-05-26 21:30:20 +0530792#ifdef WLAN_FEATURE_LINK_LAYER_STATS
793
794static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
795 struct sk_buff *vendor_event)
796{
797 if (nla_put_u8(vendor_event,
798 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
799 stats->rate.preamble) ||
800 nla_put_u8(vendor_event,
801 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
802 stats->rate.nss) ||
803 nla_put_u8(vendor_event,
804 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
805 stats->rate.bw) ||
806 nla_put_u8(vendor_event,
807 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
808 stats->rate.rateMcsIdx) ||
809 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
810 stats->rate.bitrate ) ||
811 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
812 stats->txMpdu ) ||
813 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
814 stats->rxMpdu ) ||
815 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
816 stats->mpduLost ) ||
817 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
818 stats->retries) ||
819 nla_put_u32(vendor_event,
820 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
821 stats->retriesShort ) ||
822 nla_put_u32(vendor_event,
823 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
824 stats->retriesLong))
825 {
826 hddLog(VOS_TRACE_LEVEL_ERROR,
827 FL("QCA_WLAN_VENDOR_ATTR put fail"));
828 return FALSE;
829 }
830 return TRUE;
831}
832
833static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
834 struct sk_buff *vendor_event)
835{
836 u32 i = 0;
837 struct nlattr *rateInfo;
838 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
839 stats->type) ||
840 nla_put(vendor_event,
841 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
842 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
843 nla_put_u32(vendor_event,
844 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
845 stats->capabilities) ||
846 nla_put_u32(vendor_event,
847 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
848 stats->numRate))
849 {
850 hddLog(VOS_TRACE_LEVEL_ERROR,
851 FL("QCA_WLAN_VENDOR_ATTR put fail"));
852 goto error;
853 }
854
855 rateInfo = nla_nest_start(vendor_event,
856 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530857 if(!rateInfo)
858 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530859 for (i = 0; i < stats->numRate; i++)
860 {
861 struct nlattr *rates;
862 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
863 stats->rateStats +
864 (i * sizeof(tSirWifiRateStat)));
865 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530866 if(!rates)
867 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530868
869 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
870 {
871 hddLog(VOS_TRACE_LEVEL_ERROR,
872 FL("QCA_WLAN_VENDOR_ATTR put fail"));
873 return FALSE;
874 }
875 nla_nest_end(vendor_event, rates);
876 }
877 nla_nest_end(vendor_event, rateInfo);
878
879 return TRUE;
880error:
881 return FALSE;
882}
883
884static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
885 struct sk_buff *vendor_event)
886{
887 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
888 stats->ac ) ||
889 nla_put_u32(vendor_event,
890 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
891 stats->txMpdu ) ||
892 nla_put_u32(vendor_event,
893 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
894 stats->rxMpdu ) ||
895 nla_put_u32(vendor_event,
896 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
897 stats->txMcast ) ||
898 nla_put_u32(vendor_event,
899 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
900 stats->rxMcast ) ||
901 nla_put_u32(vendor_event,
902 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
903 stats->rxAmpdu ) ||
904 nla_put_u32(vendor_event,
905 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
906 stats->txAmpdu ) ||
907 nla_put_u32(vendor_event,
908 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
909 stats->mpduLost )||
910 nla_put_u32(vendor_event,
911 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
912 stats->retries ) ||
913 nla_put_u32(vendor_event,
914 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
915 stats->retriesShort ) ||
916 nla_put_u32(vendor_event,
917 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
918 stats->retriesLong ) ||
919 nla_put_u32(vendor_event,
920 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
921 stats->contentionTimeMin ) ||
922 nla_put_u32(vendor_event,
923 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
924 stats->contentionTimeMax ) ||
925 nla_put_u32(vendor_event,
926 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
927 stats->contentionTimeAvg ) ||
928 nla_put_u32(vendor_event,
929 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
930 stats->contentionNumSamples ))
931 {
932 hddLog(VOS_TRACE_LEVEL_ERROR,
933 FL("QCA_WLAN_VENDOR_ATTR put fail") );
934 return FALSE;
935 }
936 return TRUE;
937}
938
939static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
940 struct sk_buff *vendor_event)
941{
Dino Myclec8f3f332014-07-21 16:48:27 +0530942 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530943 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
944 nla_put(vendor_event,
945 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
946 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
947 nla_put_u32(vendor_event,
948 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
949 stats->state ) ||
950 nla_put_u32(vendor_event,
951 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
952 stats->roaming ) ||
953 nla_put_u32(vendor_event,
954 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
955 stats->capabilities ) ||
956 nla_put(vendor_event,
957 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
958 strlen(stats->ssid), stats->ssid) ||
959 nla_put(vendor_event,
960 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
961 WNI_CFG_BSSID_LEN, stats->bssid) ||
962 nla_put(vendor_event,
963 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
964 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
965 nla_put(vendor_event,
966 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
967 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
968 )
969 {
970 hddLog(VOS_TRACE_LEVEL_ERROR,
971 FL("QCA_WLAN_VENDOR_ATTR put fail") );
972 return FALSE;
973 }
974 return TRUE;
975}
976
Dino Mycle3b9536d2014-07-09 22:05:24 +0530977static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
978 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530979 struct sk_buff *vendor_event)
980{
981 int i = 0;
982 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530983 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
984 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530985 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530986
Sunil Duttc69bccb2014-05-26 21:30:20 +0530987 if (FALSE == put_wifi_interface_info(
988 &pWifiIfaceStat->info,
989 vendor_event))
990 {
991 hddLog(VOS_TRACE_LEVEL_ERROR,
992 FL("QCA_WLAN_VENDOR_ATTR put fail") );
993 return FALSE;
994
995 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530996 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
997 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
998 if (NULL == pWifiIfaceStatTL)
999 {
1000 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
1001 return FALSE;
1002 }
1003
Srinivas Dasaria8a304f2014-11-15 16:13:37 +05301004 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
1005 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
1006 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
1007 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1008
1009 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1010 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1011 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1012 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301013
1014 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1015 {
1016 if (VOS_STATUS_SUCCESS ==
1017 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1018 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1019 {
1020 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1021 * obtained from TL structure
1022 */
1023
1024 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1025 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301026 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1027
Srinivas Dasari98947432014-11-07 19:41:24 +05301028 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1029 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1030 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1031 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1032 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1033 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1034 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1035 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301036
Srinivas Dasari98947432014-11-07 19:41:24 +05301037 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1038 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1039 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1040 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1041 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1042 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1043 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1044 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301045
Srinivas Dasari98947432014-11-07 19:41:24 +05301046 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1047 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1048 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1049 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1050 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1051 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1052 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1053 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301054 }
1055 else
1056 {
1057 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1058 }
1059
Dino Mycle3b9536d2014-07-09 22:05:24 +05301060 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1061 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1062 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1063 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1064 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1065 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1066 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1067 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1068 }
1069 else
1070 {
1071 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1072 }
1073
1074
Sunil Duttc69bccb2014-05-26 21:30:20 +05301075
1076 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301077 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1078 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_IFACE) ||
1079 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301080 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1081 pWifiIfaceStat->beaconRx) ||
1082 nla_put_u32(vendor_event,
1083 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1084 pWifiIfaceStat->mgmtRx) ||
1085 nla_put_u32(vendor_event,
1086 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1087 pWifiIfaceStat->mgmtActionRx) ||
1088 nla_put_u32(vendor_event,
1089 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1090 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301091 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301092 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1093 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301094 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301095 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1096 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301097 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301098 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1099 pWifiIfaceStat->rssiAck))
1100 {
1101 hddLog(VOS_TRACE_LEVEL_ERROR,
1102 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301103 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301104 return FALSE;
1105 }
1106
1107 wmmInfo = nla_nest_start(vendor_event,
1108 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301109 if(!wmmInfo)
1110 {
1111 vos_mem_free(pWifiIfaceStatTL);
1112 return FALSE;
1113 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301114 for (i = 0; i < WIFI_AC_MAX; i++)
1115 {
1116 struct nlattr *wmmStats;
1117 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301118 if(!wmmStats)
1119 {
1120 vos_mem_free(pWifiIfaceStatTL);
1121 return FALSE;
1122 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301123 if (FALSE == put_wifi_wmm_ac_stat(
1124 &pWifiIfaceStat->AccessclassStats[i],
1125 vendor_event))
1126 {
1127 hddLog(VOS_TRACE_LEVEL_ERROR,
1128 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301129 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301130 return FALSE;
1131 }
1132
1133 nla_nest_end(vendor_event, wmmStats);
1134 }
1135 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301136 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301137 return TRUE;
1138}
1139
1140static tSirWifiInterfaceMode
1141 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1142{
1143 switch (deviceMode)
1144 {
1145 case WLAN_HDD_INFRA_STATION:
1146 return WIFI_INTERFACE_STA;
1147 case WLAN_HDD_SOFTAP:
1148 return WIFI_INTERFACE_SOFTAP;
1149 case WLAN_HDD_P2P_CLIENT:
1150 return WIFI_INTERFACE_P2P_CLIENT;
1151 case WLAN_HDD_P2P_GO:
1152 return WIFI_INTERFACE_P2P_GO;
1153 case WLAN_HDD_IBSS:
1154 return WIFI_INTERFACE_IBSS;
1155 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301156 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301157 }
1158}
1159
1160static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1161 tpSirWifiInterfaceInfo pInfo)
1162{
1163 v_U8_t *staMac = NULL;
1164 hdd_station_ctx_t *pHddStaCtx;
1165 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1166 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1167
1168 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1169
1170 vos_mem_copy(pInfo->macAddr,
1171 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1172
1173 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1174 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1175 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1176 {
1177 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1178 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1179 {
1180 pInfo->state = WIFI_DISCONNECTED;
1181 }
1182 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1183 {
1184 hddLog(VOS_TRACE_LEVEL_ERROR,
1185 "%s: Session ID %d, Connection is in progress", __func__,
1186 pAdapter->sessionId);
1187 pInfo->state = WIFI_ASSOCIATING;
1188 }
1189 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1190 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1191 {
1192 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1193 hddLog(VOS_TRACE_LEVEL_ERROR,
1194 "%s: client " MAC_ADDRESS_STR
1195 " is in the middle of WPS/EAPOL exchange.", __func__,
1196 MAC_ADDR_ARRAY(staMac));
1197 pInfo->state = WIFI_AUTHENTICATING;
1198 }
1199 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1200 {
1201 pInfo->state = WIFI_ASSOCIATED;
1202 vos_mem_copy(pInfo->bssid,
1203 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1204 vos_mem_copy(pInfo->ssid,
1205 pHddStaCtx->conn_info.SSID.SSID.ssId,
1206 pHddStaCtx->conn_info.SSID.SSID.length);
1207 //NULL Terminate the string.
1208 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1209 }
1210 }
1211 vos_mem_copy(pInfo->countryStr,
1212 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1213
1214 vos_mem_copy(pInfo->apCountryStr,
1215 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1216
1217 return TRUE;
1218}
1219
1220/*
1221 * hdd_link_layer_process_peer_stats () - This function is called after
1222 * receiving Link Layer Peer statistics from FW.This function converts
1223 * the firmware data to the NL data and sends the same to the kernel/upper
1224 * layers.
1225 */
1226static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1227 v_VOID_t *pData)
1228{
1229 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1230 tpSirWifiRateStat pWifiRateStat;
1231 tpSirWifiPeerStat pWifiPeerStat;
1232 tpSirWifiPeerInfo pWifiPeerInfo;
1233 struct nlattr *peerInfo;
1234 struct sk_buff *vendor_event;
1235 int status, i;
1236
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301237 ENTER();
1238
Sunil Duttc69bccb2014-05-26 21:30:20 +05301239 status = wlan_hdd_validate_context(pHddCtx);
1240 if (0 != status)
1241 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301242 return;
1243 }
1244
1245 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1246
1247 hddLog(VOS_TRACE_LEVEL_INFO,
1248 "LL_STATS_PEER_ALL : numPeers %u",
1249 pWifiPeerStat->numPeers);
1250 {
1251 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1252 {
1253 pWifiPeerInfo = (tpSirWifiPeerInfo)
1254 ((uint8 *)pWifiPeerStat->peerInfo +
1255 ( i * sizeof(tSirWifiPeerInfo)));
1256
Dasari Srinivas1be0c4e2014-10-19 13:03:41 +05301257 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) {
1258 pWifiPeerInfo->type = WIFI_PEER_AP;
1259 }
1260 if (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) {
1261 pWifiPeerInfo->type = WIFI_PEER_P2P_GO;
1262 }
1263
Sunil Duttc69bccb2014-05-26 21:30:20 +05301264 hddLog(VOS_TRACE_LEVEL_INFO,
1265 " %d) LL_STATS Channel Stats "
1266 " Peer Type %u "
1267 " peerMacAddress %pM "
1268 " capabilities 0x%x "
1269 " numRate %u ",
1270 i,
1271 pWifiPeerInfo->type,
1272 pWifiPeerInfo->peerMacAddress,
1273 pWifiPeerInfo->capabilities,
1274 pWifiPeerInfo->numRate);
1275 {
1276 int j;
1277 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1278 {
1279 pWifiRateStat = (tpSirWifiRateStat)
1280 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1281 ( j * sizeof(tSirWifiRateStat)));
1282
1283 hddLog(VOS_TRACE_LEVEL_INFO,
1284 " peer Rate Stats "
1285 " preamble %u "
1286 " nss %u "
1287 " bw %u "
1288 " rateMcsIdx %u "
1289 " reserved %u "
1290 " bitrate %u "
1291 " txMpdu %u "
1292 " rxMpdu %u "
1293 " mpduLost %u "
1294 " retries %u "
1295 " retriesShort %u "
1296 " retriesLong %u",
1297 pWifiRateStat->rate.preamble,
1298 pWifiRateStat->rate.nss,
1299 pWifiRateStat->rate.bw,
1300 pWifiRateStat->rate.rateMcsIdx,
1301 pWifiRateStat->rate.reserved,
1302 pWifiRateStat->rate.bitrate,
1303 pWifiRateStat->txMpdu,
1304 pWifiRateStat->rxMpdu,
1305 pWifiRateStat->mpduLost,
1306 pWifiRateStat->retries,
1307 pWifiRateStat->retriesShort,
1308 pWifiRateStat->retriesLong);
1309 }
1310 }
1311 }
1312 }
1313
1314 /*
1315 * Allocate a size of 4096 for the peer stats comprising
1316 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1317 * sizeof (tSirWifiRateStat).Each field is put with an
1318 * NL attribute.The size of 4096 is considered assuming
1319 * that number of rates shall not exceed beyond 50 with
1320 * the sizeof (tSirWifiRateStat) being 32.
1321 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301322 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1323 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301324 if (!vendor_event)
1325 {
1326 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301327 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301328 __func__);
1329 return;
1330 }
1331 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301332 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1333 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_PEER) ||
1334 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301335 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1336 pWifiPeerStat->numPeers))
1337 {
1338 hddLog(VOS_TRACE_LEVEL_ERROR,
1339 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1340 kfree_skb(vendor_event);
1341 return;
1342 }
1343
1344 peerInfo = nla_nest_start(vendor_event,
1345 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301346 if(!peerInfo)
1347 {
1348 hddLog(VOS_TRACE_LEVEL_ERROR,
1349 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1350 __func__);
1351 kfree_skb(vendor_event);
1352 return;
1353 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301354
1355 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1356 pWifiPeerStat->peerInfo);
1357
1358 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1359 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301360 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301361 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301362
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301363 if(!peers)
1364 {
1365 hddLog(VOS_TRACE_LEVEL_ERROR,
1366 "%s: peer stats put fail",
1367 __func__);
1368 kfree_skb(vendor_event);
1369 return;
1370 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301371 if (FALSE == put_wifi_peer_info(
1372 pWifiPeerInfo, vendor_event))
1373 {
1374 hddLog(VOS_TRACE_LEVEL_ERROR,
1375 "%s: put_wifi_peer_info put fail", __func__);
1376 kfree_skb(vendor_event);
1377 return;
1378 }
1379
1380 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1381 pWifiPeerStat->peerInfo +
1382 (i * sizeof(tSirWifiPeerInfo)) +
1383 (numRate * sizeof (tSirWifiRateStat)));
1384 nla_nest_end(vendor_event, peers);
1385 }
1386 nla_nest_end(vendor_event, peerInfo);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301387 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301388 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301389}
1390
1391/*
1392 * hdd_link_layer_process_iface_stats () - This function is called after
1393 * receiving Link Layer Interface statistics from FW.This function converts
1394 * the firmware data to the NL data and sends the same to the kernel/upper
1395 * layers.
1396 */
1397static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1398 v_VOID_t *pData)
1399{
1400 tpSirWifiIfaceStat pWifiIfaceStat;
1401 struct sk_buff *vendor_event;
1402 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1403 int status;
1404
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301405 ENTER();
1406
Sunil Duttc69bccb2014-05-26 21:30:20 +05301407 status = wlan_hdd_validate_context(pHddCtx);
1408 if (0 != status)
1409 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301410 return;
1411 }
1412 /*
1413 * Allocate a size of 4096 for the interface stats comprising
1414 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1415 * assuming that all these fit with in the limit.Please take
1416 * a call on the limit based on the data requirements on
1417 * interface statistics.
1418 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301419 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1420 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301421 if (!vendor_event)
1422 {
1423 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301424 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301425 return;
1426 }
1427
1428 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1429
Dino Mycle3b9536d2014-07-09 22:05:24 +05301430
1431 if (FALSE == hdd_get_interface_info( pAdapter,
1432 &pWifiIfaceStat->info))
1433 {
1434 hddLog(VOS_TRACE_LEVEL_ERROR,
1435 FL("hdd_get_interface_info get fail") );
1436 kfree_skb(vendor_event);
1437 return;
1438 }
1439
1440 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1441 vendor_event))
1442 {
1443 hddLog(VOS_TRACE_LEVEL_ERROR,
1444 FL("put_wifi_iface_stats fail") );
1445 kfree_skb(vendor_event);
1446 return;
1447 }
1448
Sunil Duttc69bccb2014-05-26 21:30:20 +05301449 hddLog(VOS_TRACE_LEVEL_INFO,
1450 "WMI_LINK_STATS_IFACE Data");
1451
1452 hddLog(VOS_TRACE_LEVEL_INFO,
1453 "LL_STATS_IFACE: "
1454 " Mode %u "
1455 " MAC %pM "
1456 " State %u "
1457 " Roaming %u "
1458 " capabilities 0x%x "
1459 " SSID %s "
1460 " BSSID %pM",
1461 pWifiIfaceStat->info.mode,
1462 pWifiIfaceStat->info.macAddr,
1463 pWifiIfaceStat->info.state,
1464 pWifiIfaceStat->info.roaming,
1465 pWifiIfaceStat->info.capabilities,
1466 pWifiIfaceStat->info.ssid,
1467 pWifiIfaceStat->info.bssid);
1468
1469 hddLog(VOS_TRACE_LEVEL_INFO,
1470 " AP country str: %c%c%c",
1471 pWifiIfaceStat->info.apCountryStr[0],
1472 pWifiIfaceStat->info.apCountryStr[1],
1473 pWifiIfaceStat->info.apCountryStr[2]);
1474
1475
1476 hddLog(VOS_TRACE_LEVEL_INFO,
1477 " Country Str Association: %c%c%c",
1478 pWifiIfaceStat->info.countryStr[0],
1479 pWifiIfaceStat->info.countryStr[1],
1480 pWifiIfaceStat->info.countryStr[2]);
1481
1482 hddLog(VOS_TRACE_LEVEL_INFO,
1483 " beaconRx %u "
1484 " mgmtRx %u "
1485 " mgmtActionRx %u "
1486 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301487 " rssiMgmt %d "
1488 " rssiData %d "
1489 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301490 pWifiIfaceStat->beaconRx,
1491 pWifiIfaceStat->mgmtRx,
1492 pWifiIfaceStat->mgmtActionRx,
1493 pWifiIfaceStat->mgmtActionTx,
1494 pWifiIfaceStat->rssiMgmt,
1495 pWifiIfaceStat->rssiData,
1496 pWifiIfaceStat->rssiAck );
1497
1498
1499 {
1500 int i;
1501 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1502 {
1503 hddLog(VOS_TRACE_LEVEL_INFO,
1504
1505 " %d) LL_STATS IFACE: "
1506 " ac: %u txMpdu: %u "
1507 " rxMpdu: %u txMcast: %u "
1508 " rxMcast: %u rxAmpdu: %u "
1509 " txAmpdu: %u mpduLost: %u "
1510 " retries: %u retriesShort: %u "
1511 " retriesLong: %u contentionTimeMin: %u "
1512 " contentionTimeMax: %u contentionTimeAvg: %u "
1513 " contentionNumSamples: %u",
1514 i,
1515 pWifiIfaceStat->AccessclassStats[i].ac,
1516 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1517 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1518 pWifiIfaceStat->AccessclassStats[i].txMcast,
1519 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1520 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1521 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1522 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1523 pWifiIfaceStat->AccessclassStats[i].retries,
1524 pWifiIfaceStat->
1525 AccessclassStats[i].retriesShort,
1526 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1527 pWifiIfaceStat->
1528 AccessclassStats[i].contentionTimeMin,
1529 pWifiIfaceStat->
1530 AccessclassStats[i].contentionTimeMax,
1531 pWifiIfaceStat->
1532 AccessclassStats[i].contentionTimeAvg,
1533 pWifiIfaceStat->
1534 AccessclassStats[i].contentionNumSamples);
1535
1536 }
1537 }
1538
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301539 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301540
1541 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301542}
1543
1544/*
1545 * hdd_link_layer_process_radio_stats () - This function is called after
1546 * receiving Link Layer Radio statistics from FW.This function converts
1547 * the firmware data to the NL data and sends the same to the kernel/upper
1548 * layers.
1549 */
1550static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1551 v_VOID_t *pData)
1552{
1553 int status, i;
1554 tpSirWifiRadioStat pWifiRadioStat;
1555 tpSirWifiChannelStats pWifiChannelStats;
1556 struct sk_buff *vendor_event;
1557 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1558 struct nlattr *chList;
1559
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301560 ENTER();
1561
Sunil Duttc69bccb2014-05-26 21:30:20 +05301562 status = wlan_hdd_validate_context(pHddCtx);
1563 if (0 != status)
1564 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301565 return;
1566 }
1567 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1568
1569 hddLog(VOS_TRACE_LEVEL_INFO,
1570 "LL_STATS_RADIO"
1571 " radio is %d onTime is %u "
1572 " txTime is %u rxTime is %u "
1573 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301574 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301575 " onTimePnoScan is %u onTimeHs20 is %u "
1576 " numChannels is %u",
1577 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1578 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1579 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301580 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301581 pWifiRadioStat->onTimeRoamScan,
1582 pWifiRadioStat->onTimePnoScan,
1583 pWifiRadioStat->onTimeHs20,
1584 pWifiRadioStat->numChannels);
1585 /*
1586 * Allocate a size of 4096 for the Radio stats comprising
1587 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1588 * (tSirWifiChannelStats).Each channel data is put with an
1589 * NL attribute.The size of 4096 is considered assuming that
1590 * number of channels shall not exceed beyond 60 with the
1591 * sizeof (tSirWifiChannelStats) being 24 bytes.
1592 */
1593
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301594 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1595 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301596 if (!vendor_event)
1597 {
1598 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301599 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301600 return;
1601 }
1602
1603 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301604 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1605 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_RADIO) ||
1606 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301607 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1608 pWifiRadioStat->radio) ||
1609 nla_put_u32(vendor_event,
1610 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1611 pWifiRadioStat->onTime) ||
1612 nla_put_u32(vendor_event,
1613 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1614 pWifiRadioStat->txTime) ||
1615 nla_put_u32(vendor_event,
1616 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1617 pWifiRadioStat->rxTime) ||
1618 nla_put_u32(vendor_event,
1619 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1620 pWifiRadioStat->onTimeScan) ||
1621 nla_put_u32(vendor_event,
1622 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1623 pWifiRadioStat->onTimeNbd) ||
1624 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301625 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1626 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301627 nla_put_u32(vendor_event,
1628 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1629 pWifiRadioStat->onTimeRoamScan) ||
1630 nla_put_u32(vendor_event,
1631 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1632 pWifiRadioStat->onTimePnoScan) ||
1633 nla_put_u32(vendor_event,
1634 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1635 pWifiRadioStat->onTimeHs20) ||
1636 nla_put_u32(vendor_event,
1637 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1638 pWifiRadioStat->numChannels))
1639 {
1640 hddLog(VOS_TRACE_LEVEL_ERROR,
1641 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1642 kfree_skb(vendor_event);
1643 return ;
1644 }
1645
1646 chList = nla_nest_start(vendor_event,
1647 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301648 if(!chList)
1649 {
1650 hddLog(VOS_TRACE_LEVEL_ERROR,
1651 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1652 __func__);
1653 kfree_skb(vendor_event);
1654 return;
1655 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301656 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1657 {
1658 struct nlattr *chInfo;
1659
1660 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1661 pWifiRadioStat->channels +
1662 (i * sizeof(tSirWifiChannelStats)));
1663
1664 hddLog(VOS_TRACE_LEVEL_INFO,
1665 " %d) Channel Info"
1666 " width is %u "
1667 " CenterFreq %u "
1668 " CenterFreq0 %u "
1669 " CenterFreq1 %u "
1670 " onTime %u "
1671 " ccaBusyTime %u",
1672 i,
1673 pWifiChannelStats->channel.width,
1674 pWifiChannelStats->channel.centerFreq,
1675 pWifiChannelStats->channel.centerFreq0,
1676 pWifiChannelStats->channel.centerFreq1,
1677 pWifiChannelStats->onTime,
1678 pWifiChannelStats->ccaBusyTime);
1679
1680
1681 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301682 if(!chInfo)
1683 {
1684 hddLog(VOS_TRACE_LEVEL_ERROR,
1685 "%s: failed to put chInfo",
1686 __func__);
1687 kfree_skb(vendor_event);
1688 return;
1689 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301690
1691 if (nla_put_u32(vendor_event,
1692 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1693 pWifiChannelStats->channel.width) ||
1694 nla_put_u32(vendor_event,
1695 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1696 pWifiChannelStats->channel.centerFreq) ||
1697 nla_put_u32(vendor_event,
1698 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1699 pWifiChannelStats->channel.centerFreq0) ||
1700 nla_put_u32(vendor_event,
1701 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1702 pWifiChannelStats->channel.centerFreq1) ||
1703 nla_put_u32(vendor_event,
1704 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1705 pWifiChannelStats->onTime) ||
1706 nla_put_u32(vendor_event,
1707 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1708 pWifiChannelStats->ccaBusyTime))
1709 {
1710 hddLog(VOS_TRACE_LEVEL_ERROR,
1711 FL("cfg80211_vendor_event_alloc failed") );
1712 kfree_skb(vendor_event);
1713 return ;
1714 }
1715 nla_nest_end(vendor_event, chInfo);
1716 }
1717 nla_nest_end(vendor_event, chList);
1718
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301719 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301720
1721 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301722 return;
1723}
1724
1725/*
1726 * hdd_link_layer_stats_ind_callback () - This function is called after
1727 * receiving Link Layer indications from FW.This callback converts the firmware
1728 * data to the NL data and send the same to the kernel/upper layers.
1729 */
1730static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1731 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301732 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301733{
Dino Mycled3d50022014-07-07 12:58:25 +05301734 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1735 hdd_adapter_t *pAdapter = NULL;
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301736 struct hdd_ll_stats_context *context;
Dino Mycled3d50022014-07-07 12:58:25 +05301737 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301738 int status;
1739
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301740 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301741
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301742 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301743 if (0 != status)
1744 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301745 return;
1746 }
1747
Dino Mycled3d50022014-07-07 12:58:25 +05301748 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1749 if (NULL == pAdapter)
1750 {
1751 hddLog(VOS_TRACE_LEVEL_ERROR,
1752 FL(" MAC address %pM does not exist with host"),
1753 macAddr);
1754 return;
1755 }
1756
Sunil Duttc69bccb2014-05-26 21:30:20 +05301757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301758 "%s: Interface: %s LLStats indType: %d", __func__,
1759 pAdapter->dev->name, indType);
1760
Sunil Duttc69bccb2014-05-26 21:30:20 +05301761 switch (indType)
1762 {
1763 case SIR_HAL_LL_STATS_RESULTS_RSP:
1764 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301765 hddLog(VOS_TRACE_LEVEL_INFO,
1766 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1767 hddLog(VOS_TRACE_LEVEL_INFO,
1768 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1769 linkLayerStatsResults->paramId);
1770 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301771 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1772 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301773 hddLog(VOS_TRACE_LEVEL_INFO,
1774 "LL_STATS RESULTS RESPONSE respId = %u",
1775 linkLayerStatsResults->respId);
1776 hddLog(VOS_TRACE_LEVEL_INFO,
1777 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1778 linkLayerStatsResults->moreResultToFollow);
1779 hddLog(VOS_TRACE_LEVEL_INFO,
1780 "LL_STATS RESULTS RESPONSE result = %p",
1781 linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301782 spin_lock(&hdd_context_lock);
1783 context = &pHddCtx->ll_stats_context;
1784 /* validate response received from target */
1785 if ((context->request_id != linkLayerStatsResults->respId) ||
1786 !(context->request_bitmap & linkLayerStatsResults->paramId))
1787 {
1788 spin_unlock(&hdd_context_lock);
1789 hddLog(LOGE,
1790 FL("Error : Request id %d response id %d request bitmap 0x%x"
1791 "response bitmap 0x%x"),
1792 context->request_id, linkLayerStatsResults->respId,
1793 context->request_bitmap, linkLayerStatsResults->paramId);
1794 return;
1795 }
1796 spin_unlock(&hdd_context_lock);
1797
Sunil Duttc69bccb2014-05-26 21:30:20 +05301798 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1799 {
1800 hdd_link_layer_process_radio_stats(pAdapter,
1801 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301802 spin_lock(&hdd_context_lock);
1803 context->request_bitmap &= ~(WMI_LINK_STATS_RADIO);
1804 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301805 }
1806 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1807 {
1808 hdd_link_layer_process_iface_stats(pAdapter,
1809 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301810 spin_lock(&hdd_context_lock);
1811 context->request_bitmap &= ~(WMI_LINK_STATS_IFACE);
1812 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301813 }
1814 else if ( linkLayerStatsResults->paramId &
1815 WMI_LINK_STATS_ALL_PEER )
1816 {
1817 hdd_link_layer_process_peer_stats(pAdapter,
1818 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301819 spin_lock(&hdd_context_lock);
1820 context->request_bitmap &= ~(WMI_LINK_STATS_ALL_PEER);
1821 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301822 } /* WMI_LINK_STATS_ALL_PEER */
1823 else
1824 {
1825 hddLog(VOS_TRACE_LEVEL_ERROR,
1826 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1827 }
1828
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301829 spin_lock(&hdd_context_lock);
1830 /* complete response event if all requests are completed */
1831 if (0 == context->request_bitmap)
1832 complete(&context->response_event);
1833 spin_unlock(&hdd_context_lock);
1834
Sunil Duttc69bccb2014-05-26 21:30:20 +05301835 break;
1836 }
1837 default:
1838 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1839 break;
1840 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301841
1842 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301843 return;
1844}
1845
1846const struct
1847nla_policy
1848qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1849{
1850 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1851 { .type = NLA_U32 },
1852 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1853 { .type = NLA_U32 },
1854};
1855
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301856static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1857 struct wireless_dev *wdev,
1858 const void *data,
1859 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301860{
1861 int status;
1862 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301863 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301864 struct net_device *dev = wdev->netdev;
1865 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1866 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1867
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301868 ENTER();
1869
Sunil Duttc69bccb2014-05-26 21:30:20 +05301870 status = wlan_hdd_validate_context(pHddCtx);
1871 if (0 != status)
1872 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301873 return -EINVAL;
1874 }
1875
1876 if (NULL == pAdapter)
1877 {
1878 hddLog(VOS_TRACE_LEVEL_ERROR,
1879 FL("HDD adapter is Null"));
1880 return -ENODEV;
1881 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301882 /* check the LLStats Capability */
1883 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1884 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1885 {
1886 hddLog(VOS_TRACE_LEVEL_ERROR,
1887 FL("Link Layer Statistics not supported by Firmware"));
1888 return -EINVAL;
1889 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301890
1891 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1892 (struct nlattr *)data,
1893 data_len, qca_wlan_vendor_ll_set_policy))
1894 {
1895 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1896 return -EINVAL;
1897 }
1898 if (!tb_vendor
1899 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1900 {
1901 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1902 return -EINVAL;
1903 }
1904 if (!tb_vendor[
1905 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1906 {
1907 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1908 return -EINVAL;
1909 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301910 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301911 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301912
Dino Mycledf0a5d92014-07-04 09:41:55 +05301913 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301914 nla_get_u32(
1915 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1916
Dino Mycledf0a5d92014-07-04 09:41:55 +05301917 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301918 nla_get_u32(
1919 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1920
Dino Mycled3d50022014-07-07 12:58:25 +05301921 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1922 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301923
1924
1925 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301926 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301927 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301928 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301929 hddLog(VOS_TRACE_LEVEL_INFO,
1930 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301931 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301932 hddLog(VOS_TRACE_LEVEL_INFO,
1933 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301934 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301935
1936 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1937 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301938 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301939 {
1940 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1941 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301942 return -EINVAL;
1943
1944 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301945
Sunil Duttc69bccb2014-05-26 21:30:20 +05301946 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301947 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301948 {
1949 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1950 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301951 return -EINVAL;
1952 }
1953
1954 pAdapter->isLinkLayerStatsSet = 1;
1955
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301956 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301957 return 0;
1958}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301959static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1960 struct wireless_dev *wdev,
1961 const void *data,
1962 int data_len)
1963{
1964 int ret = 0;
1965
1966 vos_ssr_protect(__func__);
1967 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1968 vos_ssr_unprotect(__func__);
1969
1970 return ret;
1971}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301972
1973const struct
1974nla_policy
1975qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1976{
1977 /* Unsigned 32bit value provided by the caller issuing the GET stats
1978 * command. When reporting
1979 * the stats results, the driver uses the same value to indicate
1980 * which GET request the results
1981 * correspond to.
1982 */
1983 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1984
1985 /* Unsigned 32bit value . bit mask to identify what statistics are
1986 requested for retrieval */
1987 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1988};
1989
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301990static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1991 struct wireless_dev *wdev,
1992 const void *data,
1993 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301994{
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301995 unsigned long rc;
1996 struct hdd_ll_stats_context *context;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301997 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1998 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301999 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302000 struct net_device *dev = wdev->netdev;
2001 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mukul Sharma10313ba2015-07-29 19:14:39 +05302002 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302003 int status;
2004
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302005 ENTER();
2006
Sunil Duttc69bccb2014-05-26 21:30:20 +05302007 status = wlan_hdd_validate_context(pHddCtx);
2008 if (0 != status)
2009 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302010 return -EINVAL ;
2011 }
2012
2013 if (NULL == pAdapter)
2014 {
2015 hddLog(VOS_TRACE_LEVEL_FATAL,
2016 "%s: HDD adapter is Null", __func__);
2017 return -ENODEV;
2018 }
Mukul Sharma10313ba2015-07-29 19:14:39 +05302019
2020 if (pHddStaCtx == NULL)
2021 {
2022 hddLog(VOS_TRACE_LEVEL_FATAL,
2023 "%s: HddStaCtx is Null", __func__);
2024 return -ENODEV;
2025 }
2026
Dino Mycledf0a5d92014-07-04 09:41:55 +05302027 /* check the LLStats Capability */
2028 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2029 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2030 {
2031 hddLog(VOS_TRACE_LEVEL_ERROR,
2032 FL("Link Layer Statistics not supported by Firmware"));
2033 return -EINVAL;
2034 }
2035
Sunil Duttc69bccb2014-05-26 21:30:20 +05302036
2037 if (!pAdapter->isLinkLayerStatsSet)
2038 {
2039 hddLog(VOS_TRACE_LEVEL_FATAL,
2040 "%s: isLinkLayerStatsSet : %d",
2041 __func__, pAdapter->isLinkLayerStatsSet);
2042 return -EINVAL;
2043 }
2044
Mukul Sharma10313ba2015-07-29 19:14:39 +05302045 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
2046 {
2047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2048 "%s: Roaming in progress, so unable to proceed this request", __func__);
2049 return -EBUSY;
2050 }
2051
Sunil Duttc69bccb2014-05-26 21:30:20 +05302052 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2053 (struct nlattr *)data,
2054 data_len, qca_wlan_vendor_ll_get_policy))
2055 {
2056 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2057 return -EINVAL;
2058 }
2059
2060 if (!tb_vendor
2061 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2062 {
2063 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2064 return -EINVAL;
2065 }
2066
2067 if (!tb_vendor
2068 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2069 {
2070 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
2071 return -EINVAL;
2072 }
2073
Sunil Duttc69bccb2014-05-26 21:30:20 +05302074
Dino Mycledf0a5d92014-07-04 09:41:55 +05302075 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302076 nla_get_u32( tb_vendor[
2077 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05302078 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302079 nla_get_u32( tb_vendor[
2080 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
2081
Dino Mycled3d50022014-07-07 12:58:25 +05302082 vos_mem_copy(linkLayerStatsGetReq.macAddr,
2083 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302084
2085 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302086 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302087 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302088 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302089 hddLog(VOS_TRACE_LEVEL_INFO,
2090 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302091 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302092
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302093 spin_lock(&hdd_context_lock);
2094 context = &pHddCtx->ll_stats_context;
2095 context->request_id = linkLayerStatsGetReq.reqId;
2096 context->request_bitmap = linkLayerStatsGetReq.paramIdMask;
2097 INIT_COMPLETION(context->response_event);
2098 spin_unlock(&hdd_context_lock);
2099
Sunil Duttc69bccb2014-05-26 21:30:20 +05302100 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302101 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302102 {
2103 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2104 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302105 return -EINVAL;
2106 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302107
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302108 rc = wait_for_completion_timeout(&context->response_event,
2109 msecs_to_jiffies(WLAN_WAIT_TIME_LL_STATS));
2110 if (!rc)
2111 {
2112 hddLog(LOGE,
2113 FL("Target response timed out request id %d request bitmap 0x%x"),
2114 context->request_id, context->request_bitmap);
2115 return -ETIMEDOUT;
2116 }
2117
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302118 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302119 return 0;
2120}
2121
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302122static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2123 struct wireless_dev *wdev,
2124 const void *data,
2125 int data_len)
2126{
2127 int ret = 0;
2128
2129 vos_ssr_protect(__func__);
2130 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
2131 vos_ssr_unprotect(__func__);
2132
2133 return ret;
2134}
2135
Sunil Duttc69bccb2014-05-26 21:30:20 +05302136const struct
2137nla_policy
2138qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
2139{
2140 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
2141 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
2142 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
2143 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
2144};
2145
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302146static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2147 struct wireless_dev *wdev,
2148 const void *data,
2149 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302150{
2151 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2152 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302153 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302154 struct net_device *dev = wdev->netdev;
2155 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2156 u32 statsClearReqMask;
2157 u8 stopReq;
2158 int status;
2159
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302160 ENTER();
2161
Sunil Duttc69bccb2014-05-26 21:30:20 +05302162 status = wlan_hdd_validate_context(pHddCtx);
2163 if (0 != status)
2164 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302165 return -EINVAL;
2166 }
2167
2168 if (NULL == pAdapter)
2169 {
2170 hddLog(VOS_TRACE_LEVEL_FATAL,
2171 "%s: HDD adapter is Null", __func__);
2172 return -ENODEV;
2173 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302174 /* check the LLStats Capability */
2175 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2176 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2177 {
2178 hddLog(VOS_TRACE_LEVEL_ERROR,
2179 FL("Enable LLStats Capability"));
2180 return -EINVAL;
2181 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302182
2183 if (!pAdapter->isLinkLayerStatsSet)
2184 {
2185 hddLog(VOS_TRACE_LEVEL_FATAL,
2186 "%s: isLinkLayerStatsSet : %d",
2187 __func__, pAdapter->isLinkLayerStatsSet);
2188 return -EINVAL;
2189 }
2190
2191 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2192 (struct nlattr *)data,
2193 data_len, qca_wlan_vendor_ll_clr_policy))
2194 {
2195 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2196 return -EINVAL;
2197 }
2198
2199 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2200
2201 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2202 {
2203 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2204 return -EINVAL;
2205
2206 }
2207
Sunil Duttc69bccb2014-05-26 21:30:20 +05302208
Dino Mycledf0a5d92014-07-04 09:41:55 +05302209 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302210 nla_get_u32(
2211 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2212
Dino Mycledf0a5d92014-07-04 09:41:55 +05302213 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302214 nla_get_u8(
2215 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2216
2217 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302218 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302219
Dino Mycled3d50022014-07-07 12:58:25 +05302220 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2221 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302222
2223 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302224 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302225 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302226 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302227 hddLog(VOS_TRACE_LEVEL_INFO,
2228 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302229 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302230 hddLog(VOS_TRACE_LEVEL_INFO,
2231 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302232 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302233
2234 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302235 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302236 {
2237 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302238 hdd_station_ctx_t *pHddStaCtx;
2239
2240 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2241 if (VOS_STATUS_SUCCESS !=
2242 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2243 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2244 {
2245 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2246 "WLANTL_ClearInterfaceStats Failed", __func__);
2247 return -EINVAL;
2248 }
2249 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2250 (statsClearReqMask & WIFI_STATS_IFACE)) {
2251 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2252 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2253 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2254 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2255 }
2256
Sunil Duttc69bccb2014-05-26 21:30:20 +05302257 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2258 2 * sizeof(u32) +
2259 NLMSG_HDRLEN);
2260
2261 if (temp_skbuff != NULL)
2262 {
2263
2264 if (nla_put_u32(temp_skbuff,
2265 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2266 statsClearReqMask) ||
2267 nla_put_u32(temp_skbuff,
2268 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2269 stopReq))
2270 {
2271 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2272 kfree_skb(temp_skbuff);
2273 return -EINVAL;
2274 }
2275 /* If the ask is to stop the stats collection as part of clear
2276 * (stopReq = 1) , ensure that no further requests of get
2277 * go to the firmware by having isLinkLayerStatsSet set to 0.
2278 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302279 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302280 * case the firmware is just asked to clear the statistics.
2281 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302282 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302283 pAdapter->isLinkLayerStatsSet = 0;
2284 return cfg80211_vendor_cmd_reply(temp_skbuff);
2285 }
2286 return -ENOMEM;
2287 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302288
2289 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302290 return -EINVAL;
2291}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302292static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2293 struct wireless_dev *wdev,
2294 const void *data,
2295 int data_len)
2296{
2297 int ret = 0;
2298
2299 vos_ssr_protect(__func__);
2300 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2301 vos_ssr_unprotect(__func__);
2302
2303 return ret;
2304
2305
2306}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302307#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2308
Dino Mycle6fb96c12014-06-10 11:52:40 +05302309#ifdef WLAN_FEATURE_EXTSCAN
2310static const struct nla_policy
2311wlan_hdd_extscan_config_policy
2312 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2313{
2314 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2315 { .type = NLA_U32 },
2316 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2317 { .type = NLA_U32 },
2318 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2319 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2320 { .type = NLA_U32 },
2321 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2322 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2323
2324 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2325 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2326 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2327 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2328 { .type = NLA_U8 },
2329 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2330 { .type = NLA_U32 },
2331 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2332 { .type = NLA_U32 },
2333 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2334 { .type = NLA_U32 },
2335 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] =
2336 { .type = NLA_U8 },
2337 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2338 { .type = NLA_U8 },
2339 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2340 { .type = NLA_U8 },
2341
2342 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2343 { .type = NLA_U32 },
2344 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2345 { .type = NLA_UNSPEC },
2346 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2347 { .type = NLA_S32 },
2348 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2349 { .type = NLA_S32 },
2350 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2351 { .type = NLA_U32 },
2352 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2353 { .type = NLA_U32 },
2354 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] =
2355 { .type = NLA_U32 },
2356 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]
2357 = { .type = NLA_U32 },
2358 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] =
2359 { .type = NLA_U32 },
2360 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type =
2361 NLA_U32 },
2362};
2363
2364static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg)
2365{
2366 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2367 struct sk_buff *skb = NULL;
2368 tpSirEXTScanCapabilitiesEvent pData =
2369 (tpSirEXTScanCapabilitiesEvent) pMsg;
2370
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302371 ENTER();
2372
2373 if (wlan_hdd_validate_context(pHddCtx))
2374 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302375 return;
2376 }
2377
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302378 if (!pMsg)
2379 {
2380 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2381 return;
2382 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302383 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302384#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2385 NULL,
2386#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302387 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2388 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
2389 GFP_KERNEL);
2390
2391 if (!skb) {
2392 hddLog(VOS_TRACE_LEVEL_ERROR,
2393 FL("cfg80211_vendor_event_alloc failed"));
2394 return;
2395 }
2396
2397 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2398 hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize);
2399 hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets);
2400 hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan);
2401 hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)",
2402 pData->maxRssiSampleSize);
2403 hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)",
2404 pData->maxScanReportingThreshold);
2405 hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs);
2406 hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)",
2407 pData->maxSignificantWifiChangeAPs);
2408 hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)",
2409 pData->maxBsidHistoryEntries);
2410
2411 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2412 pData->requestId) ||
2413 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) ||
2414 nla_put_u32(skb,
2415 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
2416 pData->scanCacheSize) ||
2417 nla_put_u32(skb,
2418 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
2419 pData->scanBuckets) ||
2420 nla_put_u32(skb,
2421 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
2422 pData->maxApPerScan) ||
2423 nla_put_u32(skb,
2424 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
2425 pData->maxRssiSampleSize) ||
2426 nla_put_u32(skb,
2427 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
2428 pData->maxScanReportingThreshold) ||
2429 nla_put_u32(skb,
2430 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS,
2431 pData->maxHotlistAPs) ||
2432 nla_put_u32(skb,
2433 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
2434 pData->maxSignificantWifiChangeAPs) ||
2435 nla_put_u32(skb,
2436 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
2437 pData->maxBsidHistoryEntries)) {
2438 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2439 goto nla_put_failure;
2440 }
2441
2442 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302443 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302444 return;
2445
2446nla_put_failure:
2447 kfree_skb(skb);
2448 return;
2449}
2450
2451
2452static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2453{
2454 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2455 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2456 struct sk_buff *skb = NULL;
2457 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
2458
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302459 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302460
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302461 if (wlan_hdd_validate_context(pHddCtx)){
2462 return;
2463 }
2464 if (!pMsg)
2465 {
2466 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302467 return;
2468 }
2469
2470 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302471#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2472 NULL,
2473#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302474 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2475 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
2476 GFP_KERNEL);
2477
2478 if (!skb) {
2479 hddLog(VOS_TRACE_LEVEL_ERROR,
2480 FL("cfg80211_vendor_event_alloc failed"));
2481 return;
2482 }
2483 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2484 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2485 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2486
2487 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2488 pData->requestId) ||
2489 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2490 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2491 goto nla_put_failure;
2492 }
2493
2494 /*
2495 * Store the Request ID for comparing with the requestID obtained
2496 * in other requests.HDD shall return a failure is the extscan_stop
2497 * request is issued with a different requestId as that of the
2498 * extscan_start request. Also, This requestId shall be used while
2499 * indicating the full scan results to the upper layers.
2500 * The requestId is stored with the assumption that the firmware
2501 * shall return the ext scan start request's requestId in ext scan
2502 * start response.
2503 */
2504 if (pData->status == 0)
2505 pMac->sme.extScanStartReqId = pData->requestId;
2506
2507
2508 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302509 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302510 return;
2511
2512nla_put_failure:
2513 kfree_skb(skb);
2514 return;
2515}
2516
2517
2518static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2519{
2520 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2521 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2522 struct sk_buff *skb = NULL;
2523
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302524 ENTER();
2525
2526 if (wlan_hdd_validate_context(pHddCtx)){
2527 return;
2528 }
2529 if (!pMsg)
2530 {
2531 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302532 return;
2533 }
2534
2535 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302536#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2537 NULL,
2538#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302539 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2540 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2541 GFP_KERNEL);
2542
2543 if (!skb) {
2544 hddLog(VOS_TRACE_LEVEL_ERROR,
2545 FL("cfg80211_vendor_event_alloc failed"));
2546 return;
2547 }
2548 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2549 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2550
2551 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2552 pData->requestId) ||
2553 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2554 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2555 goto nla_put_failure;
2556 }
2557
2558 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302559 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302560 return;
2561
2562nla_put_failure:
2563 kfree_skb(skb);
2564 return;
2565}
2566
2567
2568static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2569 void *pMsg)
2570{
2571 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2572 struct sk_buff *skb = NULL;
2573 tpSirEXTScanSetBssidHotListRspParams pData =
2574 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2575
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302576 ENTER();
2577
2578 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302579 return;
2580 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302581 if (!pMsg)
2582 {
2583 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2584 return;
2585 }
2586
Dino Mycle6fb96c12014-06-10 11:52:40 +05302587 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302588#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2589 NULL,
2590#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302591 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2592 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2593 GFP_KERNEL);
2594
2595 if (!skb) {
2596 hddLog(VOS_TRACE_LEVEL_ERROR,
2597 FL("cfg80211_vendor_event_alloc failed"));
2598 return;
2599 }
2600 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2601 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2602 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2603
2604 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2605 pData->requestId) ||
2606 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2607 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2608 goto nla_put_failure;
2609 }
2610
2611 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302612 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302613 return;
2614
2615nla_put_failure:
2616 kfree_skb(skb);
2617 return;
2618}
2619
2620static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2621 void *pMsg)
2622{
2623 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2624 struct sk_buff *skb = NULL;
2625 tpSirEXTScanResetBssidHotlistRspParams pData =
2626 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2627
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302628 ENTER();
2629
2630 if (wlan_hdd_validate_context(pHddCtx)) {
2631 return;
2632 }
2633 if (!pMsg)
2634 {
2635 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302636 return;
2637 }
2638
2639 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302640#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2641 NULL,
2642#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302643 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2644 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2645 GFP_KERNEL);
2646
2647 if (!skb) {
2648 hddLog(VOS_TRACE_LEVEL_ERROR,
2649 FL("cfg80211_vendor_event_alloc failed"));
2650 return;
2651 }
2652 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2653 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2654
2655 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2656 pData->requestId) ||
2657 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2658 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2659 goto nla_put_failure;
2660 }
2661
2662 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302663 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302664 return;
2665
2666nla_put_failure:
2667 kfree_skb(skb);
2668 return;
2669}
2670
2671
2672static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2673 void *pMsg)
2674{
2675 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2676 struct sk_buff *skb = NULL;
2677 tpSirEXTScanSetSignificantChangeRspParams pData =
2678 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2679
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302680 ENTER();
2681
2682 if (wlan_hdd_validate_context(pHddCtx)) {
2683 return;
2684 }
2685 if (!pMsg)
2686 {
2687 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302688 return;
2689 }
2690
2691 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302692#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2693 NULL,
2694#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302695 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2696 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2697 GFP_KERNEL);
2698
2699 if (!skb) {
2700 hddLog(VOS_TRACE_LEVEL_ERROR,
2701 FL("cfg80211_vendor_event_alloc failed"));
2702 return;
2703 }
2704 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2705 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2706 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2707
2708 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2709 pData->requestId) ||
2710 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2711 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2712 goto nla_put_failure;
2713 }
2714
2715 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302716 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302717 return;
2718
2719nla_put_failure:
2720 kfree_skb(skb);
2721 return;
2722}
2723
2724
2725static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2726 void *pMsg)
2727{
2728 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2729 struct sk_buff *skb = NULL;
2730 tpSirEXTScanResetSignificantChangeRspParams pData =
2731 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2732
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302733 ENTER();
2734
2735 if (wlan_hdd_validate_context(pHddCtx)) {
2736 return;
2737 }
2738 if (!pMsg)
2739 {
2740 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302741 return;
2742 }
2743
2744 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302745#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2746 NULL,
2747#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302748 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2749 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2750 GFP_KERNEL);
2751
2752 if (!skb) {
2753 hddLog(VOS_TRACE_LEVEL_ERROR,
2754 FL("cfg80211_vendor_event_alloc failed"));
2755 return;
2756 }
2757 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2758 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2759 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2760
2761 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2762 pData->requestId) ||
2763 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2764 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2765 goto nla_put_failure;
2766 }
2767
2768 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302769 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302770 return;
2771
2772nla_put_failure:
2773 kfree_skb(skb);
2774 return;
2775}
2776
2777static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2778 void *pMsg)
2779{
2780 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2781 struct sk_buff *skb = NULL;
2782 tANI_U32 i = 0, j, resultsPerEvent;
2783 tANI_S32 totalResults;
2784 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2785 tpSirWifiScanResult pSirWifiScanResult;
2786
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302787 ENTER();
2788
2789 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302790 return;
2791 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302792 if (!pMsg)
2793 {
2794 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2795 return;
2796 }
2797
Dino Mycle6fb96c12014-06-10 11:52:40 +05302798 totalResults = pData->numOfAps;
2799 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2800 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2801 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2802
2803 do{
2804 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2805 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2806 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2807
2808 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302809#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2810 NULL,
2811#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302812 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2813 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2814 GFP_KERNEL);
2815
2816 if (!skb) {
2817 hddLog(VOS_TRACE_LEVEL_ERROR,
2818 FL("cfg80211_vendor_event_alloc failed"));
2819 return;
2820 }
2821
2822 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2823
2824 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2825 pData->requestId) ||
2826 nla_put_u32(skb,
2827 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2828 resultsPerEvent)) {
2829 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2830 goto fail;
2831 }
2832 if (nla_put_u8(skb,
2833 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2834 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2835 {
2836 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2837 goto fail;
2838 }
2839
2840 if (resultsPerEvent) {
2841 struct nlattr *aps;
2842
2843 aps = nla_nest_start(skb,
2844 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2845 if (!aps)
2846 {
2847 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2848 goto fail;
2849 }
2850
2851 for (j = 0; j < resultsPerEvent; j++, i++) {
2852 struct nlattr *ap;
2853 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2854 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2855
2856 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2857 "Ssid (%s)"
2858 "Bssid: %pM "
2859 "Channel (%u)"
2860 "Rssi (%d)"
2861 "RTT (%u)"
2862 "RTT_SD (%u)",
2863 i,
2864 pSirWifiScanResult->ts,
2865 pSirWifiScanResult->ssid,
2866 pSirWifiScanResult->bssid,
2867 pSirWifiScanResult->channel,
2868 pSirWifiScanResult->rssi,
2869 pSirWifiScanResult->rtt,
2870 pSirWifiScanResult->rtt_sd);
2871
2872 ap = nla_nest_start(skb, j + 1);
2873 if (!ap)
2874 {
2875 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2876 goto fail;
2877 }
2878
2879 if (nla_put_u64(skb,
2880 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2881 pSirWifiScanResult->ts) )
2882 {
2883 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2884 goto fail;
2885 }
2886 if (nla_put(skb,
2887 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2888 sizeof(pSirWifiScanResult->ssid),
2889 pSirWifiScanResult->ssid) )
2890 {
2891 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2892 goto fail;
2893 }
2894 if (nla_put(skb,
2895 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2896 sizeof(pSirWifiScanResult->bssid),
2897 pSirWifiScanResult->bssid) )
2898 {
2899 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2900 goto fail;
2901 }
2902 if (nla_put_u32(skb,
2903 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2904 pSirWifiScanResult->channel) )
2905 {
2906 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2907 goto fail;
2908 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302909 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302910 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2911 pSirWifiScanResult->rssi) )
2912 {
2913 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2914 goto fail;
2915 }
2916 if (nla_put_u32(skb,
2917 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2918 pSirWifiScanResult->rtt) )
2919 {
2920 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2921 goto fail;
2922 }
2923 if (nla_put_u32(skb,
2924 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2925 pSirWifiScanResult->rtt_sd))
2926 {
2927 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2928 goto fail;
2929 }
2930
2931 nla_nest_end(skb, ap);
2932 }
2933 nla_nest_end(skb, aps);
2934
2935 }
2936 cfg80211_vendor_event(skb, GFP_KERNEL);
2937 } while (totalResults > 0);
2938
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302939 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302940 return;
2941fail:
2942 kfree_skb(skb);
2943 return;
2944}
2945
2946static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2947 void *pMsg)
2948{
2949 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2950 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2951 struct sk_buff *skb = NULL;
2952 tANI_U32 i;
2953
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302954 ENTER();
2955
2956 if (wlan_hdd_validate_context(pHddCtx)) {
2957 return;
2958 }
2959 if (!pMsg)
2960 {
2961 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302962 return;
2963 }
2964
2965 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302966#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2967 NULL,
2968#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302969 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2970 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
2971 GFP_KERNEL);
2972
2973 if (!skb) {
2974 hddLog(VOS_TRACE_LEVEL_ERROR,
2975 FL("cfg80211_vendor_event_alloc failed"));
2976 return;
2977 }
2978 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2979 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2980 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2981 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2982
2983 for (i = 0; i < pData->numOfAps; i++) {
2984 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2985 "Ssid (%s) "
2986 "Bssid (" MAC_ADDRESS_STR ") "
2987 "Channel (%u) "
2988 "Rssi (%d) "
2989 "RTT (%u) "
2990 "RTT_SD (%u) ",
2991 i,
2992 pData->ap[i].ts,
2993 pData->ap[i].ssid,
2994 MAC_ADDR_ARRAY(pData->ap[i].bssid),
2995 pData->ap[i].channel,
2996 pData->ap[i].rssi,
2997 pData->ap[i].rtt,
2998 pData->ap[i].rtt_sd);
2999 }
3000
3001 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3002 pData->requestId) ||
3003 nla_put_u32(skb,
3004 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3005 pData->numOfAps)) {
3006 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3007 goto fail;
3008 }
3009 if (pData->numOfAps) {
3010 struct nlattr *aps;
3011
3012 aps = nla_nest_start(skb,
3013 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3014 if (!aps)
3015 goto fail;
3016
3017 for (i = 0; i < pData->numOfAps; i++) {
3018 struct nlattr *ap;
3019
3020 ap = nla_nest_start(skb, i + 1);
3021 if (!ap)
3022 goto fail;
3023
3024 if (nla_put_u64(skb,
3025 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3026 pData->ap[i].ts) ||
3027 nla_put(skb,
3028 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3029 sizeof(pData->ap[i].ssid),
3030 pData->ap[i].ssid) ||
3031 nla_put(skb,
3032 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3033 sizeof(pData->ap[i].bssid),
3034 pData->ap[i].bssid) ||
3035 nla_put_u32(skb,
3036 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3037 pData->ap[i].channel) ||
3038 nla_put_s32(skb,
3039 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
3040 pData->ap[i].rssi) ||
3041 nla_put_u32(skb,
3042 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3043 pData->ap[i].rtt) ||
3044 nla_put_u32(skb,
3045 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3046 pData->ap[i].rtt_sd))
3047 goto fail;
3048
3049 nla_nest_end(skb, ap);
3050 }
3051 nla_nest_end(skb, aps);
3052
3053 if (nla_put_u8(skb,
3054 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3055 pData->moreData))
3056 goto fail;
3057 }
3058
3059 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303060 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303061 return;
3062
3063fail:
3064 kfree_skb(skb);
3065 return;
3066
3067}
3068static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
3069 void *pMsg)
3070{
3071 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3072 struct sk_buff *skb = NULL;
3073 tANI_U32 i, j;
3074 tpSirWifiSignificantChangeEvent pData =
3075 (tpSirWifiSignificantChangeEvent) pMsg;
3076
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303077 ENTER();
3078
3079 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303080 return;
3081 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303082 if (!pMsg)
3083 {
3084 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3085 return;
3086 }
3087
Dino Mycle6fb96c12014-06-10 11:52:40 +05303088 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303089#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3090 NULL,
3091#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303092 EXTSCAN_EVENT_BUF_SIZE,
3093 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
3094 GFP_KERNEL);
3095
3096 if (!skb) {
3097 hddLog(VOS_TRACE_LEVEL_ERROR,
3098 FL("cfg80211_vendor_event_alloc failed"));
3099 return;
3100 }
3101 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3102 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3103 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
3104 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
3105 pData->numSigRssiBss);
3106 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
3107
3108 for (i = 0; i < pData->numSigRssiBss; i++) {
3109 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
3110 " num RSSI %u ",
3111 i, pData->sigRssiResult[i].bssid,
3112 pData->sigRssiResult[i].channel,
3113 pData->sigRssiResult[i].numRssi);
3114
3115 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
3116
3117 hddLog(VOS_TRACE_LEVEL_INFO,
3118 " [%d]",
Dino Myclec8f3f332014-07-21 16:48:27 +05303119 pData->sigRssiResult[i].rssi[j]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303120
3121 }
3122 }
3123
3124
3125 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3126 pData->requestId) ||
3127 nla_put_u32(skb,
3128 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3129 pData->numSigRssiBss)) {
3130 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3131 goto fail;
3132 }
3133
3134 if (pData->numSigRssiBss) {
3135 struct nlattr *aps;
3136 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3137 if (!aps)
3138 goto fail;
3139 for (i = 0; i < pData->numSigRssiBss; i++) {
3140 struct nlattr *ap;
3141
3142 ap = nla_nest_start(skb, i);
3143 if (!ap)
3144 goto fail;
3145 if (nla_put(skb,
3146 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
3147 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
3148 nla_put_u32(skb,
3149 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
3150 pData->sigRssiResult[i].channel) ||
3151 nla_put_u32(skb,
3152 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
3153 pData->sigRssiResult[i].numRssi) ||
3154 nla_put(skb,
3155 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
3156 sizeof(s32) * pData->sigRssiResult[i].numRssi,
3157 pData->sigRssiResult[i].rssi))
3158 goto fail;
3159 nla_nest_end(skb, ap);
3160 }
3161 nla_nest_end(skb, aps);
3162 if (nla_put_u8(skb,
3163 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3164 pData->moreData))
3165 goto fail;
3166 }
3167 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303168 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303169 return;
3170fail:
3171 kfree_skb(skb);
3172 return;
3173}
3174
3175static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3176 void *pMsg)
3177{
3178 struct sk_buff *skb;
3179 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3180 tpSirWifiFullScanResultEvent pData =
3181 (tpSirWifiFullScanResultEvent) (pMsg);
3182
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303183 ENTER();
3184
3185 if (wlan_hdd_validate_context(pHddCtx)) {
3186 return;
3187 }
3188 if (!pMsg)
3189 {
3190 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303191 return;
3192 }
3193
3194 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303195#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3196 NULL,
3197#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303198 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3199 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3200 GFP_KERNEL);
3201
3202 if (!skb) {
3203 hddLog(VOS_TRACE_LEVEL_ERROR,
3204 FL("cfg80211_vendor_event_alloc failed"));
3205 return;
3206 }
3207
3208 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3209 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3210 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3211 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3212 "Ssid (%s)"
3213 "Bssid (" MAC_ADDRESS_STR ")"
3214 "Channel (%u)"
3215 "Rssi (%d)"
3216 "RTT (%u)"
3217 "RTT_SD (%u)"),
3218 pData->ap.ts,
3219 pData->ap.ssid,
3220 MAC_ADDR_ARRAY(pData->ap.bssid),
3221 pData->ap.channel,
3222 pData->ap.rssi,
3223 pData->ap.rtt,
3224 pData->ap.rtt_sd);
3225 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3226 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3227 pData->requestId) ||
3228 nla_put_u64(skb,
3229 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3230 pData->ap.ts) ||
3231 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3232 sizeof(pData->ap.ssid),
3233 pData->ap.ssid) ||
3234 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3235 WNI_CFG_BSSID_LEN,
3236 pData->ap.bssid) ||
3237 nla_put_u32(skb,
3238 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3239 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303240 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303241 pData->ap.rssi) ||
3242 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3243 pData->ap.rtt) ||
3244 nla_put_u32(skb,
3245 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3246 pData->ap.rtt_sd) ||
3247 nla_put_u16(skb,
3248 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3249 pData->ap.beaconPeriod) ||
3250 nla_put_u16(skb,
3251 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3252 pData->ap.capability) ||
3253 nla_put_u32(skb,
3254 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3255 pData->ieLength))
3256 {
3257 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3258 goto nla_put_failure;
3259 }
3260 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3261 pData->ieLength,
3262 pData->ie))
3263 {
3264 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3265 goto nla_put_failure;
3266 }
3267
3268 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303269 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303270 return;
3271
3272nla_put_failure:
3273 kfree_skb(skb);
3274 return;
3275}
3276
3277static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3278 void *pMsg)
3279{
3280 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3281 struct sk_buff *skb = NULL;
3282 tpSirEXTScanResultsAvailableIndParams pData =
3283 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3284
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303285 ENTER();
3286
3287 if (wlan_hdd_validate_context(pHddCtx)){
3288 return;
3289 }
3290 if (!pMsg)
3291 {
3292 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303293 return;
3294 }
3295
3296 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303297#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3298 NULL,
3299#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303300 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3301 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3302 GFP_KERNEL);
3303
3304 if (!skb) {
3305 hddLog(VOS_TRACE_LEVEL_ERROR,
3306 FL("cfg80211_vendor_event_alloc failed"));
3307 return;
3308 }
3309
3310 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3311 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3312 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3313 pData->numResultsAvailable);
3314 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3315 pData->requestId) ||
3316 nla_put_u32(skb,
3317 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3318 pData->numResultsAvailable)) {
3319 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3320 goto nla_put_failure;
3321 }
3322
3323 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303324 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303325 return;
3326
3327nla_put_failure:
3328 kfree_skb(skb);
3329 return;
3330}
3331
3332static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3333{
3334 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3335 struct sk_buff *skb = NULL;
3336 tpSirEXTScanProgressIndParams pData =
3337 (tpSirEXTScanProgressIndParams) pMsg;
3338
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303339 ENTER();
3340
3341 if (wlan_hdd_validate_context(pHddCtx)){
3342 return;
3343 }
3344 if (!pMsg)
3345 {
3346 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303347 return;
3348 }
3349
3350 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303351#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3352 NULL,
3353#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303354 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3355 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3356 GFP_KERNEL);
3357
3358 if (!skb) {
3359 hddLog(VOS_TRACE_LEVEL_ERROR,
3360 FL("cfg80211_vendor_event_alloc failed"));
3361 return;
3362 }
3363 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3364 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3365 pData->extScanEventType);
3366 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3367 pData->status);
3368
3369 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3370 pData->extScanEventType) ||
3371 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303372 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3373 pData->requestId) ||
3374 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303375 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3376 pData->status)) {
3377 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3378 goto nla_put_failure;
3379 }
3380
3381 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303382 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303383 return;
3384
3385nla_put_failure:
3386 kfree_skb(skb);
3387 return;
3388}
3389
3390void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3391 void *pMsg)
3392{
3393 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3394
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303395 ENTER();
3396
Dino Mycle6fb96c12014-06-10 11:52:40 +05303397 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303398 return;
3399 }
3400
3401 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3402
3403
3404 switch(evType) {
3405 case SIR_HAL_EXTSCAN_START_RSP:
3406 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3407 break;
3408
3409 case SIR_HAL_EXTSCAN_STOP_RSP:
3410 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3411 break;
3412 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3413 /* There is no need to send this response to upper layer
3414 Just log the message */
3415 hddLog(VOS_TRACE_LEVEL_INFO,
3416 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3417 break;
3418 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3419 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3420 break;
3421
3422 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3423 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3424 break;
3425
3426 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
3427 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
3428 break;
3429
3430 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
3431 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
3432 break;
3433 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
3434 wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg);
3435 break;
3436 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3437 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3438 break;
3439 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3440 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3441 break;
3442 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3443 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3444 break;
3445 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3446 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3447 break;
3448 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
3449 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
3450 break;
3451 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3452 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3453 break;
3454 default:
3455 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3456 break;
3457 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303458 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303459}
3460
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303461static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3462 struct wireless_dev *wdev,
3463 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303464{
Dino Myclee8843b32014-07-04 14:21:45 +05303465 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303466 struct net_device *dev = wdev->netdev;
3467 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3468 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3469 struct nlattr
3470 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3471 eHalStatus status;
3472
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303473 ENTER();
3474
Dino Mycle6fb96c12014-06-10 11:52:40 +05303475 status = wlan_hdd_validate_context(pHddCtx);
3476 if (0 != status)
3477 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303478 return -EINVAL;
3479 }
Dino Myclee8843b32014-07-04 14:21:45 +05303480 /* check the EXTScan Capability */
3481 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3482 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3483 {
3484 hddLog(VOS_TRACE_LEVEL_ERROR,
3485 FL("EXTScan not enabled/supported by Firmware"));
3486 return -EINVAL;
3487 }
3488
Dino Mycle6fb96c12014-06-10 11:52:40 +05303489 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3490 data, dataLen,
3491 wlan_hdd_extscan_config_policy)) {
3492 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3493 return -EINVAL;
3494 }
3495
3496 /* Parse and fetch request Id */
3497 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3498 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3499 return -EINVAL;
3500 }
3501
Dino Mycle6fb96c12014-06-10 11:52:40 +05303502
Dino Myclee8843b32014-07-04 14:21:45 +05303503 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303504 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303505 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303506
Dino Myclee8843b32014-07-04 14:21:45 +05303507 reqMsg.sessionId = pAdapter->sessionId;
3508 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303509
Dino Myclee8843b32014-07-04 14:21:45 +05303510 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303511 if (!HAL_STATUS_SUCCESS(status)) {
3512 hddLog(VOS_TRACE_LEVEL_ERROR,
3513 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303514 return -EINVAL;
3515 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303516 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303517 return 0;
3518}
3519
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303520static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3521 struct wireless_dev *wdev,
3522 const void *data, int dataLen)
3523{
3524 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303525
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303526 vos_ssr_protect(__func__);
3527 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3528 vos_ssr_unprotect(__func__);
3529
3530 return ret;
3531}
3532
3533static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3534 struct wireless_dev *wdev,
3535 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303536{
Dino Myclee8843b32014-07-04 14:21:45 +05303537 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303538 struct net_device *dev = wdev->netdev;
3539 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3540 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3541 struct nlattr
3542 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3543 eHalStatus status;
3544
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303545 ENTER();
3546
Dino Mycle6fb96c12014-06-10 11:52:40 +05303547 status = wlan_hdd_validate_context(pHddCtx);
3548 if (0 != status)
3549 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303550 return -EINVAL;
3551 }
Dino Myclee8843b32014-07-04 14:21:45 +05303552 /* check the EXTScan Capability */
3553 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3554 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3555 {
3556 hddLog(VOS_TRACE_LEVEL_ERROR,
3557 FL("EXTScan not enabled/supported by Firmware"));
3558 return -EINVAL;
3559 }
3560
Dino Mycle6fb96c12014-06-10 11:52:40 +05303561 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3562 data, dataLen,
3563 wlan_hdd_extscan_config_policy)) {
3564 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3565 return -EINVAL;
3566 }
3567 /* Parse and fetch request Id */
3568 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3569 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3570 return -EINVAL;
3571 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303572
Dino Myclee8843b32014-07-04 14:21:45 +05303573 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303574 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3575
Dino Myclee8843b32014-07-04 14:21:45 +05303576 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303577
Dino Myclee8843b32014-07-04 14:21:45 +05303578 reqMsg.sessionId = pAdapter->sessionId;
3579 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303580
3581 /* Parse and fetch flush parameter */
3582 if (!tb
3583 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3584 {
3585 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3586 goto failed;
3587 }
Dino Myclee8843b32014-07-04 14:21:45 +05303588 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303589 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3590
Dino Myclee8843b32014-07-04 14:21:45 +05303591 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303592
Dino Myclee8843b32014-07-04 14:21:45 +05303593 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303594 if (!HAL_STATUS_SUCCESS(status)) {
3595 hddLog(VOS_TRACE_LEVEL_ERROR,
3596 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303597 return -EINVAL;
3598 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303599 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303600 return 0;
3601
3602failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303603 return -EINVAL;
3604}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303605static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3606 struct wireless_dev *wdev,
3607 const void *data, int dataLen)
3608{
3609 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303610
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303611 vos_ssr_protect(__func__);
3612 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3613 vos_ssr_unprotect(__func__);
3614
3615 return ret;
3616}
3617
3618static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303619 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303620 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303621{
3622 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3623 struct net_device *dev = wdev->netdev;
3624 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3625 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3626 struct nlattr
3627 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3628 struct nlattr
3629 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3630 struct nlattr *apTh;
3631 eHalStatus status;
3632 tANI_U8 i = 0;
3633 int rem;
3634
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303635 ENTER();
3636
Dino Mycle6fb96c12014-06-10 11:52:40 +05303637 status = wlan_hdd_validate_context(pHddCtx);
3638 if (0 != status)
3639 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303640 return -EINVAL;
3641 }
Dino Myclee8843b32014-07-04 14:21:45 +05303642 /* check the EXTScan Capability */
3643 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3644 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3645 {
3646 hddLog(VOS_TRACE_LEVEL_ERROR,
3647 FL("EXTScan not enabled/supported by Firmware"));
3648 return -EINVAL;
3649 }
3650
Dino Mycle6fb96c12014-06-10 11:52:40 +05303651 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3652 data, dataLen,
3653 wlan_hdd_extscan_config_policy)) {
3654 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3655 return -EINVAL;
3656 }
3657
3658 /* Parse and fetch request Id */
3659 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3660 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3661 return -EINVAL;
3662 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303663 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3664 vos_mem_malloc(sizeof(*pReqMsg));
3665 if (!pReqMsg) {
3666 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3667 return -ENOMEM;
3668 }
3669
Dino Myclee8843b32014-07-04 14:21:45 +05303670
Dino Mycle6fb96c12014-06-10 11:52:40 +05303671 pReqMsg->requestId = nla_get_u32(
3672 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3673 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3674
3675 /* Parse and fetch number of APs */
3676 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3677 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3678 goto fail;
3679 }
3680
3681 pReqMsg->sessionId = pAdapter->sessionId;
3682 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3683
3684 pReqMsg->numAp = nla_get_u32(
3685 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3686 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3687
3688 nla_for_each_nested(apTh,
3689 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3690 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3691 nla_data(apTh), nla_len(apTh),
3692 NULL)) {
3693 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3694 goto fail;
3695 }
3696
3697 /* Parse and fetch MAC address */
3698 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3699 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3700 goto fail;
3701 }
3702 memcpy(pReqMsg->ap[i].bssid, nla_data(
3703 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3704 sizeof(tSirMacAddr));
3705 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3706
3707 /* Parse and fetch low RSSI */
3708 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3709 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3710 goto fail;
3711 }
3712 pReqMsg->ap[i].low = nla_get_s32(
3713 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3714 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3715
3716 /* Parse and fetch high RSSI */
3717 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3718 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3719 goto fail;
3720 }
3721 pReqMsg->ap[i].high = nla_get_s32(
3722 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3723 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3724 pReqMsg->ap[i].high);
3725
3726 /* Parse and fetch channel */
3727 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3728 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3729 goto fail;
3730 }
3731 pReqMsg->ap[i].channel = nla_get_u32(
3732 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3733 hddLog(VOS_TRACE_LEVEL_INFO,
3734 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3735 i++;
3736 }
3737 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3738 if (!HAL_STATUS_SUCCESS(status)) {
3739 hddLog(VOS_TRACE_LEVEL_ERROR,
3740 FL("sme_SetBssHotlist failed(err=%d)"), status);
3741 vos_mem_free(pReqMsg);
3742 return -EINVAL;
3743 }
3744
Dino Myclee8843b32014-07-04 14:21:45 +05303745 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303746 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303747 return 0;
3748
3749fail:
3750 vos_mem_free(pReqMsg);
3751 return -EINVAL;
3752}
3753
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303754static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3755 struct wireless_dev *wdev,
3756 const void *data, int dataLen)
3757{
3758 int ret = 0;
3759
3760 vos_ssr_protect(__func__);
3761 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3762 dataLen);
3763 vos_ssr_unprotect(__func__);
3764
3765 return ret;
3766}
3767
3768static int __wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303769 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303770 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303771{
3772 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3773 struct net_device *dev = wdev->netdev;
3774 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3775 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3776 struct nlattr
3777 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3778 struct nlattr
3779 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3780 struct nlattr *apTh;
3781 eHalStatus status;
3782 int i = 0;
3783 int rem;
3784
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303785 ENTER();
3786
Dino Mycle6fb96c12014-06-10 11:52:40 +05303787 status = wlan_hdd_validate_context(pHddCtx);
3788 if (0 != status)
3789 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303790 return -EINVAL;
3791 }
Dino Myclee8843b32014-07-04 14:21:45 +05303792 /* check the EXTScan Capability */
3793 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3794 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3795 {
3796 hddLog(VOS_TRACE_LEVEL_ERROR,
3797 FL("EXTScan not enabled/supported by Firmware"));
3798 return -EINVAL;
3799 }
3800
Dino Mycle6fb96c12014-06-10 11:52:40 +05303801 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3802 data, dataLen,
3803 wlan_hdd_extscan_config_policy)) {
3804 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3805 return -EINVAL;
3806 }
3807
3808 /* Parse and fetch request Id */
3809 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3810 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3811 return -EINVAL;
3812 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303813 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303814 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303815 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303816 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3817 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303818 }
3819
Dino Myclee8843b32014-07-04 14:21:45 +05303820
3821
Dino Mycle6fb96c12014-06-10 11:52:40 +05303822 pReqMsg->requestId = nla_get_u32(
3823 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3824 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3825
3826 /* Parse and fetch RSSI sample size */
3827 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3828 {
3829 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3830 goto fail;
3831 }
3832 pReqMsg->rssiSampleSize = nla_get_u32(
3833 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3834 hddLog(VOS_TRACE_LEVEL_INFO,
3835 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3836
3837 /* Parse and fetch lost AP sample size */
3838 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3839 {
3840 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3841 goto fail;
3842 }
3843 pReqMsg->lostApSampleSize = nla_get_u32(
3844 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3845 hddLog(VOS_TRACE_LEVEL_INFO,
3846 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3847 /* Parse and fetch minimum Breaching */
3848 if (!tb
3849 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3850 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3851 goto fail;
3852 }
3853 pReqMsg->minBreaching = nla_get_u32(
3854 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3855 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3856
3857 /* Parse and fetch number of APs */
3858 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3859 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3860 goto fail;
3861 }
3862 pReqMsg->numAp = nla_get_u32(
3863 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3864 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3865
3866 pReqMsg->sessionId = pAdapter->sessionId;
3867 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3868
3869 nla_for_each_nested(apTh,
3870 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3871 if(nla_parse(tb2,
3872 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3873 nla_data(apTh), nla_len(apTh),
3874 NULL)) {
3875 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3876 goto fail;
3877 }
3878
3879 /* Parse and fetch MAC address */
3880 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3881 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3882 goto fail;
3883 }
3884 memcpy(pReqMsg->ap[i].bssid, nla_data(
3885 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3886 sizeof(tSirMacAddr));
3887
3888 /* Parse and fetch low RSSI */
3889 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3890 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3891 goto fail;
3892 }
3893 pReqMsg->ap[i].low = nla_get_s32(
3894 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3895 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3896
3897 /* Parse and fetch high RSSI */
3898 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3899 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3900 goto fail;
3901 }
3902 pReqMsg->ap[i].high = nla_get_s32(
3903 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3904 hddLog(VOS_TRACE_LEVEL_INFO,
3905 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
3906
3907 /* Parse and fetch channel */
3908 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3909 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3910 goto fail;
3911 }
3912 pReqMsg->ap[i].channel = nla_get_u32(
3913 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3914 hddLog(VOS_TRACE_LEVEL_INFO,
3915 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3916 i++;
3917 }
3918
3919 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
3920 if (!HAL_STATUS_SUCCESS(status)) {
3921 hddLog(VOS_TRACE_LEVEL_ERROR,
3922 FL("sme_SetSignificantChange failed(err=%d)"), status);
3923 vos_mem_free(pReqMsg);
3924 return -EINVAL;
3925 }
Dino Myclee8843b32014-07-04 14:21:45 +05303926 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303927 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303928 return 0;
3929
3930fail:
3931 vos_mem_free(pReqMsg);
3932 return -EINVAL;
3933}
3934
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303935static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
3936 struct wireless_dev *wdev,
3937 const void *data, int dataLen)
3938{
3939 int ret = 0;
3940
3941 vos_ssr_protect(__func__);
3942 ret = __wlan_hdd_cfg80211_extscan_set_significant_change(wiphy, wdev, data,
3943 dataLen);
3944 vos_ssr_unprotect(__func__);
3945
3946 return ret;
3947}
3948
3949static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303950 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303951 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303952{
3953 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3954 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3955 tANI_U8 numChannels = 0;
3956 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3957 tANI_U32 requestId;
3958 tWifiBand wifiBand;
3959 eHalStatus status;
3960 struct sk_buff *replySkb;
3961 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303962 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303963
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303964 ENTER();
3965
Dino Mycle6fb96c12014-06-10 11:52:40 +05303966 status = wlan_hdd_validate_context(pHddCtx);
3967 if (0 != status)
3968 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303969 return -EINVAL;
3970 }
Dino Myclee8843b32014-07-04 14:21:45 +05303971
Dino Mycle6fb96c12014-06-10 11:52:40 +05303972 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3973 data, dataLen,
3974 wlan_hdd_extscan_config_policy)) {
3975 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3976 return -EINVAL;
3977 }
3978
3979 /* Parse and fetch request Id */
3980 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3981 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3982 return -EINVAL;
3983 }
3984 requestId = nla_get_u32(
3985 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3986 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3987
3988 /* Parse and fetch wifi band */
3989 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3990 {
3991 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3992 return -EINVAL;
3993 }
3994 wifiBand = nla_get_u32(
3995 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3996 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3997
3998 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
3999 wifiBand, ChannelList,
4000 &numChannels);
4001 if (eHAL_STATUS_SUCCESS != status) {
4002 hddLog(VOS_TRACE_LEVEL_ERROR,
4003 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
4004 return -EINVAL;
4005 }
4006 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
4007 for (i = 0; i < numChannels; i++)
4008 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
4009
4010 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
4011 sizeof(u32) * numChannels +
4012 NLMSG_HDRLEN);
4013
4014 if (!replySkb) {
4015 hddLog(VOS_TRACE_LEVEL_ERROR,
4016 FL("valid channels: buffer alloc fail"));
4017 return -EINVAL;
4018 }
4019 if (nla_put_u32(replySkb,
4020 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
4021 numChannels) ||
4022 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
4023 sizeof(u32) * numChannels, ChannelList)) {
4024
4025 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4026 kfree_skb(replySkb);
4027 return -EINVAL;
4028 }
4029
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304030 ret = cfg80211_vendor_cmd_reply(replySkb);
4031
4032 EXIT();
4033 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304034}
4035
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304036static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
4037 struct wireless_dev *wdev,
4038 const void *data, int dataLen)
4039{
4040 int ret = 0;
4041
4042 vos_ssr_protect(__func__);
4043 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
4044 dataLen);
4045 vos_ssr_unprotect(__func__);
4046
4047 return ret;
4048}
4049
4050static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304051 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304052 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304053{
Dino Myclee8843b32014-07-04 14:21:45 +05304054 tpSirEXTScanStartReqParams pReqMsg = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304055 struct net_device *dev = wdev->netdev;
4056 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4057 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4058 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4059 struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4060 struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4061 struct nlattr *buckets;
4062 struct nlattr *channels;
4063 int rem1;
4064 int rem2;
4065 eHalStatus status;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304066 tANI_U32 j = 0, index = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304067
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304068 ENTER();
4069
Dino Mycle6fb96c12014-06-10 11:52:40 +05304070 status = wlan_hdd_validate_context(pHddCtx);
4071 if (0 != status)
4072 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304073 return -EINVAL;
4074 }
Dino Myclee8843b32014-07-04 14:21:45 +05304075 /* check the EXTScan Capability */
4076 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4077 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4078 {
4079 hddLog(VOS_TRACE_LEVEL_ERROR,
4080 FL("EXTScan not enabled/supported by Firmware"));
4081 return -EINVAL;
4082 }
4083
Dino Mycle6fb96c12014-06-10 11:52:40 +05304084 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4085 data, dataLen,
4086 wlan_hdd_extscan_config_policy)) {
4087 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4088 return -EINVAL;
4089 }
4090
4091 /* Parse and fetch request Id */
4092 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4093 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4094 return -EINVAL;
4095 }
4096
Dino Myclee8843b32014-07-04 14:21:45 +05304097 pReqMsg = (tpSirEXTScanStartReqParams)
4098 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304099 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304100 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4101 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304102 }
4103
4104 pReqMsg->requestId = nla_get_u32(
4105 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4106 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4107
4108 pReqMsg->sessionId = pAdapter->sessionId;
4109 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4110
4111 /* Parse and fetch base period */
4112 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) {
4113 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4114 goto fail;
4115 }
4116 pReqMsg->basePeriod = nla_get_u32(
4117 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]);
4118 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4119 pReqMsg->basePeriod);
4120
4121 /* Parse and fetch max AP per scan */
4122 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) {
4123 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4124 goto fail;
4125 }
4126 pReqMsg->maxAPperScan = nla_get_u32(
4127 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]);
4128 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4129 pReqMsg->maxAPperScan);
4130
4131 /* Parse and fetch report threshold */
4132 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) {
4133 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4134 goto fail;
4135 }
4136 pReqMsg->reportThreshold = nla_get_u8(
4137 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]);
4138 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
4139 pReqMsg->reportThreshold);
4140
4141 /* Parse and fetch number of buckets */
4142 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) {
4143 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4144 goto fail;
4145 }
4146 pReqMsg->numBuckets = nla_get_u8(
4147 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]);
4148 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4149 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4150 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4151 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4152 }
4153 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4154 pReqMsg->numBuckets);
4155 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4156 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4157 goto fail;
4158 }
4159
4160 nla_for_each_nested(buckets,
4161 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4162 if(nla_parse(bucket,
4163 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4164 nla_data(buckets), nla_len(buckets), NULL)) { //policy
4165 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4166 goto fail;
4167 }
4168
4169 /* Parse and fetch bucket spec */
4170 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4171 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed"));
4172 goto fail;
4173 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304174
4175 pReqMsg->buckets[index].bucket = nla_get_u8(
4176 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4177
4178 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"),
4179 pReqMsg->buckets[index].bucket);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304180
4181 /* Parse and fetch wifi band */
4182 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4183 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4184 goto fail;
4185 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304186 pReqMsg->buckets[index].band = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304187 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4188 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304189 pReqMsg->buckets[index].band);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304190
4191 /* Parse and fetch period */
4192 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4193 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed"));
4194 goto fail;
4195 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304196 pReqMsg->buckets[index].period = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304197 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4198 hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304199 pReqMsg->buckets[index].period);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304200
4201 /* Parse and fetch report events */
4202 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4203 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed"));
4204 goto fail;
4205 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304206 pReqMsg->buckets[index].reportEvents = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304207 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4208 hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304209 pReqMsg->buckets[index].reportEvents);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304210
4211 /* Parse and fetch number of channels */
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304212 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS])
4213 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304214 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed"));
4215 goto fail;
4216 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304217 pReqMsg->buckets[index].numChannels = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304218 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4219 hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304220 pReqMsg->buckets[index].numChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304221
4222 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4223 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed"));
4224 goto fail;
4225 }
4226
4227 j = 0;
4228 nla_for_each_nested(channels,
4229 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4230 if(nla_parse(channel,
4231 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4232 nla_data(channels), nla_len(channels),
4233 NULL)) { //wlan_hdd_extscan_config_policy here
4234 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4235 goto fail;
4236 }
4237
4238 /* Parse and fetch channel */
4239 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4240 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4241 goto fail;
4242 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304243 pReqMsg->buckets[index].channels[j].channel = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304244 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4245 hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304246 pReqMsg->buckets[index].channels[j].channel);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304247
4248 /* Parse and fetch dwell time */
4249 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4250 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed"));
4251 goto fail;
4252 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304253 pReqMsg->buckets[index].channels[j].dwellTimeMs = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304254 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4255 hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304256 pReqMsg->buckets[index].channels[j].dwellTimeMs);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304257
4258 /* Parse and fetch channel spec passive */
4259 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4260 hddLog(VOS_TRACE_LEVEL_ERROR,
4261 FL("attr channel spec passive failed"));
4262 goto fail;
4263 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304264 pReqMsg->buckets[index].channels[j].passive = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304265 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4266 hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304267 pReqMsg->buckets[index].channels[j].passive);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304268 j++;
4269 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304270 index++;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304271 }
4272 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4273 if (!HAL_STATUS_SUCCESS(status)) {
4274 hddLog(VOS_TRACE_LEVEL_ERROR,
4275 FL("sme_EXTScanStart failed(err=%d)"), status);
4276 vos_mem_free(pReqMsg);
4277 return -EINVAL;
4278 }
4279
Dino Myclee8843b32014-07-04 14:21:45 +05304280 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304281 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304282 return 0;
4283
4284fail:
4285 vos_mem_free(pReqMsg);
4286 return -EINVAL;
4287}
4288
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304289static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4290 struct wireless_dev *wdev,
4291 const void *data, int dataLen)
4292{
4293 int ret = 0;
4294
4295 vos_ssr_protect(__func__);
4296 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4297 vos_ssr_unprotect(__func__);
4298
4299 return ret;
4300}
4301
4302static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304303 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304304 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304305{
Dino Myclee8843b32014-07-04 14:21:45 +05304306 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304307 struct net_device *dev = wdev->netdev;
4308 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4309 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4310 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4311 eHalStatus status;
4312
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304313 ENTER();
4314
Dino Mycle6fb96c12014-06-10 11:52:40 +05304315 status = wlan_hdd_validate_context(pHddCtx);
4316 if (0 != status)
4317 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304318 return -EINVAL;
4319 }
Dino Myclee8843b32014-07-04 14:21:45 +05304320 /* check the EXTScan Capability */
4321 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4322 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4323 {
4324 hddLog(VOS_TRACE_LEVEL_ERROR,
4325 FL("EXTScan not enabled/supported by Firmware"));
4326 return -EINVAL;
4327 }
4328
Dino Mycle6fb96c12014-06-10 11:52:40 +05304329 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4330 data, dataLen,
4331 wlan_hdd_extscan_config_policy)) {
4332 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4333 return -EINVAL;
4334 }
4335
4336 /* Parse and fetch request Id */
4337 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4338 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4339 return -EINVAL;
4340 }
4341
Dino Myclee8843b32014-07-04 14:21:45 +05304342 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304343 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304344 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304345
Dino Myclee8843b32014-07-04 14:21:45 +05304346 reqMsg.sessionId = pAdapter->sessionId;
4347 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304348
Dino Myclee8843b32014-07-04 14:21:45 +05304349 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304350 if (!HAL_STATUS_SUCCESS(status)) {
4351 hddLog(VOS_TRACE_LEVEL_ERROR,
4352 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304353 return -EINVAL;
4354 }
4355
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304356 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304357 return 0;
4358}
4359
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304360static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4361 struct wireless_dev *wdev,
4362 const void *data, int dataLen)
4363{
4364 int ret = 0;
4365
4366 vos_ssr_protect(__func__);
4367 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4368 vos_ssr_unprotect(__func__);
4369
4370 return ret;
4371}
4372
4373static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304374 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304375 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304376{
Dino Myclee8843b32014-07-04 14:21:45 +05304377 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304378 struct net_device *dev = wdev->netdev;
4379 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4380 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4381 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4382 eHalStatus status;
4383
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304384 ENTER();
4385
Dino Mycle6fb96c12014-06-10 11:52:40 +05304386 status = wlan_hdd_validate_context(pHddCtx);
4387 if (0 != status)
4388 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304389 return -EINVAL;
4390 }
Dino Myclee8843b32014-07-04 14:21:45 +05304391 /* check the EXTScan Capability */
4392 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4393 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4394 {
4395 hddLog(VOS_TRACE_LEVEL_ERROR,
4396 FL("EXTScan not enabled/supported by Firmware"));
4397 return -EINVAL;
4398 }
4399
Dino Mycle6fb96c12014-06-10 11:52:40 +05304400 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4401 data, dataLen,
4402 wlan_hdd_extscan_config_policy)) {
4403 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4404 return -EINVAL;
4405 }
4406
4407 /* Parse and fetch request Id */
4408 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4409 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4410 return -EINVAL;
4411 }
4412
Dino Myclee8843b32014-07-04 14:21:45 +05304413 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304414 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304415 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304416
Dino Myclee8843b32014-07-04 14:21:45 +05304417 reqMsg.sessionId = pAdapter->sessionId;
4418 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304419
Dino Myclee8843b32014-07-04 14:21:45 +05304420 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304421 if (!HAL_STATUS_SUCCESS(status)) {
4422 hddLog(VOS_TRACE_LEVEL_ERROR,
4423 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304424 return -EINVAL;
4425 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304426 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304427 return 0;
4428}
4429
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304430static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4431 struct wireless_dev *wdev,
4432 const void *data, int dataLen)
4433{
4434 int ret = 0;
4435
4436 vos_ssr_protect(__func__);
4437 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4438 vos_ssr_unprotect(__func__);
4439
4440 return ret;
4441}
4442
4443static int __wlan_hdd_cfg80211_extscan_reset_significant_change(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304444 struct wiphy *wiphy,
4445 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304446 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304447{
Dino Myclee8843b32014-07-04 14:21:45 +05304448 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304449 struct net_device *dev = wdev->netdev;
4450 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4451 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4452 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4453 eHalStatus status;
4454
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304455 ENTER();
4456
Dino Mycle6fb96c12014-06-10 11:52:40 +05304457 status = wlan_hdd_validate_context(pHddCtx);
4458 if (0 != status)
4459 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304460 return -EINVAL;
4461 }
Dino Myclee8843b32014-07-04 14:21:45 +05304462 /* check the EXTScan Capability */
4463 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4464 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4465 {
4466 hddLog(VOS_TRACE_LEVEL_ERROR,
4467 FL("EXTScan not enabled/supported by Firmware"));
4468 return -EINVAL;
4469 }
4470
Dino Mycle6fb96c12014-06-10 11:52:40 +05304471 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4472 data, dataLen,
4473 wlan_hdd_extscan_config_policy)) {
4474 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4475 return -EINVAL;
4476 }
4477
4478 /* Parse and fetch request Id */
4479 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4480 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4481 return -EINVAL;
4482 }
4483
Dino Mycle6fb96c12014-06-10 11:52:40 +05304484
Dino Myclee8843b32014-07-04 14:21:45 +05304485 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304486 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304487 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304488
Dino Myclee8843b32014-07-04 14:21:45 +05304489 reqMsg.sessionId = pAdapter->sessionId;
4490 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304491
Dino Myclee8843b32014-07-04 14:21:45 +05304492 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304493 if (!HAL_STATUS_SUCCESS(status)) {
4494 hddLog(VOS_TRACE_LEVEL_ERROR,
4495 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304496 return -EINVAL;
4497 }
4498
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304499 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304500 return 0;
4501}
4502
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304503static int wlan_hdd_cfg80211_extscan_reset_significant_change(
4504 struct wiphy *wiphy,
4505 struct wireless_dev *wdev,
4506 const void *data, int dataLen)
4507{
4508 int ret = 0;
4509
4510 vos_ssr_protect(__func__);
4511 ret = __wlan_hdd_cfg80211_extscan_reset_significant_change(wiphy,
4512 wdev, data,
4513 dataLen);
4514 vos_ssr_unprotect(__func__);
4515
4516 return ret;
4517}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304518#endif /* WLAN_FEATURE_EXTSCAN */
4519
Atul Mittal115287b2014-07-08 13:26:33 +05304520/*EXT TDLS*/
4521static const struct nla_policy
4522wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4523{
4524 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4525 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4526 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4527 {.type = NLA_S32 },
4528 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4529 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4530
4531};
4532
4533static const struct nla_policy
4534wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4535{
4536 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4537
4538};
4539
4540static const struct nla_policy
4541wlan_hdd_tdls_config_state_change_policy[
4542 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4543{
4544 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4545 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4546 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304547 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4548 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4549 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304550
4551};
4552
4553static const struct nla_policy
4554wlan_hdd_tdls_config_get_status_policy[
4555 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4556{
4557 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4558 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4559 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304560 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4561 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4562 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304563
4564};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304565
4566static const struct nla_policy
4567wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4568{
4569 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4570};
4571
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304572static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304573 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304574 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304575 int data_len)
4576{
4577
4578 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4579 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4580
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304581 ENTER();
4582
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304583 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304584 return -EINVAL;
4585 }
4586 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05304587 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304588 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304589 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304590 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05304591 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304592 return -ENOTSUPP;
4593 }
4594
4595 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4596 data, data_len, wlan_hdd_mac_config)) {
4597 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4598 return -EINVAL;
4599 }
4600
4601 /* Parse and fetch mac address */
4602 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4603 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4604 return -EINVAL;
4605 }
4606
4607 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4608 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4609 VOS_MAC_ADDR_LAST_3_BYTES);
4610
Siddharth Bhal76972212014-10-15 16:22:51 +05304611 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4612
4613 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304614 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4615 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304616 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4617 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4618 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4619 {
4620 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4621 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4622 VOS_MAC_ADDRESS_LEN);
4623 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304624 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304625
Siddharth Bhal76972212014-10-15 16:22:51 +05304626 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
4627 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304628 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4629 }
4630
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304631 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304632 return 0;
4633}
4634
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304635static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4636 struct wireless_dev *wdev,
4637 const void *data,
4638 int data_len)
4639{
4640 int ret = 0;
4641
4642 vos_ssr_protect(__func__);
4643 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
4644 vos_ssr_unprotect(__func__);
4645
4646 return ret;
4647}
4648
4649static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304650 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304651 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304652 int data_len)
4653{
4654 u8 peer[6] = {0};
4655 struct net_device *dev = wdev->netdev;
4656 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4657 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4658 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4659 eHalStatus ret;
4660 tANI_S32 state;
4661 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304662 tANI_S32 global_operating_class = 0;
4663 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304664 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304665 int retVal;
4666
4667 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304668
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304669 if (!pAdapter) {
4670 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4671 return -EINVAL;
4672 }
4673
Atul Mittal115287b2014-07-08 13:26:33 +05304674 ret = wlan_hdd_validate_context(pHddCtx);
4675 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304676 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304677 return -EINVAL;
4678 }
4679 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304680 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304681 return -ENOTSUPP;
4682 }
4683 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4684 data, data_len,
4685 wlan_hdd_tdls_config_get_status_policy)) {
4686 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4687 return -EINVAL;
4688 }
4689
4690 /* Parse and fetch mac address */
4691 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4692 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4693 return -EINVAL;
4694 }
4695
4696 memcpy(peer, nla_data(
4697 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4698 sizeof(peer));
4699 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4700
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05304701 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05304702
Atul Mittal115287b2014-07-08 13:26:33 +05304703 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304704 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304705 NLMSG_HDRLEN);
4706
4707 if (!skb) {
4708 hddLog(VOS_TRACE_LEVEL_ERROR,
4709 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4710 return -EINVAL;
4711 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304712 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reason (%d) Status (%d) class (%d) channel (%d) peer" MAC_ADDRESS_STR),
Atul Mittal115287b2014-07-08 13:26:33 +05304713 reason,
4714 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304715 global_operating_class,
4716 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304717 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304718 if (nla_put_s32(skb,
4719 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4720 state) ||
4721 nla_put_s32(skb,
4722 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4723 reason) ||
4724 nla_put_s32(skb,
4725 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4726 global_operating_class) ||
4727 nla_put_s32(skb,
4728 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4729 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304730
4731 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4732 goto nla_put_failure;
4733 }
4734
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304735 retVal = cfg80211_vendor_cmd_reply(skb);
4736 EXIT();
4737 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05304738
4739nla_put_failure:
4740 kfree_skb(skb);
4741 return -EINVAL;
4742}
4743
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304744static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4745 struct wireless_dev *wdev,
4746 const void *data,
4747 int data_len)
4748{
4749 int ret = 0;
4750
4751 vos_ssr_protect(__func__);
4752 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
4753 vos_ssr_unprotect(__func__);
4754
4755 return ret;
4756}
4757
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05304758static int wlan_hdd_cfg80211_exttdls_callback(
4759#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
4760 const tANI_U8* mac,
4761#else
4762 tANI_U8* mac,
4763#endif
Atul Mittal115287b2014-07-08 13:26:33 +05304764 tANI_S32 state,
4765 tANI_S32 reason,
4766 void *ctx)
4767{
4768 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05304769 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304770 tANI_S32 global_operating_class = 0;
4771 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304772 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05304773
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304774 ENTER();
4775
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304776 if (!pAdapter) {
4777 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4778 return -EINVAL;
4779 }
4780
4781 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05304782 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304783 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304784 return -EINVAL;
4785 }
4786
4787 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304788 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304789 return -ENOTSUPP;
4790 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05304791 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
4792#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
4793 NULL,
4794#endif
Atul Mittal115287b2014-07-08 13:26:33 +05304795 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4796 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4797 GFP_KERNEL);
4798
4799 if (!skb) {
4800 hddLog(VOS_TRACE_LEVEL_ERROR,
4801 FL("cfg80211_vendor_event_alloc failed"));
4802 return -EINVAL;
4803 }
4804 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304805 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4806 reason,
4807 state,
4808 global_operating_class,
4809 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304810 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4811 MAC_ADDR_ARRAY(mac));
4812
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304813 if (nla_put(skb,
4814 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4815 VOS_MAC_ADDR_SIZE, mac) ||
4816 nla_put_s32(skb,
4817 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4818 state) ||
4819 nla_put_s32(skb,
4820 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4821 reason) ||
4822 nla_put_s32(skb,
4823 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4824 channel) ||
4825 nla_put_s32(skb,
4826 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4827 global_operating_class)
4828 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304829 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4830 goto nla_put_failure;
4831 }
4832
4833 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304834 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05304835 return (0);
4836
4837nla_put_failure:
4838 kfree_skb(skb);
4839 return -EINVAL;
4840}
4841
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304842static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304843 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304844 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304845 int data_len)
4846{
4847 u8 peer[6] = {0};
4848 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304849 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4850 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4851 eHalStatus status;
4852 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304853 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304854 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304855
4856 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304857
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304858 if (!dev) {
4859 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4860 return -EINVAL;
4861 }
4862
4863 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4864 if (!pAdapter) {
4865 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4866 return -EINVAL;
4867 }
4868
Atul Mittal115287b2014-07-08 13:26:33 +05304869 status = wlan_hdd_validate_context(pHddCtx);
4870 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304871 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304872 return -EINVAL;
4873 }
4874 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304875 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304876 return -ENOTSUPP;
4877 }
4878 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4879 data, data_len,
4880 wlan_hdd_tdls_config_enable_policy)) {
4881 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4882 return -EINVAL;
4883 }
4884
4885 /* Parse and fetch mac address */
4886 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4887 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4888 return -EINVAL;
4889 }
4890
4891 memcpy(peer, nla_data(
4892 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4893 sizeof(peer));
4894 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4895
4896 /* Parse and fetch channel */
4897 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4898 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4899 return -EINVAL;
4900 }
4901 pReqMsg.channel = nla_get_s32(
4902 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4903 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4904
4905 /* Parse and fetch global operating class */
4906 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4907 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4908 return -EINVAL;
4909 }
4910 pReqMsg.global_operating_class = nla_get_s32(
4911 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4912 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4913 pReqMsg.global_operating_class);
4914
4915 /* Parse and fetch latency ms */
4916 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4917 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4918 return -EINVAL;
4919 }
4920 pReqMsg.max_latency_ms = nla_get_s32(
4921 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4922 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4923 pReqMsg.max_latency_ms);
4924
4925 /* Parse and fetch required bandwidth kbps */
4926 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4927 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4928 return -EINVAL;
4929 }
4930
4931 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4932 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4933 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4934 pReqMsg.min_bandwidth_kbps);
4935
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304936 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05304937 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05304938 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304939 wlan_hdd_cfg80211_exttdls_callback);
4940
4941 EXIT();
4942 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304943}
4944
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304945static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4946 struct wireless_dev *wdev,
4947 const void *data,
4948 int data_len)
4949{
4950 int ret = 0;
4951
4952 vos_ssr_protect(__func__);
4953 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
4954 vos_ssr_unprotect(__func__);
4955
4956 return ret;
4957}
4958
4959static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304960 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304961 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304962 int data_len)
4963{
4964 u8 peer[6] = {0};
4965 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304966 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4967 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4968 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304969 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304970 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304971
4972 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304973
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304974 if (!dev) {
4975 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4976 return -EINVAL;
4977 }
4978
4979 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4980 if (!pAdapter) {
4981 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
4982 return -EINVAL;
4983 }
4984
Atul Mittal115287b2014-07-08 13:26:33 +05304985 status = wlan_hdd_validate_context(pHddCtx);
4986 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304987 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304988 return -EINVAL;
4989 }
4990 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304991 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304992 return -ENOTSUPP;
4993 }
4994 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4995 data, data_len,
4996 wlan_hdd_tdls_config_disable_policy)) {
4997 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4998 return -EINVAL;
4999 }
5000 /* Parse and fetch mac address */
5001 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
5002 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5003 return -EINVAL;
5004 }
5005
5006 memcpy(peer, nla_data(
5007 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
5008 sizeof(peer));
5009 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5010
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305011 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
5012
5013 EXIT();
5014 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305015}
5016
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305017static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
5018 struct wireless_dev *wdev,
5019 const void *data,
5020 int data_len)
5021{
5022 int ret = 0;
5023
5024 vos_ssr_protect(__func__);
5025 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
5026 vos_ssr_unprotect(__func__);
5027
5028 return ret;
5029}
5030
Dasari Srinivas7875a302014-09-26 17:50:57 +05305031static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305032__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05305033 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305034 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05305035{
5036 struct net_device *dev = wdev->netdev;
5037 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5038 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5039 struct sk_buff *skb = NULL;
5040 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305041 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305042
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305043 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305044
5045 ret = wlan_hdd_validate_context(pHddCtx);
5046 if (0 != ret)
5047 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305048 return ret;
5049 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305050 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
5051 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
5052 fset |= WIFI_FEATURE_INFRA;
5053 }
5054
5055 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
5056 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
5057 fset |= WIFI_FEATURE_INFRA_5G;
5058 }
5059
5060#ifdef WLAN_FEATURE_P2P
5061 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
5062 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
5063 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
5064 fset |= WIFI_FEATURE_P2P;
5065 }
5066#endif
5067
5068 /* Soft-AP is supported currently by default */
5069 fset |= WIFI_FEATURE_SOFT_AP;
5070
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05305071 /* HOTSPOT is a supplicant feature, enable it by default */
5072 fset |= WIFI_FEATURE_HOTSPOT;
5073
Dasari Srinivas7875a302014-09-26 17:50:57 +05305074#ifdef WLAN_FEATURE_EXTSCAN
5075 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
5076 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
5077 hddLog(LOG1, FL("EXTScan is supported by firmware"));
5078 fset |= WIFI_FEATURE_EXTSCAN;
5079 }
5080#endif
5081
Dasari Srinivas7875a302014-09-26 17:50:57 +05305082 if (sme_IsFeatureSupportedByFW(NAN)) {
5083 hddLog(LOG1, FL("NAN is supported by firmware"));
5084 fset |= WIFI_FEATURE_NAN;
5085 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305086
5087 /* D2D RTT is not supported currently by default */
5088 if (sme_IsFeatureSupportedByFW(RTT)) {
5089 hddLog(LOG1, FL("RTT is supported by firmware"));
5090 fset |= WIFI_FEATURE_D2AP_RTT;
5091 }
5092
5093#ifdef FEATURE_WLAN_BATCH_SCAN
5094 if (fset & WIFI_FEATURE_EXTSCAN) {
5095 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5096 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5097 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5098 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5099 fset |= WIFI_FEATURE_BATCH_SCAN;
5100 }
5101#endif
5102
5103#ifdef FEATURE_WLAN_SCAN_PNO
5104 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5105 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5106 hddLog(LOG1, FL("PNO is supported by firmware"));
5107 fset |= WIFI_FEATURE_PNO;
5108 }
5109#endif
5110
5111 /* STA+STA is supported currently by default */
5112 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5113
5114#ifdef FEATURE_WLAN_TDLS
5115 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5116 sme_IsFeatureSupportedByFW(TDLS)) {
5117 hddLog(LOG1, FL("TDLS is supported by firmware"));
5118 fset |= WIFI_FEATURE_TDLS;
5119 }
5120
5121 /* TDLS_OFFCHANNEL is not supported currently by default */
5122#endif
5123
5124#ifdef WLAN_AP_STA_CONCURRENCY
5125 /* AP+STA concurrency is supported currently by default */
5126 fset |= WIFI_FEATURE_AP_STA;
5127#endif
5128
Mukul Sharma5add0532015-08-17 15:57:47 +05305129#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5130 fset |= WIFI_FEATURE_LINK_LAYER_STATS;
5131 hddLog(LOG1, FL("Link layer stats is supported by driver"));
5132#endif
5133
Dasari Srinivas7875a302014-09-26 17:50:57 +05305134 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5135 NLMSG_HDRLEN);
5136
5137 if (!skb) {
5138 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5139 return -EINVAL;
5140 }
5141 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5142
5143 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5144 hddLog(LOGE, FL("nla put fail"));
5145 goto nla_put_failure;
5146 }
5147
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305148 ret = cfg80211_vendor_cmd_reply(skb);
5149 EXIT();
5150 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305151
5152nla_put_failure:
5153 kfree_skb(skb);
5154 return -EINVAL;
5155}
5156
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305157static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305158wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5159 struct wireless_dev *wdev,
5160 const void *data, int data_len)
5161{
5162 int ret = 0;
5163
5164 vos_ssr_protect(__func__);
5165 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5166 vos_ssr_unprotect(__func__);
5167
5168 return ret;
5169}
5170
5171static int
5172__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305173 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305174 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305175{
5176 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5177 uint8_t i, feature_sets, max_feature_sets;
5178 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5179 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305180 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5181 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305182
5183 ENTER();
5184
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305185 ret = wlan_hdd_validate_context(pHddCtx);
5186 if (0 != ret)
5187 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305188 return ret;
5189 }
5190
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305191 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5192 data, data_len, NULL)) {
5193 hddLog(LOGE, FL("Invalid ATTR"));
5194 return -EINVAL;
5195 }
5196
5197 /* Parse and fetch max feature set */
5198 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5199 hddLog(LOGE, FL("Attr max feature set size failed"));
5200 return -EINVAL;
5201 }
5202 max_feature_sets = nla_get_u32(
5203 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5204 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5205
5206 /* Fill feature combination matrix */
5207 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305208 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5209 WIFI_FEATURE_P2P;
5210
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305211 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5212 WIFI_FEATURE_SOFT_AP;
5213
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305214 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5215 WIFI_FEATURE_SOFT_AP;
5216
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305217 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5218 WIFI_FEATURE_SOFT_AP |
5219 WIFI_FEATURE_P2P;
5220
5221 /* Add more feature combinations here */
5222
5223 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5224 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5225 hddLog(LOG1, "Feature set matrix");
5226 for (i = 0; i < feature_sets; i++)
5227 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5228
5229 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5230 sizeof(u32) * feature_sets +
5231 NLMSG_HDRLEN);
5232
5233 if (reply_skb) {
5234 if (nla_put_u32(reply_skb,
5235 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5236 feature_sets) ||
5237 nla_put(reply_skb,
5238 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5239 sizeof(u32) * feature_sets, feature_set_matrix)) {
5240 hddLog(LOGE, FL("nla put fail"));
5241 kfree_skb(reply_skb);
5242 return -EINVAL;
5243 }
5244
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305245 ret = cfg80211_vendor_cmd_reply(reply_skb);
5246 EXIT();
5247 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305248 }
5249 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5250 return -ENOMEM;
5251
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305252}
5253
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305254static int
5255wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5256 struct wireless_dev *wdev,
5257 const void *data, int data_len)
5258{
5259 int ret = 0;
5260
5261 vos_ssr_protect(__func__);
5262 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5263 data_len);
5264 vos_ssr_unprotect(__func__);
5265
5266 return ret;
5267}
5268
Agarwal Ashish738843c2014-09-25 12:27:56 +05305269static const struct nla_policy
5270wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5271 +1] =
5272{
5273 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5274};
5275
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305276static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305277 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305278 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305279 int data_len)
5280{
5281 struct net_device *dev = wdev->netdev;
5282 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5283 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5284 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5285 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5286 eHalStatus status;
5287 u32 dfsFlag = 0;
5288
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305289 ENTER();
5290
Agarwal Ashish738843c2014-09-25 12:27:56 +05305291 status = wlan_hdd_validate_context(pHddCtx);
5292 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305293 return -EINVAL;
5294 }
5295 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5296 data, data_len,
5297 wlan_hdd_set_no_dfs_flag_config_policy)) {
5298 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5299 return -EINVAL;
5300 }
5301
5302 /* Parse and fetch required bandwidth kbps */
5303 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5304 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5305 return -EINVAL;
5306 }
5307
5308 dfsFlag = nla_get_u32(
5309 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5310 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
5311 dfsFlag);
5312
5313 pHddCtx->disable_dfs_flag = dfsFlag;
5314
5315 sme_disable_dfs_channel(hHal, dfsFlag);
5316 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305317
5318 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05305319 return 0;
5320}
Atul Mittal115287b2014-07-08 13:26:33 +05305321
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305322static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
5323 struct wireless_dev *wdev,
5324 const void *data,
5325 int data_len)
5326{
5327 int ret = 0;
5328
5329 vos_ssr_protect(__func__);
5330 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
5331 vos_ssr_unprotect(__func__);
5332
5333 return ret;
5334
5335}
5336
Mukul Sharma2a271632014-10-13 14:59:01 +05305337const struct
5338nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
5339{
5340 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
5341 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
5342};
5343
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305344static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05305345 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05305346{
5347
5348 u8 bssid[6] = {0};
5349 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5350 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5351 eHalStatus status = eHAL_STATUS_SUCCESS;
5352 v_U32_t isFwrRoamEnabled = FALSE;
5353 int ret;
5354
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305355 ENTER();
5356
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305357 ret = wlan_hdd_validate_context(pHddCtx);
5358 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305359 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05305360 }
5361
5362 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
5363 data, data_len,
5364 qca_wlan_vendor_attr);
5365 if (ret){
5366 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5367 return -EINVAL;
5368 }
5369
5370 /* Parse and fetch Enable flag */
5371 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
5372 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
5373 return -EINVAL;
5374 }
5375
5376 isFwrRoamEnabled = nla_get_u32(
5377 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
5378
5379 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
5380
5381 /* Parse and fetch bssid */
5382 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
5383 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
5384 return -EINVAL;
5385 }
5386
5387 memcpy(bssid, nla_data(
5388 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
5389 sizeof(bssid));
5390 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
5391
5392 //Update roaming
5393 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305394 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05305395 return status;
5396}
5397
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305398static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
5399 struct wireless_dev *wdev, const void *data, int data_len)
5400{
5401 int ret = 0;
5402
5403 vos_ssr_protect(__func__);
5404 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
5405 vos_ssr_unprotect(__func__);
5406
5407 return ret;
5408}
5409
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305410/**
5411 * __wlan_hdd_cfg80211_setband() - set band
5412 * @wiphy: Pointer to wireless phy
5413 * @wdev: Pointer to wireless device
5414 * @data: Pointer to data
5415 * @data_len: Data length
5416 *
5417 * Return: 0 on success, negative errno on failure
5418 */
5419static int
5420__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5421 struct wireless_dev *wdev,
5422 const void *data,
5423 int data_len)
5424{
5425 struct net_device *dev = wdev->netdev;
5426 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5427 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5428 int ret;
5429 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
5430 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
5431
5432 ENTER();
5433
5434 ret = wlan_hdd_validate_context(hdd_ctx);
5435 if (0 != ret) {
5436 hddLog(LOGE, FL("HDD context is not valid"));
5437 return ret;
5438 }
5439
5440 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
5441 policy)) {
5442 hddLog(LOGE, FL("Invalid ATTR"));
5443 return -EINVAL;
5444 }
5445
5446 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
5447 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
5448 return -EINVAL;
5449 }
5450
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05305451 hdd_ctx->isSetBandByNL = TRUE;
5452 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305453 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05305454 hdd_ctx->isSetBandByNL = FALSE;
5455
5456 EXIT();
5457 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305458}
5459
5460/**
5461 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
5462 * @wiphy: wiphy structure pointer
5463 * @wdev: Wireless device structure pointer
5464 * @data: Pointer to the data received
5465 * @data_len: Length of @data
5466 *
5467 * Return: 0 on success; errno on failure
5468 */
5469static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5470 struct wireless_dev *wdev,
5471 const void *data,
5472 int data_len)
5473{
5474 int ret = 0;
5475
5476 vos_ssr_protect(__func__);
5477 ret = __wlan_hdd_cfg80211_setband(wiphy,
5478 wdev, data, data_len);
5479 vos_ssr_unprotect(__func__);
5480
5481 return ret;
5482}
5483
Sunil Duttc69bccb2014-05-26 21:30:20 +05305484const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
5485{
Mukul Sharma2a271632014-10-13 14:59:01 +05305486 {
5487 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5488 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
5489 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5490 WIPHY_VENDOR_CMD_NEED_NETDEV |
5491 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305492 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05305493 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305494
5495 {
5496 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5497 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
5498 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5499 WIPHY_VENDOR_CMD_NEED_NETDEV |
5500 WIPHY_VENDOR_CMD_NEED_RUNNING,
5501 .doit = wlan_hdd_cfg80211_nan_request
5502 },
5503
Sunil Duttc69bccb2014-05-26 21:30:20 +05305504#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5505 {
5506 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5507 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
5508 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5509 WIPHY_VENDOR_CMD_NEED_NETDEV |
5510 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305511 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05305512 },
5513
5514 {
5515 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5516 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
5517 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5518 WIPHY_VENDOR_CMD_NEED_NETDEV |
5519 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305520 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05305521 },
5522
5523 {
5524 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5525 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
5526 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5527 WIPHY_VENDOR_CMD_NEED_NETDEV |
5528 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305529 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05305530 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305531#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305532#ifdef WLAN_FEATURE_EXTSCAN
5533 {
5534 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5535 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
5536 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5537 WIPHY_VENDOR_CMD_NEED_NETDEV |
5538 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305539 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05305540 },
5541 {
5542 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5543 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
5544 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5545 WIPHY_VENDOR_CMD_NEED_NETDEV |
5546 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305547 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05305548 },
5549 {
5550 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5551 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
5552 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5553 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305554 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05305555 },
5556 {
5557 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5558 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
5559 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5560 WIPHY_VENDOR_CMD_NEED_NETDEV |
5561 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305562 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05305563 },
5564 {
5565 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5566 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
5567 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5568 WIPHY_VENDOR_CMD_NEED_NETDEV |
5569 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305570 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05305571 },
5572 {
5573 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5574 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
5575 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5576 WIPHY_VENDOR_CMD_NEED_NETDEV |
5577 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305578 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305579 },
5580 {
5581 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5582 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
5583 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5584 WIPHY_VENDOR_CMD_NEED_NETDEV |
5585 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305586 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305587 },
5588 {
5589 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5590 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
5591 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5592 WIPHY_VENDOR_CMD_NEED_NETDEV |
5593 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305594 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305595 },
5596 {
5597 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5598 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
5599 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5600 WIPHY_VENDOR_CMD_NEED_NETDEV |
5601 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305602 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305603 },
5604#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305605/*EXT TDLS*/
5606 {
5607 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5608 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
5609 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5610 WIPHY_VENDOR_CMD_NEED_NETDEV |
5611 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305612 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05305613 },
5614 {
5615 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5616 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
5617 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5618 WIPHY_VENDOR_CMD_NEED_NETDEV |
5619 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305620 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05305621 },
5622 {
5623 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5624 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
5625 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5626 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305627 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05305628 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05305629 {
5630 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5631 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
5632 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5633 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305634 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05305635 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05305636 {
5637 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5638 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
5639 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5640 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305641 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05305642 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305643 {
5644 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5645 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
5646 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5647 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305648 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305649 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305650 {
5651 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5652 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
5653 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5654 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305655 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305656 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305657 {
5658 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5659 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
5660 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5661 WIPHY_VENDOR_CMD_NEED_NETDEV |
5662 WIPHY_VENDOR_CMD_NEED_RUNNING,
5663 .doit = wlan_hdd_cfg80211_setband
5664 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05305665};
5666
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005667/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05305668static const
5669struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005670{
5671#ifdef FEATURE_WLAN_CH_AVOID
5672 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05305673 .vendor_id = QCA_NL80211_VENDOR_ID,
5674 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005675 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305676#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
5677#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5678 {
5679 /* Index = 1*/
5680 .vendor_id = QCA_NL80211_VENDOR_ID,
5681 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
5682 },
5683 {
5684 /* Index = 2*/
5685 .vendor_id = QCA_NL80211_VENDOR_ID,
5686 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
5687 },
5688 {
5689 /* Index = 3*/
5690 .vendor_id = QCA_NL80211_VENDOR_ID,
5691 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
5692 },
5693 {
5694 /* Index = 4*/
5695 .vendor_id = QCA_NL80211_VENDOR_ID,
5696 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
5697 },
5698 {
5699 /* Index = 5*/
5700 .vendor_id = QCA_NL80211_VENDOR_ID,
5701 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
5702 },
5703 {
5704 /* Index = 6*/
5705 .vendor_id = QCA_NL80211_VENDOR_ID,
5706 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
5707 },
5708#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305709#ifdef WLAN_FEATURE_EXTSCAN
5710 {
5711 .vendor_id = QCA_NL80211_VENDOR_ID,
5712 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
5713 },
5714 {
5715 .vendor_id = QCA_NL80211_VENDOR_ID,
5716 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
5717 },
5718 {
5719 .vendor_id = QCA_NL80211_VENDOR_ID,
5720 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
5721 },
5722 {
5723 .vendor_id = QCA_NL80211_VENDOR_ID,
5724 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
5725 },
5726 {
5727 .vendor_id = QCA_NL80211_VENDOR_ID,
5728 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
5729 },
5730 {
5731 .vendor_id = QCA_NL80211_VENDOR_ID,
5732 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
5733 },
5734 {
5735 .vendor_id = QCA_NL80211_VENDOR_ID,
5736 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
5737 },
5738 {
5739 .vendor_id = QCA_NL80211_VENDOR_ID,
5740 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
5741 },
5742 {
5743 .vendor_id = QCA_NL80211_VENDOR_ID,
5744 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
5745 },
5746 {
5747 .vendor_id = QCA_NL80211_VENDOR_ID,
5748 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
5749 },
5750 {
5751 .vendor_id = QCA_NL80211_VENDOR_ID,
5752 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
5753 },
5754 {
5755 .vendor_id = QCA_NL80211_VENDOR_ID,
5756 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
5757 },
5758 {
5759 .vendor_id = QCA_NL80211_VENDOR_ID,
5760 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
5761 },
5762#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305763/*EXT TDLS*/
5764 {
5765 .vendor_id = QCA_NL80211_VENDOR_ID,
5766 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
5767 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305768
5769 {
5770 .vendor_id = QCA_NL80211_VENDOR_ID,
5771 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
5772 },
5773
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005774};
5775
Jeff Johnson295189b2012-06-20 16:38:30 -07005776/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305777 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305778 * This function is called by hdd_wlan_startup()
5779 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305780 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07005781 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305782struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07005783{
5784 struct wiphy *wiphy;
5785 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305786 /*
5787 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 */
5789 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
5790
5791 if (!wiphy)
5792 {
5793 /* Print error and jump into err label and free the memory */
5794 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
5795 return NULL;
5796 }
5797
Sunil Duttc69bccb2014-05-26 21:30:20 +05305798
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 return wiphy;
5800}
5801
5802/*
5803 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305804 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 * private ioctl to change the band value
5806 */
5807int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
5808{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305809 int i, j;
5810 eNVChannelEnabledType channelEnabledState;
5811
Jeff Johnsone7245742012-09-05 17:12:55 -07005812 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305813
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305814 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005815 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305816
5817 if (NULL == wiphy->bands[i])
5818 {
5819 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5820 __func__, i);
5821 continue;
5822 }
5823
5824 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5825 {
5826 struct ieee80211_supported_band *band = wiphy->bands[i];
5827
5828 channelEnabledState = vos_nv_getChannelEnabledState(
5829 band->channels[j].hw_value);
5830
5831 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
5832 {
Abhishek Singh678227a2014-11-04 10:52:38 +05305833 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305834 continue;
5835 }
5836 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
5837 {
5838 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5839 continue;
5840 }
5841
5842 if (NV_CHANNEL_DISABLE == channelEnabledState ||
5843 NV_CHANNEL_INVALID == channelEnabledState)
5844 {
5845 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5846 }
5847 else if (NV_CHANNEL_DFS == channelEnabledState)
5848 {
5849 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5850 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
5851 }
5852 else
5853 {
5854 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
5855 |IEEE80211_CHAN_RADAR);
5856 }
5857 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005858 }
5859 return 0;
5860}
5861/*
5862 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305863 * This function is called by hdd_wlan_startup()
5864 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 * This function is used to initialize and register wiphy structure.
5866 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305867int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005868 struct wiphy *wiphy,
5869 hdd_config_t *pCfg
5870 )
5871{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305872 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305873 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5874
Jeff Johnsone7245742012-09-05 17:12:55 -07005875 ENTER();
5876
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 /* Now bind the underlying wlan device with wiphy */
5878 set_wiphy_dev(wiphy, dev);
5879
5880 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005881
Kiet Lam6c583332013-10-14 05:37:09 +05305882#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07005883 /* the flag for the other case would be initialzed in
5884 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07005885 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05305886#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005887
Amar Singhalfddc28c2013-09-05 13:03:40 -07005888 /* This will disable updating of NL channels from passive to
5889 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305890#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
5891 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
5892#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07005893 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305894#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07005895
Amar Singhala49cbc52013-10-08 18:37:44 -07005896
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005897#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07005898 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
5899 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
5900 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07005901 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305902#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
5903 wiphy->regulatory_flags = REGULATORY_COUNTRY_IE_IGNORE;
5904#else
5905 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
5906#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005907#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005908
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005909#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005910 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08005911#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005912 || pCfg->isFastRoamIniFeatureEnabled
5913#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005914#ifdef FEATURE_WLAN_ESE
5915 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005916#endif
5917 )
5918 {
5919 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
5920 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08005921#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005922#ifdef FEATURE_WLAN_TDLS
5923 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
5924 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
5925#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305926#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05305927 if (pCfg->configPNOScanSupport)
5928 {
5929 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
5930 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
5931 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
5932 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
5933 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305934#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005935
Abhishek Singh10d85972015-04-17 10:27:23 +05305936#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5937 wiphy->features |= NL80211_FEATURE_HT_IBSS;
5938#endif
5939
Amar Singhalfddc28c2013-09-05 13:03:40 -07005940#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005941 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
5942 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07005943 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005944 driver need to determine what to do with both
5945 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07005946
5947 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07005948#else
5949 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005950#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005951
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305952 wiphy->max_scan_ssids = MAX_SCAN_SSID;
5953
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05305954 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07005955
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305956 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
5957
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05305959 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
5960 | BIT(NL80211_IFTYPE_ADHOC)
5961 | BIT(NL80211_IFTYPE_P2P_CLIENT)
5962 | BIT(NL80211_IFTYPE_P2P_GO)
5963 | BIT(NL80211_IFTYPE_AP);
5964
5965 if (VOS_MONITOR_MODE == hdd_get_conparam())
5966 {
5967 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
5968 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005969
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305970 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005971 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305972#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5973 if( pCfg->enableMCC )
5974 {
5975 /* Currently, supports up to two channels */
5976 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005977
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305978 if( !pCfg->allowMCCGODiffBI )
5979 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005980
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305981 }
5982 wiphy->iface_combinations = &wlan_hdd_iface_combination;
5983 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005984#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305985 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005986
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 /* Before registering we need to update the ht capabilitied based
5988 * on ini values*/
5989 if( !pCfg->ShortGI20MhzEnable )
5990 {
5991 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5992 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5993 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5994 }
5995
5996 if( !pCfg->ShortGI40MhzEnable )
5997 {
5998 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
5999 }
6000
6001 if( !pCfg->nChannelBondingMode5GHz )
6002 {
6003 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
6004 }
6005
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306006 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05306007 if (true == hdd_is_5g_supported(pHddCtx))
6008 {
6009 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
6010 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306011
6012 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
6013 {
6014
6015 if (NULL == wiphy->bands[i])
6016 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05306017 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306018 __func__, i);
6019 continue;
6020 }
6021
6022 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
6023 {
6024 struct ieee80211_supported_band *band = wiphy->bands[i];
6025
6026 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
6027 {
6028 // Enable social channels for P2P
6029 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
6030 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
6031 else
6032 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
6033 continue;
6034 }
6035 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
6036 {
6037 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
6038 continue;
6039 }
6040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 }
6042 /*Initialise the supported cipher suite details*/
6043 wiphy->cipher_suites = hdd_cipher_suites;
6044 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
6045
6046 /*signal strength in mBm (100*dBm) */
6047 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
6048
6049#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05306050 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07006051#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006052
Sunil Duttc69bccb2014-05-26 21:30:20 +05306053 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
6054 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08006055 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
6056 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
6057
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306058 EXIT();
6059 return 0;
6060}
6061
6062/* In this function we are registering wiphy. */
6063int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
6064{
6065 ENTER();
6066 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006067 if (0 > wiphy_register(wiphy))
6068 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306069 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07006070 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
6071 return -EIO;
6072 }
6073
6074 EXIT();
6075 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306076}
Jeff Johnson295189b2012-06-20 16:38:30 -07006077
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306078/* In this function we are updating channel list when,
6079 regulatory domain is FCC and country code is US.
6080 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
6081 As per FCC smart phone is not a indoor device.
6082 GO should not opeate on indoor channels */
6083void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
6084{
6085 int j;
6086 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6087 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
6088 //Default counrtycode from NV at the time of wiphy initialization.
6089 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
6090 &defaultCountryCode[0]))
6091 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006092 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306093 }
6094 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
6095 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306096 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
6097 {
6098 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
6099 return;
6100 }
6101 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
6102 {
6103 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
6104 // Mark UNII -1 band channel as passive
6105 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
6106 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
6107 }
6108 }
6109}
6110
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05306111/* This function registers for all frame which supplicant is interested in */
6112void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07006113{
Jeff Johnson295189b2012-06-20 16:38:30 -07006114 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6115 /* Register for all P2P action, public action etc frames */
6116 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
6117
Jeff Johnsone7245742012-09-05 17:12:55 -07006118 ENTER();
6119
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 /* Right now we are registering these frame when driver is getting
6121 initialized. Once we will move to 2.6.37 kernel, in which we have
6122 frame register ops, we will move this code as a part of that */
6123 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306124 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006125 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6126
6127 /* GAS Initial Response */
6128 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6129 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306130
Jeff Johnson295189b2012-06-20 16:38:30 -07006131 /* GAS Comeback Request */
6132 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6133 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6134
6135 /* GAS Comeback Response */
6136 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6137 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6138
6139 /* P2P Public Action */
6140 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306141 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 P2P_PUBLIC_ACTION_FRAME_SIZE );
6143
6144 /* P2P Action */
6145 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6146 (v_U8_t*)P2P_ACTION_FRAME,
6147 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07006148
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05306149 /* WNM BSS Transition Request frame */
6150 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6151 (v_U8_t*)WNM_BSS_ACTION_FRAME,
6152 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006153
6154 /* WNM-Notification */
6155 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6156 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6157 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006158}
6159
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05306160void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07006161{
Jeff Johnson295189b2012-06-20 16:38:30 -07006162 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6163 /* Register for all P2P action, public action etc frames */
6164 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
6165
Jeff Johnsone7245742012-09-05 17:12:55 -07006166 ENTER();
6167
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 /* Right now we are registering these frame when driver is getting
6169 initialized. Once we will move to 2.6.37 kernel, in which we have
6170 frame register ops, we will move this code as a part of that */
6171 /* GAS Initial Request */
6172
6173 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6174 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6175
6176 /* GAS Initial Response */
6177 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6178 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306179
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 /* GAS Comeback Request */
6181 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6182 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6183
6184 /* GAS Comeback Response */
6185 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6186 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6187
6188 /* P2P Public Action */
6189 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306190 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006191 P2P_PUBLIC_ACTION_FRAME_SIZE );
6192
6193 /* P2P Action */
6194 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6195 (v_U8_t*)P2P_ACTION_FRAME,
6196 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006197 /* WNM-Notification */
6198 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6199 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6200 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006201}
6202
6203#ifdef FEATURE_WLAN_WAPI
6204void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05306205 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006206{
6207 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6208 tCsrRoamSetKey setKey;
6209 v_BOOL_t isConnected = TRUE;
6210 int status = 0;
6211 v_U32_t roamId= 0xFF;
6212 tANI_U8 *pKeyPtr = NULL;
6213 int n = 0;
6214
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306215 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
6216 __func__, hdd_device_modetoString(pAdapter->device_mode),
6217 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006218
Gopichand Nakkalae7480202013-02-11 15:24:22 +05306219 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 setKey.keyId = key_index; // Store Key ID
6221 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
6222 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
6223 setKey.paeRole = 0 ; // the PAE role
6224 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
6225 {
6226 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
6227 }
6228 else
6229 {
6230 isConnected = hdd_connIsConnected(pHddStaCtx);
6231 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
6232 }
6233 setKey.keyLength = key_Len;
6234 pKeyPtr = setKey.Key;
6235 memcpy( pKeyPtr, key, key_Len);
6236
Arif Hussain6d2a3322013-11-17 19:50:10 -08006237 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 __func__, key_Len);
6239 for (n = 0 ; n < key_Len; n++)
6240 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
6241 __func__,n,setKey.Key[n]);
6242
6243 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6244 if ( isConnected )
6245 {
6246 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
6247 pAdapter->sessionId, &setKey, &roamId );
6248 }
6249 if ( status != 0 )
6250 {
6251 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6252 "[%4d] sme_RoamSetKey returned ERROR status= %d",
6253 __LINE__, status );
6254 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6255 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05306256 /* Need to clear any trace of key value in the memory.
6257 * Thus zero out the memory even though it is local
6258 * variable.
6259 */
6260 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006261}
6262#endif /* FEATURE_WLAN_WAPI*/
6263
6264#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306265int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 beacon_data_t **ppBeacon,
6267 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006268#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306269int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006270 beacon_data_t **ppBeacon,
6271 struct cfg80211_beacon_data *params,
6272 int dtim_period)
6273#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306274{
Jeff Johnson295189b2012-06-20 16:38:30 -07006275 int size;
6276 beacon_data_t *beacon = NULL;
6277 beacon_data_t *old = NULL;
6278 int head_len,tail_len;
6279
Jeff Johnsone7245742012-09-05 17:12:55 -07006280 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006281 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306282 {
6283 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6284 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306286 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006287
6288 old = pAdapter->sessionCtx.ap.beacon;
6289
6290 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306291 {
6292 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6293 FL("session(%d) old and new heads points to NULL"),
6294 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306296 }
6297
6298 if (params->tail && !params->tail_len)
6299 {
6300 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6301 FL("tail_len is zero but tail is not NULL"));
6302 return -EINVAL;
6303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006304
Jeff Johnson295189b2012-06-20 16:38:30 -07006305#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
6306 /* Kernel 3.0 is not updating dtim_period for set beacon */
6307 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306308 {
6309 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6310 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006311 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306312 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006313#endif
6314
6315 if(params->head)
6316 head_len = params->head_len;
6317 else
6318 head_len = old->head_len;
6319
6320 if(params->tail || !old)
6321 tail_len = params->tail_len;
6322 else
6323 tail_len = old->tail_len;
6324
6325 size = sizeof(beacon_data_t) + head_len + tail_len;
6326
6327 beacon = kzalloc(size, GFP_KERNEL);
6328
6329 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306330 {
6331 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6332 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306334 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006335
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006336#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006337 if(params->dtim_period || !old )
6338 beacon->dtim_period = params->dtim_period;
6339 else
6340 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006341#else
6342 if(dtim_period || !old )
6343 beacon->dtim_period = dtim_period;
6344 else
6345 beacon->dtim_period = old->dtim_period;
6346#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306347
Jeff Johnson295189b2012-06-20 16:38:30 -07006348 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
6349 beacon->tail = beacon->head + head_len;
6350 beacon->head_len = head_len;
6351 beacon->tail_len = tail_len;
6352
6353 if(params->head) {
6354 memcpy (beacon->head,params->head,beacon->head_len);
6355 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306356 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07006357 if(old)
6358 memcpy (beacon->head,old->head,beacon->head_len);
6359 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306360
Jeff Johnson295189b2012-06-20 16:38:30 -07006361 if(params->tail) {
6362 memcpy (beacon->tail,params->tail,beacon->tail_len);
6363 }
6364 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306365 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07006366 memcpy (beacon->tail,old->tail,beacon->tail_len);
6367 }
6368
6369 *ppBeacon = beacon;
6370
6371 kfree(old);
6372
6373 return 0;
6374
6375}
Jeff Johnson295189b2012-06-20 16:38:30 -07006376
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05306377v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
6378#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
6379 const v_U8_t *pIes,
6380#else
6381 v_U8_t *pIes,
6382#endif
6383 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006384{
6385 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05306386 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07006387 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306388
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306390 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006391 elem_id = ptr[0];
6392 elem_len = ptr[1];
6393 left -= 2;
6394 if(elem_len > left)
6395 {
6396 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006397 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 eid,elem_len,left);
6399 return NULL;
6400 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306401 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006402 {
6403 return ptr;
6404 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306405
Jeff Johnson295189b2012-06-20 16:38:30 -07006406 left -= elem_len;
6407 ptr += (elem_len + 2);
6408 }
6409 return NULL;
6410}
6411
Jeff Johnson295189b2012-06-20 16:38:30 -07006412/* Check if rate is 11g rate or not */
6413static int wlan_hdd_rate_is_11g(u8 rate)
6414{
Sanjay Devnani28322e22013-06-21 16:13:40 -07006415 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006416 u8 i;
6417 for (i = 0; i < 8; i++)
6418 {
6419 if(rate == gRateArray[i])
6420 return TRUE;
6421 }
6422 return FALSE;
6423}
6424
6425/* Check for 11g rate and set proper 11g only mode */
6426static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
6427 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
6428{
6429 u8 i, num_rates = pIe[0];
6430
6431 pIe += 1;
6432 for ( i = 0; i < num_rates; i++)
6433 {
6434 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
6435 {
6436 /* If rate set have 11g rate than change the mode to 11G */
6437 *pSapHw_mode = eSAP_DOT11_MODE_11g;
6438 if (pIe[i] & BASIC_RATE_MASK)
6439 {
6440 /* If we have 11g rate as basic rate, it means mode
6441 is 11g only mode.
6442 */
6443 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
6444 *pCheckRatesfor11g = FALSE;
6445 }
6446 }
6447 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
6448 {
6449 *require_ht = TRUE;
6450 }
6451 }
6452 return;
6453}
6454
6455static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
6456{
6457 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6458 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6459 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6460 u8 checkRatesfor11g = TRUE;
6461 u8 require_ht = FALSE;
6462 u8 *pIe=NULL;
6463
6464 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
6465
6466 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
6467 pBeacon->head_len, WLAN_EID_SUPP_RATES);
6468 if (pIe != NULL)
6469 {
6470 pIe += 1;
6471 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6472 &pConfig->SapHw_mode);
6473 }
6474
6475 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6476 WLAN_EID_EXT_SUPP_RATES);
6477 if (pIe != NULL)
6478 {
6479
6480 pIe += 1;
6481 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6482 &pConfig->SapHw_mode);
6483 }
6484
6485 if( pConfig->channel > 14 )
6486 {
6487 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
6488 }
6489
6490 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6491 WLAN_EID_HT_CAPABILITY);
6492
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306493 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006494 {
6495 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
6496 if(require_ht)
6497 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
6498 }
6499}
6500
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306501static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
6502 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
6503{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006504 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306505 v_U8_t *pIe = NULL;
6506 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6507
6508 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
6509 pBeacon->tail, pBeacon->tail_len);
6510
6511 if (pIe)
6512 {
6513 ielen = pIe[1] + 2;
6514 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6515 {
6516 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
6517 }
6518 else
6519 {
6520 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
6521 return -EINVAL;
6522 }
6523 *total_ielen += ielen;
6524 }
6525 return 0;
6526}
6527
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006528static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
6529 v_U8_t *genie, v_U8_t *total_ielen)
6530{
6531 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6532 int left = pBeacon->tail_len;
6533 v_U8_t *ptr = pBeacon->tail;
6534 v_U8_t elem_id, elem_len;
6535 v_U16_t ielen = 0;
6536
6537 if ( NULL == ptr || 0 == left )
6538 return;
6539
6540 while (left >= 2)
6541 {
6542 elem_id = ptr[0];
6543 elem_len = ptr[1];
6544 left -= 2;
6545 if (elem_len > left)
6546 {
6547 hddLog( VOS_TRACE_LEVEL_ERROR,
6548 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
6549 elem_id, elem_len, left);
6550 return;
6551 }
6552 if (IE_EID_VENDOR == elem_id)
6553 {
6554 /* skipping the VSIE's which we don't want to include or
6555 * it will be included by existing code
6556 */
6557 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
6558#ifdef WLAN_FEATURE_WFD
6559 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
6560#endif
6561 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6562 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6563 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
6564 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6565 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
6566 {
6567 ielen = ptr[1] + 2;
6568 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6569 {
6570 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
6571 *total_ielen += ielen;
6572 }
6573 else
6574 {
6575 hddLog( VOS_TRACE_LEVEL_ERROR,
6576 "IE Length is too big "
6577 "IEs eid=%d elem_len=%d total_ie_lent=%d",
6578 elem_id, elem_len, *total_ielen);
6579 }
6580 }
6581 }
6582
6583 left -= elem_len;
6584 ptr += (elem_len + 2);
6585 }
6586 return;
6587}
6588
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006589#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006590static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6591 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006592#else
6593static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6594 struct cfg80211_beacon_data *params)
6595#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006596{
6597 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306598 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07006600 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006601
6602 genie = vos_mem_malloc(MAX_GENIE_LEN);
6603
6604 if(genie == NULL) {
6605
6606 return -ENOMEM;
6607 }
6608
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306609 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6610 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306612 hddLog(LOGE,
6613 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306614 ret = -EINVAL;
6615 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006616 }
6617
6618#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306619 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6620 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
6621 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306622 hddLog(LOGE,
6623 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306624 ret = -EINVAL;
6625 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006626 }
6627#endif
6628
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306629 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6630 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306632 hddLog(LOGE,
6633 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306634 ret = -EINVAL;
6635 goto done;
6636 }
6637
6638 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
6639 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006640 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006641 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006642
6643 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6644 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
6645 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6646 {
6647 hddLog(LOGE,
6648 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006649 ret = -EINVAL;
6650 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006651 }
6652
6653 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6654 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6655 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6656 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6657 ==eHAL_STATUS_FAILURE)
6658 {
6659 hddLog(LOGE,
6660 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006661 ret = -EINVAL;
6662 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 }
6664
6665 // Added for ProResp IE
6666 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
6667 {
6668 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
6669 u8 probe_rsp_ie_len[3] = {0};
6670 u8 counter = 0;
6671 /* Check Probe Resp Length if it is greater then 255 then Store
6672 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
6673 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
6674 Store More then 255 bytes into One Variable.
6675 */
6676 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6677 {
6678 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6679 {
6680 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6681 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6682 }
6683 else
6684 {
6685 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6686 rem_probe_resp_ie_len = 0;
6687 }
6688 }
6689
6690 rem_probe_resp_ie_len = 0;
6691
6692 if (probe_rsp_ie_len[0] > 0)
6693 {
6694 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6695 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6696 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6697 probe_rsp_ie_len[0], NULL,
6698 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6699 {
6700 hddLog(LOGE,
6701 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006702 ret = -EINVAL;
6703 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 }
6705 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6706 }
6707
6708 if (probe_rsp_ie_len[1] > 0)
6709 {
6710 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6711 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6712 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6713 probe_rsp_ie_len[1], NULL,
6714 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6715 {
6716 hddLog(LOGE,
6717 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006718 ret = -EINVAL;
6719 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006720 }
6721 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6722 }
6723
6724 if (probe_rsp_ie_len[2] > 0)
6725 {
6726 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6727 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6728 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6729 probe_rsp_ie_len[2], NULL,
6730 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6731 {
6732 hddLog(LOGE,
6733 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006734 ret = -EINVAL;
6735 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006736 }
6737 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6738 }
6739
6740 if (probe_rsp_ie_len[1] == 0 )
6741 {
6742 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6743 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
6744 eANI_BOOLEAN_FALSE) )
6745 {
6746 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006747 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 }
6749 }
6750
6751 if (probe_rsp_ie_len[2] == 0 )
6752 {
6753 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6754 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
6755 eANI_BOOLEAN_FALSE) )
6756 {
6757 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006758 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006759 }
6760 }
6761
6762 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6763 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6764 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6765 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6766 == eHAL_STATUS_FAILURE)
6767 {
6768 hddLog(LOGE,
6769 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006770 ret = -EINVAL;
6771 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 }
6773 }
6774 else
6775 {
6776 // Reset WNI_CFG_PROBE_RSP Flags
6777 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
6778
6779 hddLog(VOS_TRACE_LEVEL_INFO,
6780 "%s: No Probe Response IE received in set beacon",
6781 __func__);
6782 }
6783
6784 // Added for AssocResp IE
6785 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
6786 {
6787 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6788 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
6789 params->assocresp_ies_len, NULL,
6790 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6791 {
6792 hddLog(LOGE,
6793 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006794 ret = -EINVAL;
6795 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006796 }
6797
6798 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6799 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
6800 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6801 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6802 == eHAL_STATUS_FAILURE)
6803 {
6804 hddLog(LOGE,
6805 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006806 ret = -EINVAL;
6807 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006808 }
6809 }
6810 else
6811 {
6812 hddLog(VOS_TRACE_LEVEL_INFO,
6813 "%s: No Assoc Response IE received in set beacon",
6814 __func__);
6815
6816 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6817 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6818 eANI_BOOLEAN_FALSE) )
6819 {
6820 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006821 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 }
6823 }
6824
Jeff Johnsone7245742012-09-05 17:12:55 -07006825done:
Jeff Johnson295189b2012-06-20 16:38:30 -07006826 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306827 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006828}
Jeff Johnson295189b2012-06-20 16:38:30 -07006829
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306830/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006831 * FUNCTION: wlan_hdd_validate_operation_channel
6832 * called by wlan_hdd_cfg80211_start_bss() and
6833 * wlan_hdd_cfg80211_set_channel()
6834 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306835 * channel list.
6836 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07006837VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006838{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306839
Jeff Johnson295189b2012-06-20 16:38:30 -07006840 v_U32_t num_ch = 0;
6841 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6842 u32 indx = 0;
6843 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306844 v_U8_t fValidChannel = FALSE, count = 0;
6845 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306846
Jeff Johnson295189b2012-06-20 16:38:30 -07006847 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6848
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306849 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306851 /* Validate the channel */
6852 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006853 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306854 if ( channel == rfChannels[count].channelNum )
6855 {
6856 fValidChannel = TRUE;
6857 break;
6858 }
6859 }
6860 if (fValidChannel != TRUE)
6861 {
6862 hddLog(VOS_TRACE_LEVEL_ERROR,
6863 "%s: Invalid Channel [%d]", __func__, channel);
6864 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006865 }
6866 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306867 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006868 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306869 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6870 valid_ch, &num_ch))
6871 {
6872 hddLog(VOS_TRACE_LEVEL_ERROR,
6873 "%s: failed to get valid channel list", __func__);
6874 return VOS_STATUS_E_FAILURE;
6875 }
6876 for (indx = 0; indx < num_ch; indx++)
6877 {
6878 if (channel == valid_ch[indx])
6879 {
6880 break;
6881 }
6882 }
6883
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306884 if (indx >= num_ch)
6885 {
6886 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6887 {
6888 eCsrBand band;
6889 unsigned int freq;
6890
6891 sme_GetFreqBand(hHal, &band);
6892
6893 if (eCSR_BAND_5G == band)
6894 {
6895#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
6896 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
6897 {
6898 freq = ieee80211_channel_to_frequency(channel,
6899 IEEE80211_BAND_2GHZ);
6900 }
6901 else
6902 {
6903 freq = ieee80211_channel_to_frequency(channel,
6904 IEEE80211_BAND_5GHZ);
6905 }
6906#else
6907 freq = ieee80211_channel_to_frequency(channel);
6908#endif
6909 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
6910 return VOS_STATUS_SUCCESS;
6911 }
6912 }
6913
6914 hddLog(VOS_TRACE_LEVEL_ERROR,
6915 "%s: Invalid Channel [%d]", __func__, channel);
6916 return VOS_STATUS_E_FAILURE;
6917 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006918 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306919
Jeff Johnson295189b2012-06-20 16:38:30 -07006920 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306921
Jeff Johnson295189b2012-06-20 16:38:30 -07006922}
6923
Viral Modi3a32cc52013-02-08 11:14:52 -08006924/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306925 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08006926 * This function is used to set the channel number
6927 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306928static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08006929 struct ieee80211_channel *chan,
6930 enum nl80211_channel_type channel_type
6931 )
6932{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306933 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08006934 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07006935 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08006936 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306937 hdd_context_t *pHddCtx;
6938 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006939
6940 ENTER();
6941
6942 if( NULL == dev )
6943 {
6944 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006945 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006946 return -ENODEV;
6947 }
6948 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306949
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306950 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6951 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
6952 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08006953 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306954 "%s: device_mode = %s (%d) freq = %d", __func__,
6955 hdd_device_modetoString(pAdapter->device_mode),
6956 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306957
6958 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6959 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306960 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08006961 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306962 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006963 }
6964
6965 /*
6966 * Do freq to chan conversion
6967 * TODO: for 11a
6968 */
6969
6970 channel = ieee80211_frequency_to_channel(freq);
6971
6972 /* Check freq range */
6973 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
6974 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
6975 {
6976 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006977 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08006978 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
6979 WNI_CFG_CURRENT_CHANNEL_STAMAX);
6980 return -EINVAL;
6981 }
6982
6983 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6984
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05306985 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
6986 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08006987 {
6988 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
6989 {
6990 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006991 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08006992 return -EINVAL;
6993 }
6994 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6995 "%s: set channel to [%d] for device mode =%d",
6996 __func__, channel,pAdapter->device_mode);
6997 }
6998 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08006999 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08007000 )
7001 {
7002 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7003 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
7004 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7005
7006 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
7007 {
7008 /* Link is up then return cant set channel*/
7009 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007010 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08007011 return -EINVAL;
7012 }
7013
7014 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
7015 pHddStaCtx->conn_info.operationChannel = channel;
7016 pRoamProfile->ChannelInfo.ChannelList =
7017 &pHddStaCtx->conn_info.operationChannel;
7018 }
7019 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08007020 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08007021 )
7022 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307023 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
7024 {
7025 if(VOS_STATUS_SUCCESS !=
7026 wlan_hdd_validate_operation_channel(pAdapter,channel))
7027 {
7028 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007029 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307030 return -EINVAL;
7031 }
7032 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
7033 }
7034 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08007035 {
7036 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
7037
7038 /* If auto channel selection is configured as enable/ 1 then ignore
7039 channel set by supplicant
7040 */
7041 if ( cfg_param->apAutoChannelSelection )
7042 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307043 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
7044 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08007045 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307046 "%s: set channel to auto channel (0) for device mode =%s (%d)",
7047 __func__, hdd_device_modetoString(pAdapter->device_mode),
7048 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08007049 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307050 else
7051 {
7052 if(VOS_STATUS_SUCCESS !=
7053 wlan_hdd_validate_operation_channel(pAdapter,channel))
7054 {
7055 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007056 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307057 return -EINVAL;
7058 }
7059 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
7060 }
Viral Modi3a32cc52013-02-08 11:14:52 -08007061 }
7062 }
7063 else
7064 {
7065 hddLog(VOS_TRACE_LEVEL_FATAL,
7066 "%s: Invalid device mode failed to set valid channel", __func__);
7067 return -EINVAL;
7068 }
7069 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307070 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08007071}
7072
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05307073static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
7074 struct net_device *dev,
7075 struct ieee80211_channel *chan,
7076 enum nl80211_channel_type channel_type
7077 )
7078{
7079 int ret;
7080
7081 vos_ssr_protect(__func__);
7082 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
7083 vos_ssr_unprotect(__func__);
7084
7085 return ret;
7086}
7087
Jeff Johnson295189b2012-06-20 16:38:30 -07007088#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7089static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
7090 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007091#else
7092static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
7093 struct cfg80211_beacon_data *params,
7094 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307095 enum nl80211_hidden_ssid hidden_ssid,
7096 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007097#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007098{
7099 tsap_Config_t *pConfig;
7100 beacon_data_t *pBeacon = NULL;
7101 struct ieee80211_mgmt *pMgmt_frame;
7102 v_U8_t *pIe=NULL;
7103 v_U16_t capab_info;
7104 eCsrAuthType RSNAuthType;
7105 eCsrEncryptionType RSNEncryptType;
7106 eCsrEncryptionType mcRSNEncryptType;
7107 int status = VOS_STATUS_SUCCESS;
7108 tpWLAN_SAPEventCB pSapEventCallback;
7109 hdd_hostapd_state_t *pHostapdState;
7110 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
7111 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307112 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007113 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307114 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07007115 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08007116 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05307117 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07007118 v_BOOL_t MFPCapable = VOS_FALSE;
7119 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307120 v_BOOL_t sapEnable11AC =
7121 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07007122 ENTER();
7123
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307124 iniConfig = pHddCtx->cfg_ini;
7125
Jeff Johnson295189b2012-06-20 16:38:30 -07007126 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
7127
7128 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
7129
7130 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
7131
7132 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
7133
7134 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
7135
7136 //channel is already set in the set_channel Call back
7137 //pConfig->channel = pCommitConfig->channel;
7138
7139 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307140 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07007141 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
7142
7143 pConfig->dtim_period = pBeacon->dtim_period;
7144
Arif Hussain6d2a3322013-11-17 19:50:10 -08007145 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07007146 pConfig->dtim_period);
7147
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08007148 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07007149 {
7150 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007151 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05307152 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
7153 {
7154 tANI_BOOLEAN restartNeeded;
7155 pConfig->ieee80211d = 1;
7156 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
7157 sme_setRegInfo(hHal, pConfig->countryCode);
7158 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
7159 }
7160 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07007161 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07007162 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007163 pConfig->ieee80211d = 1;
7164 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
7165 sme_setRegInfo(hHal, pConfig->countryCode);
7166 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07007167 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007168 else
7169 {
7170 pConfig->ieee80211d = 0;
7171 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307172 /*
7173 * If auto channel is configured i.e. channel is 0,
7174 * so skip channel validation.
7175 */
7176 if( AUTO_CHANNEL_SELECT != pConfig->channel )
7177 {
7178 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
7179 {
7180 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007181 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307182 return -EINVAL;
7183 }
7184 }
7185 else
7186 {
7187 if(1 != pHddCtx->is_dynamic_channel_range_set)
7188 {
7189 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
7190 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
7191 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
7192 }
7193 pHddCtx->is_dynamic_channel_range_set = 0;
7194 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007195 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007196 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007197 {
7198 pConfig->ieee80211d = 0;
7199 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307200
7201#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7202 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7203 pConfig->authType = eSAP_OPEN_SYSTEM;
7204 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7205 pConfig->authType = eSAP_SHARED_KEY;
7206 else
7207 pConfig->authType = eSAP_AUTO_SWITCH;
7208#else
7209 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7210 pConfig->authType = eSAP_OPEN_SYSTEM;
7211 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7212 pConfig->authType = eSAP_SHARED_KEY;
7213 else
7214 pConfig->authType = eSAP_AUTO_SWITCH;
7215#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007216
7217 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307218
7219 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07007220 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
7221
7222 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
7223
7224 /*Set wps station to configured*/
7225 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
7226
7227 if(pIe)
7228 {
7229 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
7230 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007231 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07007232 return -EINVAL;
7233 }
7234 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
7235 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007236 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07007237 /* Check 15 bit of WPS IE as it contain information for wps state
7238 * WPS state
7239 */
7240 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
7241 {
7242 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
7243 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
7244 {
7245 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
7246 }
7247 }
7248 }
7249 else
7250 {
7251 pConfig->wps_state = SAP_WPS_DISABLED;
7252 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307253 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07007254
c_hpothufe599e92014-06-16 11:38:55 +05307255 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7256 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7257 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
7258 eCSR_ENCRYPT_TYPE_NONE;
7259
Jeff Johnson295189b2012-06-20 16:38:30 -07007260 pConfig->RSNWPAReqIELength = 0;
7261 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307262 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007263 WLAN_EID_RSN);
7264 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307265 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7267 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7268 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307269 /* The actual processing may eventually be more extensive than
7270 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07007271 * by the app.
7272 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307273 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007274 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7275 &RSNEncryptType,
7276 &mcRSNEncryptType,
7277 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007278 &MFPCapable,
7279 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007280 pConfig->pRSNWPAReqIE[1]+2,
7281 pConfig->pRSNWPAReqIE );
7282
7283 if( VOS_STATUS_SUCCESS == status )
7284 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307285 /* Now copy over all the security attributes you have
7286 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007287 * */
7288 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7289 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7290 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7291 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307292 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007293 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007294 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7295 }
7296 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307297
Jeff Johnson295189b2012-06-20 16:38:30 -07007298 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7299 pBeacon->tail, pBeacon->tail_len);
7300
7301 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
7302 {
7303 if (pConfig->pRSNWPAReqIE)
7304 {
7305 /*Mixed mode WPA/WPA2*/
7306 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
7307 pConfig->RSNWPAReqIELength += pIe[1] + 2;
7308 }
7309 else
7310 {
7311 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7312 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7313 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307314 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007315 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7316 &RSNEncryptType,
7317 &mcRSNEncryptType,
7318 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007319 &MFPCapable,
7320 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007321 pConfig->pRSNWPAReqIE[1]+2,
7322 pConfig->pRSNWPAReqIE );
7323
7324 if( VOS_STATUS_SUCCESS == status )
7325 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307326 /* Now copy over all the security attributes you have
7327 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007328 * */
7329 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7330 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7331 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7332 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307333 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007334 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007335 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7336 }
7337 }
7338 }
7339
Jeff Johnson4416a782013-03-25 14:17:50 -07007340 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
7341 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
7342 return -EINVAL;
7343 }
7344
Jeff Johnson295189b2012-06-20 16:38:30 -07007345 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
7346
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007347#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007348 if (params->ssid != NULL)
7349 {
7350 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
7351 pConfig->SSIDinfo.ssid.length = params->ssid_len;
7352 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7353 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7354 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007355#else
7356 if (ssid != NULL)
7357 {
7358 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
7359 pConfig->SSIDinfo.ssid.length = ssid_len;
7360 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7361 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7362 }
7363#endif
7364
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307365 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07007366 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307367
Jeff Johnson295189b2012-06-20 16:38:30 -07007368 /* default value */
7369 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
7370 pConfig->num_accept_mac = 0;
7371 pConfig->num_deny_mac = 0;
7372
7373 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7374 pBeacon->tail, pBeacon->tail_len);
7375
7376 /* pIe for black list is following form:
7377 type : 1 byte
7378 length : 1 byte
7379 OUI : 4 bytes
7380 acl type : 1 byte
7381 no of mac addr in black list: 1 byte
7382 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307383 */
7384 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007385 {
7386 pConfig->SapMacaddr_acl = pIe[6];
7387 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007388 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007389 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307390 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
7391 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007392 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7393 for (i = 0; i < pConfig->num_deny_mac; i++)
7394 {
7395 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7396 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007398 }
7399 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7400 pBeacon->tail, pBeacon->tail_len);
7401
7402 /* pIe for white list is following form:
7403 type : 1 byte
7404 length : 1 byte
7405 OUI : 4 bytes
7406 acl type : 1 byte
7407 no of mac addr in white list: 1 byte
7408 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307409 */
7410 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007411 {
7412 pConfig->SapMacaddr_acl = pIe[6];
7413 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007414 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007415 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307416 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
7417 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007418 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7419 for (i = 0; i < pConfig->num_accept_mac; i++)
7420 {
7421 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7422 acl_entry++;
7423 }
7424 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307425
Jeff Johnson295189b2012-06-20 16:38:30 -07007426 wlan_hdd_set_sapHwmode(pHostapdAdapter);
7427
Jeff Johnsone7245742012-09-05 17:12:55 -07007428#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007429 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307430 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
7431 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05307432 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
7433 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007434 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
7435 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307436 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
7437 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07007438 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307439 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007440 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307441 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007442
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307443 /* If ACS disable and selected channel <= 14
7444 * OR
7445 * ACS enabled and ACS operating band is choosen as 2.4
7446 * AND
7447 * VHT in 2.4G Disabled
7448 * THEN
7449 * Fallback to 11N mode
7450 */
7451 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
7452 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05307453 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307454 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007455 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307456 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
7457 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007458 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
7459 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007460 }
7461#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307462
Jeff Johnson295189b2012-06-20 16:38:30 -07007463 // ht_capab is not what the name conveys,this is used for protection bitmap
7464 pConfig->ht_capab =
7465 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
7466
7467 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
7468 {
7469 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
7470 return -EINVAL;
7471 }
7472
7473 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307474 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07007475 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
7476 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307477 pConfig->obssProtEnabled =
7478 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07007479
Chet Lanctot8cecea22014-02-11 19:09:36 -08007480#ifdef WLAN_FEATURE_11W
7481 pConfig->mfpCapable = MFPCapable;
7482 pConfig->mfpRequired = MFPRequired;
7483 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
7484 pConfig->mfpCapable, pConfig->mfpRequired);
7485#endif
7486
Arif Hussain6d2a3322013-11-17 19:50:10 -08007487 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07007488 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007489 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
7490 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
7491 (int)pConfig->channel);
7492 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
7493 pConfig->SapHw_mode, pConfig->privacy,
7494 pConfig->authType);
7495 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
7496 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
7497 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
7498 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07007499
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307500 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 {
7502 //Bss already started. just return.
7503 //TODO Probably it should update some beacon params.
7504 hddLog( LOGE, "Bss Already started...Ignore the request");
7505 EXIT();
7506 return 0;
7507 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307508
Agarwal Ashish51325b52014-06-16 16:50:49 +05307509 if (vos_max_concurrent_connections_reached()) {
7510 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7511 return -EINVAL;
7512 }
7513
Jeff Johnson295189b2012-06-20 16:38:30 -07007514 pConfig->persona = pHostapdAdapter->device_mode;
7515
Peng Xu2446a892014-09-05 17:21:18 +05307516 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
7517 if ( NULL != psmeConfig)
7518 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307519 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05307520 sme_GetConfigParam(hHal, psmeConfig);
7521 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307522#ifdef WLAN_FEATURE_AP_HT40_24G
7523 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
7524 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
7525 && pHddCtx->cfg_ini->apHT40_24GEnabled)
7526 {
7527 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
7528 sme_UpdateConfig (hHal, psmeConfig);
7529 }
7530#endif
Peng Xu2446a892014-09-05 17:21:18 +05307531 vos_mem_free(psmeConfig);
7532 }
Peng Xuafc34e32014-09-25 13:23:55 +05307533 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05307534
Jeff Johnson295189b2012-06-20 16:38:30 -07007535 pSapEventCallback = hdd_hostapd_SAPEventCB;
7536 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
7537 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
7538 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007539 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 return -EINVAL;
7541 }
7542
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307543 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07007544 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
7545
7546 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307547
Jeff Johnson295189b2012-06-20 16:38:30 -07007548 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307549 {
7550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007551 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07007552 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007553 VOS_ASSERT(0);
7554 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307555
Jeff Johnson295189b2012-06-20 16:38:30 -07007556 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05307557 /* Initialize WMM configuation */
7558 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307559 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007560
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007561#ifdef WLAN_FEATURE_P2P_DEBUG
7562 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
7563 {
7564 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
7565 {
7566 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7567 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007568 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007569 }
7570 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
7571 {
7572 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7573 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007574 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007575 }
7576 }
7577#endif
7578
Jeff Johnson295189b2012-06-20 16:38:30 -07007579 pHostapdState->bCommit = TRUE;
7580 EXIT();
7581
7582 return 0;
7583}
7584
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007585#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307586static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307587 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007588 struct beacon_parameters *params)
7589{
7590 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307591 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307592 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007593
7594 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307595
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307596 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7597 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
7598 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307599 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
7600 hdd_device_modetoString(pAdapter->device_mode),
7601 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007602
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307603 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7604 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307605 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007606 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307607 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007608 }
7609
Agarwal Ashish51325b52014-06-16 16:50:49 +05307610 if (vos_max_concurrent_connections_reached()) {
7611 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7612 return -EINVAL;
7613 }
7614
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307615 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007616 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007617 )
7618 {
7619 beacon_data_t *old,*new;
7620
7621 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307622
Jeff Johnson295189b2012-06-20 16:38:30 -07007623 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307624 {
7625 hddLog(VOS_TRACE_LEVEL_WARN,
7626 FL("already beacon info added to session(%d)"),
7627 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007628 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007630
7631 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7632
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307633 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07007634 {
7635 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007636 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007637 return -EINVAL;
7638 }
7639
7640 pAdapter->sessionCtx.ap.beacon = new;
7641
7642 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7643 }
7644
7645 EXIT();
7646 return status;
7647}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307648
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307649static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
7650 struct net_device *dev,
7651 struct beacon_parameters *params)
7652{
7653 int ret;
7654
7655 vos_ssr_protect(__func__);
7656 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
7657 vos_ssr_unprotect(__func__);
7658
7659 return ret;
7660}
7661
7662static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007663 struct net_device *dev,
7664 struct beacon_parameters *params)
7665{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307666 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307667 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7668 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307669 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007670
7671 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307672
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307673 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7674 TRACE_CODE_HDD_CFG80211_SET_BEACON,
7675 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
7676 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7677 __func__, hdd_device_modetoString(pAdapter->device_mode),
7678 pAdapter->device_mode);
7679
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307680 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7681 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307682 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007683 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307684 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007685 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307686
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307687 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007688 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307689 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007690 {
7691 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307692
Jeff Johnson295189b2012-06-20 16:38:30 -07007693 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307694
Jeff Johnson295189b2012-06-20 16:38:30 -07007695 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307696 {
7697 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7698 FL("session(%d) old and new heads points to NULL"),
7699 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007700 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007702
7703 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7704
7705 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307706 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007707 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007708 return -EINVAL;
7709 }
7710
7711 pAdapter->sessionCtx.ap.beacon = new;
7712
7713 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7714 }
7715
7716 EXIT();
7717 return status;
7718}
7719
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307720static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
7721 struct net_device *dev,
7722 struct beacon_parameters *params)
7723{
7724 int ret;
7725
7726 vos_ssr_protect(__func__);
7727 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
7728 vos_ssr_unprotect(__func__);
7729
7730 return ret;
7731}
7732
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007733#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7734
7735#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307736static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007737 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007738#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307739static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007740 struct net_device *dev)
7741#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007742{
7743 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07007744 hdd_context_t *pHddCtx = NULL;
7745 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307746 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307747 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007748
7749 ENTER();
7750
7751 if (NULL == pAdapter)
7752 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307753 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007754 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007755 return -ENODEV;
7756 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007757
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307758 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7759 TRACE_CODE_HDD_CFG80211_STOP_AP,
7760 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307761 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7762 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307763 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007764 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307765 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07007766 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007767
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007768 pScanInfo = &pHddCtx->scan_info;
7769
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307770 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7771 __func__, hdd_device_modetoString(pAdapter->device_mode),
7772 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007773
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307774 ret = wlan_hdd_scan_abort(pAdapter);
7775
Girish Gowli4bf7a632014-06-12 13:42:11 +05307776 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07007777 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307778 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7779 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307780
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307781 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07007782 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7784 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08007785
Jeff Johnsone7245742012-09-05 17:12:55 -07007786 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307787 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07007788 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307789 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07007790 }
7791
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05307792 /* Delete all associated STAs before stopping AP/P2P GO */
7793 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05307794 hdd_hostapd_stop(dev);
7795
Jeff Johnson295189b2012-06-20 16:38:30 -07007796 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007797 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007798 )
7799 {
7800 beacon_data_t *old;
7801
7802 old = pAdapter->sessionCtx.ap.beacon;
7803
7804 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307805 {
7806 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7807 FL("session(%d) beacon data points to NULL"),
7808 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007809 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307810 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007811
Jeff Johnson295189b2012-06-20 16:38:30 -07007812 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007813
7814 mutex_lock(&pHddCtx->sap_lock);
7815 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7816 {
Jeff Johnson4416a782013-03-25 14:17:50 -07007817 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007818 {
7819 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7820
7821 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
7822
7823 if (!VOS_IS_STATUS_SUCCESS(status))
7824 {
7825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007826 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007827 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307828 }
7829 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007830 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307831 /* BSS stopped, clear the active sessions for this device mode */
7832 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 }
7834 mutex_unlock(&pHddCtx->sap_lock);
7835
7836 if(status != VOS_STATUS_SUCCESS)
7837 {
7838 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007839 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007840 return -EINVAL;
7841 }
7842
Jeff Johnson4416a782013-03-25 14:17:50 -07007843 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007844 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
7845 ==eHAL_STATUS_FAILURE)
7846 {
7847 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007848 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007849 }
7850
Jeff Johnson4416a782013-03-25 14:17:50 -07007851 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007852 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7853 eANI_BOOLEAN_FALSE) )
7854 {
7855 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007856 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007857 }
7858
7859 // Reset WNI_CFG_PROBE_RSP Flags
7860 wlan_hdd_reset_prob_rspies(pAdapter);
7861
7862 pAdapter->sessionCtx.ap.beacon = NULL;
7863 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007864#ifdef WLAN_FEATURE_P2P_DEBUG
7865 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
7866 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
7867 {
7868 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
7869 "GO got removed");
7870 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
7871 }
7872#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 }
7874 EXIT();
7875 return status;
7876}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007877
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307878#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7879static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
7880 struct net_device *dev)
7881{
7882 int ret;
7883
7884 vos_ssr_protect(__func__);
7885 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
7886 vos_ssr_unprotect(__func__);
7887
7888 return ret;
7889}
7890#else
7891static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
7892 struct net_device *dev)
7893{
7894 int ret;
7895
7896 vos_ssr_protect(__func__);
7897 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
7898 vos_ssr_unprotect(__func__);
7899
7900 return ret;
7901}
7902#endif
7903
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007904#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
7905
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307906static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307907 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007908 struct cfg80211_ap_settings *params)
7909{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307910 hdd_adapter_t *pAdapter;
7911 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307912 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007913
7914 ENTER();
7915
Girish Gowlib143d7a2015-02-18 19:39:55 +05307916 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007917 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307918 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05307919 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307920 return -ENODEV;
7921 }
7922
7923 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7924 if (NULL == pAdapter)
7925 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307926 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307927 "%s: HDD adapter is Null", __func__);
7928 return -ENODEV;
7929 }
7930
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307931 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7932 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
7933 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307934 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
7935 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307936 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307937 "%s: HDD adapter magic is invalid", __func__);
7938 return -ENODEV;
7939 }
7940
7941 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307942 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307943 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307944 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307945 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307946 }
7947
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307948 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
7949 __func__, hdd_device_modetoString(pAdapter->device_mode),
7950 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307951
7952 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007953 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007954 )
7955 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307956 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007957
7958 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307959
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007960 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307961 {
7962 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7963 FL("already beacon info added to session(%d)"),
7964 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007965 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307966 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007967
Girish Gowlib143d7a2015-02-18 19:39:55 +05307968#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7969 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7970 &new,
7971 &params->beacon);
7972#else
7973 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7974 &new,
7975 &params->beacon,
7976 params->dtim_period);
7977#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007978
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307979 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007980 {
7981 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307982 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007983 return -EINVAL;
7984 }
7985 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08007986#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07007987 wlan_hdd_cfg80211_set_channel(wiphy, dev,
7988#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
7989 params->channel, params->channel_type);
7990#else
7991 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
7992#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08007993#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007994 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307995 params->ssid_len, params->hidden_ssid,
7996 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007997 }
7998
7999 EXIT();
8000 return status;
8001}
8002
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308003static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
8004 struct net_device *dev,
8005 struct cfg80211_ap_settings *params)
8006{
8007 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008008
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308009 vos_ssr_protect(__func__);
8010 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
8011 vos_ssr_unprotect(__func__);
8012
8013 return ret;
8014}
8015
8016static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008017 struct net_device *dev,
8018 struct cfg80211_beacon_data *params)
8019{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308020 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308021 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308022 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008023
8024 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308025
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308026 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8027 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
8028 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08008029 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008030 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308031
8032 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8033 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308034 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07008035 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308036 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07008037 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008038
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308039 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008040 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308041 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008042 {
8043 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308044
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008045 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308046
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008047 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308048 {
8049 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8050 FL("session(%d) beacon data points to NULL"),
8051 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008052 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308053 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008054
8055 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
8056
8057 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308058 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008059 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008060 return -EINVAL;
8061 }
8062
8063 pAdapter->sessionCtx.ap.beacon = new;
8064
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05308065 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
8066 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008067 }
8068
8069 EXIT();
8070 return status;
8071}
8072
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308073static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
8074 struct net_device *dev,
8075 struct cfg80211_beacon_data *params)
8076{
8077 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008078
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308079 vos_ssr_protect(__func__);
8080 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
8081 vos_ssr_unprotect(__func__);
8082
8083 return ret;
8084}
8085
8086#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008087
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308088static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008089 struct net_device *dev,
8090 struct bss_parameters *params)
8091{
8092 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308093 hdd_context_t *pHddCtx;
8094 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008095
8096 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308097
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308098 if (NULL == pAdapter)
8099 {
8100 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8101 "%s: HDD adapter is Null", __func__);
8102 return -ENODEV;
8103 }
8104 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308105 ret = wlan_hdd_validate_context(pHddCtx);
8106 if (0 != ret)
8107 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308108 return ret;
8109 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308110 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8111 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
8112 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308113 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8114 __func__, hdd_device_modetoString(pAdapter->device_mode),
8115 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008116
8117 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008118 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308119 )
Jeff Johnson295189b2012-06-20 16:38:30 -07008120 {
8121 /* ap_isolate == -1 means that in change bss, upper layer doesn't
8122 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308123 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07008124 {
8125 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308126 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008127 }
8128
8129 EXIT();
8130 return 0;
8131}
8132
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308133static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
8134 struct net_device *dev,
8135 struct bss_parameters *params)
8136{
8137 int ret;
8138
8139 vos_ssr_protect(__func__);
8140 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
8141 vos_ssr_unprotect(__func__);
8142
8143 return ret;
8144}
Kiet Lam10841362013-11-01 11:36:50 +05308145/* FUNCTION: wlan_hdd_change_country_code_cd
8146* to wait for contry code completion
8147*/
8148void* wlan_hdd_change_country_code_cb(void *pAdapter)
8149{
8150 hdd_adapter_t *call_back_pAdapter = pAdapter;
8151 complete(&call_back_pAdapter->change_country_code);
8152 return NULL;
8153}
8154
Jeff Johnson295189b2012-06-20 16:38:30 -07008155/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308156 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07008157 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
8158 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308159int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008160 struct net_device *ndev,
8161 enum nl80211_iftype type,
8162 u32 *flags,
8163 struct vif_params *params
8164 )
8165{
8166 struct wireless_dev *wdev;
8167 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008168 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07008169 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008170 tCsrRoamProfile *pRoamProfile = NULL;
8171 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308172 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008173 eMib_dot11DesiredBssType connectedBssType;
8174 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308175 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008176
8177 ENTER();
8178
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308179 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008180 {
8181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8182 "%s: Adapter context is null", __func__);
8183 return VOS_STATUS_E_FAILURE;
8184 }
8185
8186 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8187 if (!pHddCtx)
8188 {
8189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8190 "%s: HDD context is null", __func__);
8191 return VOS_STATUS_E_FAILURE;
8192 }
8193
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308194 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8195 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
8196 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308197 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308198 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07008199 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308200 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 }
8202
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308203 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8204 __func__, hdd_device_modetoString(pAdapter->device_mode),
8205 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008206
Agarwal Ashish51325b52014-06-16 16:50:49 +05308207 if (vos_max_concurrent_connections_reached()) {
8208 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
8209 return -EINVAL;
8210 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308211 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07008212 wdev = ndev->ieee80211_ptr;
8213
8214#ifdef WLAN_BTAMP_FEATURE
8215 if((NL80211_IFTYPE_P2P_CLIENT == type)||
8216 (NL80211_IFTYPE_ADHOC == type)||
8217 (NL80211_IFTYPE_AP == type)||
8218 (NL80211_IFTYPE_P2P_GO == type))
8219 {
8220 pHddCtx->isAmpAllowed = VOS_FALSE;
8221 // stop AMP traffic
8222 status = WLANBAP_StopAmp();
8223 if(VOS_STATUS_SUCCESS != status )
8224 {
8225 pHddCtx->isAmpAllowed = VOS_TRUE;
8226 hddLog(VOS_TRACE_LEVEL_FATAL,
8227 "%s: Failed to stop AMP", __func__);
8228 return -EINVAL;
8229 }
8230 }
8231#endif //WLAN_BTAMP_FEATURE
8232 /* Reset the current device mode bit mask*/
8233 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
8234
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05308235 /* Notify Mode change in case of concurrency.
8236 * Below function invokes TDLS teardown Functionality Since TDLS is
8237 * not Supported in case of concurrency i.e Once P2P session
8238 * is detected disable offchannel and teardown TDLS links
8239 */
8240 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
8241
Jeff Johnson295189b2012-06-20 16:38:30 -07008242 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008243 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07008244 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07008245 )
8246 {
8247 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008248 if (!pWextState)
8249 {
8250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8251 "%s: pWextState is null", __func__);
8252 return VOS_STATUS_E_FAILURE;
8253 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008254 pRoamProfile = &pWextState->roamProfile;
8255 LastBSSType = pRoamProfile->BSSType;
8256
8257 switch (type)
8258 {
8259 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008260 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008261 hddLog(VOS_TRACE_LEVEL_INFO,
8262 "%s: setting interface Type to INFRASTRUCTURE", __func__);
8263 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07008264#ifdef WLAN_FEATURE_11AC
8265 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
8266 {
8267 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
8268 }
8269#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308270 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07008271 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008272 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008273 //Check for sub-string p2p to confirm its a p2p interface
8274 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308275 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +05308276#ifdef FEATURE_WLAN_TDLS
8277 mutex_lock(&pHddCtx->tdls_lock);
8278 wlan_hdd_tdls_exit(pAdapter, TRUE);
8279 mutex_unlock(&pHddCtx->tdls_lock);
8280#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008281 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8282 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8283 }
8284 else
8285 {
8286 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008287 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008288 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008289 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05308290
Jeff Johnson295189b2012-06-20 16:38:30 -07008291 case NL80211_IFTYPE_ADHOC:
8292 hddLog(VOS_TRACE_LEVEL_INFO,
8293 "%s: setting interface Type to ADHOC", __func__);
8294 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
8295 pRoamProfile->phyMode =
8296 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07008297 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008298 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +05308299 hdd_set_ibss_ops( pAdapter );
8300 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +05308301
8302 status = hdd_sta_id_hash_attach(pAdapter);
8303 if (VOS_STATUS_SUCCESS != status) {
8304 hddLog(VOS_TRACE_LEVEL_ERROR,
8305 FL("Failed to initialize hash for IBSS"));
8306 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008307 break;
8308
8309 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008310 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008311 {
8312 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8313 "%s: setting interface Type to %s", __func__,
8314 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
8315
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008316 //Cancel any remain on channel for GO mode
8317 if (NL80211_IFTYPE_P2P_GO == type)
8318 {
8319 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
8320 }
Mohit Khanna0f232092012-09-11 14:46:08 -07008321 if (NL80211_IFTYPE_AP == type)
8322 {
8323 /* As Loading WLAN Driver one interface being created for p2p device
8324 * address. This will take one HW STA and the max number of clients
8325 * that can connect to softAP will be reduced by one. so while changing
8326 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
8327 * interface as it is not required in SoftAP mode.
8328 */
8329
8330 // Get P2P Adapter
8331 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
8332
8333 if (pP2pAdapter)
8334 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05308335 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +05308336 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07008337 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
8338 }
8339 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05308340 //Disable IMPS & BMPS for SAP/GO
8341 if(VOS_STATUS_E_FAILURE ==
8342 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
8343 {
8344 //Fail to Exit BMPS
8345 VOS_ASSERT(0);
8346 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05308347
8348 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
8349
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308350#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07008351
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308352 /* A Mutex Lock is introduced while changing the mode to
8353 * protect the concurrent access for the Adapters by TDLS
8354 * module.
8355 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308356 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308357#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008358 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +05308359 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008360 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07008361 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8362 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308363#ifdef FEATURE_WLAN_TDLS
8364 mutex_unlock(&pHddCtx->tdls_lock);
8365#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008366 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
8367 (pConfig->apRandomBssidEnabled))
8368 {
8369 /* To meet Android requirements create a randomized
8370 MAC address of the form 02:1A:11:Fx:xx:xx */
8371 get_random_bytes(&ndev->dev_addr[3], 3);
8372 ndev->dev_addr[0] = 0x02;
8373 ndev->dev_addr[1] = 0x1A;
8374 ndev->dev_addr[2] = 0x11;
8375 ndev->dev_addr[3] |= 0xF0;
8376 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
8377 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08008378 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
8379 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008380 }
8381
Jeff Johnson295189b2012-06-20 16:38:30 -07008382 hdd_set_ap_ops( pAdapter->dev );
8383
Kiet Lam10841362013-11-01 11:36:50 +05308384 /* This is for only SAP mode where users can
8385 * control country through ini.
8386 * P2P GO follows station country code
8387 * acquired during the STA scanning. */
8388 if((NL80211_IFTYPE_AP == type) &&
8389 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
8390 {
8391 int status = 0;
8392 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
8393 "%s: setting country code from INI ", __func__);
8394 init_completion(&pAdapter->change_country_code);
8395 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
8396 (void *)(tSmeChangeCountryCallback)
8397 wlan_hdd_change_country_code_cb,
8398 pConfig->apCntryCode, pAdapter,
8399 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05308400 eSIR_FALSE,
8401 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05308402 if (eHAL_STATUS_SUCCESS == status)
8403 {
8404 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308405 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05308406 &pAdapter->change_country_code,
8407 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308408 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05308409 {
8410 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308411 FL("SME Timed out while setting country code %ld"),
8412 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08008413
8414 if (pHddCtx->isLogpInProgress)
8415 {
8416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8417 "%s: LOGP in Progress. Ignore!!!", __func__);
8418 return -EAGAIN;
8419 }
Kiet Lam10841362013-11-01 11:36:50 +05308420 }
8421 }
8422 else
8423 {
8424 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008425 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05308426 return -EINVAL;
8427 }
8428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008429 status = hdd_init_ap_mode(pAdapter);
8430 if(status != VOS_STATUS_SUCCESS)
8431 {
8432 hddLog(VOS_TRACE_LEVEL_FATAL,
8433 "%s: Error initializing the ap mode", __func__);
8434 return -EINVAL;
8435 }
8436 hdd_set_conparam(1);
8437
Nirav Shah7e3c8132015-06-22 23:51:42 +05308438 status = hdd_sta_id_hash_attach(pAdapter);
8439 if (VOS_STATUS_SUCCESS != status)
8440 {
8441 hddLog(VOS_TRACE_LEVEL_ERROR,
8442 FL("Failed to initialize hash for AP"));
8443 return -EINVAL;
8444 }
8445
Jeff Johnson295189b2012-06-20 16:38:30 -07008446 /*interface type changed update in wiphy structure*/
8447 if(wdev)
8448 {
8449 wdev->iftype = type;
8450 pHddCtx->change_iface = type;
8451 }
8452 else
8453 {
8454 hddLog(VOS_TRACE_LEVEL_ERROR,
8455 "%s: ERROR !!!! Wireless dev is NULL", __func__);
8456 return -EINVAL;
8457 }
8458 goto done;
8459 }
8460
8461 default:
8462 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8463 __func__);
8464 return -EOPNOTSUPP;
8465 }
8466 }
8467 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008468 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07008469 )
8470 {
8471 switch(type)
8472 {
8473 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008474 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008475 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05308476
8477 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308478#ifdef FEATURE_WLAN_TDLS
8479
8480 /* A Mutex Lock is introduced while changing the mode to
8481 * protect the concurrent access for the Adapters by TDLS
8482 * module.
8483 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308484 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308485#endif
c_hpothu002231a2015-02-05 14:58:51 +05308486 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008487 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008488 //Check for sub-string p2p to confirm its a p2p interface
8489 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008490 {
8491 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8492 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8493 }
8494 else
8495 {
8496 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008497 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008499 hdd_set_conparam(0);
8500 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008501 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
8502 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308503#ifdef FEATURE_WLAN_TDLS
8504 mutex_unlock(&pHddCtx->tdls_lock);
8505#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05308506 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008507 if( VOS_STATUS_SUCCESS != status )
8508 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07008509 /* In case of JB, for P2P-GO, only change interface will be called,
8510 * This is the right place to enable back bmps_imps()
8511 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308512 if (pHddCtx->hdd_wlan_suspended)
8513 {
8514 hdd_set_pwrparams(pHddCtx);
8515 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008516 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008517 goto done;
8518 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008519 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008520 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008521 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8522 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 goto done;
8524 default:
8525 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8526 __func__);
8527 return -EOPNOTSUPP;
8528
8529 }
8530
8531 }
8532 else
8533 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308534 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
8535 __func__, hdd_device_modetoString(pAdapter->device_mode),
8536 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008537 return -EOPNOTSUPP;
8538 }
8539
8540
8541 if(pRoamProfile)
8542 {
8543 if ( LastBSSType != pRoamProfile->BSSType )
8544 {
8545 /*interface type changed update in wiphy structure*/
8546 wdev->iftype = type;
8547
8548 /*the BSS mode changed, We need to issue disconnect
8549 if connected or in IBSS disconnect state*/
8550 if ( hdd_connGetConnectedBssType(
8551 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
8552 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
8553 {
8554 /*need to issue a disconnect to CSR.*/
8555 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8556 if( eHAL_STATUS_SUCCESS ==
8557 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8558 pAdapter->sessionId,
8559 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
8560 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308561 ret = wait_for_completion_interruptible_timeout(
8562 &pAdapter->disconnect_comp_var,
8563 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8564 if (ret <= 0)
8565 {
8566 hddLog(VOS_TRACE_LEVEL_ERROR,
8567 FL("wait on disconnect_comp_var failed %ld"), ret);
8568 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008569 }
8570 }
8571 }
8572 }
8573
8574done:
8575 /*set bitmask based on updated value*/
8576 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07008577
8578 /* Only STA mode support TM now
8579 * all other mode, TM feature should be disabled */
8580 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
8581 (~VOS_STA & pHddCtx->concurrency_mode) )
8582 {
8583 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
8584 }
8585
Jeff Johnson295189b2012-06-20 16:38:30 -07008586#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308587 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05308588 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07008589 {
8590 //we are ok to do AMP
8591 pHddCtx->isAmpAllowed = VOS_TRUE;
8592 }
8593#endif //WLAN_BTAMP_FEATURE
8594 EXIT();
8595 return 0;
8596}
8597
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308598/*
8599 * FUNCTION: wlan_hdd_cfg80211_change_iface
8600 * wrapper function to protect the actual implementation from SSR.
8601 */
8602int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
8603 struct net_device *ndev,
8604 enum nl80211_iftype type,
8605 u32 *flags,
8606 struct vif_params *params
8607 )
8608{
8609 int ret;
8610
8611 vos_ssr_protect(__func__);
8612 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
8613 vos_ssr_unprotect(__func__);
8614
8615 return ret;
8616}
8617
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008618#ifdef FEATURE_WLAN_TDLS
8619static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308620 struct net_device *dev,
8621#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
8622 const u8 *mac,
8623#else
8624 u8 *mac,
8625#endif
8626 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008627{
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008628 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008629 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308630 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308631 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308632 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308633 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008634
8635 ENTER();
8636
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308637 if (!dev) {
8638 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
8639 return -EINVAL;
8640 }
8641
8642 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8643 if (!pAdapter) {
8644 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
8645 return -EINVAL;
8646 }
8647
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308648 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008649 {
8650 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8651 "Invalid arguments");
8652 return -EINVAL;
8653 }
Hoonki Lee27511902013-03-14 18:19:06 -07008654
8655 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
8656 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
8657 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308658 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -07008659 "%s: TDLS mode is disabled OR not enabled in FW."
8660 MAC_ADDRESS_STR " Request declined.",
8661 __func__, MAC_ADDR_ARRAY(mac));
8662 return -ENOTSUPP;
8663 }
8664
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008665 if (pHddCtx->isLogpInProgress)
8666 {
8667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8668 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05308669 wlan_hdd_tdls_set_link_status(pAdapter,
8670 mac,
8671 eTDLS_LINK_IDLE,
8672 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008673 return -EBUSY;
8674 }
8675
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308676 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05308677 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008678
8679 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308680 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008681 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
8682 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308683 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008684 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008685 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308686 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008687
8688 /* in add station, we accept existing valid staId if there is */
8689 if ((0 == update) &&
8690 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
8691 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008692 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308693 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008694 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008695 " link_status %d. staId %d. add station ignored.",
8696 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
8697 return 0;
8698 }
8699 /* in change station, we accept only when staId is valid */
8700 if ((1 == update) &&
8701 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
8702 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
8703 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308704 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008705 "%s: " MAC_ADDRESS_STR
8706 " link status %d. staId %d. change station %s.",
8707 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
8708 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
8709 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008710 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008711
8712 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05308713 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008714 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008715 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8716 "%s: " MAC_ADDRESS_STR
8717 " TDLS setup is ongoing. Request declined.",
8718 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07008719 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008720 }
8721
8722 /* first to check if we reached to maximum supported TDLS peer.
8723 TODO: for now, return -EPERM looks working fine,
8724 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308725 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
8726 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008727 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008728 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8729 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308730 " TDLS Max peer already connected. Request declined."
8731 " Num of peers (%d), Max allowed (%d).",
8732 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
8733 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008734 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008735 }
8736 else
8737 {
8738 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308739 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008740 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008741 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008742 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8743 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
8744 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008745 return -EPERM;
8746 }
8747 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008748 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05308749 wlan_hdd_tdls_set_link_status(pAdapter,
8750 mac,
8751 eTDLS_LINK_CONNECTING,
8752 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008753
Jeff Johnsond75fe012013-04-06 10:53:06 -07008754 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308755 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008756 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008758 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008759 if(StaParams->htcap_present)
8760 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008762 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008764 "ht_capa->extended_capabilities: %0x",
8765 StaParams->HTCap.extendedHtCapInfo);
8766 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008768 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008770 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008771 if(StaParams->vhtcap_present)
8772 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308773 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008774 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
8775 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
8776 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
8777 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008778 {
8779 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008780 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008781 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008783 "[%d]: %x ", i, StaParams->supported_rates[i]);
8784 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07008785 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308786 else if ((1 == update) && (NULL == StaParams))
8787 {
8788 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8789 "%s : update is true, but staParams is NULL. Error!", __func__);
8790 return -EPERM;
8791 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008792
8793 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
8794
8795 if (!update)
8796 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308797 /*Before adding sta make sure that device exited from BMPS*/
8798 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8799 {
8800 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8801 "%s: Adding tdls peer sta. Disable BMPS", __func__);
8802 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8803 if (status != VOS_STATUS_SUCCESS) {
8804 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
8805 }
8806 }
8807
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308808 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008809 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308810 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308811 hddLog(VOS_TRACE_LEVEL_ERROR,
8812 FL("Failed to add TDLS peer STA. Enable Bmps"));
8813 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308814 return -EPERM;
8815 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008816 }
8817 else
8818 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308819 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008820 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308821 if (ret != eHAL_STATUS_SUCCESS) {
8822 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
8823 return -EPERM;
8824 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008825 }
8826
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308827 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008828 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
8829
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308830 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008831 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308833 "%s: timeout waiting for tdls add station indication %ld",
8834 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008835 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008836 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308837
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008838 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
8839 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008841 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008842 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008843 }
8844
8845 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008846
8847error:
Atul Mittal115287b2014-07-08 13:26:33 +05308848 wlan_hdd_tdls_set_link_status(pAdapter,
8849 mac,
8850 eTDLS_LINK_IDLE,
8851 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008852 return -EPERM;
8853
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008854}
8855#endif
8856
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308857static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008858 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308859#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
8860 const u8 *mac,
8861#else
Jeff Johnson295189b2012-06-20 16:38:30 -07008862 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308863#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008864 struct station_parameters *params)
8865{
8866 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308867 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308868 hdd_context_t *pHddCtx;
8869 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008870 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308871 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008872#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008873 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008874 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308875 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008876#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008877
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308878 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308879
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308880 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308881 if ((NULL == pAdapter))
8882 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308884 "invalid adapter ");
8885 return -EINVAL;
8886 }
8887
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308888 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8889 TRACE_CODE_HDD_CHANGE_STATION,
8890 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05308891 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308892
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308893 ret = wlan_hdd_validate_context(pHddCtx);
8894 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +05308895 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308896 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308897 }
8898
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308899 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8900
8901 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008902 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8904 "invalid HDD station context");
8905 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008907 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
8908
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008909 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
8910 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07008911 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008912 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07008913 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308914 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008915 WLANTL_STA_AUTHENTICATED);
8916
Gopichand Nakkala29149562013-05-10 21:43:41 +05308917 if (status != VOS_STATUS_SUCCESS)
8918 {
8919 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8920 "%s: Not able to change TL state to AUTHENTICATED", __func__);
8921 return -EINVAL;
8922 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008923 }
8924 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07008925 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
8926 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308927#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008928 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
8929 StaParams.capability = params->capability;
8930 StaParams.uapsd_queues = params->uapsd_queues;
8931 StaParams.max_sp = params->max_sp;
8932
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308933 /* Convert (first channel , number of channels) tuple to
8934 * the total list of channels. This goes with the assumption
8935 * that if the first channel is < 14, then the next channels
8936 * are an incremental of 1 else an incremental of 4 till the number
8937 * of channels.
8938 */
8939 if (0 != params->supported_channels_len) {
8940 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
8941 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
8942 {
8943 int wifi_chan_index;
8944 StaParams.supported_channels[j] = params->supported_channels[i];
8945 wifi_chan_index =
8946 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
8947 no_of_channels = params->supported_channels[i+1];
8948 for(k=1; k <= no_of_channels; k++)
8949 {
8950 StaParams.supported_channels[j+1] =
8951 StaParams.supported_channels[j] + wifi_chan_index;
8952 j+=1;
8953 }
8954 }
8955 StaParams.supported_channels_len = j;
8956 }
8957 vos_mem_copy(StaParams.supported_oper_classes,
8958 params->supported_oper_classes,
8959 params->supported_oper_classes_len);
8960 StaParams.supported_oper_classes_len =
8961 params->supported_oper_classes_len;
8962
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008963 if (0 != params->ext_capab_len)
8964 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
8965 sizeof(StaParams.extn_capability));
8966
8967 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008968 {
8969 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008970 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008971 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008972
8973 StaParams.supported_rates_len = params->supported_rates_len;
8974
8975 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
8976 * The supported_rates array , for all the structures propogating till Add Sta
8977 * to the firmware has to be modified , if the supplicant (ieee80211) is
8978 * modified to send more rates.
8979 */
8980
8981 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
8982 */
8983 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
8984 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
8985
8986 if (0 != StaParams.supported_rates_len) {
8987 int i = 0;
8988 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
8989 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008990 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008991 "Supported Rates with Length %d", StaParams.supported_rates_len);
8992 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008993 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008994 "[%d]: %0x", i, StaParams.supported_rates[i]);
8995 }
8996
8997 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008998 {
8999 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009000 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07009001 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009002
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009003 if (0 != params->ext_capab_len ) {
9004 /*Define A Macro : TODO Sunil*/
9005 if ((1<<4) & StaParams.extn_capability[3]) {
9006 isBufSta = 1;
9007 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05309008 /* TDLS Channel Switching Support */
9009 if ((1<<6) & StaParams.extn_capability[3]) {
9010 isOffChannelSupported = 1;
9011 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009012 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05309013 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
9014 &StaParams, isBufSta,
9015 isOffChannelSupported);
9016
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309017 if (VOS_STATUS_SUCCESS != status) {
9018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9019 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
9020 return -EINVAL;
9021 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009022 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
9023
9024 if (VOS_STATUS_SUCCESS != status) {
9025 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9026 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
9027 return -EINVAL;
9028 }
9029 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07009030#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05309031 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009032 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009033 return status;
9034}
9035
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309036#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
9037static int wlan_hdd_change_station(struct wiphy *wiphy,
9038 struct net_device *dev,
9039 const u8 *mac,
9040 struct station_parameters *params)
9041#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309042static int wlan_hdd_change_station(struct wiphy *wiphy,
9043 struct net_device *dev,
9044 u8 *mac,
9045 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309046#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309047{
9048 int ret;
9049
9050 vos_ssr_protect(__func__);
9051 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
9052 vos_ssr_unprotect(__func__);
9053
9054 return ret;
9055}
9056
Jeff Johnson295189b2012-06-20 16:38:30 -07009057/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309058 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009059 * This function is used to initialize the key information
9060 */
9061#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309062static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009063 struct net_device *ndev,
9064 u8 key_index, bool pairwise,
9065 const u8 *mac_addr,
9066 struct key_params *params
9067 )
9068#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309069static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009070 struct net_device *ndev,
9071 u8 key_index, const u8 *mac_addr,
9072 struct key_params *params
9073 )
9074#endif
9075{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009076 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07009077 tCsrRoamSetKey setKey;
9078 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309079 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009080 v_U32_t roamId= 0xFF;
9081 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009082 hdd_hostapd_state_t *pHostapdState;
9083 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009084 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309085 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009086
9087 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309088
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309089 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9090 TRACE_CODE_HDD_CFG80211_ADD_KEY,
9091 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309092 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9093 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309094 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009095 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309096 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009097 }
9098
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309099 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9100 __func__, hdd_device_modetoString(pAdapter->device_mode),
9101 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009102
9103 if (CSR_MAX_NUM_KEY <= key_index)
9104 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009105 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009106 key_index);
9107
9108 return -EINVAL;
9109 }
9110
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009111 if (CSR_MAX_KEY_LEN < params->key_len)
9112 {
9113 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
9114 params->key_len);
9115
9116 return -EINVAL;
9117 }
9118
9119 hddLog(VOS_TRACE_LEVEL_INFO,
9120 "%s: called with key index = %d & key length %d",
9121 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07009122
9123 /*extract key idx, key len and key*/
9124 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9125 setKey.keyId = key_index;
9126 setKey.keyLength = params->key_len;
9127 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
9128
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009129 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07009130 {
9131 case WLAN_CIPHER_SUITE_WEP40:
9132 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
9133 break;
9134
9135 case WLAN_CIPHER_SUITE_WEP104:
9136 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
9137 break;
9138
9139 case WLAN_CIPHER_SUITE_TKIP:
9140 {
9141 u8 *pKey = &setKey.Key[0];
9142 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
9143
9144 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
9145
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009146 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07009147
9148 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009149 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07009150 |--------------|----------|----------|
9151 <---16bytes---><--8bytes--><--8bytes-->
9152
9153 */
9154 /*Sme expects the 32 bytes key to be in the below order
9155
9156 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009157 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07009158 |--------------|----------|----------|
9159 <---16bytes---><--8bytes--><--8bytes-->
9160 */
9161 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009162 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07009163
9164 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009165 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009166
9167 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009168 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009169
9170
9171 break;
9172 }
9173
9174 case WLAN_CIPHER_SUITE_CCMP:
9175 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
9176 break;
9177
9178#ifdef FEATURE_WLAN_WAPI
9179 case WLAN_CIPHER_SUITE_SMS4:
9180 {
9181 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9182 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
9183 params->key, params->key_len);
9184 return 0;
9185 }
9186#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009187
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009188#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009189 case WLAN_CIPHER_SUITE_KRK:
9190 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
9191 break;
9192#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009193
9194#ifdef WLAN_FEATURE_11W
9195 case WLAN_CIPHER_SUITE_AES_CMAC:
9196 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07009197 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07009198#endif
9199
Jeff Johnson295189b2012-06-20 16:38:30 -07009200 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009201 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07009202 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309203 status = -EOPNOTSUPP;
9204 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009205 }
9206
9207 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
9208 __func__, setKey.encType);
9209
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009210 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07009211#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9212 (!pairwise)
9213#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009214 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07009215#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009216 )
9217 {
9218 /* set group key*/
9219 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9220 "%s- %d: setting Broadcast key",
9221 __func__, __LINE__);
9222 setKey.keyDirection = eSIR_RX_ONLY;
9223 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9224 }
9225 else
9226 {
9227 /* set pairwise key*/
9228 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9229 "%s- %d: setting pairwise key",
9230 __func__, __LINE__);
9231 setKey.keyDirection = eSIR_TX_RX;
9232 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9233 }
9234 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
9235 {
9236 setKey.keyDirection = eSIR_TX_RX;
9237 /*Set the group key*/
9238 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9239 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009240
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009241 if ( 0 != status )
9242 {
9243 hddLog(VOS_TRACE_LEVEL_ERROR,
9244 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309245 status = -EINVAL;
9246 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009247 }
9248 /*Save the keys here and call sme_RoamSetKey for setting
9249 the PTK after peer joins the IBSS network*/
9250 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
9251 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309252 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009253 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05309254 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
9255 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
9256 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009257 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009258 if( pHostapdState->bssState == BSS_START )
9259 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009260 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9261 vos_status = wlan_hdd_check_ula_done(pAdapter);
9262
9263 if ( vos_status != VOS_STATUS_SUCCESS )
9264 {
9265 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9266 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9267 __LINE__, vos_status );
9268
9269 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9270
9271 status = -EINVAL;
9272 goto end;
9273 }
9274
Jeff Johnson295189b2012-06-20 16:38:30 -07009275 status = WLANSAP_SetKeySta( pVosContext, &setKey);
9276
9277 if ( status != eHAL_STATUS_SUCCESS )
9278 {
9279 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9280 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9281 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309282 status = -EINVAL;
9283 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009284 }
9285 }
9286
9287 /* Saving WEP keys */
9288 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
9289 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
9290 {
9291 //Save the wep key in ap context. Issue setkey after the BSS is started.
9292 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9293 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
9294 }
9295 else
9296 {
9297 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009298 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009299 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
9300 }
9301 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009302 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9303 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009304 {
9305 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9306 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9307
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309308#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9309 if (!pairwise)
9310#else
9311 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9312#endif
9313 {
9314 /* set group key*/
9315 if (pHddStaCtx->roam_info.deferKeyComplete)
9316 {
9317 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9318 "%s- %d: Perform Set key Complete",
9319 __func__, __LINE__);
9320 hdd_PerformRoamSetKeyComplete(pAdapter);
9321 }
9322 }
9323
Jeff Johnson295189b2012-06-20 16:38:30 -07009324 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
9325
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08009326 pWextState->roamProfile.Keys.defaultIndex = key_index;
9327
9328
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009329 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009330 params->key, params->key_len);
9331
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309332
Jeff Johnson295189b2012-06-20 16:38:30 -07009333 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9334
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309335 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009336 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309337 __func__, setKey.peerMac[0], setKey.peerMac[1],
9338 setKey.peerMac[2], setKey.peerMac[3],
9339 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009340 setKey.keyDirection);
9341
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009342 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +05309343
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009344 if ( vos_status != VOS_STATUS_SUCCESS )
9345 {
9346 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009347 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9348 __LINE__, vos_status );
9349
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009350 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009351
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009352 status = -EINVAL;
9353 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009354
9355 }
9356
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009357#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309358 /* The supplicant may attempt to set the PTK once pre-authentication
9359 is done. Save the key in the UMAC and include it in the ADD BSS
9360 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009361 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309362 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009363 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309364 hddLog(VOS_TRACE_LEVEL_INFO_MED,
9365 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309366 status = 0;
9367 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309368 }
9369 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
9370 {
9371 hddLog(VOS_TRACE_LEVEL_ERROR,
9372 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309373 status = -EINVAL;
9374 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009375 }
9376#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07009377
9378 /* issue set key request to SME*/
9379 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9380 pAdapter->sessionId, &setKey, &roamId );
9381
9382 if ( 0 != status )
9383 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309384 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009385 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
9386 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309387 status = -EINVAL;
9388 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009389 }
9390
9391
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309392 /* in case of IBSS as there was no information available about WEP keys during
9393 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07009394 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309395 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
9396 !( ( IW_AUTH_KEY_MGMT_802_1X
9397 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07009398 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
9399 )
9400 &&
9401 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
9402 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
9403 )
9404 )
9405 {
9406 setKey.keyDirection = eSIR_RX_ONLY;
9407 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9408
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309409 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009410 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309411 __func__, setKey.peerMac[0], setKey.peerMac[1],
9412 setKey.peerMac[2], setKey.peerMac[3],
9413 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009414 setKey.keyDirection);
9415
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309416 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009417 pAdapter->sessionId, &setKey, &roamId );
9418
9419 if ( 0 != status )
9420 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309421 hddLog(VOS_TRACE_LEVEL_ERROR,
9422 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009423 __func__, status);
9424 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309425 status = -EINVAL;
9426 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009427 }
9428 }
9429 }
9430
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309431end:
9432 /* Need to clear any trace of key value in the memory.
9433 * Thus zero out the memory even though it is local
9434 * variable.
9435 */
9436 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309437 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309438 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009439}
9440
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309441#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9442static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9443 struct net_device *ndev,
9444 u8 key_index, bool pairwise,
9445 const u8 *mac_addr,
9446 struct key_params *params
9447 )
9448#else
9449static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9450 struct net_device *ndev,
9451 u8 key_index, const u8 *mac_addr,
9452 struct key_params *params
9453 )
9454#endif
9455{
9456 int ret;
9457 vos_ssr_protect(__func__);
9458#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9459 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
9460 mac_addr, params);
9461#else
9462 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
9463 params);
9464#endif
9465 vos_ssr_unprotect(__func__);
9466
9467 return ret;
9468}
9469
Jeff Johnson295189b2012-06-20 16:38:30 -07009470/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309471 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009472 * This function is used to get the key information
9473 */
9474#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309475static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309476 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009477 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309478 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009479 const u8 *mac_addr, void *cookie,
9480 void (*callback)(void *cookie, struct key_params*)
9481 )
9482#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309483static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309484 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 struct net_device *ndev,
9486 u8 key_index, const u8 *mac_addr, void *cookie,
9487 void (*callback)(void *cookie, struct key_params*)
9488 )
9489#endif
9490{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309491 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309492 hdd_wext_state_t *pWextState = NULL;
9493 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009494 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309495 hdd_context_t *pHddCtx;
9496 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009497
9498 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309499
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309500 if (NULL == pAdapter)
9501 {
9502 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9503 "%s: HDD adapter is Null", __func__);
9504 return -ENODEV;
9505 }
9506
9507 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9508 ret = wlan_hdd_validate_context(pHddCtx);
9509 if (0 != ret)
9510 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309511 return ret;
9512 }
9513
9514 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9515 pRoamProfile = &(pWextState->roamProfile);
9516
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309517 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9518 __func__, hdd_device_modetoString(pAdapter->device_mode),
9519 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309520
Jeff Johnson295189b2012-06-20 16:38:30 -07009521 memset(&params, 0, sizeof(params));
9522
9523 if (CSR_MAX_NUM_KEY <= key_index)
9524 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309525 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07009526 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009528
9529 switch(pRoamProfile->EncryptionType.encryptionType[0])
9530 {
9531 case eCSR_ENCRYPT_TYPE_NONE:
9532 params.cipher = IW_AUTH_CIPHER_NONE;
9533 break;
9534
9535 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
9536 case eCSR_ENCRYPT_TYPE_WEP40:
9537 params.cipher = WLAN_CIPHER_SUITE_WEP40;
9538 break;
9539
9540 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
9541 case eCSR_ENCRYPT_TYPE_WEP104:
9542 params.cipher = WLAN_CIPHER_SUITE_WEP104;
9543 break;
9544
9545 case eCSR_ENCRYPT_TYPE_TKIP:
9546 params.cipher = WLAN_CIPHER_SUITE_TKIP;
9547 break;
9548
9549 case eCSR_ENCRYPT_TYPE_AES:
9550 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
9551 break;
9552
9553 default:
9554 params.cipher = IW_AUTH_CIPHER_NONE;
9555 break;
9556 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309557
c_hpothuaaf19692014-05-17 17:01:48 +05309558 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9559 TRACE_CODE_HDD_CFG80211_GET_KEY,
9560 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309561
Jeff Johnson295189b2012-06-20 16:38:30 -07009562 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
9563 params.seq_len = 0;
9564 params.seq = NULL;
9565 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
9566 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309567 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009568 return 0;
9569}
9570
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309571#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9572static int wlan_hdd_cfg80211_get_key(
9573 struct wiphy *wiphy,
9574 struct net_device *ndev,
9575 u8 key_index, bool pairwise,
9576 const u8 *mac_addr, void *cookie,
9577 void (*callback)(void *cookie, struct key_params*)
9578 )
9579#else
9580static int wlan_hdd_cfg80211_get_key(
9581 struct wiphy *wiphy,
9582 struct net_device *ndev,
9583 u8 key_index, const u8 *mac_addr, void *cookie,
9584 void (*callback)(void *cookie, struct key_params*)
9585 )
9586#endif
9587{
9588 int ret;
9589
9590 vos_ssr_protect(__func__);
9591#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9592 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
9593 mac_addr, cookie, callback);
9594#else
9595 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
9596 callback);
9597#endif
9598 vos_ssr_unprotect(__func__);
9599
9600 return ret;
9601}
9602
Jeff Johnson295189b2012-06-20 16:38:30 -07009603/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309604 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009605 * This function is used to delete the key information
9606 */
9607#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309608static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009609 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309610 u8 key_index,
9611 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009612 const u8 *mac_addr
9613 )
9614#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309615static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009616 struct net_device *ndev,
9617 u8 key_index,
9618 const u8 *mac_addr
9619 )
9620#endif
9621{
9622 int status = 0;
9623
9624 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309625 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009626 //it is observed that this is invalidating peer
9627 //key index whenever re-key is done. This is affecting data link.
9628 //It should be ok to ignore del_key.
9629#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309630 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
9631 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009632 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
9633 tCsrRoamSetKey setKey;
9634 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309635
Jeff Johnson295189b2012-06-20 16:38:30 -07009636 ENTER();
9637
9638 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
9639 __func__,pAdapter->device_mode);
9640
9641 if (CSR_MAX_NUM_KEY <= key_index)
9642 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309643 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009644 key_index);
9645
9646 return -EINVAL;
9647 }
9648
9649 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9650 setKey.keyId = key_index;
9651
9652 if (mac_addr)
9653 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9654 else
9655 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
9656
9657 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
9658
9659 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009660 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309661 )
9662 {
9663
9664 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07009665 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9666 if( pHostapdState->bssState == BSS_START)
9667 {
9668 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309669
Jeff Johnson295189b2012-06-20 16:38:30 -07009670 if ( status != eHAL_STATUS_SUCCESS )
9671 {
9672 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9673 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9674 __LINE__, status );
9675 }
9676 }
9677 }
9678 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309679 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07009680 )
9681 {
9682 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9683
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309684 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9685
9686 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309688 __func__, setKey.peerMac[0], setKey.peerMac[1],
9689 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07009690 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309691 if(pAdapter->sessionCtx.station.conn_info.connState ==
9692 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07009693 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309694 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009695 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309696
Jeff Johnson295189b2012-06-20 16:38:30 -07009697 if ( 0 != status )
9698 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309699 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009700 "%s: sme_RoamSetKey failure, returned %d",
9701 __func__, status);
9702 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9703 return -EINVAL;
9704 }
9705 }
9706 }
9707#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07009708 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009709 return status;
9710}
9711
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309712#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9713static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9714 struct net_device *ndev,
9715 u8 key_index,
9716 bool pairwise,
9717 const u8 *mac_addr
9718 )
9719#else
9720static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9721 struct net_device *ndev,
9722 u8 key_index,
9723 const u8 *mac_addr
9724 )
9725#endif
9726{
9727 int ret;
9728
9729 vos_ssr_protect(__func__);
9730#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9731 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
9732 mac_addr);
9733#else
9734 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
9735#endif
9736 vos_ssr_unprotect(__func__);
9737
9738 return ret;
9739}
9740
Jeff Johnson295189b2012-06-20 16:38:30 -07009741/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309742 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009743 * This function is used to set the default tx key index
9744 */
9745#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309746static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009747 struct net_device *ndev,
9748 u8 key_index,
9749 bool unicast, bool multicast)
9750#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309751static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009752 struct net_device *ndev,
9753 u8 key_index)
9754#endif
9755{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309756 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309757 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05309758 hdd_wext_state_t *pWextState;
9759 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309760 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009761
9762 ENTER();
9763
Gopichand Nakkala29149562013-05-10 21:43:41 +05309764 if ((NULL == pAdapter))
9765 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05309767 "invalid adapter");
9768 return -EINVAL;
9769 }
9770
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309771 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9772 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
9773 pAdapter->sessionId, key_index));
9774
Gopichand Nakkala29149562013-05-10 21:43:41 +05309775 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9776 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9777
9778 if ((NULL == pWextState) || (NULL == pHddStaCtx))
9779 {
9780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9781 "invalid Wext state or HDD context");
9782 return -EINVAL;
9783 }
9784
Arif Hussain6d2a3322013-11-17 19:50:10 -08009785 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309787
Jeff Johnson295189b2012-06-20 16:38:30 -07009788 if (CSR_MAX_NUM_KEY <= key_index)
9789 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309790 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009791 key_index);
9792
9793 return -EINVAL;
9794 }
9795
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309796 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9797 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309798 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009799 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309800 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009801 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309802
Jeff Johnson295189b2012-06-20 16:38:30 -07009803 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07009804 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309805 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009806 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05309807 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08009808 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309809 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08009810 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009811 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309812 {
9813 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07009814 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309815
Jeff Johnson295189b2012-06-20 16:38:30 -07009816 tCsrRoamSetKey setKey;
9817 v_U32_t roamId= 0xFF;
9818 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309819
9820 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009821 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309822
Jeff Johnson295189b2012-06-20 16:38:30 -07009823 Keys->defaultIndex = (u8)key_index;
9824 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9825 setKey.keyId = key_index;
9826 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309827
9828 vos_mem_copy(&setKey.Key[0],
9829 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009830 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309831
Gopichand Nakkala29149562013-05-10 21:43:41 +05309832 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309833
9834 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07009835 &pHddStaCtx->conn_info.bssId[0],
9836 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309837
Gopichand Nakkala29149562013-05-10 21:43:41 +05309838 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
9839 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
9840 eCSR_ENCRYPT_TYPE_WEP104)
9841 {
9842 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
9843 even though ap is configured for WEP-40 encryption. In this canse the key length
9844 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
9845 type(104) and switching encryption type to 40*/
9846 pWextState->roamProfile.EncryptionType.encryptionType[0] =
9847 eCSR_ENCRYPT_TYPE_WEP40;
9848 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
9849 eCSR_ENCRYPT_TYPE_WEP40;
9850 }
9851
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309852 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07009853 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309854
Jeff Johnson295189b2012-06-20 16:38:30 -07009855 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309856 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009857 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309858
Jeff Johnson295189b2012-06-20 16:38:30 -07009859 if ( 0 != status )
9860 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309861 hddLog(VOS_TRACE_LEVEL_ERROR,
9862 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009863 status);
9864 return -EINVAL;
9865 }
9866 }
9867 }
9868
9869 /* In SoftAp mode setting key direction for default mode */
9870 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
9871 {
9872 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
9873 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
9874 (eCSR_ENCRYPT_TYPE_AES !=
9875 pWextState->roamProfile.EncryptionType.encryptionType[0])
9876 )
9877 {
9878 /* Saving key direction for default key index to TX default */
9879 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9880 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
9881 }
9882 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309883 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009884 return status;
9885}
9886
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309887#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9888static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9889 struct net_device *ndev,
9890 u8 key_index,
9891 bool unicast, bool multicast)
9892#else
9893static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9894 struct net_device *ndev,
9895 u8 key_index)
9896#endif
9897{
9898 int ret;
9899 vos_ssr_protect(__func__);
9900#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9901 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
9902 multicast);
9903#else
9904 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
9905#endif
9906 vos_ssr_unprotect(__func__);
9907
9908 return ret;
9909}
9910
Jeff Johnson295189b2012-06-20 16:38:30 -07009911/*
9912 * FUNCTION: wlan_hdd_cfg80211_inform_bss
9913 * This function is used to inform the BSS details to nl80211 interface.
9914 */
9915static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
9916 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
9917{
9918 struct net_device *dev = pAdapter->dev;
9919 struct wireless_dev *wdev = dev->ieee80211_ptr;
9920 struct wiphy *wiphy = wdev->wiphy;
9921 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
9922 int chan_no;
9923 int ie_length;
9924 const char *ie;
9925 unsigned int freq;
9926 struct ieee80211_channel *chan;
9927 int rssi = 0;
9928 struct cfg80211_bss *bss = NULL;
9929
Jeff Johnson295189b2012-06-20 16:38:30 -07009930 if( NULL == pBssDesc )
9931 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009932 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009933 return bss;
9934 }
9935
9936 chan_no = pBssDesc->channelId;
9937 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
9938 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
9939
9940 if( NULL == ie )
9941 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009942 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009943 return bss;
9944 }
9945
9946#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
9947 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
9948 {
9949 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9950 }
9951 else
9952 {
9953 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9954 }
9955#else
9956 freq = ieee80211_channel_to_frequency(chan_no);
9957#endif
9958
9959 chan = __ieee80211_get_channel(wiphy, freq);
9960
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05309961 if (!chan) {
9962 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
9963 return NULL;
9964 }
9965
Abhishek Singhaee43942014-06-16 18:55:47 +05309966 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07009967
Anand N Sunkad9f80b742015-07-30 20:05:51 +05309968 return cfg80211_inform_bss(wiphy, chan,
9969#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
9970 CFG80211_BSS_FTYPE_UNKNOWN,
9971#endif
9972 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309973 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07009974 pBssDesc->capabilityInfo,
9975 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05309976 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07009977}
9978
9979
9980
9981/*
9982 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
9983 * This function is used to inform the BSS details to nl80211 interface.
9984 */
9985struct cfg80211_bss*
9986wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
9987 tSirBssDescription *bss_desc
9988 )
9989{
9990 /*
9991 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
9992 already exists in bss data base of cfg80211 for that particular BSS ID.
9993 Using cfg80211_inform_bss_frame to update the bss entry instead of
9994 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
9995 now there is no possibility to get the mgmt(probe response) frame from PE,
9996 converting bss_desc to ieee80211_mgmt(probe response) and passing to
9997 cfg80211_inform_bss_frame.
9998 */
9999 struct net_device *dev = pAdapter->dev;
10000 struct wireless_dev *wdev = dev->ieee80211_ptr;
10001 struct wiphy *wiphy = wdev->wiphy;
10002 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080010003#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
10004 qcom_ie_age *qie_age = NULL;
10005 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
10006#else
Jeff Johnson295189b2012-06-20 16:38:30 -070010007 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080010008#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010009 const char *ie =
10010 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
10011 unsigned int freq;
10012 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053010013 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010014 struct cfg80211_bss *bss_status = NULL;
10015 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
10016 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070010017 hdd_context_t *pHddCtx;
10018 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070010019#ifdef WLAN_OPEN_SOURCE
10020 struct timespec ts;
10021#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010022
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010023
Wilson Yangf80a0542013-10-07 13:02:37 -070010024 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10025 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070010026 if (0 != status)
10027 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070010028 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070010029 }
10030
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053010031 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070010032 if (!mgmt)
10033 {
10034 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10035 "%s: memory allocation failed ", __func__);
10036 return NULL;
10037 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070010038
Jeff Johnson295189b2012-06-20 16:38:30 -070010039 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070010040
10041#ifdef WLAN_OPEN_SOURCE
10042 /* Android does not want the timestamp from the frame.
10043 Instead it wants a monotonic increasing value */
10044 get_monotonic_boottime(&ts);
10045 mgmt->u.probe_resp.timestamp =
10046 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
10047#else
10048 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070010049 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
10050 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070010051
10052#endif
10053
Jeff Johnson295189b2012-06-20 16:38:30 -070010054 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
10055 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080010056
10057#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
10058 /* GPS Requirement: need age ie per entry. Using vendor specific. */
10059 /* Assuming this is the last IE, copy at the end */
10060 ie_length -=sizeof(qcom_ie_age);
10061 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
10062 qie_age->element_id = QCOM_VENDOR_IE_ID;
10063 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
10064 qie_age->oui_1 = QCOM_OUI1;
10065 qie_age->oui_2 = QCOM_OUI2;
10066 qie_age->oui_3 = QCOM_OUI3;
10067 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
10068 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
10069#endif
10070
Jeff Johnson295189b2012-06-20 16:38:30 -070010071 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053010072 if (bss_desc->fProbeRsp)
10073 {
10074 mgmt->frame_control |=
10075 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
10076 }
10077 else
10078 {
10079 mgmt->frame_control |=
10080 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
10081 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010082
10083#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010084 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070010085 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
10086 {
10087 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
10088 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010089 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070010090 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
10091
10092 {
10093 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
10094 }
10095 else
10096 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010097 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
10098 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070010099 kfree(mgmt);
10100 return NULL;
10101 }
10102#else
10103 freq = ieee80211_channel_to_frequency(chan_no);
10104#endif
10105 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080010106 /*when the band is changed on the fly using the GUI, three things are done
10107 * 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)
10108 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
10109 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
10110 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
10111 * and discards the channels correponding to previous band and calls back with zero bss results.
10112 * 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
10113 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
10114 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
10115 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
10116 * So drop the bss and continue to next bss.
10117 */
10118 if(chan == NULL)
10119 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010120 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -070010121 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080010122 return NULL;
10123 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053010124 /*To keep the rssi icon of the connected AP in the scan window
10125 *and the rssi icon of the wireless networks in sync
10126 * */
10127 if (( eConnectionState_Associated ==
10128 pAdapter->sessionCtx.station.conn_info.connState ) &&
10129 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
10130 pAdapter->sessionCtx.station.conn_info.bssId,
10131 WNI_CFG_BSSID_LEN)) &&
10132 (pHddCtx->hdd_wlan_suspended == FALSE))
10133 {
10134 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
10135 rssi = (pAdapter->rssi * 100);
10136 }
10137 else
10138 {
10139 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
10140 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010141
Nirav Shah20ac06f2013-12-12 18:14:06 +053010142 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053010143 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
10144 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053010145
Jeff Johnson295189b2012-06-20 16:38:30 -070010146 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
10147 frame_len, rssi, GFP_KERNEL);
10148 kfree(mgmt);
10149 return bss_status;
10150}
10151
10152/*
10153 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
10154 * This function is used to update the BSS data base of CFG8011
10155 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010156struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070010157 tCsrRoamInfo *pRoamInfo
10158 )
10159{
10160 tCsrRoamConnectedProfile roamProfile;
10161 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10162 struct cfg80211_bss *bss = NULL;
10163
10164 ENTER();
10165
10166 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
10167 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
10168
10169 if (NULL != roamProfile.pBssDesc)
10170 {
Girish Gowlif4b68022014-08-28 23:18:57 +053010171 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10172 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010173
10174 if (NULL == bss)
10175 {
10176 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
10177 __func__);
10178 }
10179
10180 sme_RoamFreeConnectProfile(hHal, &roamProfile);
10181 }
10182 else
10183 {
10184 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
10185 __func__);
10186 }
10187 return bss;
10188}
10189
10190/*
10191 * FUNCTION: wlan_hdd_cfg80211_update_bss
10192 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010193static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
10194 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070010195 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010196{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010197 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010198 tCsrScanResultInfo *pScanResult;
10199 eHalStatus status = 0;
10200 tScanResultHandle pResult;
10201 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070010202 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010203 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070010204 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010205
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010206 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10207 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
10208 NO_SESSION, pAdapter->sessionId));
10209
Wilson Yangf80a0542013-10-07 13:02:37 -070010210 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10211
10212 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -070010213 {
Wilson Yangf80a0542013-10-07 13:02:37 -070010214 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10215 "%s:LOGP in Progress. Ignore!!!",__func__);
10216 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010217 }
10218
Wilson Yangf80a0542013-10-07 13:02:37 -070010219
10220 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +053010221 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -070010222 {
10223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10224 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
10225 return VOS_STATUS_E_PERM;
10226 }
10227
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010228 if (pAdapter->request != NULL)
10229 {
10230 if ((pAdapter->request->n_ssids == 1)
10231 && (pAdapter->request->ssids != NULL)
10232 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
10233 is_p2p_scan = true;
10234 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010235 /*
10236 * start getting scan results and populate cgf80211 BSS database
10237 */
10238 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
10239
10240 /* no scan results */
10241 if (NULL == pResult)
10242 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010243 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
10244 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053010245 wlan_hdd_get_frame_logs(pAdapter,
10246 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070010247 return status;
10248 }
10249
10250 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
10251
10252 while (pScanResult)
10253 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010254 /*
10255 * cfg80211_inform_bss() is not updating ie field of bss entry, if
10256 * entry already exists in bss data base of cfg80211 for that
10257 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
10258 * bss entry instead of cfg80211_inform_bss, But this call expects
10259 * mgmt packet as input. As of now there is no possibility to get
10260 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070010261 * ieee80211_mgmt(probe response) and passing to c
10262 * fg80211_inform_bss_frame.
10263 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010264 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
10265 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
10266 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010267 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10268 continue; //Skip the non p2p bss entries
10269 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010270 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10271 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010272
Jeff Johnson295189b2012-06-20 16:38:30 -070010273
10274 if (NULL == bss_status)
10275 {
10276 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010277 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010278 }
10279 else
10280 {
Yue Maf49ba872013-08-19 12:04:25 -070010281 cfg80211_put_bss(
10282#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10283 wiphy,
10284#endif
10285 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010286 }
10287
10288 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10289 }
10290
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010291 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010292 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010293 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010294}
10295
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010296void
10297hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
10298{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010299 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080010300 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010301} /****** end hddPrintMacAddr() ******/
10302
10303void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010304hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010305{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010306 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010307 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010308 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
10309 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
10310 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010311} /****** end hddPrintPmkId() ******/
10312
10313//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
10314//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
10315
10316//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
10317//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
10318
10319#define dump_bssid(bssid) \
10320 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010321 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
10322 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010323 }
10324
10325#define dump_pmkid(pMac, pmkid) \
10326 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010327 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
10328 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010329 }
10330
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070010331#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010332/*
10333 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
10334 * This function is used to notify the supplicant of a new PMKSA candidate.
10335 */
10336int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010337 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010338 int index, bool preauth )
10339{
Jeff Johnsone7245742012-09-05 17:12:55 -070010340#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010341 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010342 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010343
10344 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070010345 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010346
10347 if( NULL == pRoamInfo )
10348 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010349 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010350 return -EINVAL;
10351 }
10352
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010353 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
10354 {
10355 dump_bssid(pRoamInfo->bssid);
10356 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010357 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010358 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010359#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010360 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010361}
10362#endif //FEATURE_WLAN_LFR
10363
Yue Maef608272013-04-08 23:09:17 -070010364#ifdef FEATURE_WLAN_LFR_METRICS
10365/*
10366 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
10367 * 802.11r/LFR metrics reporting function to report preauth initiation
10368 *
10369 */
10370#define MAX_LFR_METRICS_EVENT_LENGTH 100
10371VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
10372 tCsrRoamInfo *pRoamInfo)
10373{
10374 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10375 union iwreq_data wrqu;
10376
10377 ENTER();
10378
10379 if (NULL == pAdapter)
10380 {
10381 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10382 return VOS_STATUS_E_FAILURE;
10383 }
10384
10385 /* create the event */
10386 memset(&wrqu, 0, sizeof(wrqu));
10387 memset(metrics_notification, 0, sizeof(metrics_notification));
10388
10389 wrqu.data.pointer = metrics_notification;
10390 wrqu.data.length = scnprintf(metrics_notification,
10391 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
10392 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10393
10394 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10395
10396 EXIT();
10397
10398 return VOS_STATUS_SUCCESS;
10399}
10400
10401/*
10402 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
10403 * 802.11r/LFR metrics reporting function to report preauth completion
10404 * or failure
10405 */
10406VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
10407 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
10408{
10409 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10410 union iwreq_data wrqu;
10411
10412 ENTER();
10413
10414 if (NULL == pAdapter)
10415 {
10416 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10417 return VOS_STATUS_E_FAILURE;
10418 }
10419
10420 /* create the event */
10421 memset(&wrqu, 0, sizeof(wrqu));
10422 memset(metrics_notification, 0, sizeof(metrics_notification));
10423
10424 scnprintf(metrics_notification, sizeof(metrics_notification),
10425 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
10426 MAC_ADDR_ARRAY(pRoamInfo->bssid));
10427
10428 if (1 == preauth_status)
10429 strncat(metrics_notification, " TRUE", 5);
10430 else
10431 strncat(metrics_notification, " FALSE", 6);
10432
10433 wrqu.data.pointer = metrics_notification;
10434 wrqu.data.length = strlen(metrics_notification);
10435
10436 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10437
10438 EXIT();
10439
10440 return VOS_STATUS_SUCCESS;
10441}
10442
10443/*
10444 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
10445 * 802.11r/LFR metrics reporting function to report handover initiation
10446 *
10447 */
10448VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
10449 tCsrRoamInfo *pRoamInfo)
10450{
10451 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10452 union iwreq_data wrqu;
10453
10454 ENTER();
10455
10456 if (NULL == pAdapter)
10457 {
10458 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10459 return VOS_STATUS_E_FAILURE;
10460 }
10461
10462 /* create the event */
10463 memset(&wrqu, 0, sizeof(wrqu));
10464 memset(metrics_notification, 0, sizeof(metrics_notification));
10465
10466 wrqu.data.pointer = metrics_notification;
10467 wrqu.data.length = scnprintf(metrics_notification,
10468 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
10469 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10470
10471 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10472
10473 EXIT();
10474
10475 return VOS_STATUS_SUCCESS;
10476}
10477#endif
10478
Jeff Johnson295189b2012-06-20 16:38:30 -070010479/*
10480 * FUNCTION: hdd_cfg80211_scan_done_callback
10481 * scanning callback function, called after finishing scan
10482 *
10483 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010484static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070010485 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
10486{
10487 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010488 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070010489 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010490 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010491 struct cfg80211_scan_request *req = NULL;
10492 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010493 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010494 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010495 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010496 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010497
10498 ENTER();
10499
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010500 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053010501 if (NULL == pHddCtx) {
10502 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010503 goto allow_suspend;
10504 }
10505
10506 pScanInfo = &pHddCtx->scan_info;
10507
Jeff Johnson295189b2012-06-20 16:38:30 -070010508 hddLog(VOS_TRACE_LEVEL_INFO,
10509 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080010510 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010511 __func__, halHandle, pContext, (int) scanId, (int) status);
10512
Kiet Lamac06e2c2013-10-23 16:25:07 +053010513 pScanInfo->mScanPendingCounter = 0;
10514
Jeff Johnson295189b2012-06-20 16:38:30 -070010515 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010516 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070010517 &pScanInfo->scan_req_completion_event,
10518 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010519 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070010520 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010521 hddLog(VOS_TRACE_LEVEL_ERROR,
10522 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070010523 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010524 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010525 }
10526
Yue Maef608272013-04-08 23:09:17 -070010527 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010528 {
10529 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010530 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010531 }
10532
10533 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010534 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070010535 {
10536 hddLog(VOS_TRACE_LEVEL_INFO,
10537 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010538 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070010539 (int) scanId);
10540 }
10541
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010542 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010543 pAdapter);
10544
10545 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010546 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010547
10548
10549 /* If any client wait scan result through WEXT
10550 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010551 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070010552 {
10553 /* The other scan request waiting for current scan finish
10554 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010555 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010556 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010557 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070010558 }
10559 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010560 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010561 {
10562 struct net_device *dev = pAdapter->dev;
10563 union iwreq_data wrqu;
10564 int we_event;
10565 char *msg;
10566
10567 memset(&wrqu, '\0', sizeof(wrqu));
10568 we_event = SIOCGIWSCAN;
10569 msg = NULL;
10570 wireless_send_event(dev, we_event, &wrqu, msg);
10571 }
10572 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010573 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010574
10575 /* Get the Scan Req */
10576 req = pAdapter->request;
10577
10578 if (!req)
10579 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010580 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010581 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010582 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010583 }
10584
Jeff Johnson295189b2012-06-20 16:38:30 -070010585 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070010586 /* Scan is no longer pending */
10587 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010588
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010589 /* last_scan_timestamp is used to decide if new scan
10590 * is needed or not on station interface. If last station
10591 * scan time and new station scan time is less then
10592 * last_scan_timestamp ; driver will return cached scan.
10593 */
10594 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
10595 {
10596 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
10597
10598 if ( req->n_channels )
10599 {
10600 for (i = 0; i < req->n_channels ; i++ )
10601 {
10602 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
10603 }
10604 /* store no of channel scanned */
10605 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
10606 }
10607
10608 }
10609
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070010610 /*
10611 * cfg80211_scan_done informing NL80211 about completion
10612 * of scanning
10613 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010614 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
10615 {
10616 aborted = true;
10617 }
10618 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080010619 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070010620
Siddharth Bhal76972212014-10-15 16:22:51 +053010621 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
10622 /* Generate new random mac addr for next scan */
10623 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
10624 hdd_processSpoofMacAddrRequest(pHddCtx);
10625 }
10626
Jeff Johnsone7245742012-09-05 17:12:55 -070010627allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010628 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010629 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070010630
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010631 /* Acquire wakelock to handle the case where APP's tries to suspend
10632 * immediatly after the driver gets connect request(i.e after scan)
10633 * from supplicant, this result in app's is suspending and not able
10634 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010635 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010636
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010637#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010638 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010639#endif
10640
Jeff Johnson295189b2012-06-20 16:38:30 -070010641 EXIT();
10642 return 0;
10643}
10644
10645/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053010646 * FUNCTION: hdd_isConnectionInProgress
10647 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010648 *
10649 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010650v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010651{
10652 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10653 hdd_station_ctx_t *pHddStaCtx = NULL;
10654 hdd_adapter_t *pAdapter = NULL;
10655 VOS_STATUS status = 0;
10656 v_U8_t staId = 0;
10657 v_U8_t *staMac = NULL;
10658
c_hpothu9b781ba2013-12-30 20:57:45 +053010659 if (TRUE == pHddCtx->btCoexModeSet)
10660 {
10661 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053010662 FL("BTCoex Mode operation in progress"));
10663 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053010664 }
10665
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010666 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10667
10668 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10669 {
10670 pAdapter = pAdapterNode->pAdapter;
10671
10672 if( pAdapter )
10673 {
10674 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010675 "%s: Adapter with device mode %s (%d) exists",
10676 __func__, hdd_device_modetoString(pAdapter->device_mode),
10677 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010678 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053010679 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10680 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
10681 (eConnectionState_Connecting ==
10682 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
10683 {
10684 hddLog(VOS_TRACE_LEVEL_ERROR,
10685 "%s: %p(%d) Connection is in progress", __func__,
10686 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10687 return VOS_TRUE;
10688 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010689 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053010690 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010691 {
10692 hddLog(VOS_TRACE_LEVEL_ERROR,
10693 "%s: %p(%d) Reassociation is in progress", __func__,
10694 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10695 return VOS_TRUE;
10696 }
10697 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010698 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10699 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010700 {
10701 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10702 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010703 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010704 {
10705 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
10706 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010707 "%s: client " MAC_ADDRESS_STR
10708 " is in the middle of WPS/EAPOL exchange.", __func__,
10709 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010710 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010711 }
10712 }
10713 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
10714 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
10715 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010716 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10717 ptSapContext pSapCtx = NULL;
10718 pSapCtx = VOS_GET_SAP_CB(pVosContext);
10719 if(pSapCtx == NULL){
10720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10721 FL("psapCtx is NULL"));
10722 return VOS_FALSE;
10723 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010724 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
10725 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010726 if ((pSapCtx->aStaInfo[staId].isUsed) &&
10727 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010728 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010729 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010730
10731 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010732 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
10733 "middle of WPS/EAPOL exchange.", __func__,
10734 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010735 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010736 }
10737 }
10738 }
10739 }
10740 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10741 pAdapterNode = pNext;
10742 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053010743 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010744}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010745
10746/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010747 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070010748 * this scan respond to scan trigger and update cfg80211 scan database
10749 * later, scan dump command can be used to recieve scan results
10750 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010751int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010752#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10753 struct net_device *dev,
10754#endif
10755 struct cfg80211_scan_request *request)
10756{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010757 hdd_adapter_t *pAdapter = NULL;
10758 hdd_context_t *pHddCtx = NULL;
10759 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010760 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010761 tCsrScanRequest scanRequest;
10762 tANI_U8 *channelList = NULL, i;
10763 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010764 int status;
10765 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010766 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010767 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053010768 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010769 bool is_p2p_scan = false;
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010770 v_S7_t rssi=0;
10771 hdd_station_ctx_t *pHddStaCtx=NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010772
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010773#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
10774 struct net_device *dev = NULL;
10775 if (NULL == request)
10776 {
10777 hddLog(VOS_TRACE_LEVEL_ERROR,
10778 "%s: scan req param null", __func__);
10779 return -EINVAL;
10780 }
10781 dev = request->wdev->netdev;
10782#endif
10783
10784 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
10785 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
10786 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10787
Jeff Johnson295189b2012-06-20 16:38:30 -070010788 ENTER();
10789
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010790 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10791 __func__, hdd_device_modetoString(pAdapter->device_mode),
10792 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010793
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010794 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010795 if (0 != status)
10796 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010797 return status;
10798 }
10799
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010800 if (NULL == pwextBuf)
10801 {
10802 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
10803 __func__);
10804 return -EIO;
10805 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010806 cfg_param = pHddCtx->cfg_ini;
10807 pScanInfo = &pHddCtx->scan_info;
10808
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010809 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10810 if ( (pHddStaCtx != NULL) && (TRUE == hdd_connIsConnected(pHddStaCtx)))
10811 {
10812 wlan_hdd_get_roam_rssi(pAdapter, &rssi);
10813 hddLog(VOS_TRACE_LEVEL_INFO, FL("rssi: %d"), rssi);
10814 }
10815
Jeff Johnson295189b2012-06-20 16:38:30 -070010816#ifdef WLAN_BTAMP_FEATURE
10817 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010818 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070010819 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010820 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010821 "%s: No scanning when AMP is on", __func__);
10822 return -EOPNOTSUPP;
10823 }
10824#endif
10825 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010826 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010827 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010828 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010829 "%s: Not scanning on device_mode = %s (%d)",
10830 __func__, hdd_device_modetoString(pAdapter->device_mode),
10831 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010832 return -EOPNOTSUPP;
10833 }
10834
10835 if (TRUE == pScanInfo->mScanPending)
10836 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010837 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
10838 {
10839 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
10840 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010841 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010842 }
10843
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010844 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070010845 //Channel and action frame is pending
10846 //Otherwise Cancel Remain On Channel and allow Scan
10847 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010848 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070010849 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010850 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010851 return -EBUSY;
10852 }
10853
Jeff Johnson295189b2012-06-20 16:38:30 -070010854 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
10855 {
10856 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080010857 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010858 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010859 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010860 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
10861 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010862 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010863 "%s: MAX TM Level Scan not allowed", __func__);
10864 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010865 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010866 }
10867 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
10868
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010869 /* Check if scan is allowed at this point of time.
10870 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010871 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010872 {
10873 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
10874 return -EBUSY;
10875 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010876
Jeff Johnson295189b2012-06-20 16:38:30 -070010877 vos_mem_zero( &scanRequest, sizeof(scanRequest));
10878
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010879 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
10880 * Becasue of this, driver is assuming that this is not wildcard scan and so
10881 * is not aging out the scan results.
10882 */
10883 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070010884 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010885 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010886 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010887
10888 if ((request->ssids) && (0 < request->n_ssids))
10889 {
10890 tCsrSSIDInfo *SsidInfo;
10891 int j;
10892 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
10893 /* Allocate num_ssid tCsrSSIDInfo structure */
10894 SsidInfo = scanRequest.SSIDs.SSIDList =
10895 ( tCsrSSIDInfo *)vos_mem_malloc(
10896 request->n_ssids*sizeof(tCsrSSIDInfo));
10897
10898 if(NULL == scanRequest.SSIDs.SSIDList)
10899 {
10900 hddLog(VOS_TRACE_LEVEL_ERROR,
10901 "%s: memory alloc failed SSIDInfo buffer", __func__);
10902 return -ENOMEM;
10903 }
10904
10905 /* copy all the ssid's and their length */
10906 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
10907 {
10908 /* get the ssid length */
10909 SsidInfo->SSID.length = request->ssids[j].ssid_len;
10910 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
10911 SsidInfo->SSID.length);
10912 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
10913 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
10914 j, SsidInfo->SSID.ssId);
10915 }
10916 /* set the scan type to active */
10917 scanRequest.scanType = eSIR_ACTIVE_SCAN;
10918 }
10919 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070010920 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010921 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10922 TRACE_CODE_HDD_CFG80211_SCAN,
10923 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070010924 /* set the scan type to active */
10925 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010926 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010927 else
10928 {
10929 /*Set the scan type to default type, in this case it is ACTIVE*/
10930 scanRequest.scanType = pScanInfo->scan_mode;
10931 }
10932 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
10933 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070010934
10935 /* set BSSType to default type */
10936 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
10937
10938 /*TODO: scan the requested channels only*/
10939
10940 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010941 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070010942 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010943 hddLog(VOS_TRACE_LEVEL_WARN,
10944 "No of Scan Channels exceeded limit: %d", request->n_channels);
10945 request->n_channels = MAX_CHANNEL;
10946 }
10947
10948 hddLog(VOS_TRACE_LEVEL_INFO,
10949 "No of Scan Channels: %d", request->n_channels);
10950
10951
10952 if( request->n_channels )
10953 {
10954 char chList [(request->n_channels*5)+1];
10955 int len;
10956 channelList = vos_mem_malloc( request->n_channels );
10957 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053010958 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010959 hddLog(VOS_TRACE_LEVEL_ERROR,
10960 "%s: memory alloc failed channelList", __func__);
10961 status = -ENOMEM;
10962 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053010963 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010964
10965 for( i = 0, len = 0; i < request->n_channels ; i++ )
10966 {
10967 channelList[i] = request->channels[i]->hw_value;
10968 len += snprintf(chList+len, 5, "%d ", channelList[i]);
10969 }
10970
Nirav Shah20ac06f2013-12-12 18:14:06 +053010971 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010972 "Channel-List: %s ", chList);
10973 }
c_hpothu53512302014-04-15 18:49:53 +053010974
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010975 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
10976 scanRequest.ChannelInfo.ChannelList = channelList;
10977
10978 /* set requestType to full scan */
10979 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
10980
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010981 /* if there is back to back scan happening in driver with in
10982 * nDeferScanTimeInterval interval driver should defer new scan request
10983 * and should provide last cached scan results instead of new channel list.
10984 * This rule is not applicable if scan is p2p scan.
10985 * This condition will work only in case when last request no of channels
10986 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053010987 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053010988 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010989 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010990
Sushant Kaushik86592172015-04-27 16:35:03 +053010991 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
10992 /* if wps ie is NULL , then only defer scan */
10993 if ( pWpsIe == NULL &&
10994 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053010995 {
10996 if ( pScanInfo->last_scan_timestamp !=0 &&
10997 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
10998 {
10999 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
11000 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
11001 vos_mem_compare(pScanInfo->last_scan_channelList,
11002 channelList, pScanInfo->last_scan_numChannels))
11003 {
11004 hddLog(VOS_TRACE_LEVEL_WARN,
11005 " New and old station scan time differ is less then %u",
11006 pHddCtx->cfg_ini->nDeferScanTimeInterval);
11007
11008 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011009 pAdapter);
11010
Agarwal Ashish57e84372014-12-05 18:26:53 +053011011 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053011012 "Return old cached scan as all channels and no of channels are same");
11013
Agarwal Ashish57e84372014-12-05 18:26:53 +053011014 if (0 > ret)
11015 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011016
Agarwal Ashish57e84372014-12-05 18:26:53 +053011017 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053011018
11019 status = eHAL_STATUS_SUCCESS;
11020 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053011021 }
11022 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011023 }
11024
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011025 /* Flush the scan results(only p2p beacons) for STA scan and P2P
11026 * search (Flush on both full scan and social scan but not on single
11027 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
11028 */
11029
11030 /* Supplicant does single channel scan after 8-way handshake
11031 * and in that case driver shoudnt flush scan results. If
11032 * driver flushes the scan results here and unfortunately if
11033 * the AP doesnt respond to our probe req then association
11034 * fails which is not desired
11035 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053011036 if ((request->n_ssids == 1)
11037 && (request->ssids != NULL)
11038 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
11039 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011040
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053011041 if( is_p2p_scan ||
11042 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011043 {
11044 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
11045 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
11046 pAdapter->sessionId );
11047 }
11048
11049 if( request->ie_len )
11050 {
11051 /* save this for future association (join requires this) */
11052 /*TODO: Array needs to be converted to dynamic allocation,
11053 * as multiple ie.s can be sent in cfg80211_scan_request structure
11054 * CR 597966
11055 */
11056 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
11057 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
11058 pScanInfo->scanAddIE.length = request->ie_len;
11059
11060 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11061 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
11062 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070011063 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011064 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070011065 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011066 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
11067 memcpy( pwextBuf->roamProfile.addIEScan,
11068 request->ie, request->ie_len);
11069 }
11070 else
11071 {
11072 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
11073 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070011074 }
11075
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011076 }
11077 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
11078 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
11079
11080 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
11081 request->ie_len);
11082 if (pP2pIe != NULL)
11083 {
11084#ifdef WLAN_FEATURE_P2P_DEBUG
11085 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
11086 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
11087 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053011088 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011089 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
11090 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
11091 "Go nego completed to Connection is started");
11092 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
11093 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053011094 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011095 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
11096 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070011097 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011098 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
11099 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
11100 "Disconnected state to Connection is started");
11101 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
11102 "for 4way Handshake");
11103 }
11104#endif
11105
11106 /* no_cck will be set during p2p find to disable 11b rates */
11107 if(TRUE == request->no_cck)
11108 {
11109 hddLog(VOS_TRACE_LEVEL_INFO,
11110 "%s: This is a P2P Search", __func__);
11111 scanRequest.p2pSearch = 1;
11112
11113 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053011114 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011115 /* set requestType to P2P Discovery */
11116 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
11117 }
11118
11119 /*
11120 Skip Dfs Channel in case of P2P Search
11121 if it is set in ini file
11122 */
11123 if(cfg_param->skipDfsChnlInP2pSearch)
11124 {
11125 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053011126 }
11127 else
11128 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011129 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053011130 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011131
Agarwal Ashish4f616132013-12-30 23:32:50 +053011132 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011133 }
11134 }
11135
11136 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
11137
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053011138#ifdef FEATURE_WLAN_TDLS
11139 /* if tdls disagree scan right now, return immediately.
11140 tdls will schedule the scan when scan is allowed. (return SUCCESS)
11141 or will reject the scan if any TDLS is in progress. (return -EBUSY)
11142 */
11143 status = wlan_hdd_tdls_scan_callback (pAdapter,
11144 wiphy,
11145#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11146 dev,
11147#endif
11148 request);
11149 if(status <= 0)
11150 {
11151 if(!status)
11152 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
11153 "scan rejected %d", __func__, status);
11154 else
11155 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
11156 __func__, status);
11157
11158 return status;
11159 }
11160#endif
11161
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070011162 /* acquire the wakelock to avoid the apps suspend during the scan. To
11163 * address the following issues.
11164 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
11165 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
11166 * for long time, this result in apps running at full power for long time.
11167 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
11168 * be stuck in full power because of resume BMPS
11169 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011170 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070011171
Nirav Shah20ac06f2013-12-12 18:14:06 +053011172 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
11173 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011174 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
11175 scanRequest.requestType, scanRequest.scanType,
11176 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053011177 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
11178
Siddharth Bhal76972212014-10-15 16:22:51 +053011179 if (pHddCtx->spoofMacAddr.isEnabled)
11180 {
11181 hddLog(VOS_TRACE_LEVEL_INFO,
11182 "%s: MAC Spoofing enabled for current scan", __func__);
11183 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
11184 * to fill TxBds for probe request during current scan
11185 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011186 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053011187 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011188
11189 if(status != VOS_STATUS_SUCCESS)
11190 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011191 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011192 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053011193#ifdef FEATURE_WLAN_TDLS
11194 wlan_hdd_tdls_scan_done_callback(pAdapter);
11195#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011196 goto free_mem;
11197 }
Siddharth Bhal76972212014-10-15 16:22:51 +053011198 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053011199 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070011200 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011201 pAdapter->sessionId, &scanRequest, &scanId,
11202 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070011203
Jeff Johnson295189b2012-06-20 16:38:30 -070011204 if (eHAL_STATUS_SUCCESS != status)
11205 {
11206 hddLog(VOS_TRACE_LEVEL_ERROR,
11207 "%s: sme_ScanRequest returned error %d", __func__, status);
11208 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011209 if(eHAL_STATUS_RESOURCES == status)
11210 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053011211 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
11212 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011213 status = -EBUSY;
11214 } else {
11215 status = -EIO;
11216 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011217 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053011218
11219#ifdef FEATURE_WLAN_TDLS
11220 wlan_hdd_tdls_scan_done_callback(pAdapter);
11221#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011222 goto free_mem;
11223 }
11224
11225 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053011226 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011227 pAdapter->request = request;
11228 pScanInfo->scanId = scanId;
11229
11230 complete(&pScanInfo->scan_req_completion_event);
11231
11232free_mem:
11233 if( scanRequest.SSIDs.SSIDList )
11234 {
11235 vos_mem_free(scanRequest.SSIDs.SSIDList);
11236 }
11237
11238 if( channelList )
11239 vos_mem_free( channelList );
11240
11241 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011242 return status;
11243}
11244
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011245int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
11246#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11247 struct net_device *dev,
11248#endif
11249 struct cfg80211_scan_request *request)
11250{
11251 int ret;
11252
11253 vos_ssr_protect(__func__);
11254 ret = __wlan_hdd_cfg80211_scan(wiphy,
11255#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11256 dev,
11257#endif
11258 request);
11259 vos_ssr_unprotect(__func__);
11260
11261 return ret;
11262}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011263
11264void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
11265{
11266 v_U8_t iniDot11Mode =
11267 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
11268 eHddDot11Mode hddDot11Mode = iniDot11Mode;
11269
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011270 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
11271 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011272 switch ( iniDot11Mode )
11273 {
11274 case eHDD_DOT11_MODE_AUTO:
11275 case eHDD_DOT11_MODE_11ac:
11276 case eHDD_DOT11_MODE_11ac_ONLY:
11277#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053011278 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
11279 sme_IsFeatureSupportedByFW(DOT11AC) )
11280 hddDot11Mode = eHDD_DOT11_MODE_11ac;
11281 else
11282 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011283#else
11284 hddDot11Mode = eHDD_DOT11_MODE_11n;
11285#endif
11286 break;
11287 case eHDD_DOT11_MODE_11n:
11288 case eHDD_DOT11_MODE_11n_ONLY:
11289 hddDot11Mode = eHDD_DOT11_MODE_11n;
11290 break;
11291 default:
11292 hddDot11Mode = iniDot11Mode;
11293 break;
11294 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011295#ifdef WLAN_FEATURE_AP_HT40_24G
11296 if (operationChannel > SIR_11B_CHANNEL_END)
11297#endif
11298 {
11299 /* This call decides required channel bonding mode */
11300 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011301 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
11302 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011303 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011304}
11305
Jeff Johnson295189b2012-06-20 16:38:30 -070011306/*
11307 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011308 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011309 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011310int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011311 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070011312{
11313 int status = 0;
11314 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080011315 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011316 v_U32_t roamId;
11317 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070011318 eCsrAuthType RSNAuthType;
11319
11320 ENTER();
11321
11322 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080011323 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11324
11325 status = wlan_hdd_validate_context(pHddCtx);
11326 if (status)
11327 {
Yue Mae36e3552014-03-05 17:06:20 -080011328 return status;
11329 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011330
Jeff Johnson295189b2012-06-20 16:38:30 -070011331 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
11332 {
11333 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
11334 return -EINVAL;
11335 }
11336
11337 pRoamProfile = &pWextState->roamProfile;
11338
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011339 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070011340 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011341 hdd_station_ctx_t *pHddStaCtx;
11342 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011343
Siddharth Bhalda0d1622015-04-24 15:47:49 +053011344 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
11345
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011346 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070011347 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
11348 {
11349 /*QoS not enabled in cfg file*/
11350 pRoamProfile->uapsd_mask = 0;
11351 }
11352 else
11353 {
11354 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011355 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070011356 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
11357 }
11358
11359 pRoamProfile->SSIDs.numOfSSIDs = 1;
11360 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
11361 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011362 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070011363 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
11364 ssid, ssid_len);
11365
11366 if (bssid)
11367 {
11368 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
11369 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
11370 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011371 /* Save BSSID in seperate variable as well, as RoamProfile
11372 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070011373 case of join failure we should send valid BSSID to supplicant
11374 */
11375 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
11376 WNI_CFG_BSSID_LEN);
11377 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070011378 else
11379 {
11380 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
11381 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011382
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011383 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
11384 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011385 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
11386 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011387 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011388 /*set gen ie*/
11389 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
11390 /*set auth*/
11391 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
11392 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011393#ifdef FEATURE_WLAN_WAPI
11394 if (pAdapter->wapi_info.nWapiMode)
11395 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011396 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011397 switch (pAdapter->wapi_info.wapiAuthMode)
11398 {
11399 case WAPI_AUTH_MODE_PSK:
11400 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011401 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011402 pAdapter->wapi_info.wapiAuthMode);
11403 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
11404 break;
11405 }
11406 case WAPI_AUTH_MODE_CERT:
11407 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011408 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011409 pAdapter->wapi_info.wapiAuthMode);
11410 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
11411 break;
11412 }
11413 } // End of switch
11414 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
11415 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
11416 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011417 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011418 pRoamProfile->AuthType.numEntries = 1;
11419 pRoamProfile->EncryptionType.numEntries = 1;
11420 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11421 pRoamProfile->mcEncryptionType.numEntries = 1;
11422 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11423 }
11424 }
11425#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011426#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011427 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011428 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11429 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
11430 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011431 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
11432 sizeof (tSirGtkOffloadParams));
11433 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011434 }
11435#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011436 pRoamProfile->csrPersona = pAdapter->device_mode;
11437
Jeff Johnson32d95a32012-09-10 13:15:23 -070011438 if( operatingChannel )
11439 {
11440 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
11441 pRoamProfile->ChannelInfo.numOfChannels = 1;
11442 }
Chet Lanctot186b5732013-03-18 10:26:30 -070011443 else
11444 {
11445 pRoamProfile->ChannelInfo.ChannelList = NULL;
11446 pRoamProfile->ChannelInfo.numOfChannels = 0;
11447 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011448 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
11449 {
11450 hdd_select_cbmode(pAdapter,operatingChannel);
11451 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011452
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011453 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
11454 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011455 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011456 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011457 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
11458 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011459 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11460 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053011461 {
11462 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11463 "%s: Set HDD connState to eConnectionState_Connecting",
11464 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011465 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
11466 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053011467 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011468 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011469 pAdapter->sessionId, pRoamProfile, &roamId);
11470
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011471 if ((eHAL_STATUS_SUCCESS != status) &&
11472 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11473 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011474
11475 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011476 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
11477 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
11478 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011479 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011480 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011481 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011482
11483 pRoamProfile->ChannelInfo.ChannelList = NULL;
11484 pRoamProfile->ChannelInfo.numOfChannels = 0;
11485
Jeff Johnson295189b2012-06-20 16:38:30 -070011486 }
11487 else
11488 {
11489 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
11490 return -EINVAL;
11491 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080011492 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011493 return status;
11494}
11495
11496/*
11497 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
11498 * This function is used to set the authentication type (OPEN/SHARED).
11499 *
11500 */
11501static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
11502 enum nl80211_auth_type auth_type)
11503{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011504 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011505 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11506
11507 ENTER();
11508
11509 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011510 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070011511 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011512 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011513 hddLog(VOS_TRACE_LEVEL_INFO,
11514 "%s: set authentication type to AUTOSWITCH", __func__);
11515 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
11516 break;
11517
11518 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011519#ifdef WLAN_FEATURE_VOWIFI_11R
11520 case NL80211_AUTHTYPE_FT:
11521#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011522 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011523 "%s: set authentication type to OPEN", __func__);
11524 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11525 break;
11526
11527 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011528 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011529 "%s: set authentication type to SHARED", __func__);
11530 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
11531 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011532#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011533 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011534 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011535 "%s: set authentication type to CCKM WPA", __func__);
11536 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
11537 break;
11538#endif
11539
11540
11541 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011542 hddLog(VOS_TRACE_LEVEL_ERROR,
11543 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011544 auth_type);
11545 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
11546 return -EINVAL;
11547 }
11548
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011549 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011550 pHddStaCtx->conn_info.authType;
11551 return 0;
11552}
11553
11554/*
11555 * FUNCTION: wlan_hdd_set_akm_suite
11556 * This function is used to set the key mgmt type(PSK/8021x).
11557 *
11558 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011559static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011560 u32 key_mgmt
11561 )
11562{
11563 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11564 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053011565 /* Should be in ieee802_11_defs.h */
11566#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
11567#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070011568 /*set key mgmt type*/
11569 switch(key_mgmt)
11570 {
11571 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053011572 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011573#ifdef WLAN_FEATURE_VOWIFI_11R
11574 case WLAN_AKM_SUITE_FT_PSK:
11575#endif
11576 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070011577 __func__);
11578 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
11579 break;
11580
11581 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053011582 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011583#ifdef WLAN_FEATURE_VOWIFI_11R
11584 case WLAN_AKM_SUITE_FT_8021X:
11585#endif
11586 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011587 __func__);
11588 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11589 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011590#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011591#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
11592#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
11593 case WLAN_AKM_SUITE_CCKM:
11594 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
11595 __func__);
11596 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
11597 break;
11598#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070011599#ifndef WLAN_AKM_SUITE_OSEN
11600#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
11601 case WLAN_AKM_SUITE_OSEN:
11602 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
11603 __func__);
11604 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11605 break;
11606#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011607
11608 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011609 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011610 __func__, key_mgmt);
11611 return -EINVAL;
11612
11613 }
11614 return 0;
11615}
11616
11617/*
11618 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011619 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070011620 * (NONE/WEP40/WEP104/TKIP/CCMP).
11621 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011622static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
11623 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070011624 bool ucast
11625 )
11626{
11627 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011628 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011629 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11630
11631 ENTER();
11632
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011633 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011634 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053011635 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070011636 __func__, cipher);
11637 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11638 }
11639 else
11640 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011641
Jeff Johnson295189b2012-06-20 16:38:30 -070011642 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011643 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011644 {
11645 case IW_AUTH_CIPHER_NONE:
11646 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11647 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011648
Jeff Johnson295189b2012-06-20 16:38:30 -070011649 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011650 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070011651 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011652
Jeff Johnson295189b2012-06-20 16:38:30 -070011653 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011654 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070011655 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011656
Jeff Johnson295189b2012-06-20 16:38:30 -070011657 case WLAN_CIPHER_SUITE_TKIP:
11658 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
11659 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011660
Jeff Johnson295189b2012-06-20 16:38:30 -070011661 case WLAN_CIPHER_SUITE_CCMP:
11662 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11663 break;
11664#ifdef FEATURE_WLAN_WAPI
11665 case WLAN_CIPHER_SUITE_SMS4:
11666 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
11667 break;
11668#endif
11669
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011670#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011671 case WLAN_CIPHER_SUITE_KRK:
11672 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
11673 break;
11674#endif
11675 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011676 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011677 __func__, cipher);
11678 return -EOPNOTSUPP;
11679 }
11680 }
11681
11682 if (ucast)
11683 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011684 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011685 __func__, encryptionType);
11686 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11687 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011688 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011689 encryptionType;
11690 }
11691 else
11692 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011693 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011694 __func__, encryptionType);
11695 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
11696 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
11697 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
11698 }
11699
11700 return 0;
11701}
11702
11703
11704/*
11705 * FUNCTION: wlan_hdd_cfg80211_set_ie
11706 * This function is used to parse WPA/RSN IE's.
11707 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011708int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011709#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11710 const u8 *ie,
11711#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011712 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011713#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011714 size_t ie_len
11715 )
11716{
11717 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011718#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11719 const u8 *genie = ie;
11720#else
Jeff Johnson295189b2012-06-20 16:38:30 -070011721 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011722#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011723 v_U16_t remLen = ie_len;
11724#ifdef FEATURE_WLAN_WAPI
11725 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
11726 u16 *tmp;
11727 v_U16_t akmsuiteCount;
11728 int *akmlist;
11729#endif
11730 ENTER();
11731
11732 /* clear previous assocAddIE */
11733 pWextState->assocAddIE.length = 0;
11734 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011735 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011736
11737 while (remLen >= 2)
11738 {
11739 v_U16_t eLen = 0;
11740 v_U8_t elementId;
11741 elementId = *genie++;
11742 eLen = *genie++;
11743 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011744
Arif Hussain6d2a3322013-11-17 19:50:10 -080011745 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070011746 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011747
11748 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070011749 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011750 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011751 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 -070011752 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011753 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011754 "%s: Invalid WPA IE", __func__);
11755 return -EINVAL;
11756 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011757 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070011758 {
11759 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011760 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011761 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011762
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011763 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011764 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011765 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
11766 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011767 VOS_ASSERT(0);
11768 return -ENOMEM;
11769 }
11770 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11771 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11772 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011773
Jeff Johnson295189b2012-06-20 16:38:30 -070011774 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
11775 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11776 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11777 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011778 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
11779 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011780 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
11781 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11782 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
11783 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
11784 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
11785 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011786 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053011787 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070011788 {
11789 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011790 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011791 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011792
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011793 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011794 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011795 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11796 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011797 VOS_ASSERT(0);
11798 return -ENOMEM;
11799 }
11800 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11801 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11802 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011803
Jeff Johnson295189b2012-06-20 16:38:30 -070011804 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11805 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11806 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011807#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011808 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
11809 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011810 /*Consider WFD IE, only for P2P Client */
11811 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
11812 {
11813 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011814 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011815 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011816
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011817 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011818 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011819 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11820 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011821 VOS_ASSERT(0);
11822 return -ENOMEM;
11823 }
11824 // WFD IE is saved to Additional IE ; it should be accumulated to handle
11825 // WPS IE + P2P IE + WFD IE
11826 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11827 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011828
Jeff Johnson295189b2012-06-20 16:38:30 -070011829 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11830 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11831 }
11832#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011833 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011834 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011835 HS20_OUI_TYPE_SIZE)) )
11836 {
11837 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011838 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011839 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011840
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011841 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011842 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011843 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11844 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011845 VOS_ASSERT(0);
11846 return -ENOMEM;
11847 }
11848 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11849 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011850
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011851 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11852 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11853 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011854 /* Appending OSEN Information Element in Assiciation Request */
11855 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
11856 OSEN_OUI_TYPE_SIZE)) )
11857 {
11858 v_U16_t curAddIELen = pWextState->assocAddIE.length;
11859 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
11860 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011861
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011862 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011863 {
11864 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11865 "Need bigger buffer space");
11866 VOS_ASSERT(0);
11867 return -ENOMEM;
11868 }
11869 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11870 pWextState->assocAddIE.length += eLen + 2;
11871
11872 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
11873 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11874 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11875 }
11876
Abhishek Singh4322e622015-06-10 15:42:54 +053011877 /* Update only for WPA IE */
11878 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
11879 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011880
11881 /* populating as ADDIE in beacon frames */
11882 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011883 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011884 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
11885 {
11886 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11887 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
11888 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11889 {
11890 hddLog(LOGE,
11891 "Coldn't pass "
11892 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
11893 }
11894 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
11895 else
11896 hddLog(LOGE,
11897 "Could not pass on "
11898 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
11899
11900 /* IBSS mode doesn't contain params->proberesp_ies still
11901 beaconIE's need to be populated in probe response frames */
11902 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
11903 {
11904 u16 rem_probe_resp_ie_len = eLen + 2;
11905 u8 probe_rsp_ie_len[3] = {0};
11906 u8 counter = 0;
11907
11908 /* Check Probe Resp Length if it is greater then 255 then
11909 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
11910 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
11911 not able Store More then 255 bytes into One Variable */
11912
11913 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
11914 {
11915 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
11916 {
11917 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
11918 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
11919 }
11920 else
11921 {
11922 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
11923 rem_probe_resp_ie_len = 0;
11924 }
11925 }
11926
11927 rem_probe_resp_ie_len = 0;
11928
11929 if (probe_rsp_ie_len[0] > 0)
11930 {
11931 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11932 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
11933 (tANI_U8*)(genie - 2),
11934 probe_rsp_ie_len[0], NULL,
11935 eANI_BOOLEAN_FALSE)
11936 == eHAL_STATUS_FAILURE)
11937 {
11938 hddLog(LOGE,
11939 "Could not pass"
11940 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
11941 }
11942 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
11943 }
11944
11945 if (probe_rsp_ie_len[1] > 0)
11946 {
11947 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11948 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
11949 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11950 probe_rsp_ie_len[1], NULL,
11951 eANI_BOOLEAN_FALSE)
11952 == eHAL_STATUS_FAILURE)
11953 {
11954 hddLog(LOGE,
11955 "Could not pass"
11956 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
11957 }
11958 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
11959 }
11960
11961 if (probe_rsp_ie_len[2] > 0)
11962 {
11963 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11964 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
11965 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11966 probe_rsp_ie_len[2], NULL,
11967 eANI_BOOLEAN_FALSE)
11968 == eHAL_STATUS_FAILURE)
11969 {
11970 hddLog(LOGE,
11971 "Could not pass"
11972 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
11973 }
11974 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
11975 }
11976
11977 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11978 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
11979 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11980 {
11981 hddLog(LOGE,
11982 "Could not pass"
11983 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
11984 }
11985 }
11986 else
11987 {
11988 // Reset WNI_CFG_PROBE_RSP Flags
11989 wlan_hdd_reset_prob_rspies(pAdapter);
11990
11991 hddLog(VOS_TRACE_LEVEL_INFO,
11992 "%s: No Probe Response IE received in set beacon",
11993 __func__);
11994 }
11995 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070011996 break;
11997 case DOT11F_EID_RSN:
11998 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
11999 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
12000 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
12001 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
12002 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
12003 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053012004
12005 /* Appending Extended Capabilities with Interworking bit set
12006 * in Assoc Req.
12007 *
12008 * In assoc req this EXT Cap will only be taken into account if
12009 * interworkingService bit is set to 1. Currently
12010 * driver is only interested in interworkingService capability
12011 * from supplicant. If in future any other EXT Cap info is
12012 * required from supplicat, it needs to be handled while
12013 * sending Assoc Req in LIM.
12014 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012015 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012016 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012017 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012018 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012019 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012020
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053012021 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012022 {
Jeff Johnson902c9832012-12-10 14:28:09 -080012023 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
12024 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012025 VOS_ASSERT(0);
12026 return -ENOMEM;
12027 }
12028 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
12029 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012030
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012031 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
12032 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
12033 break;
12034 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012035#ifdef FEATURE_WLAN_WAPI
12036 case WLAN_EID_WAPI:
12037 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070012038 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070012039 pAdapter->wapi_info.nWapiMode);
12040 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012041 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070012042 akmsuiteCount = WPA_GET_LE16(tmp);
12043 tmp = tmp + 1;
12044 akmlist = (int *)(tmp);
12045 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
12046 {
12047 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
12048 }
12049 else
12050 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012051 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070012052 VOS_ASSERT(0);
12053 return -EINVAL;
12054 }
12055
12056 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
12057 {
12058 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012059 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012060 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012061 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012062 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012063 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012064 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012065 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012066 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
12067 }
12068 break;
12069#endif
12070 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012071 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012072 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012073 /* when Unknown IE is received we should break and continue
12074 * to the next IE in the buffer instead we were returning
12075 * so changing this to break */
12076 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012077 }
12078 genie += eLen;
12079 remLen -= eLen;
12080 }
12081 EXIT();
12082 return 0;
12083}
12084
12085/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053012086 * FUNCTION: hdd_isWPAIEPresent
12087 * Parse the received IE to find the WPA IE
12088 *
12089 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012090static bool hdd_isWPAIEPresent(
12091#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
12092 const u8 *ie,
12093#else
12094 u8 *ie,
12095#endif
12096 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053012097{
12098 v_U8_t eLen = 0;
12099 v_U16_t remLen = ie_len;
12100 v_U8_t elementId = 0;
12101
12102 while (remLen >= 2)
12103 {
12104 elementId = *ie++;
12105 eLen = *ie++;
12106 remLen -= 2;
12107 if (eLen > remLen)
12108 {
12109 hddLog(VOS_TRACE_LEVEL_ERROR,
12110 "%s: IE length is wrong %d", __func__, eLen);
12111 return FALSE;
12112 }
12113 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
12114 {
12115 /* OUI - 0x00 0X50 0XF2
12116 WPA Information Element - 0x01
12117 WPA version - 0x01*/
12118 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
12119 return TRUE;
12120 }
12121 ie += eLen;
12122 remLen -= eLen;
12123 }
12124 return FALSE;
12125}
12126
12127/*
Jeff Johnson295189b2012-06-20 16:38:30 -070012128 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012129 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012130 * parameters during connect operation.
12131 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012132int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012133 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012134 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012135{
12136 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012137 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012138 ENTER();
12139
12140 /*set wpa version*/
12141 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
12142
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012143 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070012144 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053012145 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070012146 {
12147 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12148 }
12149 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
12150 {
12151 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12152 }
12153 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012154
12155 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012156 pWextState->wpaVersion);
12157
12158 /*set authentication type*/
12159 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
12160
12161 if (0 > status)
12162 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012163 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012164 "%s: failed to set authentication type ", __func__);
12165 return status;
12166 }
12167
12168 /*set key mgmt type*/
12169 if (req->crypto.n_akm_suites)
12170 {
12171 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
12172 if (0 > status)
12173 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012174 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070012175 __func__);
12176 return status;
12177 }
12178 }
12179
12180 /*set pairwise cipher type*/
12181 if (req->crypto.n_ciphers_pairwise)
12182 {
12183 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
12184 req->crypto.ciphers_pairwise[0], true);
12185 if (0 > status)
12186 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012187 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012188 "%s: failed to set unicast cipher type", __func__);
12189 return status;
12190 }
12191 }
12192 else
12193 {
12194 /*Reset previous cipher suite to none*/
12195 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
12196 if (0 > status)
12197 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012198 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012199 "%s: failed to set unicast cipher type", __func__);
12200 return status;
12201 }
12202 }
12203
12204 /*set group cipher type*/
12205 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
12206 false);
12207
12208 if (0 > status)
12209 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012210 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070012211 __func__);
12212 return status;
12213 }
12214
Chet Lanctot186b5732013-03-18 10:26:30 -070012215#ifdef WLAN_FEATURE_11W
12216 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
12217#endif
12218
Jeff Johnson295189b2012-06-20 16:38:30 -070012219 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
12220 if (req->ie_len)
12221 {
12222 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
12223 if ( 0 > status)
12224 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012225 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012226 __func__);
12227 return status;
12228 }
12229 }
12230
12231 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012232 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012233 {
12234 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
12235 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
12236 )
12237 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012238 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070012239 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
12240 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012241 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012242 __func__);
12243 return -EOPNOTSUPP;
12244 }
12245 else
12246 {
12247 u8 key_len = req->key_len;
12248 u8 key_idx = req->key_idx;
12249
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012250 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012251 && (CSR_MAX_NUM_KEY > key_idx)
12252 )
12253 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012254 hddLog(VOS_TRACE_LEVEL_INFO,
12255 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012256 __func__, key_idx, key_len);
12257 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012258 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012259 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012260 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070012261 (u8)key_len;
12262 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
12263 }
12264 }
12265 }
12266 }
12267
12268 return status;
12269}
12270
12271/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012272 * FUNCTION: wlan_hdd_try_disconnect
12273 * This function is used to disconnect from previous
12274 * connection
12275 */
12276static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
12277{
12278 long ret = 0;
12279 hdd_station_ctx_t *pHddStaCtx;
12280 eMib_dot11DesiredBssType connectedBssType;
12281
12282 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12283
12284 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
12285
12286 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
12287 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
12288 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
12289 {
12290 /* Issue disconnect to CSR */
12291 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12292 if( eHAL_STATUS_SUCCESS ==
12293 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12294 pAdapter->sessionId,
12295 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
12296 {
12297 ret = wait_for_completion_interruptible_timeout(
12298 &pAdapter->disconnect_comp_var,
12299 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12300 if (0 >= ret)
12301 {
12302 hddLog(LOGE, FL("Failed to receive disconnect event"));
12303 return -EALREADY;
12304 }
12305 }
12306 }
12307 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
12308 {
12309 ret = wait_for_completion_interruptible_timeout(
12310 &pAdapter->disconnect_comp_var,
12311 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12312 if (0 >= ret)
12313 {
12314 hddLog(LOGE, FL("Failed to receive disconnect event"));
12315 return -EALREADY;
12316 }
12317 }
12318
12319 return 0;
12320}
12321
12322/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053012323 * FUNCTION: __wlan_hdd_cfg80211_connect
12324 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070012325 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012326static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012327 struct net_device *ndev,
12328 struct cfg80211_connect_params *req
12329 )
12330{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012331 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012332 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012333 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053012334 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012335
12336 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012337
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012338 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12339 TRACE_CODE_HDD_CFG80211_CONNECT,
12340 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012341 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012342 "%s: device_mode = %s (%d)", __func__,
12343 hdd_device_modetoString(pAdapter->device_mode),
12344 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012345
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012346 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012347 if (!pHddCtx)
12348 {
12349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12350 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053012351 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012352 }
12353
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012354 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012355 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012356 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012357 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012358 }
12359
Agarwal Ashish51325b52014-06-16 16:50:49 +053012360 if (vos_max_concurrent_connections_reached()) {
12361 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12362 return -ECONNREFUSED;
12363 }
12364
Jeff Johnson295189b2012-06-20 16:38:30 -070012365#ifdef WLAN_BTAMP_FEATURE
12366 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012367 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070012368 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012369 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012370 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080012371 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012372 }
12373#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012374
12375 //If Device Mode is Station Concurrent Sessions Exit BMps
12376 //P2P Mode will be taken care in Open/close adapter
12377 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012378 (vos_concurrent_open_sessions_running())) {
12379 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
12380 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012381 }
12382
12383 /*Try disconnecting if already in connected state*/
12384 status = wlan_hdd_try_disconnect(pAdapter);
12385 if ( 0 > status)
12386 {
12387 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12388 " connection"));
12389 return -EALREADY;
12390 }
12391
Jeff Johnson295189b2012-06-20 16:38:30 -070012392 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012393 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070012394
12395 if ( 0 > status)
12396 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012397 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070012398 __func__);
12399 return status;
12400 }
Mohit Khanna765234a2012-09-11 15:08:35 -070012401 if ( req->channel )
12402 {
12403 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
12404 req->ssid_len, req->bssid,
12405 req->channel->hw_value);
12406 }
12407 else
12408 {
12409 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012410 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070012411 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012412
Sushant Kaushikd7083982015-03-18 14:33:24 +053012413 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012414 {
12415 //ReEnable BMPS if disabled
12416 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
12417 (NULL != pHddCtx))
12418 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012419 if (pHddCtx->hdd_wlan_suspended)
12420 {
12421 hdd_set_pwrparams(pHddCtx);
12422 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012423 //ReEnable Bmps and Imps back
12424 hdd_enable_bmps_imps(pHddCtx);
12425 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053012426 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012427 return status;
12428 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012429 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012430 EXIT();
12431 return status;
12432}
12433
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012434static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
12435 struct net_device *ndev,
12436 struct cfg80211_connect_params *req)
12437{
12438 int ret;
12439 vos_ssr_protect(__func__);
12440 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
12441 vos_ssr_unprotect(__func__);
12442
12443 return ret;
12444}
Jeff Johnson295189b2012-06-20 16:38:30 -070012445
12446/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012447 * FUNCTION: wlan_hdd_disconnect
12448 * This function is used to issue a disconnect request to SME
12449 */
12450int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
12451{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012452 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012453 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012454 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012455 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012456
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012457 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012458
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012459 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012460 if (0 != status)
12461 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012462 return status;
12463 }
12464
Sushant Kaushikb4834d22015-07-15 15:29:05 +053012465 if (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)
12466 {
12467 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
12468 pAdapter->sessionId);
12469 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012470 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012471
Agarwal Ashish47d18112014-08-04 19:55:07 +053012472 /* Need to apply spin lock before decreasing active sessions
12473 * as there can be chance for double decrement if context switch
12474 * Calls hdd_DisConnectHandler.
12475 */
12476
12477 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012478 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
12479 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012480 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
12481 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053012482 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
12483 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012484
Abhishek Singhf4669da2014-05-26 15:07:49 +053012485 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053012486 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
12487
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012488 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012489
Mihir Shete182a0b22014-08-18 16:08:48 +053012490 /*
12491 * stop tx queues before deleting STA/BSS context from the firmware.
12492 * tx has to be disabled because the firmware can get busy dropping
12493 * the tx frames after BSS/STA has been deleted and will not send
12494 * back a response resulting in WDI timeout
12495 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053012496 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053012497 netif_tx_disable(pAdapter->dev);
12498 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012499
Mihir Shete182a0b22014-08-18 16:08:48 +053012500 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012501 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12502 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012503 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
12504 {
12505 hddLog(VOS_TRACE_LEVEL_INFO,
12506 FL("status = %d, already disconnected"),
12507 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012508
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012509 }
12510 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012511 {
12512 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012513 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012514 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012515 result = -EINVAL;
12516 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012517 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012518 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012519 &pAdapter->disconnect_comp_var,
12520 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012521 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012522 {
12523 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012524 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012525 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012526 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012527 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012528 {
12529 hddLog(VOS_TRACE_LEVEL_ERROR,
12530 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012531 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012532 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012533disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012534 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12535 FL("Set HDD connState to eConnectionState_NotConnected"));
12536 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
12537
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012538 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012539 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012540}
12541
12542
12543/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012544 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070012545 * This function is used to issue a disconnect request to SME
12546 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012547static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012548 struct net_device *dev,
12549 u16 reason
12550 )
12551{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012552 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012553 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012554 tCsrRoamProfile *pRoamProfile;
12555 hdd_station_ctx_t *pHddStaCtx;
12556 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012557#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012558 tANI_U8 staIdx;
12559#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012560
Jeff Johnson295189b2012-06-20 16:38:30 -070012561 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012562
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012563 if (!pAdapter) {
12564 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
12565 return -EINVAL;
12566 }
12567
12568 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12569 if (!pHddStaCtx) {
12570 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
12571 return -EINVAL;
12572 }
12573
12574 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12575 status = wlan_hdd_validate_context(pHddCtx);
12576 if (0 != status)
12577 {
12578 return status;
12579 }
12580
12581 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
12582
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012583 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12584 TRACE_CODE_HDD_CFG80211_DISCONNECT,
12585 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012586 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
12587 __func__, hdd_device_modetoString(pAdapter->device_mode),
12588 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012589
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012590 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
12591 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070012592
Jeff Johnson295189b2012-06-20 16:38:30 -070012593 if (NULL != pRoamProfile)
12594 {
12595 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012596 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
12597 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070012598 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012599 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070012600 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012601 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012602 switch(reason)
12603 {
12604 case WLAN_REASON_MIC_FAILURE:
12605 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
12606 break;
12607
12608 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
12609 case WLAN_REASON_DISASSOC_AP_BUSY:
12610 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
12611 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
12612 break;
12613
12614 case WLAN_REASON_PREV_AUTH_NOT_VALID:
12615 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053012616 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070012617 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
12618 break;
12619
Jeff Johnson295189b2012-06-20 16:38:30 -070012620 default:
12621 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
12622 break;
12623 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012624 pScanInfo = &pHddCtx->scan_info;
12625 if (pScanInfo->mScanPending)
12626 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012627 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012628 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053012629 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012630 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012631 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053012632 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012633#ifdef FEATURE_WLAN_TDLS
12634 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012635 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012636 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012637 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
12638 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012639 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012640 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012641 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012642 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012643 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012644 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012645 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012646 status = sme_DeleteTdlsPeerSta(
12647 WLAN_HDD_GET_HAL_CTX(pAdapter),
12648 pAdapter->sessionId,
12649 mac);
12650 if (status != eHAL_STATUS_SUCCESS) {
12651 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
12652 return -EPERM;
12653 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012654 }
12655 }
12656#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012657 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012658 status = wlan_hdd_disconnect(pAdapter, reasonCode);
12659 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070012660 {
12661 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012662 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012663 __func__, (int)status );
12664 return -EINVAL;
12665 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012666 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012667 else
12668 {
12669 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
12670 "called while in %d state", __func__,
12671 pHddStaCtx->conn_info.connState);
12672 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012673 }
12674 else
12675 {
12676 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
12677 }
12678
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012679 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012680 return status;
12681}
12682
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012683static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
12684 struct net_device *dev,
12685 u16 reason
12686 )
12687{
12688 int ret;
12689 vos_ssr_protect(__func__);
12690 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
12691 vos_ssr_unprotect(__func__);
12692
12693 return ret;
12694}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012695
Jeff Johnson295189b2012-06-20 16:38:30 -070012696/*
12697 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012698 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012699 * settings in IBSS mode.
12700 */
12701static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012702 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012703 struct cfg80211_ibss_params *params
12704 )
12705{
12706 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012707 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012708 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
12709 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012710
Jeff Johnson295189b2012-06-20 16:38:30 -070012711 ENTER();
12712
12713 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070012714 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070012715
12716 if (params->ie_len && ( NULL != params->ie) )
12717 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012718 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12719 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012720 {
12721 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12722 encryptionType = eCSR_ENCRYPT_TYPE_AES;
12723 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012724 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012725 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012726 tDot11fIEWPA dot11WPAIE;
12727 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012728 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012729
Wilson Yang00256342013-10-10 23:13:38 -070012730 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012731 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12732 params->ie_len, DOT11F_EID_WPA);
12733 if ( NULL != ie )
12734 {
12735 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12736 // Unpack the WPA IE
12737 //Skip past the EID byte and length byte - and four byte WiFi OUI
12738 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
12739 &ie[2+4],
12740 ie[1] - 4,
12741 &dot11WPAIE);
12742 /*Extract the multicast cipher, the encType for unicast
12743 cipher for wpa-none is none*/
12744 encryptionType =
12745 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
12746 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012747 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012748
Jeff Johnson295189b2012-06-20 16:38:30 -070012749 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
12750
12751 if (0 > status)
12752 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012753 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012754 __func__);
12755 return status;
12756 }
12757 }
12758
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012759 pWextState->roamProfile.AuthType.authType[0] =
12760 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012761 eCSR_AUTH_TYPE_OPEN_SYSTEM;
12762
12763 if (params->privacy)
12764 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012765 /* Security enabled IBSS, At this time there is no information available
12766 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070012767 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012768 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070012769 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012770 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070012771 *enable privacy bit in beacons */
12772
12773 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
12774 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012775 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
12776 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012777 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
12778 pWextState->roamProfile.EncryptionType.numEntries = 1;
12779 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012780 return status;
12781}
12782
12783/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012784 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012785 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012786 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012787static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012788 struct net_device *dev,
12789 struct cfg80211_ibss_params *params
12790 )
12791{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012792 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012793 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12794 tCsrRoamProfile *pRoamProfile;
12795 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012796 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12797 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012798 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070012799
12800 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012801
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012802 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12803 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
12804 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012805 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012806 "%s: device_mode = %s (%d)", __func__,
12807 hdd_device_modetoString(pAdapter->device_mode),
12808 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012809
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012810 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012811 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012812 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012813 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012814 }
12815
12816 if (NULL == pWextState)
12817 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012818 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012819 __func__);
12820 return -EIO;
12821 }
12822
Agarwal Ashish51325b52014-06-16 16:50:49 +053012823 if (vos_max_concurrent_connections_reached()) {
12824 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12825 return -ECONNREFUSED;
12826 }
12827
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012828 /*Try disconnecting if already in connected state*/
12829 status = wlan_hdd_try_disconnect(pAdapter);
12830 if ( 0 > status)
12831 {
12832 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12833 " IBSS connection"));
12834 return -EALREADY;
12835 }
12836
Jeff Johnson295189b2012-06-20 16:38:30 -070012837 pRoamProfile = &pWextState->roamProfile;
12838
12839 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
12840 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012841 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012842 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012843 return -EINVAL;
12844 }
12845
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012846 /* BSSID is provided by upper layers hence no need to AUTO generate */
12847 if (NULL != params->bssid) {
12848 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12849 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
12850 hddLog (VOS_TRACE_LEVEL_ERROR,
12851 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12852 return -EIO;
12853 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012854 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012855 }
krunal sonie9002db2013-11-25 14:24:17 -080012856 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
12857 {
12858 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12859 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
12860 {
12861 hddLog (VOS_TRACE_LEVEL_ERROR,
12862 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12863 return -EIO;
12864 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012865
12866 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080012867 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012868 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080012869 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012870
Jeff Johnson295189b2012-06-20 16:38:30 -070012871 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070012872 if (NULL !=
12873#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12874 params->chandef.chan)
12875#else
12876 params->channel)
12877#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012878 {
12879 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012880 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12881 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
12882 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12883 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012884
12885 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012886 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070012887 ieee80211_frequency_to_channel(
12888#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12889 params->chandef.chan->center_freq);
12890#else
12891 params->channel->center_freq);
12892#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012893
12894 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
12895 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070012896 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012897 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
12898 __func__);
12899 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070012900 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012901
12902 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012903 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012904 if (channelNum == validChan[indx])
12905 {
12906 break;
12907 }
12908 }
12909 if (indx >= numChans)
12910 {
12911 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012912 __func__, channelNum);
12913 return -EINVAL;
12914 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012915 /* Set the Operational Channel */
12916 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
12917 channelNum);
12918 pRoamProfile->ChannelInfo.numOfChannels = 1;
12919 pHddStaCtx->conn_info.operationChannel = channelNum;
12920 pRoamProfile->ChannelInfo.ChannelList =
12921 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070012922 }
12923
12924 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012925 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070012926 if (status < 0)
12927 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012928 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070012929 __func__);
12930 return status;
12931 }
12932
12933 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012934 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012935 params->ssid_len, params->bssid,
12936 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070012937
12938 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012939 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012940
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012941 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012942 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012943}
12944
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012945static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
12946 struct net_device *dev,
12947 struct cfg80211_ibss_params *params
12948 )
12949{
12950 int ret = 0;
12951
12952 vos_ssr_protect(__func__);
12953 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
12954 vos_ssr_unprotect(__func__);
12955
12956 return ret;
12957}
12958
Jeff Johnson295189b2012-06-20 16:38:30 -070012959/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012960 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012961 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012962 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012963static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012964 struct net_device *dev
12965 )
12966{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012967 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012968 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12969 tCsrRoamProfile *pRoamProfile;
12970 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012971 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012972
12973 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012974
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012975 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12976 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
12977 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012978 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012979 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012980 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012981 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012982 }
12983
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012984 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
12985 hdd_device_modetoString(pAdapter->device_mode),
12986 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012987 if (NULL == pWextState)
12988 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012989 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012990 __func__);
12991 return -EIO;
12992 }
12993
12994 pRoamProfile = &pWextState->roamProfile;
12995
12996 /* Issue disconnect only if interface type is set to IBSS */
12997 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
12998 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012999 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070013000 __func__);
13001 return -EINVAL;
13002 }
13003
13004 /* Issue Disconnect request */
13005 INIT_COMPLETION(pAdapter->disconnect_comp_var);
13006 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
13007 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
13008
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013009 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013010 return 0;
13011}
13012
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013013static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
13014 struct net_device *dev
13015 )
13016{
13017 int ret = 0;
13018
13019 vos_ssr_protect(__func__);
13020 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
13021 vos_ssr_unprotect(__func__);
13022
13023 return ret;
13024}
13025
Jeff Johnson295189b2012-06-20 16:38:30 -070013026/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013027 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070013028 * This function is used to set the phy parameters
13029 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
13030 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013031static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013032 u32 changed)
13033{
13034 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
13035 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013036 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013037
13038 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013039
13040 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013041 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
13042 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013043
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013044 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013045 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013046 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013047 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013048 }
13049
Jeff Johnson295189b2012-06-20 16:38:30 -070013050 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
13051 {
13052 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
13053 WNI_CFG_RTS_THRESHOLD_STAMAX :
13054 wiphy->rts_threshold;
13055
13056 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013057 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070013058 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013059 hddLog(VOS_TRACE_LEVEL_ERROR,
13060 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013061 __func__, rts_threshold);
13062 return -EINVAL;
13063 }
13064
13065 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
13066 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013067 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013068 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013069 hddLog(VOS_TRACE_LEVEL_ERROR,
13070 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013071 __func__, rts_threshold);
13072 return -EIO;
13073 }
13074
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013075 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013076 rts_threshold);
13077 }
13078
13079 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
13080 {
13081 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
13082 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
13083 wiphy->frag_threshold;
13084
13085 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013086 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013087 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013088 hddLog(VOS_TRACE_LEVEL_ERROR,
13089 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013090 frag_threshold);
13091 return -EINVAL;
13092 }
13093
13094 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
13095 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013096 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013097 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013098 hddLog(VOS_TRACE_LEVEL_ERROR,
13099 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013100 __func__, frag_threshold);
13101 return -EIO;
13102 }
13103
13104 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
13105 frag_threshold);
13106 }
13107
13108 if ((changed & WIPHY_PARAM_RETRY_SHORT)
13109 || (changed & WIPHY_PARAM_RETRY_LONG))
13110 {
13111 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
13112 wiphy->retry_short :
13113 wiphy->retry_long;
13114
13115 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
13116 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
13117 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013118 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013119 __func__, retry_value);
13120 return -EINVAL;
13121 }
13122
13123 if (changed & WIPHY_PARAM_RETRY_SHORT)
13124 {
13125 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
13126 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013127 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013128 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013129 hddLog(VOS_TRACE_LEVEL_ERROR,
13130 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013131 __func__, retry_value);
13132 return -EIO;
13133 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013134 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013135 __func__, retry_value);
13136 }
13137 else if (changed & WIPHY_PARAM_RETRY_SHORT)
13138 {
13139 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
13140 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013141 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013142 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013143 hddLog(VOS_TRACE_LEVEL_ERROR,
13144 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013145 __func__, retry_value);
13146 return -EIO;
13147 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013148 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013149 __func__, retry_value);
13150 }
13151 }
13152
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013153 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013154 return 0;
13155}
13156
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013157static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
13158 u32 changed)
13159{
13160 int ret;
13161
13162 vos_ssr_protect(__func__);
13163 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
13164 vos_ssr_unprotect(__func__);
13165
13166 return ret;
13167}
13168
Jeff Johnson295189b2012-06-20 16:38:30 -070013169/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013170 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013171 * This function is used to set the txpower
13172 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013173static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013174#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13175 struct wireless_dev *wdev,
13176#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013177#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013178 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013179#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013180 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013181#endif
13182 int dbm)
13183{
13184 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013185 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013186 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
13187 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013188 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013189
13190 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013191
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013192 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13193 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
13194 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013195 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013196 if (0 != status)
13197 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013198 return status;
13199 }
13200
13201 hHal = pHddCtx->hHal;
13202
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013203 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
13204 dbm, ccmCfgSetCallback,
13205 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013206 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013207 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013208 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
13209 return -EIO;
13210 }
13211
13212 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
13213 dbm);
13214
13215 switch(type)
13216 {
13217 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
13218 /* Fall through */
13219 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
13220 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
13221 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013222 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
13223 __func__);
13224 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070013225 }
13226 break;
13227 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013228 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070013229 __func__);
13230 return -EOPNOTSUPP;
13231 break;
13232 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013233 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
13234 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070013235 return -EIO;
13236 }
13237
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013238 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013239 return 0;
13240}
13241
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013242static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
13243#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13244 struct wireless_dev *wdev,
13245#endif
13246#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13247 enum tx_power_setting type,
13248#else
13249 enum nl80211_tx_power_setting type,
13250#endif
13251 int dbm)
13252{
13253 int ret;
13254 vos_ssr_protect(__func__);
13255 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
13256#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13257 wdev,
13258#endif
13259#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13260 type,
13261#else
13262 type,
13263#endif
13264 dbm);
13265 vos_ssr_unprotect(__func__);
13266
13267 return ret;
13268}
13269
Jeff Johnson295189b2012-06-20 16:38:30 -070013270/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013271 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013272 * This function is used to read the txpower
13273 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013274static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013275#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13276 struct wireless_dev *wdev,
13277#endif
13278 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070013279{
13280
13281 hdd_adapter_t *pAdapter;
13282 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013283 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013284
Jeff Johnsone7245742012-09-05 17:12:55 -070013285 ENTER();
13286
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013287 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013288 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013289 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013290 *dbm = 0;
13291 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013292 }
13293
Jeff Johnson295189b2012-06-20 16:38:30 -070013294 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
13295 if (NULL == pAdapter)
13296 {
13297 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
13298 return -ENOENT;
13299 }
13300
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053013301 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13302 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
13303 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070013304 wlan_hdd_get_classAstats(pAdapter);
13305 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
13306
Jeff Johnsone7245742012-09-05 17:12:55 -070013307 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013308 return 0;
13309}
13310
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013311static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
13312#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13313 struct wireless_dev *wdev,
13314#endif
13315 int *dbm)
13316{
13317 int ret;
13318
13319 vos_ssr_protect(__func__);
13320 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
13321#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13322 wdev,
13323#endif
13324 dbm);
13325 vos_ssr_unprotect(__func__);
13326
13327 return ret;
13328}
13329
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013330static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013331#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13332 const u8* mac,
13333#else
13334 u8* mac,
13335#endif
13336 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070013337{
13338 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13339 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13340 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053013341 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013342
13343 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
13344 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070013345
13346 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
13347 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
13348 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
13349 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
13350 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
13351 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
13352 tANI_U16 maxRate = 0;
13353 tANI_U16 myRate;
13354 tANI_U16 currentRate = 0;
13355 tANI_U8 maxSpeedMCS = 0;
13356 tANI_U8 maxMCSIdx = 0;
13357 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053013358 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013359 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013360 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013361
Leo Chang6f8870f2013-03-26 18:11:36 -070013362#ifdef WLAN_FEATURE_11AC
13363 tANI_U32 vht_mcs_map;
13364 eDataRate11ACMaxMcs vhtMaxMcs;
13365#endif /* WLAN_FEATURE_11AC */
13366
Jeff Johnsone7245742012-09-05 17:12:55 -070013367 ENTER();
13368
Jeff Johnson295189b2012-06-20 16:38:30 -070013369 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
13370 (0 == ssidlen))
13371 {
13372 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
13373 " Invalid ssidlen, %d", __func__, ssidlen);
13374 /*To keep GUI happy*/
13375 return 0;
13376 }
13377
Mukul Sharma811205f2014-07-09 21:07:30 +053013378 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
13379 {
13380 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13381 "%s: Roaming in progress, so unable to proceed this request", __func__);
13382 return 0;
13383 }
13384
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013385 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013386 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013387 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013388 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013389 }
13390
Jeff Johnson295189b2012-06-20 16:38:30 -070013391
Kiet Lam3b17fc82013-09-27 05:24:08 +053013392 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
13393 sinfo->filled |= STATION_INFO_SIGNAL;
13394
c_hpothu09f19542014-05-30 21:53:31 +053013395 wlan_hdd_get_station_stats(pAdapter);
13396 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
13397
13398 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053013399 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
13400 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053013401 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053013402 {
13403 rate_flags = pAdapter->maxRateFlags;
13404 }
c_hpothu44ff4e02014-05-08 00:13:57 +053013405
Jeff Johnson295189b2012-06-20 16:38:30 -070013406 //convert to the UI units of 100kbps
13407 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
13408
13409#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070013410 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 -070013411 sinfo->signal,
13412 pCfg->reportMaxLinkSpeed,
13413 myRate,
13414 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013415 (int) pCfg->linkSpeedRssiMid,
13416 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070013417 (int) rate_flags,
13418 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013419#endif //LINKSPEED_DEBUG_ENABLED
13420
13421 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
13422 {
13423 // we do not want to necessarily report the current speed
13424 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
13425 {
13426 // report the max possible speed
13427 rssidx = 0;
13428 }
13429 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
13430 {
13431 // report the max possible speed with RSSI scaling
13432 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
13433 {
13434 // report the max possible speed
13435 rssidx = 0;
13436 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013437 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070013438 {
13439 // report middle speed
13440 rssidx = 1;
13441 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013442 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
13443 {
13444 // report middle speed
13445 rssidx = 2;
13446 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013447 else
13448 {
13449 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013450 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070013451 }
13452 }
13453 else
13454 {
13455 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
13456 hddLog(VOS_TRACE_LEVEL_ERROR,
13457 "%s: Invalid value for reportMaxLinkSpeed: %u",
13458 __func__, pCfg->reportMaxLinkSpeed);
13459 rssidx = 0;
13460 }
13461
13462 maxRate = 0;
13463
13464 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013465 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
13466 OperationalRates, &ORLeng))
13467 {
13468 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13469 /*To keep GUI happy*/
13470 return 0;
13471 }
13472
Jeff Johnson295189b2012-06-20 16:38:30 -070013473 for (i = 0; i < ORLeng; i++)
13474 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013475 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013476 {
13477 /* Validate Rate Set */
13478 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
13479 {
13480 currentRate = supported_data_rate[j].supported_rate[rssidx];
13481 break;
13482 }
13483 }
13484 /* Update MAX rate */
13485 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13486 }
13487
13488 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013489 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
13490 ExtendedRates, &ERLeng))
13491 {
13492 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13493 /*To keep GUI happy*/
13494 return 0;
13495 }
13496
Jeff Johnson295189b2012-06-20 16:38:30 -070013497 for (i = 0; i < ERLeng; i++)
13498 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013499 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013500 {
13501 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
13502 {
13503 currentRate = supported_data_rate[j].supported_rate[rssidx];
13504 break;
13505 }
13506 }
13507 /* Update MAX rate */
13508 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13509 }
c_hpothu79aab322014-07-14 21:11:01 +053013510
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013511 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053013512 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013513 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053013514 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070013515 {
c_hpothu79aab322014-07-14 21:11:01 +053013516 if (rate_flags & eHAL_TX_RATE_VHT80)
13517 mode = 2;
13518 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
13519 mode = 1;
13520 else
13521 mode = 0;
13522
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013523 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
13524 MCSRates, &MCSLeng))
13525 {
13526 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13527 /*To keep GUI happy*/
13528 return 0;
13529 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013530 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070013531#ifdef WLAN_FEATURE_11AC
13532 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013533 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070013534 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013535 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013536 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070013537 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013539 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013540 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013541 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070013542 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013543 maxMCSIdx = 7;
13544 }
13545 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
13546 {
13547 maxMCSIdx = 8;
13548 }
13549 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
13550 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013551 //VHT20 is supporting 0~8
13552 if (rate_flags & eHAL_TX_RATE_VHT20)
13553 maxMCSIdx = 8;
13554 else
13555 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070013556 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013557
c_hpothu79aab322014-07-14 21:11:01 +053013558 if (0 != rssidx)/*check for scaled */
13559 {
13560 //get middle rate MCS index if rssi=1/2
13561 for (i=0; i <= maxMCSIdx; i++)
13562 {
13563 if (sinfo->signal <= rssiMcsTbl[mode][i])
13564 {
13565 maxMCSIdx = i;
13566 break;
13567 }
13568 }
13569 }
13570
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013571 if (rate_flags & eHAL_TX_RATE_VHT80)
13572 {
13573 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
13574 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
13575 }
13576 else if (rate_flags & eHAL_TX_RATE_VHT40)
13577 {
13578 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
13579 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
13580 }
13581 else if (rate_flags & eHAL_TX_RATE_VHT20)
13582 {
13583 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
13584 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
13585 }
13586
Leo Chang6f8870f2013-03-26 18:11:36 -070013587 maxSpeedMCS = 1;
13588 if (currentRate > maxRate)
13589 {
13590 maxRate = currentRate;
13591 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013592
Leo Chang6f8870f2013-03-26 18:11:36 -070013593 }
13594 else
13595#endif /* WLAN_FEATURE_11AC */
13596 {
13597 if (rate_flags & eHAL_TX_RATE_HT40)
13598 {
13599 rateFlag |= 1;
13600 }
13601 if (rate_flags & eHAL_TX_RATE_SGI)
13602 {
13603 rateFlag |= 2;
13604 }
13605
Girish Gowli01abcee2014-07-31 20:18:55 +053013606 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053013607 if (rssidx == 1 || rssidx == 2)
13608 {
13609 //get middle rate MCS index if rssi=1/2
13610 for (i=0; i <= 7; i++)
13611 {
13612 if (sinfo->signal <= rssiMcsTbl[mode][i])
13613 {
13614 temp = i+1;
13615 break;
13616 }
13617 }
13618 }
c_hpothu79aab322014-07-14 21:11:01 +053013619
13620 for (i = 0; i < MCSLeng; i++)
13621 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013622 for (j = 0; j < temp; j++)
13623 {
13624 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
13625 {
13626 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013627 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013628 break;
13629 }
13630 }
13631 if ((j < temp) && (currentRate > maxRate))
13632 {
13633 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070013634 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013635 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013636 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013637 }
13638 }
13639
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013640 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
13641 {
13642 maxRate = myRate;
13643 maxSpeedMCS = 1;
13644 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13645 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013646 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053013647 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 {
13649 maxRate = myRate;
13650 if (rate_flags & eHAL_TX_RATE_LEGACY)
13651 {
13652 maxSpeedMCS = 0;
13653 }
13654 else
13655 {
13656 maxSpeedMCS = 1;
13657 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13658 }
13659 }
13660
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013661 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070013662 {
13663 sinfo->txrate.legacy = maxRate;
13664#ifdef LINKSPEED_DEBUG_ENABLED
13665 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
13666#endif //LINKSPEED_DEBUG_ENABLED
13667 }
13668 else
13669 {
13670 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070013671#ifdef WLAN_FEATURE_11AC
13672 sinfo->txrate.nss = 1;
13673 if (rate_flags & eHAL_TX_RATE_VHT80)
13674 {
13675 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013676 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070013677 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013678 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070013679 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013680 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13681 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13682 }
13683 else if (rate_flags & eHAL_TX_RATE_VHT20)
13684 {
13685 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13686 }
13687#endif /* WLAN_FEATURE_11AC */
13688 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
13689 {
13690 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13691 if (rate_flags & eHAL_TX_RATE_HT40)
13692 {
13693 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13694 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013695 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013696 if (rate_flags & eHAL_TX_RATE_SGI)
13697 {
13698 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13699 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013700
Jeff Johnson295189b2012-06-20 16:38:30 -070013701#ifdef LINKSPEED_DEBUG_ENABLED
13702 pr_info("Reporting MCS rate %d flags %x\n",
13703 sinfo->txrate.mcs,
13704 sinfo->txrate.flags );
13705#endif //LINKSPEED_DEBUG_ENABLED
13706 }
13707 }
13708 else
13709 {
13710 // report current rate instead of max rate
13711
13712 if (rate_flags & eHAL_TX_RATE_LEGACY)
13713 {
13714 //provide to the UI in units of 100kbps
13715 sinfo->txrate.legacy = myRate;
13716#ifdef LINKSPEED_DEBUG_ENABLED
13717 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
13718#endif //LINKSPEED_DEBUG_ENABLED
13719 }
13720 else
13721 {
13722 //must be MCS
13723 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013724#ifdef WLAN_FEATURE_11AC
13725 sinfo->txrate.nss = 1;
13726 if (rate_flags & eHAL_TX_RATE_VHT80)
13727 {
13728 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13729 }
13730 else
13731#endif /* WLAN_FEATURE_11AC */
13732 {
13733 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13734 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013735 if (rate_flags & eHAL_TX_RATE_SGI)
13736 {
13737 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13738 }
13739 if (rate_flags & eHAL_TX_RATE_HT40)
13740 {
13741 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13742 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013743#ifdef WLAN_FEATURE_11AC
13744 else if (rate_flags & eHAL_TX_RATE_VHT80)
13745 {
13746 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
13747 }
13748#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070013749#ifdef LINKSPEED_DEBUG_ENABLED
13750 pr_info("Reporting actual MCS rate %d flags %x\n",
13751 sinfo->txrate.mcs,
13752 sinfo->txrate.flags );
13753#endif //LINKSPEED_DEBUG_ENABLED
13754 }
13755 }
13756 sinfo->filled |= STATION_INFO_TX_BITRATE;
13757
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013758 sinfo->tx_packets =
13759 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
13760 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
13761 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
13762 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
13763
13764 sinfo->tx_retries =
13765 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
13766 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
13767 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
13768 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
13769
13770 sinfo->tx_failed =
13771 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
13772 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
13773 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
13774 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
13775
13776 sinfo->filled |=
13777 STATION_INFO_TX_PACKETS |
13778 STATION_INFO_TX_RETRIES |
13779 STATION_INFO_TX_FAILED;
13780
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013781 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13782 TRACE_CODE_HDD_CFG80211_GET_STA,
13783 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013784 EXIT();
13785 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013786}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013787#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
13788static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13789 const u8* mac, struct station_info *sinfo)
13790#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013791static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13792 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013793#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013794{
13795 int ret;
13796
13797 vos_ssr_protect(__func__);
13798 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
13799 vos_ssr_unprotect(__func__);
13800
13801 return ret;
13802}
13803
13804static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070013805 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070013806{
13807 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013808 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013809 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013810 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013811
Jeff Johnsone7245742012-09-05 17:12:55 -070013812 ENTER();
13813
Jeff Johnson295189b2012-06-20 16:38:30 -070013814 if (NULL == pAdapter)
13815 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013816 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013817 return -ENODEV;
13818 }
13819
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013820 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13821 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
13822 pAdapter->sessionId, timeout));
13823
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013824 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013825 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013826 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013827 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013828 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013829 }
13830
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013831 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
13832 (TRUE == pHddCtx->hdd_wlan_suspended) &&
13833 (pHddCtx->cfg_ini->fhostArpOffload) &&
13834 (eConnectionState_Associated ==
13835 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13836 {
Amar Singhald53568e2013-09-26 11:03:45 -070013837
13838 hddLog(VOS_TRACE_LEVEL_INFO,
13839 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053013840 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013841 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13842 {
13843 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013844 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013845 __func__, vos_status);
13846 }
13847 }
13848
Jeff Johnson295189b2012-06-20 16:38:30 -070013849 /**The get power cmd from the supplicant gets updated by the nl only
13850 *on successful execution of the function call
13851 *we are oppositely mapped w.r.t mode in the driver
13852 **/
13853 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
13854
13855 if (VOS_STATUS_E_FAILURE == vos_status)
13856 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013857 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13858 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013859 return -EINVAL;
13860 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013861 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013862 return 0;
13863}
13864
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013865static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
13866 struct net_device *dev, bool mode, int timeout)
13867{
13868 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013869
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013870 vos_ssr_protect(__func__);
13871 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
13872 vos_ssr_unprotect(__func__);
13873
13874 return ret;
13875}
Jeff Johnson295189b2012-06-20 16:38:30 -070013876#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013877static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
13878 struct net_device *netdev,
13879 u8 key_index)
13880{
13881 ENTER();
13882 return 0;
13883}
13884
Jeff Johnson295189b2012-06-20 16:38:30 -070013885static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013886 struct net_device *netdev,
13887 u8 key_index)
13888{
13889 int ret;
13890 vos_ssr_protect(__func__);
13891 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
13892 vos_ssr_unprotect(__func__);
13893 return ret;
13894}
13895#endif //LINUX_VERSION_CODE
13896
13897#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13898static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13899 struct net_device *dev,
13900 struct ieee80211_txq_params *params)
13901{
13902 ENTER();
13903 return 0;
13904}
13905#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13906static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13907 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013908{
Jeff Johnsone7245742012-09-05 17:12:55 -070013909 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070013910 return 0;
13911}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013912#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070013913
13914#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13915static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013916 struct net_device *dev,
13917 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013918{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013919 int ret;
13920
13921 vos_ssr_protect(__func__);
13922 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
13923 vos_ssr_unprotect(__func__);
13924 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013925}
13926#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13927static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
13928 struct ieee80211_txq_params *params)
13929{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013930 int ret;
13931
13932 vos_ssr_protect(__func__);
13933 ret = __wlan_hdd_set_txq_params(wiphy, params);
13934 vos_ssr_unprotect(__func__);
13935 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013936}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013937#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013938
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013939static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013940 struct net_device *dev,
13941 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070013942{
13943 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013944 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013945 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013946 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013947 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013948 v_CONTEXT_t pVosContext = NULL;
13949 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013950
Jeff Johnsone7245742012-09-05 17:12:55 -070013951 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013952
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013953 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070013954 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013955 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 return -EINVAL;
13957 }
13958
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013959 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13960 TRACE_CODE_HDD_CFG80211_DEL_STA,
13961 pAdapter->sessionId, pAdapter->device_mode));
13962
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013963 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13964 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013965 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013966 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013967 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013968 }
13969
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013971 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013972 )
13973 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013974 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13975 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13976 if(pSapCtx == NULL){
13977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13978 FL("psapCtx is NULL"));
13979 return -ENOENT;
13980 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013981 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070013982 {
13983 v_U16_t i;
13984 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
13985 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013986 if ((pSapCtx->aStaInfo[i].isUsed) &&
13987 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013989 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013990 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013991 ETHER_ADDR_LEN);
13992
Jeff Johnson295189b2012-06-20 16:38:30 -070013993 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013994 "%s: Delete STA with MAC::"
13995 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013996 __func__,
13997 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
13998 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070013999 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014000 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014001 }
14002 }
14003 }
14004 else
14005 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014006
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014007 vos_status = hdd_softap_GetStaId(pAdapter,
14008 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014009 if (!VOS_IS_STATUS_SUCCESS(vos_status))
14010 {
14011 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080014012 "%s: Skip this DEL STA as this is not used::"
14013 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014014 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014015 return -ENOENT;
14016 }
14017
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014018 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014019 {
14020 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080014021 "%s: Skip this DEL STA as deauth is in progress::"
14022 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014023 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014024 return -ENOENT;
14025 }
14026
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014027 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014028
Jeff Johnson295189b2012-06-20 16:38:30 -070014029 hddLog(VOS_TRACE_LEVEL_INFO,
14030 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080014031 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014032 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014033 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014034
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014035 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014036 if (!VOS_IS_STATUS_SUCCESS(vos_status))
14037 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014038 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014039 hddLog(VOS_TRACE_LEVEL_INFO,
14040 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080014041 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014042 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014043 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014044 return -ENOENT;
14045 }
14046
Jeff Johnson295189b2012-06-20 16:38:30 -070014047 }
14048 }
14049
14050 EXIT();
14051
14052 return 0;
14053}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014054
14055#ifdef CFG80211_DEL_STA_V2
14056static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14057 struct net_device *dev,
14058 struct station_del_parameters *param)
14059#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014060#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
14061static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14062 struct net_device *dev, const u8 *mac)
14063#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014064static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14065 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014066#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014067#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014068{
14069 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014070 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070014071
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014072 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014073
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014074#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014075 if (NULL == param) {
14076 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014077 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014078 return -EINVAL;
14079 }
14080
14081 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
14082 param->subtype, &delStaParams);
14083
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014084#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053014085 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014086 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014087#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014088 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
14089
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014090 vos_ssr_unprotect(__func__);
14091
14092 return ret;
14093}
14094
14095static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014096 struct net_device *dev,
14097#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14098 const u8 *mac,
14099#else
14100 u8 *mac,
14101#endif
14102 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014103{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014104 hdd_adapter_t *pAdapter;
14105 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014106 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014107#ifdef FEATURE_WLAN_TDLS
14108 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014109
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014110 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014111
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014112 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14113 if (NULL == pAdapter)
14114 {
14115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14116 "%s: Adapter is NULL",__func__);
14117 return -EINVAL;
14118 }
14119 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14120 status = wlan_hdd_validate_context(pHddCtx);
14121 if (0 != status)
14122 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014123 return status;
14124 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014125
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014126 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14127 TRACE_CODE_HDD_CFG80211_ADD_STA,
14128 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014129 mask = params->sta_flags_mask;
14130
14131 set = params->sta_flags_set;
14132
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014133 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014134 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
14135 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014136
14137 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
14138 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080014139 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014140 }
14141 }
14142#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014143 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014144 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014145}
14146
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014147#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
14148static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
14149 struct net_device *dev, const u8 *mac,
14150 struct station_parameters *params)
14151#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014152static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
14153 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014154#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014155{
14156 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014157
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014158 vos_ssr_protect(__func__);
14159 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
14160 vos_ssr_unprotect(__func__);
14161
14162 return ret;
14163}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014164#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070014165
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014166static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070014167 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014168{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014169 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14170 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014171 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014172 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014173 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014174 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070014175
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014176 ENTER();
14177
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014178 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014179 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014180 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014181 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014182 return -EINVAL;
14183 }
14184
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014185 if (!pmksa) {
14186 hddLog(LOGE, FL("pmksa is NULL"));
14187 return -EINVAL;
14188 }
14189
14190 if (!pmksa->bssid || !pmksa->pmkid) {
14191 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
14192 pmksa->bssid, pmksa->pmkid);
14193 return -EINVAL;
14194 }
14195
14196 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
14197 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14198
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014199 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14200 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014201 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014202 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014203 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014204 }
14205
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014206 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014207 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14208
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014209 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
14210 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014211
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014212 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014213 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014214 &pmk_id, 1, FALSE);
14215
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014216 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14217 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
14218 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014219
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014220 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014221 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014222}
14223
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014224static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
14225 struct cfg80211_pmksa *pmksa)
14226{
14227 int ret;
14228
14229 vos_ssr_protect(__func__);
14230 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
14231 vos_ssr_unprotect(__func__);
14232
14233 return ret;
14234}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014235
Wilson Yang6507c4e2013-10-01 20:11:19 -070014236
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014237static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070014238 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014239{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014240 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14241 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014242 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014243 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014244
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014245 ENTER();
14246
Wilson Yang6507c4e2013-10-01 20:11:19 -070014247 /* Validate pAdapter */
14248 if (NULL == pAdapter)
14249 {
14250 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
14251 return -EINVAL;
14252 }
14253
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014254 if (!pmksa) {
14255 hddLog(LOGE, FL("pmksa is NULL"));
14256 return -EINVAL;
14257 }
14258
14259 if (!pmksa->bssid) {
14260 hddLog(LOGE, FL("pmksa->bssid is NULL"));
14261 return -EINVAL;
14262 }
14263
Kiet Lam98c46a12014-10-31 15:34:57 -070014264 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
14265 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14266
Wilson Yang6507c4e2013-10-01 20:11:19 -070014267 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14268 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014269 if (0 != status)
14270 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014271 return status;
14272 }
14273
14274 /*Retrieve halHandle*/
14275 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14276
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014277 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14278 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
14279 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014280 /* Delete the PMKID CSR cache */
14281 if (eHAL_STATUS_SUCCESS !=
14282 sme_RoamDelPMKIDfromCache(halHandle,
14283 pAdapter->sessionId, pmksa->bssid, FALSE)) {
14284 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
14285 MAC_ADDR_ARRAY(pmksa->bssid));
14286 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014287 }
14288
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014289 EXIT();
14290 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014291}
14292
Wilson Yang6507c4e2013-10-01 20:11:19 -070014293
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014294static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
14295 struct cfg80211_pmksa *pmksa)
14296{
14297 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014298
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014299 vos_ssr_protect(__func__);
14300 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
14301 vos_ssr_unprotect(__func__);
14302
14303 return ret;
14304
14305}
14306
14307static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014308{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014309 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14310 tHalHandle halHandle;
14311 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014312 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014313
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014314 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070014315
14316 /* Validate pAdapter */
14317 if (NULL == pAdapter)
14318 {
14319 hddLog(VOS_TRACE_LEVEL_ERROR,
14320 "%s: Invalid Adapter" ,__func__);
14321 return -EINVAL;
14322 }
14323
14324 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14325 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014326 if (0 != status)
14327 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014328 return status;
14329 }
14330
14331 /*Retrieve halHandle*/
14332 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14333
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014334 /* Flush the PMKID cache in CSR */
14335 if (eHAL_STATUS_SUCCESS !=
14336 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
14337 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
14338 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014339 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014340 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080014341 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014342}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014343
14344static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
14345{
14346 int ret;
14347
14348 vos_ssr_protect(__func__);
14349 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
14350 vos_ssr_unprotect(__func__);
14351
14352 return ret;
14353}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014354#endif
14355
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014356#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014357static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14358 struct net_device *dev,
14359 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014360{
14361 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14362 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014363 hdd_context_t *pHddCtx;
14364 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014365
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014366 ENTER();
14367
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014368 if (NULL == pAdapter)
14369 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014370 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014371 return -ENODEV;
14372 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014373 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14374 ret = wlan_hdd_validate_context(pHddCtx);
14375 if (0 != ret)
14376 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014377 return ret;
14378 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014379 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014380 if (NULL == pHddStaCtx)
14381 {
14382 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
14383 return -EINVAL;
14384 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014385
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014386 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14387 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
14388 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014389 // Added for debug on reception of Re-assoc Req.
14390 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
14391 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014392 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014393 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080014394 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014395 }
14396
14397#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080014398 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014399 ftie->ie_len);
14400#endif
14401
14402 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014403 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14404 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014405 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014406
14407 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014408 return 0;
14409}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014410
14411static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14412 struct net_device *dev,
14413 struct cfg80211_update_ft_ies_params *ftie)
14414{
14415 int ret;
14416
14417 vos_ssr_protect(__func__);
14418 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
14419 vos_ssr_unprotect(__func__);
14420
14421 return ret;
14422}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014423#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014424
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014425#ifdef FEATURE_WLAN_SCAN_PNO
14426
14427void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
14428 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
14429{
14430 int ret;
14431 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
14432 hdd_context_t *pHddCtx;
14433
Nirav Shah80830bf2013-12-31 16:35:12 +053014434 ENTER();
14435
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014436 if (NULL == pAdapter)
14437 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014438 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014439 "%s: HDD adapter is Null", __func__);
14440 return ;
14441 }
14442
14443 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14444 if (NULL == pHddCtx)
14445 {
14446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14447 "%s: HDD context is Null!!!", __func__);
14448 return ;
14449 }
14450
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014451 spin_lock(&pHddCtx->schedScan_lock);
14452 if (TRUE == pHddCtx->isWiphySuspended)
14453 {
14454 pHddCtx->isSchedScanUpdatePending = TRUE;
14455 spin_unlock(&pHddCtx->schedScan_lock);
14456 hddLog(VOS_TRACE_LEVEL_INFO,
14457 "%s: Update cfg80211 scan database after it resume", __func__);
14458 return ;
14459 }
14460 spin_unlock(&pHddCtx->schedScan_lock);
14461
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014462 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
14463
14464 if (0 > ret)
14465 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
14466
14467 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14469 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014470}
14471
14472/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014473 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014474 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014475 */
14476static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
14477{
14478 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
14479 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014480 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014481 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14482 int status = 0;
14483 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
14484
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014485 /* The current firmware design does not allow PNO during any
14486 * active sessions. Hence, determine the active sessions
14487 * and return a failure.
14488 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014489 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
14490 {
14491 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014492 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014493
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014494 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
14495 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
14496 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
14497 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
14498 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053014499 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014500 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014501 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014502 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014503 }
14504 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14505 pAdapterNode = pNext;
14506 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014507 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014508}
14509
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014510void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
14511{
14512 hdd_adapter_t *pAdapter = callbackContext;
14513 hdd_context_t *pHddCtx;
14514
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014515 ENTER();
14516
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014517 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
14518 {
14519 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14520 FL("Invalid adapter or adapter has invalid magic"));
14521 return;
14522 }
14523
14524 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14525 if (0 != wlan_hdd_validate_context(pHddCtx))
14526 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014527 return;
14528 }
14529
c_hpothub53c45d2014-08-18 16:53:14 +053014530 if (VOS_STATUS_SUCCESS != status)
14531 {
14532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014533 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053014534 pHddCtx->isPnoEnable = FALSE;
14535 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014536
14537 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
14538 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014539 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014540}
14541
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014542/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014543 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
14544 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014545 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014546static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014547 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14548{
14549 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014550 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014551 hdd_context_t *pHddCtx;
14552 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014553 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053014554 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
14555 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014556 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14557 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014558 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014559 hdd_config_t *pConfig = NULL;
14560 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014561
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014562 ENTER();
14563
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014564 if (NULL == pAdapter)
14565 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014566 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014567 "%s: HDD adapter is Null", __func__);
14568 return -ENODEV;
14569 }
14570
14571 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014572 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014573
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014574 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014575 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014576 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014577 }
14578
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014579 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014580 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14581 if (NULL == hHal)
14582 {
14583 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14584 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014585 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014586 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014587 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14588 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
14589 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053014590 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014591 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053014592 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014593 {
14594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14595 "%s: aborting the existing scan is unsuccessfull", __func__);
14596 return -EBUSY;
14597 }
14598
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014599 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014600 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014602 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014603 return -EBUSY;
14604 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014605
c_hpothu37f21312014-04-09 21:49:54 +053014606 if (TRUE == pHddCtx->isPnoEnable)
14607 {
14608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14609 FL("already PNO is enabled"));
14610 return -EBUSY;
14611 }
c_hpothu225aa7c2014-10-22 17:45:13 +053014612
14613 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
14614 {
14615 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14616 "%s: abort ROC failed ", __func__);
14617 return -EBUSY;
14618 }
14619
c_hpothu37f21312014-04-09 21:49:54 +053014620 pHddCtx->isPnoEnable = TRUE;
14621
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014622 pnoRequest.enable = 1; /*Enable PNO */
14623 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014624
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014625 if (( !pnoRequest.ucNetworksCount ) ||
14626 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014627 {
14628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014629 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014630 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014631 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014632 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014633 goto error;
14634 }
14635
14636 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
14637 {
14638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014639 "%s: Incorrect number of channels %d",
14640 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014641 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014642 goto error;
14643 }
14644
14645 /* Framework provides one set of channels(all)
14646 * common for all saved profile */
14647 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14648 channels_allowed, &num_channels_allowed))
14649 {
14650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14651 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014652 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014653 goto error;
14654 }
14655 /* Checking each channel against allowed channel list */
14656 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053014657 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014658 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014659 char chList [(request->n_channels*5)+1];
14660 int len;
14661 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014662 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014663 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014664 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014665 if (request->channels[i]->hw_value == channels_allowed[indx])
14666 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014667 if ((!pConfig->enableDFSPnoChnlScan) &&
14668 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
14669 {
14670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14671 "%s : Dropping DFS channel : %d",
14672 __func__,channels_allowed[indx]);
14673 num_ignore_dfs_ch++;
14674 break;
14675 }
14676
Nirav Shah80830bf2013-12-31 16:35:12 +053014677 valid_ch[num_ch++] = request->channels[i]->hw_value;
14678 len += snprintf(chList+len, 5, "%d ",
14679 request->channels[i]->hw_value);
14680 break ;
14681 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014682 }
14683 }
Nirav Shah80830bf2013-12-31 16:35:12 +053014684 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014685
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014686 /*If all channels are DFS and dropped, then ignore the PNO request*/
14687 if (num_ignore_dfs_ch == request->n_channels)
14688 {
14689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14690 "%s : All requested channels are DFS channels", __func__);
14691 ret = -EINVAL;
14692 goto error;
14693 }
14694 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014695
14696 pnoRequest.aNetworks =
14697 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14698 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014699 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014700 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14701 FL("failed to allocate memory aNetworks %u"),
14702 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14703 goto error;
14704 }
14705 vos_mem_zero(pnoRequest.aNetworks,
14706 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14707
14708 /* Filling per profile params */
14709 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
14710 {
14711 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014712 request->match_sets[i].ssid.ssid_len;
14713
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014714 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
14715 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014716 {
14717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014718 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014719 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014720 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014721 goto error;
14722 }
14723
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014724 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014725 request->match_sets[i].ssid.ssid,
14726 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14728 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014729 i, pnoRequest.aNetworks[i].ssId.ssId);
14730 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
14731 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
14732 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014733
14734 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014735 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
14736 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014737
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014738 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014739 }
14740
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014741 for (i = 0; i < request->n_ssids; i++)
14742 {
14743 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014744 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014745 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014746 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014747 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014748 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014749 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014750 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014751 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014752 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014753 break;
14754 }
14755 j++;
14756 }
14757 }
14758 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14759 "Number of hidden networks being Configured = %d",
14760 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080014762 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014763
14764 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14765 if (pnoRequest.p24GProbeTemplate == NULL)
14766 {
14767 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14768 FL("failed to allocate memory p24GProbeTemplate %u"),
14769 SIR_PNO_MAX_PB_REQ_SIZE);
14770 goto error;
14771 }
14772
14773 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14774 if (pnoRequest.p5GProbeTemplate == NULL)
14775 {
14776 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14777 FL("failed to allocate memory p5GProbeTemplate %u"),
14778 SIR_PNO_MAX_PB_REQ_SIZE);
14779 goto error;
14780 }
14781
14782 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14783 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14784
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053014785 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
14786 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014787 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014788 pnoRequest.us24GProbeTemplateLen = request->ie_len;
14789 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
14790 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014791
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014792 pnoRequest.us5GProbeTemplateLen = request->ie_len;
14793 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
14794 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014795 }
14796
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014797 /* Driver gets only one time interval which is hardcoded in
14798 * supplicant for 10000ms. Taking power consumption into account 6 timers
14799 * will be used, Timervalue is increased exponentially i.e 10,20,40,
14800 * 80,160,320 secs. And number of scan cycle for each timer
14801 * is configurable through INI param gPNOScanTimerRepeatValue.
14802 * If it is set to 0 only one timer will be used and PNO scan cycle
14803 * will be repeated after each interval specified by supplicant
14804 * till PNO is disabled.
14805 */
14806 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014807 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014808 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014809 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014810 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
14811
14812 tempInterval = (request->interval)/1000;
14813 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14814 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
14815 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014816 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014817 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014818 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014819 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014820 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014821 tempInterval *= 2;
14822 }
14823 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014824 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014825
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014826 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014827
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014828 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014829 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
14830 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014831 pAdapter->pno_req_status = 0;
14832
Nirav Shah80830bf2013-12-31 16:35:12 +053014833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14834 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014835 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
14836 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053014837
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014838 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014839 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014840 hdd_cfg80211_sched_scan_done_callback, pAdapter);
14841 if (eHAL_STATUS_SUCCESS != status)
14842 {
14843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014844 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014845 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014846 goto error;
14847 }
14848
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014849 ret = wait_for_completion_timeout(
14850 &pAdapter->pno_comp_var,
14851 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
14852 if (0 >= ret)
14853 {
14854 // Did not receive the response for PNO enable in time.
14855 // Assuming the PNO enable was success.
14856 // Returning error from here, because we timeout, results
14857 // in side effect of Wifi (Wifi Setting) not to work.
14858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14859 FL("Timed out waiting for PNO to be Enabled"));
14860 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014861 }
14862
14863 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053014864 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014865
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014866error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14868 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053014869 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014870 if (pnoRequest.aNetworks)
14871 vos_mem_free(pnoRequest.aNetworks);
14872 if (pnoRequest.p24GProbeTemplate)
14873 vos_mem_free(pnoRequest.p24GProbeTemplate);
14874 if (pnoRequest.p5GProbeTemplate)
14875 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014876
14877 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014878 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014879}
14880
14881/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014882 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
14883 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014884 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014885static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
14886 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14887{
14888 int ret;
14889
14890 vos_ssr_protect(__func__);
14891 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
14892 vos_ssr_unprotect(__func__);
14893
14894 return ret;
14895}
14896
14897/*
14898 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
14899 * Function to disable PNO
14900 */
14901static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014902 struct net_device *dev)
14903{
14904 eHalStatus status = eHAL_STATUS_FAILURE;
14905 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14906 hdd_context_t *pHddCtx;
14907 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014908 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014909 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014910
14911 ENTER();
14912
14913 if (NULL == pAdapter)
14914 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014916 "%s: HDD adapter is Null", __func__);
14917 return -ENODEV;
14918 }
14919
14920 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014921
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014922 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014923 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014924 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014925 "%s: HDD context is Null", __func__);
14926 return -ENODEV;
14927 }
14928
14929 /* The return 0 is intentional when isLogpInProgress and
14930 * isLoadUnloadInProgress. We did observe a crash due to a return of
14931 * failure in sched_scan_stop , especially for a case where the unload
14932 * of the happens at the same time. The function __cfg80211_stop_sched_scan
14933 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
14934 * success. If it returns a failure , then its next invocation due to the
14935 * clean up of the second interface will have the dev pointer corresponding
14936 * to the first one leading to a crash.
14937 */
14938 if (pHddCtx->isLogpInProgress)
14939 {
14940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14941 "%s: LOGP in Progress. Ignore!!!", __func__);
14942 return ret;
14943 }
14944
Mihir Shete18156292014-03-11 15:38:30 +053014945 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014946 {
14947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14948 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14949 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014950 }
14951
14952 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14953 if (NULL == hHal)
14954 {
14955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14956 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014957 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014958 }
14959
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014960 pnoRequest.enable = 0; /* Disable PNO */
14961 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014962
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014963 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14964 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
14965 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014966 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014967 pAdapter->sessionId,
14968 NULL, pAdapter);
14969 if (eHAL_STATUS_SUCCESS != status)
14970 {
14971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14972 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014973 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014974 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014975 }
c_hpothu37f21312014-04-09 21:49:54 +053014976 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014977
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014978error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014979 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014980 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014981
14982 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014983 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014984}
14985
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014986/*
14987 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
14988 * NL interface to disable PNO
14989 */
14990static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
14991 struct net_device *dev)
14992{
14993 int ret;
14994
14995 vos_ssr_protect(__func__);
14996 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
14997 vos_ssr_unprotect(__func__);
14998
14999 return ret;
15000}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015001#endif /*FEATURE_WLAN_SCAN_PNO*/
15002
15003
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015004#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015005#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015006static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15007 struct net_device *dev,
15008 u8 *peer, u8 action_code,
15009 u8 dialog_token,
15010 u16 status_code, u32 peer_capability,
15011 const u8 *buf, size_t len)
15012#else /* TDLS_MGMT_VERSION2 */
15013#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
15014static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15015 struct net_device *dev,
15016 const u8 *peer, u8 action_code,
15017 u8 dialog_token, u16 status_code,
15018 u32 peer_capability, bool initiator,
15019 const u8 *buf, size_t len)
15020#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
15021static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15022 struct net_device *dev,
15023 const u8 *peer, u8 action_code,
15024 u8 dialog_token, u16 status_code,
15025 u32 peer_capability, const u8 *buf,
15026 size_t len)
15027#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
15028static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15029 struct net_device *dev,
15030 u8 *peer, u8 action_code,
15031 u8 dialog_token,
15032 u16 status_code, u32 peer_capability,
15033 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015034#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015035static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15036 struct net_device *dev,
15037 u8 *peer, u8 action_code,
15038 u8 dialog_token,
15039 u16 status_code, const u8 *buf,
15040 size_t len)
15041#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015042#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015043{
15044
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015045 hdd_adapter_t *pAdapter;
15046 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015047 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070015048 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080015049 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070015050 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015051 int ret;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015052#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015053 u32 peer_capability = 0;
15054#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015055 tANI_U16 numCurrTdlsPeers;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015056
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015057 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15058 if (NULL == pAdapter)
15059 {
15060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15061 "%s: Adapter is NULL",__func__);
15062 return -EINVAL;
15063 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015064 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15065 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
15066 pAdapter->sessionId, action_code));
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015067 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015068 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015069 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015070 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015071 "Invalid arguments");
15072 return -EINVAL;
15073 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015074 if (pHddCtx->isLogpInProgress)
15075 {
15076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15077 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053015078 wlan_hdd_tdls_set_link_status(pAdapter,
15079 peer,
15080 eTDLS_LINK_IDLE,
15081 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015082 return -EBUSY;
15083 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015084 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
15085 {
15086 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15087 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
15088 return -EAGAIN;
15089 }
Hoonki Lee27511902013-03-14 18:19:06 -070015090 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015091 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015092 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070015093 "%s: TDLS mode is disabled OR not enabled in FW."
15094 MAC_ADDRESS_STR " action %d declined.",
15095 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015096 return -ENOTSUPP;
15097 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015098
Hoonki Lee27511902013-03-14 18:19:06 -070015099 /* other than teardown frame, other mgmt frames are not sent if disabled */
15100 if (SIR_MAC_TDLS_TEARDOWN != action_code)
15101 {
15102 /* if tdls_mode is disabled to respond to peer's request */
15103 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
15104 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015105 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070015106 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015107 " TDLS mode is disabled. action %d declined.",
15108 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070015109
15110 return -ENOTSUPP;
15111 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053015112
15113 if (vos_max_concurrent_connections_reached())
15114 {
15115 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15116 return -EINVAL;
15117 }
Hoonki Lee27511902013-03-14 18:19:06 -070015118 }
15119
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015120 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
15121 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053015122 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015123 {
15124 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015125 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015126 " TDLS setup is ongoing. action %d declined.",
15127 __func__, MAC_ADDR_ARRAY(peer), action_code);
15128 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015129 }
15130 }
15131
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015132 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
15133 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080015134 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015135 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15136 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080015137 {
15138 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
15139 we return error code at 'add_station()'. Hence we have this
15140 check again in addtion to add_station().
15141 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015142 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080015143 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015144 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15145 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015146 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
15147 __func__, MAC_ADDR_ARRAY(peer), action_code,
15148 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053015149 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080015150 }
15151 else
15152 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015153 /* maximum reached. tweak to send error code to peer and return
15154 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080015155 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015156 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15157 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015158 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
15159 __func__, MAC_ADDR_ARRAY(peer), status_code,
15160 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070015161 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015162 /* fall through to send setup resp with failure status
15163 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080015164 }
15165 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015166 else
15167 {
15168 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053015169 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015170 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015171 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015172 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015173 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
15174 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015175 return -EPERM;
15176 }
15177 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015178 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015179
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015180 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053015181 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015182 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
15183 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015184
Hoonki Leea34dd892013-02-05 22:56:02 -080015185 /*Except teardown responder will not be used so just make 0*/
15186 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015187 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080015188 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015189
15190 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015191 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015192
15193 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
15194 responder = pTdlsPeer->is_responder;
15195 else
Hoonki Leea34dd892013-02-05 22:56:02 -080015196 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015197 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053015198 "%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 -070015199 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
15200 dialog_token, status_code, len);
15201 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080015202 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015203 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015204
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015205 /* For explicit trigger of DIS_REQ come out of BMPS for
15206 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070015207 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015208 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
15209 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070015210 {
15211 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
15212 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015213 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015214 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015215 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
15216 if (status != VOS_STATUS_SUCCESS) {
15217 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
15218 }
Hoonki Lee14621352013-04-16 17:51:19 -070015219 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015220 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015221 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015222 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
15223 }
15224 }
Hoonki Lee14621352013-04-16 17:51:19 -070015225 }
15226
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015227 /* make sure doesn't call send_mgmt() while it is pending */
15228 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
15229 {
15230 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015231 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015232 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015233 ret = -EBUSY;
15234 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015235 }
15236
15237 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015238 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
15239
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015240 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015241 peer, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015242
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015243 if (VOS_STATUS_SUCCESS != status)
15244 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15246 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015247 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015248 ret = -EINVAL;
15249 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015250 }
15251
Hoonki Leed37cbb32013-04-20 00:31:14 -070015252 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
15253 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
15254
15255 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015256 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070015257 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070015258 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070015259 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015260 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080015261
15262 if (pHddCtx->isLogpInProgress)
15263 {
15264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15265 "%s: LOGP in Progress. Ignore!!!", __func__);
15266 return -EAGAIN;
15267 }
15268
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015269 ret = -EINVAL;
15270 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015271 }
15272
Gopichand Nakkala05922802013-03-14 12:23:19 -070015273 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070015274 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015275 ret = max_sta_failed;
15276 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070015277 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015278
Hoonki Leea34dd892013-02-05 22:56:02 -080015279 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
15280 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015281 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015282 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15283 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015284 }
15285 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
15286 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015287 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015288 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15289 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015290 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015291
15292 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015293
15294tx_failed:
15295 /* add_station will be called before sending TDLS_SETUP_REQ and
15296 * TDLS_SETUP_RSP and as part of add_station driver will enable
15297 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
15298 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
15299 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
15300 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
15301 */
15302
15303 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
15304 (SIR_MAC_TDLS_SETUP_RSP == action_code))
15305 wlan_hdd_tdls_check_bmps(pAdapter);
15306 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015307}
15308
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015309#if TDLS_MGMT_VERSION2
15310static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15311 u8 *peer, u8 action_code, u8 dialog_token,
15312 u16 status_code, u32 peer_capability,
15313 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015314#else /* TDLS_MGMT_VERSION2 */
15315#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
15316static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15317 struct net_device *dev,
15318 const u8 *peer, u8 action_code,
15319 u8 dialog_token, u16 status_code,
15320 u32 peer_capability, bool initiator,
15321 const u8 *buf, size_t len)
15322#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
15323static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15324 struct net_device *dev,
15325 const u8 *peer, u8 action_code,
15326 u8 dialog_token, u16 status_code,
15327 u32 peer_capability, const u8 *buf,
15328 size_t len)
15329#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
15330static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15331 struct net_device *dev,
15332 u8 *peer, u8 action_code,
15333 u8 dialog_token,
15334 u16 status_code, u32 peer_capability,
15335 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015336#else
15337static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15338 u8 *peer, u8 action_code, u8 dialog_token,
15339 u16 status_code, const u8 *buf, size_t len)
15340#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015341#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015342{
15343 int ret;
15344
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015345 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015346#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015347 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15348 dialog_token, status_code,
15349 peer_capability, buf, len);
15350#else /* TDLS_MGMT_VERSION2 */
15351#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
15352 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15353 dialog_token, status_code,
15354 peer_capability, initiator,
15355 buf, len);
15356#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
15357 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15358 dialog_token, status_code,
15359 peer_capability, buf, len);
15360#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
15361 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15362 dialog_token, status_code,
15363 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015364#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015365 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15366 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015367#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015368#endif
15369 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015370
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015371 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015372}
Atul Mittal115287b2014-07-08 13:26:33 +053015373
15374int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015375#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15376 const u8 *peer,
15377#else
Atul Mittal115287b2014-07-08 13:26:33 +053015378 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015379#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015380 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053015381 cfg80211_exttdls_callback callback)
15382{
15383
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015384 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053015385 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015386 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053015387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15388 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
15389 __func__, MAC_ADDR_ARRAY(peer));
15390
15391 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15392 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15393
15394 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015395 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15396 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15397 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015398 return -ENOTSUPP;
15399 }
15400
15401 /* To cater the requirement of establishing the TDLS link
15402 * irrespective of the data traffic , get an entry of TDLS peer.
15403 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015404 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015405 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
15406 if (pTdlsPeer == NULL) {
15407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15408 "%s: peer " MAC_ADDRESS_STR " not existing",
15409 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015410 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015411 return -EINVAL;
15412 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015413 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015414
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015415 /* check FW TDLS Off Channel capability */
15416 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015417 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015418 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015419 {
15420 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
15421 pTdlsPeer->peerParams.global_operating_class =
15422 tdls_peer_params->global_operating_class;
15423 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
15424 pTdlsPeer->peerParams.min_bandwidth_kbps =
15425 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015426 /* check configured channel is valid, non dfs and
15427 * not current operating channel */
15428 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
15429 tdls_peer_params->channel)) &&
15430 (pHddStaCtx) &&
15431 (tdls_peer_params->channel !=
15432 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015433 {
15434 pTdlsPeer->isOffChannelConfigured = TRUE;
15435 }
15436 else
15437 {
15438 pTdlsPeer->isOffChannelConfigured = FALSE;
15439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15440 "%s: Configured Tdls Off Channel is not valid", __func__);
15441
15442 }
15443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015444 "%s: tdls_off_channel %d isOffChannelConfigured %d "
15445 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015446 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015447 pTdlsPeer->isOffChannelConfigured,
15448 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015449 }
15450 else
15451 {
15452 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015453 "%s: TDLS off channel FW capability %d, "
15454 "host capab %d or Invalid TDLS Peer Params", __func__,
15455 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
15456 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015457 }
15458
Atul Mittal115287b2014-07-08 13:26:33 +053015459 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
15460
15461 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15462 " %s TDLS Add Force Peer Failed",
15463 __func__);
15464 return -EINVAL;
15465 }
15466 /*EXT TDLS*/
15467
15468 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
15469 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15470 " %s TDLS set callback Failed",
15471 __func__);
15472 return -EINVAL;
15473 }
15474
15475 return(0);
15476
15477}
15478
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015479int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
15480#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15481 const u8 *peer
15482#else
15483 u8 *peer
15484#endif
15485)
Atul Mittal115287b2014-07-08 13:26:33 +053015486{
15487
15488 hddTdlsPeer_t *pTdlsPeer;
15489 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15491 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
15492 __func__, MAC_ADDR_ARRAY(peer));
15493
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015494 if (0 != wlan_hdd_validate_context(pHddCtx)) {
15495 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
15496 return -EINVAL;
15497 }
15498
Atul Mittal115287b2014-07-08 13:26:33 +053015499 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15500 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15501
15502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015503 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15504 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15505 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015506 return -ENOTSUPP;
15507 }
15508
15509
15510 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15511
15512 if ( NULL == pTdlsPeer ) {
15513 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015514 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053015515 __func__, MAC_ADDR_ARRAY(peer));
15516 return -EINVAL;
15517 }
15518 else {
15519 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
15520 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015521 /* if channel switch is configured, reset
15522 the channel for this peer */
15523 if (TRUE == pTdlsPeer->isOffChannelConfigured)
15524 {
15525 pTdlsPeer->peerParams.channel = 0;
15526 pTdlsPeer->isOffChannelConfigured = FALSE;
15527 }
Atul Mittal115287b2014-07-08 13:26:33 +053015528 }
15529
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015530 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
15531 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053015532 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015533 }
Atul Mittal115287b2014-07-08 13:26:33 +053015534
15535 /*EXT TDLS*/
15536
15537 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
15538
15539 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15540 " %s TDLS set callback Failed",
15541 __func__);
15542 return -EINVAL;
15543 }
15544 return(0);
15545
15546}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015547static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015548#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15549 const u8 *peer,
15550#else
15551 u8 *peer,
15552#endif
15553 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015554{
15555 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15556 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015557 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015558 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015559
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015560 ENTER();
15561
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015562 if (!pAdapter) {
15563 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15564 return -EINVAL;
15565 }
15566
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015567 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15568 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
15569 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015570 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015571 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015572 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070015573 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015574 return -EINVAL;
15575 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015576
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015577 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015578 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015579 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015580 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015581 }
15582
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015583
15584 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015585 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015586 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015587 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015588 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
15589 "Cannot process TDLS commands",
15590 pHddCtx->cfg_ini->fEnableTDLSSupport,
15591 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015592 return -ENOTSUPP;
15593 }
15594
15595 switch (oper) {
15596 case NL80211_TDLS_ENABLE_LINK:
15597 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015598 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015599 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015600 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053015601 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015602 tANI_U16 numCurrTdlsPeers = 0;
15603 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015604 tANI_U8 suppChannelLen = 0;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015605
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15607 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
15608 __func__, MAC_ADDR_ARRAY(peer));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015609 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015610 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015611 if ( NULL == pTdlsPeer ) {
15612 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15613 " (oper %d) not exsting. ignored",
15614 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15615 return -EINVAL;
15616 }
15617
15618 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15619 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15620 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15621 "NL80211_TDLS_ENABLE_LINK");
15622
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070015623 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
15624 {
15625 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
15626 MAC_ADDRESS_STR " failed",
15627 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
15628 return -EINVAL;
15629 }
15630
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015631 /* before starting tdls connection, set tdls
15632 * off channel established status to default value */
15633 pTdlsPeer->isOffChannelEstablished = FALSE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015634 /* TDLS Off Channel, Disable tdls channel switch,
15635 when there are more than one tdls link */
15636 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053015637 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015638 {
15639 /* get connected peer and send disable tdls off chan */
15640 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015641 if ((connPeer) &&
15642 (connPeer->isOffChannelSupported == TRUE) &&
15643 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015644 {
15645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15646 "%s: More then one peer connected, Disable "
15647 "TDLS channel switch", __func__);
15648
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015649 connPeer->isOffChannelEstablished = FALSE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015650 ret = sme_SendTdlsChanSwitchReq(
15651 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015652 pAdapter->sessionId,
15653 connPeer->peerMac,
15654 connPeer->peerParams.channel,
15655 TDLS_OFF_CHANNEL_BW_OFFSET,
15656 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015657 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015658 hddLog(VOS_TRACE_LEVEL_ERROR,
15659 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015660 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015661 }
15662 else
15663 {
15664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15665 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015666 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015667 "isOffChannelConfigured %d",
15668 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015669 (connPeer ? (connPeer->isOffChannelSupported)
15670 : -1),
15671 (connPeer ? (connPeer->isOffChannelConfigured)
15672 : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015673 }
15674 }
15675
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015676 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015677 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015678 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053015679
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015680 if (0 != wlan_hdd_tdls_get_link_establish_params(
15681 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015682 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015683 return -EINVAL;
15684 }
15685 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015686
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015687 ret = sme_SendTdlsLinkEstablishParams(
15688 WLAN_HDD_GET_HAL_CTX(pAdapter),
15689 pAdapter->sessionId, peer,
15690 &tdlsLinkEstablishParams);
15691 if (ret != VOS_STATUS_SUCCESS) {
15692 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
15693 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015694 /* Send TDLS peer UAPSD capabilities to the firmware and
15695 * register with the TL on after the response for this operation
15696 * is received .
15697 */
15698 ret = wait_for_completion_interruptible_timeout(
15699 &pAdapter->tdls_link_establish_req_comp,
15700 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
15701 if (ret <= 0)
15702 {
15703 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015704 FL("Link Establish Request Failed Status %ld"),
15705 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015706 return -EINVAL;
15707 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015708 }
Atul Mittal115287b2014-07-08 13:26:33 +053015709 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15710 eTDLS_LINK_CONNECTED,
15711 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015712 staDesc.ucSTAId = pTdlsPeer->staId;
15713 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015714 ret = WLANTL_UpdateTdlsSTAClient(
15715 pHddCtx->pvosContext,
15716 &staDesc);
15717 if (ret != VOS_STATUS_SUCCESS) {
15718 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
15719 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053015720
Gopichand Nakkala471708b2013-06-04 20:03:01 +053015721 /* Mark TDLS client Authenticated .*/
15722 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
15723 pTdlsPeer->staId,
15724 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015725 if (VOS_STATUS_SUCCESS == status)
15726 {
Hoonki Lee14621352013-04-16 17:51:19 -070015727 if (pTdlsPeer->is_responder == 0)
15728 {
15729 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
15730
15731 wlan_hdd_tdls_timer_restart(pAdapter,
15732 &pTdlsPeer->initiatorWaitTimeoutTimer,
15733 WAIT_TIME_TDLS_INITIATOR);
15734 /* suspend initiator TX until it receives direct packet from the
15735 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015736 ret = WLANTL_SuspendDataTx(
15737 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15738 &staId, NULL);
15739 if (ret != VOS_STATUS_SUCCESS) {
15740 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
15741 }
Hoonki Lee14621352013-04-16 17:51:19 -070015742 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015743
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015744 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015745 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015746 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015747 suppChannelLen =
15748 tdlsLinkEstablishParams.supportedChannelsLen;
15749
15750 if ((suppChannelLen > 0) &&
15751 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
15752 {
15753 tANI_U8 suppPeerChannel = 0;
15754 int i = 0;
15755 for (i = 0U; i < suppChannelLen; i++)
15756 {
15757 suppPeerChannel =
15758 tdlsLinkEstablishParams.supportedChannels[i];
15759
15760 pTdlsPeer->isOffChannelSupported = FALSE;
15761 if (suppPeerChannel ==
15762 pTdlsPeer->peerParams.channel)
15763 {
15764 pTdlsPeer->isOffChannelSupported = TRUE;
15765 break;
15766 }
15767 }
15768 }
15769 else
15770 {
15771 pTdlsPeer->isOffChannelSupported = FALSE;
15772 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015773 }
15774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15775 "%s: TDLS channel switch request for channel "
15776 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015777 "%d isOffChannelSupported %d", __func__,
15778 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015779 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015780 suppChannelLen,
15781 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015782
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015783 /* TDLS Off Channel, Enable tdls channel switch,
15784 when their is only one tdls link and it supports */
15785 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15786 if ((numCurrTdlsPeers == 1) &&
15787 (TRUE == pTdlsPeer->isOffChannelSupported) &&
15788 (TRUE == pTdlsPeer->isOffChannelConfigured))
15789 {
15790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15791 "%s: Send TDLS channel switch request for channel %d",
15792 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015793
15794 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015795 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
15796 pAdapter->sessionId,
15797 pTdlsPeer->peerMac,
15798 pTdlsPeer->peerParams.channel,
15799 TDLS_OFF_CHANNEL_BW_OFFSET,
15800 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015801 if (ret != VOS_STATUS_SUCCESS) {
15802 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
15803 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015804 }
15805 else
15806 {
15807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15808 "%s: TDLS channel switch request not sent"
15809 " numCurrTdlsPeers %d "
15810 "isOffChannelSupported %d "
15811 "isOffChannelConfigured %d",
15812 __func__, numCurrTdlsPeers,
15813 pTdlsPeer->isOffChannelSupported,
15814 pTdlsPeer->isOffChannelConfigured);
15815 }
15816
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015817 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015818 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015819
15820 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015821 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
15822 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015823 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015824 int ac;
15825 uint8 ucAc[4] = { WLANTL_AC_VO,
15826 WLANTL_AC_VI,
15827 WLANTL_AC_BK,
15828 WLANTL_AC_BE };
15829 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
15830 for(ac=0; ac < 4; ac++)
15831 {
15832 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15833 pTdlsPeer->staId, ucAc[ac],
15834 tlTid[ac], tlTid[ac], 0, 0,
15835 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015836 if (status != VOS_STATUS_SUCCESS) {
15837 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
15838 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015839 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015840 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015841 }
15842
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015843 }
15844 break;
15845 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080015846 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015847 tANI_U16 numCurrTdlsPeers = 0;
15848 hddTdlsPeer_t *connPeer = NULL;
15849
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15851 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
15852 __func__, MAC_ADDR_ARRAY(peer));
15853
Sunil Dutt41de4e22013-11-14 18:09:02 +053015854 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15855
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015856
Sunil Dutt41de4e22013-11-14 18:09:02 +053015857 if ( NULL == pTdlsPeer ) {
15858 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15859 " (oper %d) not exsting. ignored",
15860 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15861 return -EINVAL;
15862 }
15863
15864 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15865 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15866 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15867 "NL80211_TDLS_DISABLE_LINK");
15868
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015869 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080015870 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015871 long status;
15872
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015873 /* set tdls off channel status to false for this peer */
15874 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053015875 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15876 eTDLS_LINK_TEARING,
15877 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
15878 eTDLS_LINK_UNSPECIFIED:
15879 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015880 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
15881
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015882 status = sme_DeleteTdlsPeerSta(
15883 WLAN_HDD_GET_HAL_CTX(pAdapter),
15884 pAdapter->sessionId, peer );
15885 if (status != VOS_STATUS_SUCCESS) {
15886 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15887 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015888
15889 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
15890 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053015891 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053015892 eTDLS_LINK_IDLE,
15893 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015894 if (status <= 0)
15895 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15897 "%s: Del station failed status %ld",
15898 __func__, status);
15899 return -EPERM;
15900 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015901
15902 /* TDLS Off Channel, Enable tdls channel switch,
15903 when their is only one tdls link and it supports */
15904 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15905 if (numCurrTdlsPeers == 1)
15906 {
15907 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15908 if ((connPeer) &&
15909 (connPeer->isOffChannelSupported == TRUE) &&
15910 (connPeer->isOffChannelConfigured == TRUE))
15911 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015912 connPeer->isOffChannelEstablished = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015913 status = sme_SendTdlsChanSwitchReq(
15914 WLAN_HDD_GET_HAL_CTX(pAdapter),
15915 pAdapter->sessionId,
15916 connPeer->peerMac,
15917 connPeer->peerParams.channel,
15918 TDLS_OFF_CHANNEL_BW_OFFSET,
15919 TDLS_CHANNEL_SWITCH_ENABLE);
15920 if (status != VOS_STATUS_SUCCESS) {
15921 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
15922 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015923 }
15924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15925 "%s: TDLS channel switch "
15926 "isOffChannelSupported %d "
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015927 "isOffChannelConfigured %d "
15928 "isOffChannelEstablished %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015929 __func__,
15930 (connPeer ? connPeer->isOffChannelSupported : -1),
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015931 (connPeer ? connPeer->isOffChannelConfigured : -1),
15932 (connPeer ? connPeer->isOffChannelEstablished : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015933 }
15934 else
15935 {
15936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15937 "%s: TDLS channel switch request not sent "
15938 "numCurrTdlsPeers %d ",
15939 __func__, numCurrTdlsPeers);
15940 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015941 }
15942 else
15943 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15945 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080015946 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015947 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015948 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015949 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015950 {
Atul Mittal115287b2014-07-08 13:26:33 +053015951 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015952
Atul Mittal115287b2014-07-08 13:26:33 +053015953 if (0 != status)
15954 {
15955 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015956 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053015957 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015958 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053015959 break;
15960 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015961 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015962 {
Atul Mittal115287b2014-07-08 13:26:33 +053015963 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
15964 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015965 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053015966 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015967
Atul Mittal115287b2014-07-08 13:26:33 +053015968 if (0 != status)
15969 {
15970 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015971 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053015972 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053015973 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053015974 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015975 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015976 case NL80211_TDLS_DISCOVERY_REQ:
15977 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015979 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015980 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015981 return -ENOTSUPP;
15982 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15984 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015985 return -ENOTSUPP;
15986 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015987
15988 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015989 return 0;
15990}
Chilam NG571c65a2013-01-19 12:27:36 +053015991
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015992static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015993#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15994 const u8 *peer,
15995#else
15996 u8 *peer,
15997#endif
15998 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015999{
16000 int ret;
16001
16002 vos_ssr_protect(__func__);
16003 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
16004 vos_ssr_unprotect(__func__);
16005
16006 return ret;
16007}
16008
Chilam NG571c65a2013-01-19 12:27:36 +053016009int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
16010 struct net_device *dev, u8 *peer)
16011{
Arif Hussaina7c8e412013-11-20 11:06:42 -080016012 hddLog(VOS_TRACE_LEVEL_INFO,
16013 "tdls send discover req: "MAC_ADDRESS_STR,
16014 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053016015
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016016#if TDLS_MGMT_VERSION2
16017 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16018 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16019#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016020#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
16021 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16022 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
16023#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16024 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16025 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16026#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
16027 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16028 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16029#else
Chilam NG571c65a2013-01-19 12:27:36 +053016030 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16031 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016032#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016033#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053016034}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016035#endif
16036
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016037#ifdef WLAN_FEATURE_GTK_OFFLOAD
16038/*
16039 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
16040 * Callback rountine called upon receiving response for
16041 * get offload info
16042 */
16043void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
16044 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
16045{
16046
16047 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016048 tANI_U8 tempReplayCounter[8];
16049 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016050
16051 ENTER();
16052
16053 if (NULL == pAdapter)
16054 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053016055 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016056 "%s: HDD adapter is Null", __func__);
16057 return ;
16058 }
16059
16060 if (NULL == pGtkOffloadGetInfoRsp)
16061 {
16062 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16063 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
16064 return ;
16065 }
16066
16067 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
16068 {
16069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16070 "%s: wlan Failed to get replay counter value",
16071 __func__);
16072 return ;
16073 }
16074
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016075 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16076 /* Update replay counter */
16077 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
16078 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
16079
16080 {
16081 /* changing from little to big endian since supplicant
16082 * works on big endian format
16083 */
16084 int i;
16085 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
16086
16087 for (i = 0; i < 8; i++)
16088 {
16089 tempReplayCounter[7-i] = (tANI_U8)p[i];
16090 }
16091 }
16092
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016093 /* Update replay counter to NL */
16094 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016095 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016096}
16097
16098/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016099 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016100 * This function is used to offload GTK rekeying job to the firmware.
16101 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016102int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016103 struct cfg80211_gtk_rekey_data *data)
16104{
16105 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16106 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16107 hdd_station_ctx_t *pHddStaCtx;
16108 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016109 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016110 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016111 eHalStatus status = eHAL_STATUS_FAILURE;
16112
16113 ENTER();
16114
16115 if (NULL == pAdapter)
16116 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016117 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016118 "%s: HDD adapter is Null", __func__);
16119 return -ENODEV;
16120 }
16121
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016122 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16123 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
16124 pAdapter->sessionId, pAdapter->device_mode));
16125
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016126 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016127 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016128 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016129 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016130 }
16131
16132 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16133 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
16134 if (NULL == hHal)
16135 {
16136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16137 "%s: HAL context is Null!!!", __func__);
16138 return -EAGAIN;
16139 }
16140
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016141 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
16142 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
16143 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
16144 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016145 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016146 {
16147 /* changing from big to little endian since driver
16148 * works on little endian format
16149 */
16150 tANI_U8 *p =
16151 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
16152 int i;
16153
16154 for (i = 0; i < 8; i++)
16155 {
16156 p[7-i] = data->replay_ctr[i];
16157 }
16158 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016159
16160 if (TRUE == pHddCtx->hdd_wlan_suspended)
16161 {
16162 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016163 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
16164 sizeof (tSirGtkOffloadParams));
16165 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016166 pAdapter->sessionId);
16167
16168 if (eHAL_STATUS_SUCCESS != status)
16169 {
16170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16171 "%s: sme_SetGTKOffload failed, returned %d",
16172 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053016173
16174 /* Need to clear any trace of key value in the memory.
16175 * Thus zero out the memory even though it is local
16176 * variable.
16177 */
16178 vos_mem_zero(&hddGtkOffloadReqParams,
16179 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016180 return status;
16181 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16183 "%s: sme_SetGTKOffload successfull", __func__);
16184 }
16185 else
16186 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16188 "%s: wlan not suspended GTKOffload request is stored",
16189 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016190 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016191
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053016192 /* Need to clear any trace of key value in the memory.
16193 * Thus zero out the memory even though it is local
16194 * variable.
16195 */
16196 vos_mem_zero(&hddGtkOffloadReqParams,
16197 sizeof(hddGtkOffloadReqParams));
16198
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016199 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016200 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016201}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016202
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016203int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
16204 struct cfg80211_gtk_rekey_data *data)
16205{
16206 int ret;
16207
16208 vos_ssr_protect(__func__);
16209 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
16210 vos_ssr_unprotect(__func__);
16211
16212 return ret;
16213}
16214#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016215/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016216 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016217 * This function is used to set access control policy
16218 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016219static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16220 struct net_device *dev,
16221 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016222{
16223 int i;
16224 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16225 hdd_hostapd_state_t *pHostapdState;
16226 tsap_Config_t *pConfig;
16227 v_CONTEXT_t pVosContext = NULL;
16228 hdd_context_t *pHddCtx;
16229 int status;
16230
16231 ENTER();
16232
16233 if (NULL == pAdapter)
16234 {
16235 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16236 "%s: HDD adapter is Null", __func__);
16237 return -ENODEV;
16238 }
16239
16240 if (NULL == params)
16241 {
16242 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16243 "%s: params is Null", __func__);
16244 return -EINVAL;
16245 }
16246
16247 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16248 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016249 if (0 != status)
16250 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016251 return status;
16252 }
16253
16254 pVosContext = pHddCtx->pvosContext;
16255 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
16256
16257 if (NULL == pHostapdState)
16258 {
16259 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16260 "%s: pHostapdState is Null", __func__);
16261 return -EINVAL;
16262 }
16263
16264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
16265 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016266 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16267 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
16268 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016269
16270 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
16271 {
16272 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
16273
16274 /* default value */
16275 pConfig->num_accept_mac = 0;
16276 pConfig->num_deny_mac = 0;
16277
16278 /**
16279 * access control policy
16280 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
16281 * listed in hostapd.deny file.
16282 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
16283 * listed in hostapd.accept file.
16284 */
16285 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
16286 {
16287 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
16288 }
16289 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
16290 {
16291 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
16292 }
16293 else
16294 {
16295 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16296 "%s:Acl Policy : %d is not supported",
16297 __func__, params->acl_policy);
16298 return -ENOTSUPP;
16299 }
16300
16301 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
16302 {
16303 pConfig->num_accept_mac = params->n_acl_entries;
16304 for (i = 0; i < params->n_acl_entries; i++)
16305 {
16306 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16307 "** Add ACL MAC entry %i in WhiletList :"
16308 MAC_ADDRESS_STR, i,
16309 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16310
16311 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
16312 sizeof(qcmacaddr));
16313 }
16314 }
16315 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
16316 {
16317 pConfig->num_deny_mac = params->n_acl_entries;
16318 for (i = 0; i < params->n_acl_entries; i++)
16319 {
16320 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16321 "** Add ACL MAC entry %i in BlackList :"
16322 MAC_ADDRESS_STR, i,
16323 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16324
16325 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
16326 sizeof(qcmacaddr));
16327 }
16328 }
16329
16330 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
16331 {
16332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16333 "%s: SAP Set Mac Acl fail", __func__);
16334 return -EINVAL;
16335 }
16336 }
16337 else
16338 {
16339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053016340 "%s: Invalid device_mode = %s (%d)",
16341 __func__, hdd_device_modetoString(pAdapter->device_mode),
16342 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016343 return -EINVAL;
16344 }
16345
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016346 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016347 return 0;
16348}
16349
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016350static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16351 struct net_device *dev,
16352 const struct cfg80211_acl_data *params)
16353{
16354 int ret;
16355 vos_ssr_protect(__func__);
16356 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
16357 vos_ssr_unprotect(__func__);
16358
16359 return ret;
16360}
16361
Leo Chang9056f462013-08-01 19:21:11 -070016362#ifdef WLAN_NL80211_TESTMODE
16363#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070016364void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070016365(
16366 void *pAdapter,
16367 void *indCont
16368)
16369{
Leo Changd9df8aa2013-09-26 13:32:26 -070016370 tSirLPHBInd *lphbInd;
16371 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053016372 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070016373
16374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016375 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070016376
c_hpothu73f35e62014-04-18 13:40:08 +053016377 if (pAdapter == NULL)
16378 {
16379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16380 "%s: pAdapter is NULL\n",__func__);
16381 return;
16382 }
16383
Leo Chang9056f462013-08-01 19:21:11 -070016384 if (NULL == indCont)
16385 {
16386 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016387 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070016388 return;
16389 }
16390
c_hpothu73f35e62014-04-18 13:40:08 +053016391 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070016392 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070016393 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053016394 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070016395 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070016396 GFP_ATOMIC);
16397 if (!skb)
16398 {
16399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16400 "LPHB timeout, NL buffer alloc fail");
16401 return;
16402 }
16403
Leo Changac3ba772013-10-07 09:47:04 -070016404 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070016405 {
16406 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16407 "WLAN_HDD_TM_ATTR_CMD put fail");
16408 goto nla_put_failure;
16409 }
Leo Changac3ba772013-10-07 09:47:04 -070016410 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070016411 {
16412 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16413 "WLAN_HDD_TM_ATTR_TYPE put fail");
16414 goto nla_put_failure;
16415 }
Leo Changac3ba772013-10-07 09:47:04 -070016416 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070016417 sizeof(tSirLPHBInd), lphbInd))
16418 {
16419 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16420 "WLAN_HDD_TM_ATTR_DATA put fail");
16421 goto nla_put_failure;
16422 }
Leo Chang9056f462013-08-01 19:21:11 -070016423 cfg80211_testmode_event(skb, GFP_ATOMIC);
16424 return;
16425
16426nla_put_failure:
16427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16428 "NLA Put fail");
16429 kfree_skb(skb);
16430
16431 return;
16432}
16433#endif /* FEATURE_WLAN_LPHB */
16434
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016435static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070016436{
16437 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
16438 int err = 0;
16439#ifdef FEATURE_WLAN_LPHB
16440 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070016441 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016442
16443 ENTER();
16444
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016445 err = wlan_hdd_validate_context(pHddCtx);
16446 if (0 != err)
16447 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016448 return err;
16449 }
Leo Chang9056f462013-08-01 19:21:11 -070016450#endif /* FEATURE_WLAN_LPHB */
16451
16452 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
16453 if (err)
16454 {
16455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16456 "%s Testmode INV ATTR", __func__);
16457 return err;
16458 }
16459
16460 if (!tb[WLAN_HDD_TM_ATTR_CMD])
16461 {
16462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16463 "%s Testmode INV CMD", __func__);
16464 return -EINVAL;
16465 }
16466
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016467 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16468 TRACE_CODE_HDD_CFG80211_TESTMODE,
16469 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070016470 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
16471 {
16472#ifdef FEATURE_WLAN_LPHB
16473 /* Low Power Heartbeat configuration request */
16474 case WLAN_HDD_TM_CMD_WLAN_HB:
16475 {
16476 int buf_len;
16477 void *buf;
16478 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080016479 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070016480
16481 if (!tb[WLAN_HDD_TM_ATTR_DATA])
16482 {
16483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16484 "%s Testmode INV DATA", __func__);
16485 return -EINVAL;
16486 }
16487
16488 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
16489 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080016490
16491 hb_params_temp =(tSirLPHBReq *)buf;
16492 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
16493 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
16494 return -EINVAL;
16495
Leo Chang9056f462013-08-01 19:21:11 -070016496 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
16497 if (NULL == hb_params)
16498 {
16499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16500 "%s Request Buffer Alloc Fail", __func__);
16501 return -EINVAL;
16502 }
16503
16504 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070016505 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
16506 hb_params,
16507 wlan_hdd_cfg80211_lphb_ind_handler);
16508 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070016509 {
Leo Changd9df8aa2013-09-26 13:32:26 -070016510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16511 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070016512 vos_mem_free(hb_params);
16513 }
Leo Chang9056f462013-08-01 19:21:11 -070016514 return 0;
16515 }
16516#endif /* FEATURE_WLAN_LPHB */
16517 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16519 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070016520 return -EOPNOTSUPP;
16521 }
16522
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016523 EXIT();
16524 return err;
Leo Chang9056f462013-08-01 19:21:11 -070016525}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016526
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053016527static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
16528#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
16529 struct wireless_dev *wdev,
16530#endif
16531 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016532{
16533 int ret;
16534
16535 vos_ssr_protect(__func__);
16536 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
16537 vos_ssr_unprotect(__func__);
16538
16539 return ret;
16540}
Leo Chang9056f462013-08-01 19:21:11 -070016541#endif /* CONFIG_NL80211_TESTMODE */
16542
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016543static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016544 struct net_device *dev,
16545 int idx, struct survey_info *survey)
16546{
16547 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16548 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053016549 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016550 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053016551 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016552 v_S7_t snr,rssi;
16553 int status, i, j, filled = 0;
16554
16555 ENTER();
16556
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016557 if (NULL == pAdapter)
16558 {
16559 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16560 "%s: HDD adapter is Null", __func__);
16561 return -ENODEV;
16562 }
16563
16564 if (NULL == wiphy)
16565 {
16566 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16567 "%s: wiphy is Null", __func__);
16568 return -ENODEV;
16569 }
16570
16571 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16572 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016573 if (0 != status)
16574 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016575 return status;
16576 }
16577
Mihir Sheted9072e02013-08-21 17:02:29 +053016578 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16579
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016580 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053016581 0 != pAdapter->survey_idx ||
16582 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016583 {
16584 /* The survey dump ops when implemented completely is expected to
16585 * return a survey of all channels and the ops is called by the
16586 * kernel with incremental values of the argument 'idx' till it
16587 * returns -ENONET. But we can only support the survey for the
16588 * operating channel for now. survey_idx is used to track
16589 * that the ops is called only once and then return -ENONET for
16590 * the next iteration
16591 */
16592 pAdapter->survey_idx = 0;
16593 return -ENONET;
16594 }
16595
Mukul Sharma9d5233b2015-06-11 20:28:20 +053016596 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
16597 {
16598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16599 "%s: Roaming in progress, hence return ", __func__);
16600 return -ENONET;
16601 }
16602
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016603 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16604
16605 wlan_hdd_get_snr(pAdapter, &snr);
16606 wlan_hdd_get_rssi(pAdapter, &rssi);
16607
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016608 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16609 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
16610 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016611 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
16612 hdd_wlan_get_freq(channel, &freq);
16613
16614
16615 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
16616 {
16617 if (NULL == wiphy->bands[i])
16618 {
16619 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
16620 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
16621 continue;
16622 }
16623
16624 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
16625 {
16626 struct ieee80211_supported_band *band = wiphy->bands[i];
16627
16628 if (band->channels[j].center_freq == (v_U16_t)freq)
16629 {
16630 survey->channel = &band->channels[j];
16631 /* The Rx BDs contain SNR values in dB for the received frames
16632 * while the supplicant expects noise. So we calculate and
16633 * return the value of noise (dBm)
16634 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
16635 */
16636 survey->noise = rssi - snr;
16637 survey->filled = SURVEY_INFO_NOISE_DBM;
16638 filled = 1;
16639 }
16640 }
16641 }
16642
16643 if (filled)
16644 pAdapter->survey_idx = 1;
16645 else
16646 {
16647 pAdapter->survey_idx = 0;
16648 return -ENONET;
16649 }
16650
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016651 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016652 return 0;
16653}
16654
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016655static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
16656 struct net_device *dev,
16657 int idx, struct survey_info *survey)
16658{
16659 int ret;
16660
16661 vos_ssr_protect(__func__);
16662 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
16663 vos_ssr_unprotect(__func__);
16664
16665 return ret;
16666}
16667
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016668/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016669 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016670 * this is called when cfg80211 driver resume
16671 * driver updates latest sched_scan scan result(if any) to cfg80211 database
16672 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016673int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016674{
16675 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16676 hdd_adapter_t *pAdapter;
16677 hdd_adapter_list_node_t *pAdapterNode, *pNext;
16678 VOS_STATUS status = VOS_STATUS_SUCCESS;
16679
16680 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016681
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016682 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016683 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016684 return 0;
16685 }
16686
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016687 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
16688 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016689 spin_lock(&pHddCtx->schedScan_lock);
16690 pHddCtx->isWiphySuspended = FALSE;
16691 if (TRUE != pHddCtx->isSchedScanUpdatePending)
16692 {
16693 spin_unlock(&pHddCtx->schedScan_lock);
16694 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16695 "%s: Return resume is not due to PNO indication", __func__);
16696 return 0;
16697 }
16698 // Reset flag to avoid updatating cfg80211 data old results again
16699 pHddCtx->isSchedScanUpdatePending = FALSE;
16700 spin_unlock(&pHddCtx->schedScan_lock);
16701
16702 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
16703
16704 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
16705 {
16706 pAdapter = pAdapterNode->pAdapter;
16707 if ( (NULL != pAdapter) &&
16708 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
16709 {
16710 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016711 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16713 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016714 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016715 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016716 {
16717 /* Acquire wakelock to handle the case where APP's tries to
16718 * suspend immediately after updating the scan results. Whis
16719 * results in app's is in suspended state and not able to
16720 * process the connect request to AP
16721 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053016722 hdd_prevent_suspend_timeout(2000,
16723 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016724 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016725 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016726
16727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16728 "%s : cfg80211 scan result database updated", __func__);
16729
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016730 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016731 return 0;
16732
16733 }
16734 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16735 pAdapterNode = pNext;
16736 }
16737
16738 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16739 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016740 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016741 return 0;
16742}
16743
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016744int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
16745{
16746 int ret;
16747
16748 vos_ssr_protect(__func__);
16749 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
16750 vos_ssr_unprotect(__func__);
16751
16752 return ret;
16753}
16754
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016755/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016756 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016757 * this is called when cfg80211 driver suspends
16758 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016759int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016760 struct cfg80211_wowlan *wow)
16761{
16762 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016763 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016764
16765 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016766
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016767 ret = wlan_hdd_validate_context(pHddCtx);
16768 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016769 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016770 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016771 }
16772
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016773
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016774 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16775 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
16776 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016777 pHddCtx->isWiphySuspended = TRUE;
16778
16779 EXIT();
16780
16781 return 0;
16782}
16783
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016784int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
16785 struct cfg80211_wowlan *wow)
16786{
16787 int ret;
16788
16789 vos_ssr_protect(__func__);
16790 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
16791 vos_ssr_unprotect(__func__);
16792
16793 return ret;
16794}
Jeff Johnson295189b2012-06-20 16:38:30 -070016795/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016796static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070016797{
16798 .add_virtual_intf = wlan_hdd_add_virtual_intf,
16799 .del_virtual_intf = wlan_hdd_del_virtual_intf,
16800 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
16801 .change_station = wlan_hdd_change_station,
16802#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
16803 .add_beacon = wlan_hdd_cfg80211_add_beacon,
16804 .del_beacon = wlan_hdd_cfg80211_del_beacon,
16805 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016806#else
16807 .start_ap = wlan_hdd_cfg80211_start_ap,
16808 .change_beacon = wlan_hdd_cfg80211_change_beacon,
16809 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070016810#endif
16811 .change_bss = wlan_hdd_cfg80211_change_bss,
16812 .add_key = wlan_hdd_cfg80211_add_key,
16813 .get_key = wlan_hdd_cfg80211_get_key,
16814 .del_key = wlan_hdd_cfg80211_del_key,
16815 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016816#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070016817 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016818#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016819 .scan = wlan_hdd_cfg80211_scan,
16820 .connect = wlan_hdd_cfg80211_connect,
16821 .disconnect = wlan_hdd_cfg80211_disconnect,
16822 .join_ibss = wlan_hdd_cfg80211_join_ibss,
16823 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
16824 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
16825 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
16826 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070016827 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
16828 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053016829 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070016830#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16831 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
16832 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
16833 .set_txq_params = wlan_hdd_set_txq_params,
16834#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016835 .get_station = wlan_hdd_cfg80211_get_station,
16836 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
16837 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016838 .add_station = wlan_hdd_cfg80211_add_station,
16839#ifdef FEATURE_WLAN_LFR
16840 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
16841 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
16842 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
16843#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016844#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
16845 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
16846#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016847#ifdef FEATURE_WLAN_TDLS
16848 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
16849 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
16850#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016851#ifdef WLAN_FEATURE_GTK_OFFLOAD
16852 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
16853#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016854#ifdef FEATURE_WLAN_SCAN_PNO
16855 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
16856 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
16857#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016858 .resume = wlan_hdd_cfg80211_resume_wlan,
16859 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016860 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070016861#ifdef WLAN_NL80211_TESTMODE
16862 .testmode_cmd = wlan_hdd_cfg80211_testmode,
16863#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016864 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070016865};
16866