blob: 89dbb1ece7c61c27b19edde50cf9822f593fc7d3 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +053026 *
Kiet Lamaa8e15a2014-02-11 23:30:06 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Kiet Lama7f454d2014-07-24 12:04:06 -070030
31
Jeff Johnson295189b2012-06-20 16:38:30 -070032/**========================================================================
33
34 \file wlan_hdd_cfg80211.c
35
36 \brief WLAN Host Device Driver implementation
37
Jeff Johnson295189b2012-06-20 16:38:30 -070038 ========================================================================*/
39
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070040/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070041
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070042 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070043
44
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070045 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070047
48
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070049 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070050
51
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070052 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070053 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070054 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070055
56 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070057 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070058 ==========================================================================*/
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060
61#include <linux/version.h>
62#include <linux/module.h>
63#include <linux/kernel.h>
64#include <linux/init.h>
65#include <linux/wireless.h>
66#include <wlan_hdd_includes.h>
67#include <net/arp.h>
68#include <net/cfg80211.h>
69#include <linux/wireless.h>
70#include <wlan_hdd_wowl.h>
71#include <aniGlobal.h>
72#include "ccmApi.h"
73#include "sirParams.h"
74#include "dot11f.h"
75#include "wlan_hdd_assoc.h"
76#include "wlan_hdd_wext.h"
77#include "sme_Api.h"
78#include "wlan_hdd_p2p.h"
79#include "wlan_hdd_cfg80211.h"
80#include "wlan_hdd_hostapd.h"
81#include "sapInternal.h"
82#include "wlan_hdd_softap_tx_rx.h"
83#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053084#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053085#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053086#include "wlan_hdd_trace.h"
87#include "vos_types.h"
88#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070089#ifdef WLAN_BTAMP_FEATURE
90#include "bap_hdd_misc.h"
91#endif
92#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080093#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053094#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053095#include "wlan_qct_wda.h"
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053096#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070097#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070098
99#define g_mode_rates_size (12)
100#define a_mode_rates_size (8)
101#define FREQ_BASE_80211G (2407)
102#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700103#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530104#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800106 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
108#define HDD2GHZCHAN(freq, chan, flag) { \
109 .band = IEEE80211_BAND_2GHZ, \
110 .center_freq = (freq), \
111 .hw_value = (chan),\
112 .flags = (flag), \
113 .max_antenna_gain = 0 ,\
114 .max_power = 30, \
115}
116
117#define HDD5GHZCHAN(freq, chan, flag) { \
118 .band = IEEE80211_BAND_5GHZ, \
119 .center_freq = (freq), \
120 .hw_value = (chan),\
121 .flags = (flag), \
122 .max_antenna_gain = 0 ,\
123 .max_power = 30, \
124}
125
126#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
127{\
128 .bitrate = rate, \
129 .hw_value = rate_id, \
130 .flags = flag, \
131}
132
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530133#ifdef WLAN_FEATURE_VOWIFI_11R
134#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
135#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
136#endif
137
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530138#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530139#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530140
Sunil Duttc69bccb2014-05-26 21:30:20 +0530141#ifdef WLAN_FEATURE_LINK_LAYER_STATS
142/*
143 * Used to allocate the size of 4096 for the link layer stats.
144 * The size of 4096 is considered assuming that all data per
145 * respective event fit with in the limit.Please take a call
146 * on the limit based on the data requirements on link layer
147 * statistics.
148 */
149#define LL_STATS_EVENT_BUF_SIZE 4096
150#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530151#ifdef WLAN_FEATURE_EXTSCAN
152/*
153 * Used to allocate the size of 4096 for the EXTScan NL data.
154 * The size of 4096 is considered assuming that all data per
155 * respective event fit with in the limit.Please take a call
156 * on the limit based on the data requirements.
157 */
158
159#define EXTSCAN_EVENT_BUF_SIZE 4096
160#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
161#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530162
Atul Mittal115287b2014-07-08 13:26:33 +0530163/*EXT TDLS*/
164/*
165 * Used to allocate the size of 4096 for the TDLS.
166 * The size of 4096 is considered assuming that all data per
167 * respective event fit with in the limit.Please take a call
168 * on the limit based on the data requirements on link layer
169 * statistics.
170 */
171#define EXTTDLS_EVENT_BUF_SIZE 4096
172
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530173static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700174{
175 WLAN_CIPHER_SUITE_WEP40,
176 WLAN_CIPHER_SUITE_WEP104,
177 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800178#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700179#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
180 WLAN_CIPHER_SUITE_KRK,
181 WLAN_CIPHER_SUITE_CCMP,
182#else
183 WLAN_CIPHER_SUITE_CCMP,
184#endif
185#ifdef FEATURE_WLAN_WAPI
186 WLAN_CIPHER_SUITE_SMS4,
187#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700188#ifdef WLAN_FEATURE_11W
189 WLAN_CIPHER_SUITE_AES_CMAC,
190#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700191};
192
193static inline int is_broadcast_ether_addr(const u8 *addr)
194{
195 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
196 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
197}
198
199static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530200{
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 HDD2GHZCHAN(2412, 1, 0) ,
202 HDD2GHZCHAN(2417, 2, 0) ,
203 HDD2GHZCHAN(2422, 3, 0) ,
204 HDD2GHZCHAN(2427, 4, 0) ,
205 HDD2GHZCHAN(2432, 5, 0) ,
206 HDD2GHZCHAN(2437, 6, 0) ,
207 HDD2GHZCHAN(2442, 7, 0) ,
208 HDD2GHZCHAN(2447, 8, 0) ,
209 HDD2GHZCHAN(2452, 9, 0) ,
210 HDD2GHZCHAN(2457, 10, 0) ,
211 HDD2GHZCHAN(2462, 11, 0) ,
212 HDD2GHZCHAN(2467, 12, 0) ,
213 HDD2GHZCHAN(2472, 13, 0) ,
214 HDD2GHZCHAN(2484, 14, 0) ,
215};
216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
218{
219 HDD2GHZCHAN(2412, 1, 0) ,
220 HDD2GHZCHAN(2437, 6, 0) ,
221 HDD2GHZCHAN(2462, 11, 0) ,
222};
Jeff Johnson295189b2012-06-20 16:38:30 -0700223
224static struct ieee80211_channel hdd_channels_5_GHZ[] =
225{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700226 HDD5GHZCHAN(4920, 240, 0) ,
227 HDD5GHZCHAN(4940, 244, 0) ,
228 HDD5GHZCHAN(4960, 248, 0) ,
229 HDD5GHZCHAN(4980, 252, 0) ,
230 HDD5GHZCHAN(5040, 208, 0) ,
231 HDD5GHZCHAN(5060, 212, 0) ,
232 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 HDD5GHZCHAN(5180, 36, 0) ,
234 HDD5GHZCHAN(5200, 40, 0) ,
235 HDD5GHZCHAN(5220, 44, 0) ,
236 HDD5GHZCHAN(5240, 48, 0) ,
237 HDD5GHZCHAN(5260, 52, 0) ,
238 HDD5GHZCHAN(5280, 56, 0) ,
239 HDD5GHZCHAN(5300, 60, 0) ,
240 HDD5GHZCHAN(5320, 64, 0) ,
241 HDD5GHZCHAN(5500,100, 0) ,
242 HDD5GHZCHAN(5520,104, 0) ,
243 HDD5GHZCHAN(5540,108, 0) ,
244 HDD5GHZCHAN(5560,112, 0) ,
245 HDD5GHZCHAN(5580,116, 0) ,
246 HDD5GHZCHAN(5600,120, 0) ,
247 HDD5GHZCHAN(5620,124, 0) ,
248 HDD5GHZCHAN(5640,128, 0) ,
249 HDD5GHZCHAN(5660,132, 0) ,
250 HDD5GHZCHAN(5680,136, 0) ,
251 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800252#ifdef FEATURE_WLAN_CH144
253 HDD5GHZCHAN(5720,144, 0) ,
254#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 HDD5GHZCHAN(5745,149, 0) ,
256 HDD5GHZCHAN(5765,153, 0) ,
257 HDD5GHZCHAN(5785,157, 0) ,
258 HDD5GHZCHAN(5805,161, 0) ,
259 HDD5GHZCHAN(5825,165, 0) ,
260};
261
262static struct ieee80211_rate g_mode_rates[] =
263{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530264 HDD_G_MODE_RATETAB(10, 0x1, 0),
265 HDD_G_MODE_RATETAB(20, 0x2, 0),
266 HDD_G_MODE_RATETAB(55, 0x4, 0),
267 HDD_G_MODE_RATETAB(110, 0x8, 0),
268 HDD_G_MODE_RATETAB(60, 0x10, 0),
269 HDD_G_MODE_RATETAB(90, 0x20, 0),
270 HDD_G_MODE_RATETAB(120, 0x40, 0),
271 HDD_G_MODE_RATETAB(180, 0x80, 0),
272 HDD_G_MODE_RATETAB(240, 0x100, 0),
273 HDD_G_MODE_RATETAB(360, 0x200, 0),
274 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530276};
Jeff Johnson295189b2012-06-20 16:38:30 -0700277
278static struct ieee80211_rate a_mode_rates[] =
279{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530280 HDD_G_MODE_RATETAB(60, 0x10, 0),
281 HDD_G_MODE_RATETAB(90, 0x20, 0),
282 HDD_G_MODE_RATETAB(120, 0x40, 0),
283 HDD_G_MODE_RATETAB(180, 0x80, 0),
284 HDD_G_MODE_RATETAB(240, 0x100, 0),
285 HDD_G_MODE_RATETAB(360, 0x200, 0),
286 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 HDD_G_MODE_RATETAB(540, 0x800, 0),
288};
289
290static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
291{
292 .channels = hdd_channels_2_4_GHZ,
293 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
294 .band = IEEE80211_BAND_2GHZ,
295 .bitrates = g_mode_rates,
296 .n_bitrates = g_mode_rates_size,
297 .ht_cap.ht_supported = 1,
298 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
299 | IEEE80211_HT_CAP_GRN_FLD
300 | IEEE80211_HT_CAP_DSSSCCK40
301 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
302 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
303 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
304 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
305 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
306 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
307};
308
Jeff Johnson295189b2012-06-20 16:38:30 -0700309static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
310{
311 .channels = hdd_social_channels_2_4_GHZ,
312 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
313 .band = IEEE80211_BAND_2GHZ,
314 .bitrates = g_mode_rates,
315 .n_bitrates = g_mode_rates_size,
316 .ht_cap.ht_supported = 1,
317 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
318 | IEEE80211_HT_CAP_GRN_FLD
319 | IEEE80211_HT_CAP_DSSSCCK40
320 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
321 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
322 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
323 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
324 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
325 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
326};
Jeff Johnson295189b2012-06-20 16:38:30 -0700327
328static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
329{
330 .channels = hdd_channels_5_GHZ,
331 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
332 .band = IEEE80211_BAND_5GHZ,
333 .bitrates = a_mode_rates,
334 .n_bitrates = a_mode_rates_size,
335 .ht_cap.ht_supported = 1,
336 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
337 | IEEE80211_HT_CAP_GRN_FLD
338 | IEEE80211_HT_CAP_DSSSCCK40
339 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
340 | IEEE80211_HT_CAP_SGI_40
341 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
342 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
343 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
344 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
345 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
346 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
347};
348
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530349/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700350 TX/RX direction for each kind of interface */
351static const struct ieee80211_txrx_stypes
352wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
353 [NL80211_IFTYPE_STATION] = {
354 .tx = 0xffff,
355 .rx = BIT(SIR_MAC_MGMT_ACTION) |
356 BIT(SIR_MAC_MGMT_PROBE_REQ),
357 },
358 [NL80211_IFTYPE_AP] = {
359 .tx = 0xffff,
360 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
361 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
362 BIT(SIR_MAC_MGMT_PROBE_REQ) |
363 BIT(SIR_MAC_MGMT_DISASSOC) |
364 BIT(SIR_MAC_MGMT_AUTH) |
365 BIT(SIR_MAC_MGMT_DEAUTH) |
366 BIT(SIR_MAC_MGMT_ACTION),
367 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700368 [NL80211_IFTYPE_ADHOC] = {
369 .tx = 0xffff,
370 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
371 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
372 BIT(SIR_MAC_MGMT_PROBE_REQ) |
373 BIT(SIR_MAC_MGMT_DISASSOC) |
374 BIT(SIR_MAC_MGMT_AUTH) |
375 BIT(SIR_MAC_MGMT_DEAUTH) |
376 BIT(SIR_MAC_MGMT_ACTION),
377 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 [NL80211_IFTYPE_P2P_CLIENT] = {
379 .tx = 0xffff,
380 .rx = BIT(SIR_MAC_MGMT_ACTION) |
381 BIT(SIR_MAC_MGMT_PROBE_REQ),
382 },
383 [NL80211_IFTYPE_P2P_GO] = {
384 /* This is also same as for SoftAP */
385 .tx = 0xffff,
386 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
387 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
388 BIT(SIR_MAC_MGMT_PROBE_REQ) |
389 BIT(SIR_MAC_MGMT_DISASSOC) |
390 BIT(SIR_MAC_MGMT_AUTH) |
391 BIT(SIR_MAC_MGMT_DEAUTH) |
392 BIT(SIR_MAC_MGMT_ACTION),
393 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700394};
395
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800396#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800397static const struct ieee80211_iface_limit
398wlan_hdd_iface_limit[] = {
399 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800400 /* max = 3 ; Our driver create two interfaces during driver init
401 * wlan0 and p2p0 interfaces. p2p0 is considered as station
402 * interface until a group is formed. In JB architecture, once the
403 * group is formed, interface type of p2p0 is changed to P2P GO or
404 * Client.
405 * When supplicant remove the group, it first issue a set interface
406 * cmd to change the mode back to Station. In JB this works fine as
407 * we advertize two station type interface during driver init.
408 * Some vendors create separate interface for P2P GO/Client,
409 * after group formation(Third one). But while group remove
410 * supplicant first tries to change the mode(3rd interface) to STATION
411 * But as we advertized only two sta type interfaces nl80211 was
412 * returning error for the third one which was leading to failure in
413 * delete interface. Ideally while removing the group, supplicant
414 * should not try to change the 3rd interface mode to Station type.
415 * Till we get a fix in wpa_supplicant, we advertize max STA
416 * interface type to 3
417 */
418 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800419 .types = BIT(NL80211_IFTYPE_STATION),
420 },
421 {
422 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700423 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800424 },
425 {
426 .max = 1,
427 .types = BIT(NL80211_IFTYPE_P2P_GO) |
428 BIT(NL80211_IFTYPE_P2P_CLIENT),
429 },
430};
431
432/* By default, only single channel concurrency is allowed */
433static struct ieee80211_iface_combination
434wlan_hdd_iface_combination = {
435 .limits = wlan_hdd_iface_limit,
436 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800437 /*
438 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
439 * and p2p0 interfaces during driver init
440 * Some vendors create separate interface for P2P operations.
441 * wlan0: STA interface
442 * p2p0: P2P Device interface, action frames goes
443 * through this interface.
444 * p2p-xx: P2P interface, After GO negotiation this interface is
445 * created for p2p operations(GO/CLIENT interface).
446 */
447 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800448 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
449 .beacon_int_infra_match = false,
450};
451#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800452
Jeff Johnson295189b2012-06-20 16:38:30 -0700453static struct cfg80211_ops wlan_hdd_cfg80211_ops;
454
455/* Data rate 100KBPS based on IE Index */
456struct index_data_rate_type
457{
458 v_U8_t beacon_rate_index;
459 v_U16_t supported_rate[4];
460};
461
462/* 11B, 11G Rate table include Basic rate and Extended rate
463 The IDX field is the rate index
464 The HI field is the rate when RSSI is strong or being ignored
465 (in this case we report actual rate)
466 The MID field is the rate when RSSI is moderate
467 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
468 The LO field is the rate when RSSI is low
469 (in this case we don't report rates, actual current rate used)
470 */
471static const struct
472{
473 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700474 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700475} supported_data_rate[] =
476{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700477/* IDX HI HM LM LO (RSSI-based index */
478 {2, { 10, 10, 10, 0}},
479 {4, { 20, 20, 10, 0}},
480 {11, { 55, 20, 10, 0}},
481 {12, { 60, 55, 20, 0}},
482 {18, { 90, 55, 20, 0}},
483 {22, {110, 55, 20, 0}},
484 {24, {120, 90, 60, 0}},
485 {36, {180, 120, 60, 0}},
486 {44, {220, 180, 60, 0}},
487 {48, {240, 180, 90, 0}},
488 {66, {330, 180, 90, 0}},
489 {72, {360, 240, 90, 0}},
490 {96, {480, 240, 120, 0}},
491 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700492};
493
494/* MCS Based rate table */
495static struct index_data_rate_type supported_mcs_rate[] =
496{
497/* MCS L20 L40 S20 S40 */
498 {0, {65, 135, 72, 150}},
499 {1, {130, 270, 144, 300}},
500 {2, {195, 405, 217, 450}},
501 {3, {260, 540, 289, 600}},
502 {4, {390, 810, 433, 900}},
503 {5, {520, 1080, 578, 1200}},
504 {6, {585, 1215, 650, 1350}},
505 {7, {650, 1350, 722, 1500}}
506};
507
Leo Chang6f8870f2013-03-26 18:11:36 -0700508#ifdef WLAN_FEATURE_11AC
509
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530510#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700511
512struct index_vht_data_rate_type
513{
514 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530515 v_U16_t supported_VHT80_rate[2];
516 v_U16_t supported_VHT40_rate[2];
517 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700518};
519
520typedef enum
521{
522 DATA_RATE_11AC_MAX_MCS_7,
523 DATA_RATE_11AC_MAX_MCS_8,
524 DATA_RATE_11AC_MAX_MCS_9,
525 DATA_RATE_11AC_MAX_MCS_NA
526} eDataRate11ACMaxMcs;
527
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530528/* SSID broadcast type */
529typedef enum eSSIDBcastType
530{
531 eBCAST_UNKNOWN = 0,
532 eBCAST_NORMAL = 1,
533 eBCAST_HIDDEN = 2,
534} tSSIDBcastType;
535
Leo Chang6f8870f2013-03-26 18:11:36 -0700536/* MCS Based VHT rate table */
537static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
538{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530539/* MCS L80 S80 L40 S40 L20 S40*/
540 {0, {293, 325}, {135, 150}, {65, 72}},
541 {1, {585, 650}, {270, 300}, {130, 144}},
542 {2, {878, 975}, {405, 450}, {195, 217}},
543 {3, {1170, 1300}, {540, 600}, {260, 289}},
544 {4, {1755, 1950}, {810, 900}, {390, 433}},
545 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
546 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
547 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
548 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
549 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700550};
551#endif /* WLAN_FEATURE_11AC */
552
c_hpothu79aab322014-07-14 21:11:01 +0530553/*array index points to MCS and array value points respective rssi*/
554static int rssiMcsTbl[][10] =
555{
556/*MCS 0 1 2 3 4 5 6 7 8 9*/
557 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
558 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
559 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
560};
561
Jeff Johnson295189b2012-06-20 16:38:30 -0700562extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530563#ifdef FEATURE_WLAN_SCAN_PNO
564static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
565#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700566
Leo Chang9056f462013-08-01 19:21:11 -0700567#ifdef WLAN_NL80211_TESTMODE
568enum wlan_hdd_tm_attr
569{
570 WLAN_HDD_TM_ATTR_INVALID = 0,
571 WLAN_HDD_TM_ATTR_CMD = 1,
572 WLAN_HDD_TM_ATTR_DATA = 2,
573 WLAN_HDD_TM_ATTR_TYPE = 3,
574 /* keep last */
575 WLAN_HDD_TM_ATTR_AFTER_LAST,
576 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
577};
578
579enum wlan_hdd_tm_cmd
580{
581 WLAN_HDD_TM_CMD_WLAN_HB = 1,
582};
583
584#define WLAN_HDD_TM_DATA_MAX_LEN 5000
585
586static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
587{
588 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
589 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
590 .len = WLAN_HDD_TM_DATA_MAX_LEN },
591};
592#endif /* WLAN_NL80211_TESTMODE */
593
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800594#ifdef FEATURE_WLAN_CH_AVOID
595/*
596 * FUNCTION: wlan_hdd_send_avoid_freq_event
597 * This is called when wlan driver needs to send vendor specific
598 * avoid frequency range event to userspace
599 */
600int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
601 tHddAvoidFreqList *pAvoidFreqList)
602{
603 struct sk_buff *vendor_event;
604
605 ENTER();
606
607 if (!pHddCtx)
608 {
609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
610 "%s: HDD context is null", __func__);
611 return -1;
612 }
613
614 if (!pAvoidFreqList)
615 {
616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
617 "%s: pAvoidFreqList is null", __func__);
618 return -1;
619 }
620
621 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530622#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
623 NULL,
624#endif
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800625 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530626 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800627 GFP_KERNEL);
628 if (!vendor_event)
629 {
630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
631 "%s: cfg80211_vendor_event_alloc failed", __func__);
632 return -1;
633 }
634
635 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
636 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
637
638 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
639
640 EXIT();
641 return 0;
642}
643#endif /* FEATURE_WLAN_CH_AVOID */
644
Srinivas Dasari030bad32015-02-18 23:23:54 +0530645/*
646 * FUNCTION: __wlan_hdd_cfg80211_nan_request
647 * This is called when wlan driver needs to send vendor specific
648 * nan request event.
649 */
650static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
651 struct wireless_dev *wdev,
652 const void *data, int data_len)
653{
654 tNanRequestReq nan_req;
655 VOS_STATUS status;
656 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530657 struct net_device *dev = wdev->netdev;
658 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
659 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530660 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
661
662 if (0 == data_len)
663 {
664 hddLog(VOS_TRACE_LEVEL_ERROR,
665 FL("NAN - Invalid Request, length = 0"));
666 return ret_val;
667 }
668
669 if (NULL == data)
670 {
671 hddLog(VOS_TRACE_LEVEL_ERROR,
672 FL("NAN - Invalid Request, data is NULL"));
673 return ret_val;
674 }
675
676 status = wlan_hdd_validate_context(pHddCtx);
677 if (0 != status)
678 {
679 hddLog(VOS_TRACE_LEVEL_ERROR,
680 FL("HDD context is not valid"));
681 return -EINVAL;
682 }
683
684 hddLog(LOG1, FL("Received NAN command"));
685 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
686 (tANI_U8 *)data, data_len);
687
688 /* check the NAN Capability */
689 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
690 {
691 hddLog(VOS_TRACE_LEVEL_ERROR,
692 FL("NAN is not supported by Firmware"));
693 return -EINVAL;
694 }
695
696 nan_req.request_data_len = data_len;
697 nan_req.request_data = data;
698
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530699 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530700 if (VOS_STATUS_SUCCESS == status)
701 {
702 ret_val = 0;
703 }
704 return ret_val;
705}
706
707/*
708 * FUNCTION: wlan_hdd_cfg80211_nan_request
709 * Wrapper to protect the nan vendor command from ssr
710 */
711static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
712 struct wireless_dev *wdev,
713 const void *data, int data_len)
714{
715 int ret;
716
717 vos_ssr_protect(__func__);
718 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
719 vos_ssr_unprotect(__func__);
720
721 return ret;
722}
723
724/*
725 * FUNCTION: wlan_hdd_cfg80211_nan_callback
726 * This is a callback function and it gets called
727 * when we need to report nan response event to
728 * upper layers.
729 */
730static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
731{
732 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
733 struct sk_buff *vendor_event;
734 int status;
735 tSirNanEvent *data;
736
737 ENTER();
738 if (NULL == msg)
739 {
740 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
741 FL(" msg received here is null"));
742 return;
743 }
744 data = msg;
745
746 status = wlan_hdd_validate_context(pHddCtx);
747
748 if (0 != status)
749 {
750 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
751 FL("HDD context is not valid"));
752 return;
753 }
754
755 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530756#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
757 NULL,
758#endif
Srinivas Dasari030bad32015-02-18 23:23:54 +0530759 data->event_data_len +
760 NLMSG_HDRLEN,
761 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
762 GFP_KERNEL);
763
764 if (!vendor_event)
765 {
766 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
767 FL("cfg80211_vendor_event_alloc failed"));
768 return;
769 }
770 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
771 data->event_data_len, data->event_data))
772 {
773 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
774 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
775 kfree_skb(vendor_event);
776 return;
777 }
778 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
779 EXIT();
780}
781
782/*
783 * FUNCTION: wlan_hdd_cfg80211_nan_init
784 * This function is called to register the callback to sme layer
785 */
786inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
787{
788 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
789}
790
791
Sunil Duttc69bccb2014-05-26 21:30:20 +0530792#ifdef WLAN_FEATURE_LINK_LAYER_STATS
793
794static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
795 struct sk_buff *vendor_event)
796{
797 if (nla_put_u8(vendor_event,
798 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
799 stats->rate.preamble) ||
800 nla_put_u8(vendor_event,
801 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
802 stats->rate.nss) ||
803 nla_put_u8(vendor_event,
804 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
805 stats->rate.bw) ||
806 nla_put_u8(vendor_event,
807 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
808 stats->rate.rateMcsIdx) ||
809 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
810 stats->rate.bitrate ) ||
811 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
812 stats->txMpdu ) ||
813 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
814 stats->rxMpdu ) ||
815 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
816 stats->mpduLost ) ||
817 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
818 stats->retries) ||
819 nla_put_u32(vendor_event,
820 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
821 stats->retriesShort ) ||
822 nla_put_u32(vendor_event,
823 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
824 stats->retriesLong))
825 {
826 hddLog(VOS_TRACE_LEVEL_ERROR,
827 FL("QCA_WLAN_VENDOR_ATTR put fail"));
828 return FALSE;
829 }
830 return TRUE;
831}
832
833static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
834 struct sk_buff *vendor_event)
835{
836 u32 i = 0;
837 struct nlattr *rateInfo;
838 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
839 stats->type) ||
840 nla_put(vendor_event,
841 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
842 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
843 nla_put_u32(vendor_event,
844 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
845 stats->capabilities) ||
846 nla_put_u32(vendor_event,
847 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
848 stats->numRate))
849 {
850 hddLog(VOS_TRACE_LEVEL_ERROR,
851 FL("QCA_WLAN_VENDOR_ATTR put fail"));
852 goto error;
853 }
854
855 rateInfo = nla_nest_start(vendor_event,
856 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530857 if(!rateInfo)
858 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530859 for (i = 0; i < stats->numRate; i++)
860 {
861 struct nlattr *rates;
862 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
863 stats->rateStats +
864 (i * sizeof(tSirWifiRateStat)));
865 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530866 if(!rates)
867 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530868
869 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
870 {
871 hddLog(VOS_TRACE_LEVEL_ERROR,
872 FL("QCA_WLAN_VENDOR_ATTR put fail"));
873 return FALSE;
874 }
875 nla_nest_end(vendor_event, rates);
876 }
877 nla_nest_end(vendor_event, rateInfo);
878
879 return TRUE;
880error:
881 return FALSE;
882}
883
884static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
885 struct sk_buff *vendor_event)
886{
887 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
888 stats->ac ) ||
889 nla_put_u32(vendor_event,
890 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
891 stats->txMpdu ) ||
892 nla_put_u32(vendor_event,
893 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
894 stats->rxMpdu ) ||
895 nla_put_u32(vendor_event,
896 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
897 stats->txMcast ) ||
898 nla_put_u32(vendor_event,
899 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
900 stats->rxMcast ) ||
901 nla_put_u32(vendor_event,
902 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
903 stats->rxAmpdu ) ||
904 nla_put_u32(vendor_event,
905 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
906 stats->txAmpdu ) ||
907 nla_put_u32(vendor_event,
908 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
909 stats->mpduLost )||
910 nla_put_u32(vendor_event,
911 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
912 stats->retries ) ||
913 nla_put_u32(vendor_event,
914 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
915 stats->retriesShort ) ||
916 nla_put_u32(vendor_event,
917 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
918 stats->retriesLong ) ||
919 nla_put_u32(vendor_event,
920 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
921 stats->contentionTimeMin ) ||
922 nla_put_u32(vendor_event,
923 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
924 stats->contentionTimeMax ) ||
925 nla_put_u32(vendor_event,
926 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
927 stats->contentionTimeAvg ) ||
928 nla_put_u32(vendor_event,
929 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
930 stats->contentionNumSamples ))
931 {
932 hddLog(VOS_TRACE_LEVEL_ERROR,
933 FL("QCA_WLAN_VENDOR_ATTR put fail") );
934 return FALSE;
935 }
936 return TRUE;
937}
938
939static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
940 struct sk_buff *vendor_event)
941{
Dino Myclec8f3f332014-07-21 16:48:27 +0530942 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530943 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
944 nla_put(vendor_event,
945 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
946 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
947 nla_put_u32(vendor_event,
948 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
949 stats->state ) ||
950 nla_put_u32(vendor_event,
951 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
952 stats->roaming ) ||
953 nla_put_u32(vendor_event,
954 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
955 stats->capabilities ) ||
956 nla_put(vendor_event,
957 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
958 strlen(stats->ssid), stats->ssid) ||
959 nla_put(vendor_event,
960 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
961 WNI_CFG_BSSID_LEN, stats->bssid) ||
962 nla_put(vendor_event,
963 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
964 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
965 nla_put(vendor_event,
966 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
967 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
968 )
969 {
970 hddLog(VOS_TRACE_LEVEL_ERROR,
971 FL("QCA_WLAN_VENDOR_ATTR put fail") );
972 return FALSE;
973 }
974 return TRUE;
975}
976
Dino Mycle3b9536d2014-07-09 22:05:24 +0530977static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
978 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530979 struct sk_buff *vendor_event)
980{
981 int i = 0;
982 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530983 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
984 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530985 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530986
Sunil Duttc69bccb2014-05-26 21:30:20 +0530987 if (FALSE == put_wifi_interface_info(
988 &pWifiIfaceStat->info,
989 vendor_event))
990 {
991 hddLog(VOS_TRACE_LEVEL_ERROR,
992 FL("QCA_WLAN_VENDOR_ATTR put fail") );
993 return FALSE;
994
995 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530996 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
997 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
998 if (NULL == pWifiIfaceStatTL)
999 {
1000 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
1001 return FALSE;
1002 }
1003
Srinivas Dasaria8a304f2014-11-15 16:13:37 +05301004 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
1005 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
1006 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
1007 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1008
1009 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1010 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1011 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1012 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301013
1014 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1015 {
1016 if (VOS_STATUS_SUCCESS ==
1017 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1018 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1019 {
1020 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1021 * obtained from TL structure
1022 */
1023
1024 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1025 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301026 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1027
Srinivas Dasari98947432014-11-07 19:41:24 +05301028 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1029 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1030 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1031 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1032 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1033 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1034 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1035 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301036
Srinivas Dasari98947432014-11-07 19:41:24 +05301037 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1038 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1039 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1040 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1041 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1042 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1043 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1044 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301045
Srinivas Dasari98947432014-11-07 19:41:24 +05301046 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1047 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1048 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1049 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1050 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1051 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1052 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1053 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301054 }
1055 else
1056 {
1057 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1058 }
1059
Dino Mycle3b9536d2014-07-09 22:05:24 +05301060 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1061 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1062 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1063 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1064 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1065 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1066 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1067 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1068 }
1069 else
1070 {
1071 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1072 }
1073
1074
Sunil Duttc69bccb2014-05-26 21:30:20 +05301075
1076 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301077 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1078 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_IFACE) ||
1079 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301080 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1081 pWifiIfaceStat->beaconRx) ||
1082 nla_put_u32(vendor_event,
1083 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1084 pWifiIfaceStat->mgmtRx) ||
1085 nla_put_u32(vendor_event,
1086 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1087 pWifiIfaceStat->mgmtActionRx) ||
1088 nla_put_u32(vendor_event,
1089 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1090 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301091 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301092 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1093 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301094 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301095 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1096 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301097 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301098 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1099 pWifiIfaceStat->rssiAck))
1100 {
1101 hddLog(VOS_TRACE_LEVEL_ERROR,
1102 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301103 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301104 return FALSE;
1105 }
1106
1107 wmmInfo = nla_nest_start(vendor_event,
1108 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301109 if(!wmmInfo)
1110 {
1111 vos_mem_free(pWifiIfaceStatTL);
1112 return FALSE;
1113 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301114 for (i = 0; i < WIFI_AC_MAX; i++)
1115 {
1116 struct nlattr *wmmStats;
1117 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301118 if(!wmmStats)
1119 {
1120 vos_mem_free(pWifiIfaceStatTL);
1121 return FALSE;
1122 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301123 if (FALSE == put_wifi_wmm_ac_stat(
1124 &pWifiIfaceStat->AccessclassStats[i],
1125 vendor_event))
1126 {
1127 hddLog(VOS_TRACE_LEVEL_ERROR,
1128 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301129 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301130 return FALSE;
1131 }
1132
1133 nla_nest_end(vendor_event, wmmStats);
1134 }
1135 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301136 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301137 return TRUE;
1138}
1139
1140static tSirWifiInterfaceMode
1141 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1142{
1143 switch (deviceMode)
1144 {
1145 case WLAN_HDD_INFRA_STATION:
1146 return WIFI_INTERFACE_STA;
1147 case WLAN_HDD_SOFTAP:
1148 return WIFI_INTERFACE_SOFTAP;
1149 case WLAN_HDD_P2P_CLIENT:
1150 return WIFI_INTERFACE_P2P_CLIENT;
1151 case WLAN_HDD_P2P_GO:
1152 return WIFI_INTERFACE_P2P_GO;
1153 case WLAN_HDD_IBSS:
1154 return WIFI_INTERFACE_IBSS;
1155 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301156 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301157 }
1158}
1159
1160static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1161 tpSirWifiInterfaceInfo pInfo)
1162{
1163 v_U8_t *staMac = NULL;
1164 hdd_station_ctx_t *pHddStaCtx;
1165 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1166 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1167
1168 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1169
1170 vos_mem_copy(pInfo->macAddr,
1171 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1172
1173 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1174 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1175 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1176 {
1177 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1178 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1179 {
1180 pInfo->state = WIFI_DISCONNECTED;
1181 }
1182 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1183 {
1184 hddLog(VOS_TRACE_LEVEL_ERROR,
1185 "%s: Session ID %d, Connection is in progress", __func__,
1186 pAdapter->sessionId);
1187 pInfo->state = WIFI_ASSOCIATING;
1188 }
1189 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1190 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1191 {
1192 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1193 hddLog(VOS_TRACE_LEVEL_ERROR,
1194 "%s: client " MAC_ADDRESS_STR
1195 " is in the middle of WPS/EAPOL exchange.", __func__,
1196 MAC_ADDR_ARRAY(staMac));
1197 pInfo->state = WIFI_AUTHENTICATING;
1198 }
1199 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1200 {
1201 pInfo->state = WIFI_ASSOCIATED;
1202 vos_mem_copy(pInfo->bssid,
1203 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1204 vos_mem_copy(pInfo->ssid,
1205 pHddStaCtx->conn_info.SSID.SSID.ssId,
1206 pHddStaCtx->conn_info.SSID.SSID.length);
1207 //NULL Terminate the string.
1208 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1209 }
1210 }
1211 vos_mem_copy(pInfo->countryStr,
1212 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1213
1214 vos_mem_copy(pInfo->apCountryStr,
1215 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1216
1217 return TRUE;
1218}
1219
1220/*
1221 * hdd_link_layer_process_peer_stats () - This function is called after
1222 * receiving Link Layer Peer statistics from FW.This function converts
1223 * the firmware data to the NL data and sends the same to the kernel/upper
1224 * layers.
1225 */
1226static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1227 v_VOID_t *pData)
1228{
1229 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1230 tpSirWifiRateStat pWifiRateStat;
1231 tpSirWifiPeerStat pWifiPeerStat;
1232 tpSirWifiPeerInfo pWifiPeerInfo;
1233 struct nlattr *peerInfo;
1234 struct sk_buff *vendor_event;
1235 int status, i;
1236
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301237 ENTER();
1238
Sunil Duttc69bccb2014-05-26 21:30:20 +05301239 status = wlan_hdd_validate_context(pHddCtx);
1240 if (0 != status)
1241 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301242 return;
1243 }
1244
1245 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1246
1247 hddLog(VOS_TRACE_LEVEL_INFO,
1248 "LL_STATS_PEER_ALL : numPeers %u",
1249 pWifiPeerStat->numPeers);
1250 {
1251 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1252 {
1253 pWifiPeerInfo = (tpSirWifiPeerInfo)
1254 ((uint8 *)pWifiPeerStat->peerInfo +
1255 ( i * sizeof(tSirWifiPeerInfo)));
1256
Dasari Srinivas1be0c4e2014-10-19 13:03:41 +05301257 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) {
1258 pWifiPeerInfo->type = WIFI_PEER_AP;
1259 }
1260 if (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) {
1261 pWifiPeerInfo->type = WIFI_PEER_P2P_GO;
1262 }
1263
Sunil Duttc69bccb2014-05-26 21:30:20 +05301264 hddLog(VOS_TRACE_LEVEL_INFO,
1265 " %d) LL_STATS Channel Stats "
1266 " Peer Type %u "
1267 " peerMacAddress %pM "
1268 " capabilities 0x%x "
1269 " numRate %u ",
1270 i,
1271 pWifiPeerInfo->type,
1272 pWifiPeerInfo->peerMacAddress,
1273 pWifiPeerInfo->capabilities,
1274 pWifiPeerInfo->numRate);
1275 {
1276 int j;
1277 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1278 {
1279 pWifiRateStat = (tpSirWifiRateStat)
1280 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1281 ( j * sizeof(tSirWifiRateStat)));
1282
1283 hddLog(VOS_TRACE_LEVEL_INFO,
1284 " peer Rate Stats "
1285 " preamble %u "
1286 " nss %u "
1287 " bw %u "
1288 " rateMcsIdx %u "
1289 " reserved %u "
1290 " bitrate %u "
1291 " txMpdu %u "
1292 " rxMpdu %u "
1293 " mpduLost %u "
1294 " retries %u "
1295 " retriesShort %u "
1296 " retriesLong %u",
1297 pWifiRateStat->rate.preamble,
1298 pWifiRateStat->rate.nss,
1299 pWifiRateStat->rate.bw,
1300 pWifiRateStat->rate.rateMcsIdx,
1301 pWifiRateStat->rate.reserved,
1302 pWifiRateStat->rate.bitrate,
1303 pWifiRateStat->txMpdu,
1304 pWifiRateStat->rxMpdu,
1305 pWifiRateStat->mpduLost,
1306 pWifiRateStat->retries,
1307 pWifiRateStat->retriesShort,
1308 pWifiRateStat->retriesLong);
1309 }
1310 }
1311 }
1312 }
1313
1314 /*
1315 * Allocate a size of 4096 for the peer stats comprising
1316 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1317 * sizeof (tSirWifiRateStat).Each field is put with an
1318 * NL attribute.The size of 4096 is considered assuming
1319 * that number of rates shall not exceed beyond 50 with
1320 * the sizeof (tSirWifiRateStat) being 32.
1321 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301322 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1323 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301324 if (!vendor_event)
1325 {
1326 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301327 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301328 __func__);
1329 return;
1330 }
1331 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301332 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1333 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_PEER) ||
1334 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301335 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1336 pWifiPeerStat->numPeers))
1337 {
1338 hddLog(VOS_TRACE_LEVEL_ERROR,
1339 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1340 kfree_skb(vendor_event);
1341 return;
1342 }
1343
1344 peerInfo = nla_nest_start(vendor_event,
1345 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301346 if(!peerInfo)
1347 {
1348 hddLog(VOS_TRACE_LEVEL_ERROR,
1349 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1350 __func__);
1351 kfree_skb(vendor_event);
1352 return;
1353 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301354
1355 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1356 pWifiPeerStat->peerInfo);
1357
1358 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1359 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301360 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301361 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301362
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301363 if(!peers)
1364 {
1365 hddLog(VOS_TRACE_LEVEL_ERROR,
1366 "%s: peer stats put fail",
1367 __func__);
1368 kfree_skb(vendor_event);
1369 return;
1370 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301371 if (FALSE == put_wifi_peer_info(
1372 pWifiPeerInfo, vendor_event))
1373 {
1374 hddLog(VOS_TRACE_LEVEL_ERROR,
1375 "%s: put_wifi_peer_info put fail", __func__);
1376 kfree_skb(vendor_event);
1377 return;
1378 }
1379
1380 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1381 pWifiPeerStat->peerInfo +
1382 (i * sizeof(tSirWifiPeerInfo)) +
1383 (numRate * sizeof (tSirWifiRateStat)));
1384 nla_nest_end(vendor_event, peers);
1385 }
1386 nla_nest_end(vendor_event, peerInfo);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301387 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301388 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301389}
1390
1391/*
1392 * hdd_link_layer_process_iface_stats () - This function is called after
1393 * receiving Link Layer Interface statistics from FW.This function converts
1394 * the firmware data to the NL data and sends the same to the kernel/upper
1395 * layers.
1396 */
1397static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1398 v_VOID_t *pData)
1399{
1400 tpSirWifiIfaceStat pWifiIfaceStat;
1401 struct sk_buff *vendor_event;
1402 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1403 int status;
1404
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301405 ENTER();
1406
Sunil Duttc69bccb2014-05-26 21:30:20 +05301407 status = wlan_hdd_validate_context(pHddCtx);
1408 if (0 != status)
1409 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301410 return;
1411 }
1412 /*
1413 * Allocate a size of 4096 for the interface stats comprising
1414 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1415 * assuming that all these fit with in the limit.Please take
1416 * a call on the limit based on the data requirements on
1417 * interface statistics.
1418 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301419 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1420 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301421 if (!vendor_event)
1422 {
1423 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301424 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301425 return;
1426 }
1427
1428 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1429
Dino Mycle3b9536d2014-07-09 22:05:24 +05301430
1431 if (FALSE == hdd_get_interface_info( pAdapter,
1432 &pWifiIfaceStat->info))
1433 {
1434 hddLog(VOS_TRACE_LEVEL_ERROR,
1435 FL("hdd_get_interface_info get fail") );
1436 kfree_skb(vendor_event);
1437 return;
1438 }
1439
1440 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1441 vendor_event))
1442 {
1443 hddLog(VOS_TRACE_LEVEL_ERROR,
1444 FL("put_wifi_iface_stats fail") );
1445 kfree_skb(vendor_event);
1446 return;
1447 }
1448
Sunil Duttc69bccb2014-05-26 21:30:20 +05301449 hddLog(VOS_TRACE_LEVEL_INFO,
1450 "WMI_LINK_STATS_IFACE Data");
1451
1452 hddLog(VOS_TRACE_LEVEL_INFO,
1453 "LL_STATS_IFACE: "
1454 " Mode %u "
1455 " MAC %pM "
1456 " State %u "
1457 " Roaming %u "
1458 " capabilities 0x%x "
1459 " SSID %s "
1460 " BSSID %pM",
1461 pWifiIfaceStat->info.mode,
1462 pWifiIfaceStat->info.macAddr,
1463 pWifiIfaceStat->info.state,
1464 pWifiIfaceStat->info.roaming,
1465 pWifiIfaceStat->info.capabilities,
1466 pWifiIfaceStat->info.ssid,
1467 pWifiIfaceStat->info.bssid);
1468
1469 hddLog(VOS_TRACE_LEVEL_INFO,
1470 " AP country str: %c%c%c",
1471 pWifiIfaceStat->info.apCountryStr[0],
1472 pWifiIfaceStat->info.apCountryStr[1],
1473 pWifiIfaceStat->info.apCountryStr[2]);
1474
1475
1476 hddLog(VOS_TRACE_LEVEL_INFO,
1477 " Country Str Association: %c%c%c",
1478 pWifiIfaceStat->info.countryStr[0],
1479 pWifiIfaceStat->info.countryStr[1],
1480 pWifiIfaceStat->info.countryStr[2]);
1481
1482 hddLog(VOS_TRACE_LEVEL_INFO,
1483 " beaconRx %u "
1484 " mgmtRx %u "
1485 " mgmtActionRx %u "
1486 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301487 " rssiMgmt %d "
1488 " rssiData %d "
1489 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301490 pWifiIfaceStat->beaconRx,
1491 pWifiIfaceStat->mgmtRx,
1492 pWifiIfaceStat->mgmtActionRx,
1493 pWifiIfaceStat->mgmtActionTx,
1494 pWifiIfaceStat->rssiMgmt,
1495 pWifiIfaceStat->rssiData,
1496 pWifiIfaceStat->rssiAck );
1497
1498
1499 {
1500 int i;
1501 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1502 {
1503 hddLog(VOS_TRACE_LEVEL_INFO,
1504
1505 " %d) LL_STATS IFACE: "
1506 " ac: %u txMpdu: %u "
1507 " rxMpdu: %u txMcast: %u "
1508 " rxMcast: %u rxAmpdu: %u "
1509 " txAmpdu: %u mpduLost: %u "
1510 " retries: %u retriesShort: %u "
1511 " retriesLong: %u contentionTimeMin: %u "
1512 " contentionTimeMax: %u contentionTimeAvg: %u "
1513 " contentionNumSamples: %u",
1514 i,
1515 pWifiIfaceStat->AccessclassStats[i].ac,
1516 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1517 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1518 pWifiIfaceStat->AccessclassStats[i].txMcast,
1519 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1520 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1521 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1522 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1523 pWifiIfaceStat->AccessclassStats[i].retries,
1524 pWifiIfaceStat->
1525 AccessclassStats[i].retriesShort,
1526 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1527 pWifiIfaceStat->
1528 AccessclassStats[i].contentionTimeMin,
1529 pWifiIfaceStat->
1530 AccessclassStats[i].contentionTimeMax,
1531 pWifiIfaceStat->
1532 AccessclassStats[i].contentionTimeAvg,
1533 pWifiIfaceStat->
1534 AccessclassStats[i].contentionNumSamples);
1535
1536 }
1537 }
1538
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301539 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301540
1541 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301542}
1543
1544/*
1545 * hdd_link_layer_process_radio_stats () - This function is called after
1546 * receiving Link Layer Radio statistics from FW.This function converts
1547 * the firmware data to the NL data and sends the same to the kernel/upper
1548 * layers.
1549 */
1550static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1551 v_VOID_t *pData)
1552{
1553 int status, i;
1554 tpSirWifiRadioStat pWifiRadioStat;
1555 tpSirWifiChannelStats pWifiChannelStats;
1556 struct sk_buff *vendor_event;
1557 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1558 struct nlattr *chList;
1559
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301560 ENTER();
1561
Sunil Duttc69bccb2014-05-26 21:30:20 +05301562 status = wlan_hdd_validate_context(pHddCtx);
1563 if (0 != status)
1564 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301565 return;
1566 }
1567 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1568
1569 hddLog(VOS_TRACE_LEVEL_INFO,
1570 "LL_STATS_RADIO"
1571 " radio is %d onTime is %u "
1572 " txTime is %u rxTime is %u "
1573 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301574 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301575 " onTimePnoScan is %u onTimeHs20 is %u "
1576 " numChannels is %u",
1577 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1578 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1579 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301580 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301581 pWifiRadioStat->onTimeRoamScan,
1582 pWifiRadioStat->onTimePnoScan,
1583 pWifiRadioStat->onTimeHs20,
1584 pWifiRadioStat->numChannels);
1585 /*
1586 * Allocate a size of 4096 for the Radio stats comprising
1587 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1588 * (tSirWifiChannelStats).Each channel data is put with an
1589 * NL attribute.The size of 4096 is considered assuming that
1590 * number of channels shall not exceed beyond 60 with the
1591 * sizeof (tSirWifiChannelStats) being 24 bytes.
1592 */
1593
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301594 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1595 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301596 if (!vendor_event)
1597 {
1598 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301599 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301600 return;
1601 }
1602
1603 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301604 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1605 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_RADIO) ||
1606 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301607 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1608 pWifiRadioStat->radio) ||
1609 nla_put_u32(vendor_event,
1610 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1611 pWifiRadioStat->onTime) ||
1612 nla_put_u32(vendor_event,
1613 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1614 pWifiRadioStat->txTime) ||
1615 nla_put_u32(vendor_event,
1616 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1617 pWifiRadioStat->rxTime) ||
1618 nla_put_u32(vendor_event,
1619 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1620 pWifiRadioStat->onTimeScan) ||
1621 nla_put_u32(vendor_event,
1622 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1623 pWifiRadioStat->onTimeNbd) ||
1624 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301625 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1626 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301627 nla_put_u32(vendor_event,
1628 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1629 pWifiRadioStat->onTimeRoamScan) ||
1630 nla_put_u32(vendor_event,
1631 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1632 pWifiRadioStat->onTimePnoScan) ||
1633 nla_put_u32(vendor_event,
1634 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1635 pWifiRadioStat->onTimeHs20) ||
1636 nla_put_u32(vendor_event,
1637 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1638 pWifiRadioStat->numChannels))
1639 {
1640 hddLog(VOS_TRACE_LEVEL_ERROR,
1641 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1642 kfree_skb(vendor_event);
1643 return ;
1644 }
1645
1646 chList = nla_nest_start(vendor_event,
1647 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301648 if(!chList)
1649 {
1650 hddLog(VOS_TRACE_LEVEL_ERROR,
1651 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1652 __func__);
1653 kfree_skb(vendor_event);
1654 return;
1655 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301656 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1657 {
1658 struct nlattr *chInfo;
1659
1660 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1661 pWifiRadioStat->channels +
1662 (i * sizeof(tSirWifiChannelStats)));
1663
1664 hddLog(VOS_TRACE_LEVEL_INFO,
1665 " %d) Channel Info"
1666 " width is %u "
1667 " CenterFreq %u "
1668 " CenterFreq0 %u "
1669 " CenterFreq1 %u "
1670 " onTime %u "
1671 " ccaBusyTime %u",
1672 i,
1673 pWifiChannelStats->channel.width,
1674 pWifiChannelStats->channel.centerFreq,
1675 pWifiChannelStats->channel.centerFreq0,
1676 pWifiChannelStats->channel.centerFreq1,
1677 pWifiChannelStats->onTime,
1678 pWifiChannelStats->ccaBusyTime);
1679
1680
1681 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301682 if(!chInfo)
1683 {
1684 hddLog(VOS_TRACE_LEVEL_ERROR,
1685 "%s: failed to put chInfo",
1686 __func__);
1687 kfree_skb(vendor_event);
1688 return;
1689 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301690
1691 if (nla_put_u32(vendor_event,
1692 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1693 pWifiChannelStats->channel.width) ||
1694 nla_put_u32(vendor_event,
1695 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1696 pWifiChannelStats->channel.centerFreq) ||
1697 nla_put_u32(vendor_event,
1698 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1699 pWifiChannelStats->channel.centerFreq0) ||
1700 nla_put_u32(vendor_event,
1701 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1702 pWifiChannelStats->channel.centerFreq1) ||
1703 nla_put_u32(vendor_event,
1704 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1705 pWifiChannelStats->onTime) ||
1706 nla_put_u32(vendor_event,
1707 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1708 pWifiChannelStats->ccaBusyTime))
1709 {
1710 hddLog(VOS_TRACE_LEVEL_ERROR,
1711 FL("cfg80211_vendor_event_alloc failed") );
1712 kfree_skb(vendor_event);
1713 return ;
1714 }
1715 nla_nest_end(vendor_event, chInfo);
1716 }
1717 nla_nest_end(vendor_event, chList);
1718
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301719 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301720
1721 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301722 return;
1723}
1724
1725/*
1726 * hdd_link_layer_stats_ind_callback () - This function is called after
1727 * receiving Link Layer indications from FW.This callback converts the firmware
1728 * data to the NL data and send the same to the kernel/upper layers.
1729 */
1730static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1731 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301732 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301733{
Dino Mycled3d50022014-07-07 12:58:25 +05301734 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1735 hdd_adapter_t *pAdapter = NULL;
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301736 struct hdd_ll_stats_context *context;
Dino Mycled3d50022014-07-07 12:58:25 +05301737 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301738 int status;
1739
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301740 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301741
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301742 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301743 if (0 != status)
1744 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301745 return;
1746 }
1747
Dino Mycled3d50022014-07-07 12:58:25 +05301748 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1749 if (NULL == pAdapter)
1750 {
1751 hddLog(VOS_TRACE_LEVEL_ERROR,
1752 FL(" MAC address %pM does not exist with host"),
1753 macAddr);
1754 return;
1755 }
1756
Sunil Duttc69bccb2014-05-26 21:30:20 +05301757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301758 "%s: Interface: %s LLStats indType: %d", __func__,
1759 pAdapter->dev->name, indType);
1760
Sunil Duttc69bccb2014-05-26 21:30:20 +05301761 switch (indType)
1762 {
1763 case SIR_HAL_LL_STATS_RESULTS_RSP:
1764 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301765 hddLog(VOS_TRACE_LEVEL_INFO,
1766 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1767 hddLog(VOS_TRACE_LEVEL_INFO,
1768 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1769 linkLayerStatsResults->paramId);
1770 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301771 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1772 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301773 hddLog(VOS_TRACE_LEVEL_INFO,
1774 "LL_STATS RESULTS RESPONSE respId = %u",
1775 linkLayerStatsResults->respId);
1776 hddLog(VOS_TRACE_LEVEL_INFO,
1777 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1778 linkLayerStatsResults->moreResultToFollow);
1779 hddLog(VOS_TRACE_LEVEL_INFO,
1780 "LL_STATS RESULTS RESPONSE result = %p",
1781 linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301782 spin_lock(&hdd_context_lock);
1783 context = &pHddCtx->ll_stats_context;
1784 /* validate response received from target */
1785 if ((context->request_id != linkLayerStatsResults->respId) ||
1786 !(context->request_bitmap & linkLayerStatsResults->paramId))
1787 {
1788 spin_unlock(&hdd_context_lock);
1789 hddLog(LOGE,
1790 FL("Error : Request id %d response id %d request bitmap 0x%x"
1791 "response bitmap 0x%x"),
1792 context->request_id, linkLayerStatsResults->respId,
1793 context->request_bitmap, linkLayerStatsResults->paramId);
1794 return;
1795 }
1796 spin_unlock(&hdd_context_lock);
1797
Sunil Duttc69bccb2014-05-26 21:30:20 +05301798 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1799 {
1800 hdd_link_layer_process_radio_stats(pAdapter,
1801 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301802 spin_lock(&hdd_context_lock);
1803 context->request_bitmap &= ~(WMI_LINK_STATS_RADIO);
1804 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301805 }
1806 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1807 {
1808 hdd_link_layer_process_iface_stats(pAdapter,
1809 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301810 spin_lock(&hdd_context_lock);
1811 context->request_bitmap &= ~(WMI_LINK_STATS_IFACE);
1812 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301813 }
1814 else if ( linkLayerStatsResults->paramId &
1815 WMI_LINK_STATS_ALL_PEER )
1816 {
1817 hdd_link_layer_process_peer_stats(pAdapter,
1818 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301819 spin_lock(&hdd_context_lock);
1820 context->request_bitmap &= ~(WMI_LINK_STATS_ALL_PEER);
1821 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301822 } /* WMI_LINK_STATS_ALL_PEER */
1823 else
1824 {
1825 hddLog(VOS_TRACE_LEVEL_ERROR,
1826 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1827 }
1828
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301829 spin_lock(&hdd_context_lock);
1830 /* complete response event if all requests are completed */
1831 if (0 == context->request_bitmap)
1832 complete(&context->response_event);
1833 spin_unlock(&hdd_context_lock);
1834
Sunil Duttc69bccb2014-05-26 21:30:20 +05301835 break;
1836 }
1837 default:
1838 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1839 break;
1840 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301841
1842 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301843 return;
1844}
1845
1846const struct
1847nla_policy
1848qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1849{
1850 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1851 { .type = NLA_U32 },
1852 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1853 { .type = NLA_U32 },
1854};
1855
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301856static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1857 struct wireless_dev *wdev,
1858 const void *data,
1859 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301860{
1861 int status;
1862 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301863 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301864 struct net_device *dev = wdev->netdev;
1865 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1866 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1867
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301868 ENTER();
1869
Sunil Duttc69bccb2014-05-26 21:30:20 +05301870 status = wlan_hdd_validate_context(pHddCtx);
1871 if (0 != status)
1872 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301873 return -EINVAL;
1874 }
1875
1876 if (NULL == pAdapter)
1877 {
1878 hddLog(VOS_TRACE_LEVEL_ERROR,
1879 FL("HDD adapter is Null"));
1880 return -ENODEV;
1881 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301882 /* check the LLStats Capability */
1883 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1884 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1885 {
1886 hddLog(VOS_TRACE_LEVEL_ERROR,
1887 FL("Link Layer Statistics not supported by Firmware"));
1888 return -EINVAL;
1889 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301890
1891 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1892 (struct nlattr *)data,
1893 data_len, qca_wlan_vendor_ll_set_policy))
1894 {
1895 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1896 return -EINVAL;
1897 }
1898 if (!tb_vendor
1899 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1900 {
1901 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1902 return -EINVAL;
1903 }
1904 if (!tb_vendor[
1905 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1906 {
1907 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1908 return -EINVAL;
1909 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301910 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301911 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301912
Dino Mycledf0a5d92014-07-04 09:41:55 +05301913 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301914 nla_get_u32(
1915 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1916
Dino Mycledf0a5d92014-07-04 09:41:55 +05301917 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301918 nla_get_u32(
1919 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1920
Dino Mycled3d50022014-07-07 12:58:25 +05301921 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1922 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301923
1924
1925 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301926 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301927 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301928 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301929 hddLog(VOS_TRACE_LEVEL_INFO,
1930 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301931 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301932 hddLog(VOS_TRACE_LEVEL_INFO,
1933 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301934 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301935
1936 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1937 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301938 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301939 {
1940 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1941 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301942 return -EINVAL;
1943
1944 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301945
Sunil Duttc69bccb2014-05-26 21:30:20 +05301946 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301947 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301948 {
1949 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1950 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301951 return -EINVAL;
1952 }
1953
1954 pAdapter->isLinkLayerStatsSet = 1;
1955
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301956 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301957 return 0;
1958}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301959static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1960 struct wireless_dev *wdev,
1961 const void *data,
1962 int data_len)
1963{
1964 int ret = 0;
1965
1966 vos_ssr_protect(__func__);
1967 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1968 vos_ssr_unprotect(__func__);
1969
1970 return ret;
1971}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301972
1973const struct
1974nla_policy
1975qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1976{
1977 /* Unsigned 32bit value provided by the caller issuing the GET stats
1978 * command. When reporting
1979 * the stats results, the driver uses the same value to indicate
1980 * which GET request the results
1981 * correspond to.
1982 */
1983 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1984
1985 /* Unsigned 32bit value . bit mask to identify what statistics are
1986 requested for retrieval */
1987 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1988};
1989
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301990static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1991 struct wireless_dev *wdev,
1992 const void *data,
1993 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301994{
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301995 unsigned long rc;
1996 struct hdd_ll_stats_context *context;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301997 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1998 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301999 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302000 struct net_device *dev = wdev->netdev;
2001 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mukul Sharma10313ba2015-07-29 19:14:39 +05302002 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302003 int status;
2004
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302005 ENTER();
2006
Sunil Duttc69bccb2014-05-26 21:30:20 +05302007 status = wlan_hdd_validate_context(pHddCtx);
2008 if (0 != status)
2009 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302010 return -EINVAL ;
2011 }
2012
2013 if (NULL == pAdapter)
2014 {
2015 hddLog(VOS_TRACE_LEVEL_FATAL,
2016 "%s: HDD adapter is Null", __func__);
2017 return -ENODEV;
2018 }
Mukul Sharma10313ba2015-07-29 19:14:39 +05302019
2020 if (pHddStaCtx == NULL)
2021 {
2022 hddLog(VOS_TRACE_LEVEL_FATAL,
2023 "%s: HddStaCtx is Null", __func__);
2024 return -ENODEV;
2025 }
2026
Dino Mycledf0a5d92014-07-04 09:41:55 +05302027 /* check the LLStats Capability */
2028 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2029 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2030 {
2031 hddLog(VOS_TRACE_LEVEL_ERROR,
2032 FL("Link Layer Statistics not supported by Firmware"));
2033 return -EINVAL;
2034 }
2035
Sunil Duttc69bccb2014-05-26 21:30:20 +05302036
2037 if (!pAdapter->isLinkLayerStatsSet)
2038 {
2039 hddLog(VOS_TRACE_LEVEL_FATAL,
2040 "%s: isLinkLayerStatsSet : %d",
2041 __func__, pAdapter->isLinkLayerStatsSet);
2042 return -EINVAL;
2043 }
2044
Mukul Sharma10313ba2015-07-29 19:14:39 +05302045 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
2046 {
2047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2048 "%s: Roaming in progress, so unable to proceed this request", __func__);
2049 return -EBUSY;
2050 }
2051
Sunil Duttc69bccb2014-05-26 21:30:20 +05302052 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2053 (struct nlattr *)data,
2054 data_len, qca_wlan_vendor_ll_get_policy))
2055 {
2056 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2057 return -EINVAL;
2058 }
2059
2060 if (!tb_vendor
2061 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2062 {
2063 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2064 return -EINVAL;
2065 }
2066
2067 if (!tb_vendor
2068 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2069 {
2070 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
2071 return -EINVAL;
2072 }
2073
Sunil Duttc69bccb2014-05-26 21:30:20 +05302074
Dino Mycledf0a5d92014-07-04 09:41:55 +05302075 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302076 nla_get_u32( tb_vendor[
2077 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05302078 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302079 nla_get_u32( tb_vendor[
2080 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
2081
Dino Mycled3d50022014-07-07 12:58:25 +05302082 vos_mem_copy(linkLayerStatsGetReq.macAddr,
2083 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302084
2085 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302086 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302087 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302088 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302089 hddLog(VOS_TRACE_LEVEL_INFO,
2090 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302091 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302092
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302093 spin_lock(&hdd_context_lock);
2094 context = &pHddCtx->ll_stats_context;
2095 context->request_id = linkLayerStatsGetReq.reqId;
2096 context->request_bitmap = linkLayerStatsGetReq.paramIdMask;
2097 INIT_COMPLETION(context->response_event);
2098 spin_unlock(&hdd_context_lock);
2099
Sunil Duttc69bccb2014-05-26 21:30:20 +05302100 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302101 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302102 {
2103 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2104 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302105 return -EINVAL;
2106 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302107
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302108 rc = wait_for_completion_timeout(&context->response_event,
2109 msecs_to_jiffies(WLAN_WAIT_TIME_LL_STATS));
2110 if (!rc)
2111 {
2112 hddLog(LOGE,
2113 FL("Target response timed out request id %d request bitmap 0x%x"),
2114 context->request_id, context->request_bitmap);
2115 return -ETIMEDOUT;
2116 }
2117
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302118 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302119 return 0;
2120}
2121
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302122static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2123 struct wireless_dev *wdev,
2124 const void *data,
2125 int data_len)
2126{
2127 int ret = 0;
2128
2129 vos_ssr_protect(__func__);
2130 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
2131 vos_ssr_unprotect(__func__);
2132
2133 return ret;
2134}
2135
Sunil Duttc69bccb2014-05-26 21:30:20 +05302136const struct
2137nla_policy
2138qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
2139{
2140 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
2141 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
2142 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
2143 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
2144};
2145
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302146static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2147 struct wireless_dev *wdev,
2148 const void *data,
2149 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302150{
2151 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2152 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302153 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302154 struct net_device *dev = wdev->netdev;
2155 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2156 u32 statsClearReqMask;
2157 u8 stopReq;
2158 int status;
2159
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302160 ENTER();
2161
Sunil Duttc69bccb2014-05-26 21:30:20 +05302162 status = wlan_hdd_validate_context(pHddCtx);
2163 if (0 != status)
2164 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302165 return -EINVAL;
2166 }
2167
2168 if (NULL == pAdapter)
2169 {
2170 hddLog(VOS_TRACE_LEVEL_FATAL,
2171 "%s: HDD adapter is Null", __func__);
2172 return -ENODEV;
2173 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302174 /* check the LLStats Capability */
2175 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2176 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2177 {
2178 hddLog(VOS_TRACE_LEVEL_ERROR,
2179 FL("Enable LLStats Capability"));
2180 return -EINVAL;
2181 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302182
2183 if (!pAdapter->isLinkLayerStatsSet)
2184 {
2185 hddLog(VOS_TRACE_LEVEL_FATAL,
2186 "%s: isLinkLayerStatsSet : %d",
2187 __func__, pAdapter->isLinkLayerStatsSet);
2188 return -EINVAL;
2189 }
2190
2191 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2192 (struct nlattr *)data,
2193 data_len, qca_wlan_vendor_ll_clr_policy))
2194 {
2195 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2196 return -EINVAL;
2197 }
2198
2199 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2200
2201 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2202 {
2203 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2204 return -EINVAL;
2205
2206 }
2207
Sunil Duttc69bccb2014-05-26 21:30:20 +05302208
Dino Mycledf0a5d92014-07-04 09:41:55 +05302209 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302210 nla_get_u32(
2211 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2212
Dino Mycledf0a5d92014-07-04 09:41:55 +05302213 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302214 nla_get_u8(
2215 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2216
2217 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302218 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302219
Dino Mycled3d50022014-07-07 12:58:25 +05302220 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2221 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302222
2223 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302224 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302225 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302226 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302227 hddLog(VOS_TRACE_LEVEL_INFO,
2228 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302229 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302230 hddLog(VOS_TRACE_LEVEL_INFO,
2231 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302232 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302233
2234 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302235 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302236 {
2237 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302238 hdd_station_ctx_t *pHddStaCtx;
2239
2240 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2241 if (VOS_STATUS_SUCCESS !=
2242 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2243 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2244 {
2245 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2246 "WLANTL_ClearInterfaceStats Failed", __func__);
2247 return -EINVAL;
2248 }
2249 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2250 (statsClearReqMask & WIFI_STATS_IFACE)) {
2251 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2252 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2253 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2254 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2255 }
2256
Sunil Duttc69bccb2014-05-26 21:30:20 +05302257 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2258 2 * sizeof(u32) +
2259 NLMSG_HDRLEN);
2260
2261 if (temp_skbuff != NULL)
2262 {
2263
2264 if (nla_put_u32(temp_skbuff,
2265 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2266 statsClearReqMask) ||
2267 nla_put_u32(temp_skbuff,
2268 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2269 stopReq))
2270 {
2271 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2272 kfree_skb(temp_skbuff);
2273 return -EINVAL;
2274 }
2275 /* If the ask is to stop the stats collection as part of clear
2276 * (stopReq = 1) , ensure that no further requests of get
2277 * go to the firmware by having isLinkLayerStatsSet set to 0.
2278 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302279 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302280 * case the firmware is just asked to clear the statistics.
2281 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302282 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302283 pAdapter->isLinkLayerStatsSet = 0;
2284 return cfg80211_vendor_cmd_reply(temp_skbuff);
2285 }
2286 return -ENOMEM;
2287 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302288
2289 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302290 return -EINVAL;
2291}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302292static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2293 struct wireless_dev *wdev,
2294 const void *data,
2295 int data_len)
2296{
2297 int ret = 0;
2298
2299 vos_ssr_protect(__func__);
2300 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2301 vos_ssr_unprotect(__func__);
2302
2303 return ret;
2304
2305
2306}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302307#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2308
Dino Mycle6fb96c12014-06-10 11:52:40 +05302309#ifdef WLAN_FEATURE_EXTSCAN
2310static const struct nla_policy
2311wlan_hdd_extscan_config_policy
2312 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2313{
2314 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2315 { .type = NLA_U32 },
2316 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2317 { .type = NLA_U32 },
2318 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2319 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2320 { .type = NLA_U32 },
2321 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2322 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2323
2324 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2325 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2326 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2327 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2328 { .type = NLA_U8 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302329 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD] =
2330 { .type = NLA_U32 },
2331 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT] =
2332 { .type = NLA_U32 },
2333 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT] =
2334 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05302335 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2336 { .type = NLA_U32 },
2337 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2338 { .type = NLA_U32 },
2339 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2340 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302341 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT] =
2342 { .type = NLA_U8 },
2343 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05302344 { .type = NLA_U8 },
2345 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2346 { .type = NLA_U8 },
2347 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2348 { .type = NLA_U8 },
2349
2350 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2351 { .type = NLA_U32 },
2352 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2353 { .type = NLA_UNSPEC },
2354 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2355 { .type = NLA_S32 },
2356 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2357 { .type = NLA_S32 },
2358 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2359 { .type = NLA_U32 },
2360 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2361 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302362 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE] =
2363 { .type = NLA_U32 },
2364 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_SSID] =
2365 { .type = NLA_BINARY,
2366 .len = IEEE80211_MAX_SSID_LEN + 1 },
2367 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_LOST_SSID_SAMPLE_SIZE] =
Dino Mycle6fb96c12014-06-10 11:52:40 +05302368 { .type = NLA_U32 },
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302369 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_HOTLIST_PARAMS_NUM_SSID] =
2370 { .type = NLA_U32 },
2371 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_BAND] =
2372 { .type = NLA_U8 },
2373 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_LOW] =
2374 { .type = NLA_S32 },
2375 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SSID_THRESHOLD_PARAM_RSSI_HIGH] =
2376 { .type = NLA_S32 },
2377 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CONFIGURATION_FLAGS] =
2378 { .type = NLA_U32 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05302379};
2380
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302381/**
2382 * wlan_hdd_cfg80211_extscan_get_capabilities_rsp() - response from target
2383 * @ctx: hdd global context
2384 * @data: capabilities data
2385 *
2386 * Return: none
2387 */
2388static void
2389wlan_hdd_cfg80211_extscan_get_capabilities_rsp(void *ctx, void *pMsg)
Dino Mycle6fb96c12014-06-10 11:52:40 +05302390{
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302391 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302392 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302393 tSirEXTScanCapabilitiesEvent *data =
2394 (tSirEXTScanCapabilitiesEvent *) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302395
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302396 ENTER();
2397
2398 if (wlan_hdd_validate_context(pHddCtx))
2399 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302400 return;
2401 }
2402
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302403 if (!pMsg)
2404 {
2405 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2406 return;
2407 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302408
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302409 vos_spin_lock_acquire(&hdd_context_lock);
2410
2411 context = &pHddCtx->ext_scan_context;
2412 /* validate response received from target*/
2413 if (context->request_id != data->requestId)
2414 {
2415 vos_spin_lock_release(&hdd_context_lock);
2416 hddLog(LOGE,
2417 FL("Target response id did not match: request_id %d resposne_id %d"),
2418 context->request_id, data->requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302419 return;
2420 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302421 else
2422 {
2423 context->capability_response = *data;
2424 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302425 }
2426
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302427 vos_spin_lock_release(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302428
Dino Mycle6fb96c12014-06-10 11:52:40 +05302429 return;
2430}
2431
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302432/*
2433 * define short names for the global vendor params
2434 * used by wlan_hdd_send_ext_scan_capability()
2435 */
2436#define PARAM_REQUEST_ID \
2437 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
2438#define PARAM_STATUS \
2439 QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS
2440#define MAX_SCAN_CACHE_SIZE \
2441 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE
2442#define MAX_SCAN_BUCKETS \
2443 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS
2444#define MAX_AP_CACHE_PER_SCAN \
2445 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN
2446#define MAX_RSSI_SAMPLE_SIZE \
2447 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE
2448#define MAX_SCAN_RPT_THRHOLD \
2449 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD
2450#define MAX_HOTLIST_BSSIDS \
2451 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_BSSIDS
2452#define MAX_BSSID_HISTORY_ENTRIES \
2453 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES
2454#define MAX_HOTLIST_SSIDS \
2455 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_SSIDS
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302456#define MAX_SIGNIFICANT_WIFI_CHANGE_APS \
2457 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302458
2459static int wlan_hdd_send_ext_scan_capability(void *ctx)
2460{
2461 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2462 struct sk_buff *skb = NULL;
2463 int ret;
2464 tSirEXTScanCapabilitiesEvent *data;
2465 tANI_U32 nl_buf_len;
2466
2467 ret = wlan_hdd_validate_context(pHddCtx);
2468 if (0 != ret)
2469 {
2470 return ret;
2471 }
2472
2473 data = &(pHddCtx->ext_scan_context.capability_response);
2474
2475 nl_buf_len = NLMSG_HDRLEN;
2476 nl_buf_len += (sizeof(data->requestId) + NLA_HDRLEN) +
2477 (sizeof(data->status) + NLA_HDRLEN) +
2478 (sizeof(data->scanCacheSize) + NLA_HDRLEN) +
2479 (sizeof(data->scanBuckets) + NLA_HDRLEN) +
2480 (sizeof(data->maxApPerScan) + NLA_HDRLEN) +
2481 (sizeof(data->maxRssiSampleSize) + NLA_HDRLEN) +
2482 (sizeof(data->maxScanReportingThreshold) + NLA_HDRLEN) +
2483 (sizeof(data->maxHotlistAPs) + NLA_HDRLEN) +
2484 (sizeof(data->maxBsidHistoryEntries) + NLA_HDRLEN) +
2485 (sizeof(data->maxHotlistSSIDs) + NLA_HDRLEN);
2486
2487 skb = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy, nl_buf_len);
2488
2489 if (!skb)
2490 {
2491 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
2492 return -ENOMEM;
2493 }
2494
2495 hddLog(LOG1, "Req Id (%u) Status (%u)", data->requestId, data->status);
2496 hddLog(LOG1, "Scan cache size (%u) Scan buckets (%u) Max AP per scan (%u)",
2497 data->scanCacheSize, data->scanBuckets, data->maxApPerScan);
2498 hddLog(LOG1, "max_rssi_sample_size (%u) max_scan_reporting_threshold (%u)",
2499 data->maxRssiSampleSize, data->maxScanReportingThreshold);
2500 hddLog(LOG1, "max_hotlist_bssids (%u) max_bssid_history_entries (%u)"
2501 "max_hotlist_ssids (%u)", data->maxHotlistAPs,
2502 data->maxBsidHistoryEntries, data->maxHotlistSSIDs);
2503
2504 if (nla_put_u32(skb, PARAM_REQUEST_ID, data->requestId) ||
2505 nla_put_u32(skb, PARAM_STATUS, data->status) ||
2506 nla_put_u32(skb, MAX_SCAN_CACHE_SIZE, data->scanCacheSize) ||
2507 nla_put_u32(skb, MAX_SCAN_BUCKETS, data->scanBuckets) ||
2508 nla_put_u32(skb, MAX_AP_CACHE_PER_SCAN,
2509 data->maxApPerScan) ||
2510 nla_put_u32(skb, MAX_RSSI_SAMPLE_SIZE,
2511 data->maxRssiSampleSize) ||
2512 nla_put_u32(skb, MAX_SCAN_RPT_THRHOLD,
2513 data->maxScanReportingThreshold) ||
2514 nla_put_u32(skb, MAX_HOTLIST_BSSIDS, data->maxHotlistAPs) ||
2515 nla_put_u32(skb, MAX_BSSID_HISTORY_ENTRIES,
2516 data->maxBsidHistoryEntries) ||
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302517 nla_put_u32(skb, MAX_HOTLIST_SSIDS, data->maxHotlistSSIDs) ||
2518 nla_put_u32(skb, MAX_SIGNIFICANT_WIFI_CHANGE_APS, 0))
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302519 {
2520 hddLog(LOGE, FL("nla put fail"));
2521 goto nla_put_failure;
2522 }
2523
2524 cfg80211_vendor_cmd_reply(skb);
2525 return 0;
2526
2527nla_put_failure:
2528 kfree_skb(skb);
2529 return -EINVAL;;
2530}
2531
2532/*
2533 * done with short names for the global vendor params
2534 * used by wlan_hdd_send_ext_scan_capability()
2535 */
2536#undef PARAM_REQUEST_ID
2537#undef PARAM_STATUS
2538#undef MAX_SCAN_CACHE_SIZE
2539#undef MAX_SCAN_BUCKETS
2540#undef MAX_AP_CACHE_PER_SCAN
2541#undef MAX_RSSI_SAMPLE_SIZE
2542#undef MAX_SCAN_RPT_THRHOLD
2543#undef MAX_HOTLIST_BSSIDS
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05302544#undef MAX_BSSID_HISTORY_ENTRIES
2545#undef MAX_HOTLIST_SSIDS
Dino Mycle6fb96c12014-06-10 11:52:40 +05302546
2547static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2548{
2549 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2550 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302551 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302552 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302553
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302554 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302555
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302556 if (wlan_hdd_validate_context(pHddCtx))
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302557 return;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302558
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302559 if (!pMsg)
2560 {
2561 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302562 return;
2563 }
2564
Dino Mycle6fb96c12014-06-10 11:52:40 +05302565 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2566 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2567
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302568 context = &pHddCtx->ext_scan_context;
2569 spin_lock(&hdd_context_lock);
2570 if (context->request_id == pData->requestId) {
2571 context->response_status = pData->status ? -EINVAL : 0;
2572 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302573 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05302574 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302575
2576 /*
2577 * Store the Request ID for comparing with the requestID obtained
2578 * in other requests.HDD shall return a failure is the extscan_stop
2579 * request is issued with a different requestId as that of the
2580 * extscan_start request. Also, This requestId shall be used while
2581 * indicating the full scan results to the upper layers.
2582 * The requestId is stored with the assumption that the firmware
2583 * shall return the ext scan start request's requestId in ext scan
2584 * start response.
2585 */
2586 if (pData->status == 0)
2587 pMac->sme.extScanStartReqId = pData->requestId;
2588
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302589 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302590 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302591}
2592
2593
2594static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2595{
2596 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2597 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302598 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302599
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302600 ENTER();
2601
2602 if (wlan_hdd_validate_context(pHddCtx)){
2603 return;
2604 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302605
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302606 if (!pMsg)
2607 {
2608 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302609 return;
2610 }
2611
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302612 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2613 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302614
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302615 context = &pHddCtx->ext_scan_context;
2616 spin_lock(&hdd_context_lock);
2617 if (context->request_id == pData->requestId) {
2618 context->response_status = pData->status ? -EINVAL : 0;
2619 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302620 }
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05302621 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302622
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302623 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302624 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302625}
2626
Dino Mycle6fb96c12014-06-10 11:52:40 +05302627static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2628 void *pMsg)
2629{
2630 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302631 tpSirEXTScanSetBssidHotListRspParams pData =
2632 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302633 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302634
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302635 ENTER();
2636
2637 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302638 return;
2639 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302640
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302641 if (!pMsg)
2642 {
2643 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2644 return;
2645 }
2646
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302647 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2648 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302649
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302650 context = &pHddCtx->ext_scan_context;
2651 spin_lock(&hdd_context_lock);
2652 if (context->request_id == pData->requestId) {
2653 context->response_status = pData->status ? -EINVAL : 0;
2654 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302655 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302656 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302657
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302658 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302659 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302660}
2661
2662static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2663 void *pMsg)
2664{
2665 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302666 tpSirEXTScanResetBssidHotlistRspParams pData =
2667 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302668 struct hdd_ext_scan_context *context;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302669
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302670 ENTER();
2671
2672 if (wlan_hdd_validate_context(pHddCtx)) {
2673 return;
2674 }
2675 if (!pMsg)
2676 {
2677 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302678 return;
2679 }
2680
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302681 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id %u Status %u", pData->requestId,
2682 pData->status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302683
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302684 context = &pHddCtx->ext_scan_context;
2685 spin_lock(&hdd_context_lock);
2686 if (context->request_id == pData->requestId) {
2687 context->response_status = pData->status ? -EINVAL : 0;
2688 complete(&context->response_event);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302689 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05302690 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302691
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302692 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302693 return;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302694}
2695
Dino Mycle6fb96c12014-06-10 11:52:40 +05302696static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2697 void *pMsg)
2698{
2699 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2700 struct sk_buff *skb = NULL;
2701 tANI_U32 i = 0, j, resultsPerEvent;
2702 tANI_S32 totalResults;
2703 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2704 tpSirWifiScanResult pSirWifiScanResult;
2705
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302706 ENTER();
2707
2708 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302709 return;
2710 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302711 if (!pMsg)
2712 {
2713 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2714 return;
2715 }
2716
Dino Mycle6fb96c12014-06-10 11:52:40 +05302717 totalResults = pData->numOfAps;
2718 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2719 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2720 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2721
2722 do{
2723 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2724 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2725 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2726
2727 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302728#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2729 NULL,
2730#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302731 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2732 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2733 GFP_KERNEL);
2734
2735 if (!skb) {
2736 hddLog(VOS_TRACE_LEVEL_ERROR,
2737 FL("cfg80211_vendor_event_alloc failed"));
2738 return;
2739 }
2740
2741 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2742
2743 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2744 pData->requestId) ||
2745 nla_put_u32(skb,
2746 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2747 resultsPerEvent)) {
2748 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2749 goto fail;
2750 }
2751 if (nla_put_u8(skb,
2752 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2753 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2754 {
2755 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2756 goto fail;
2757 }
2758
2759 if (resultsPerEvent) {
2760 struct nlattr *aps;
2761
2762 aps = nla_nest_start(skb,
2763 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2764 if (!aps)
2765 {
2766 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2767 goto fail;
2768 }
2769
2770 for (j = 0; j < resultsPerEvent; j++, i++) {
2771 struct nlattr *ap;
2772 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2773 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2774
2775 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2776 "Ssid (%s)"
2777 "Bssid: %pM "
2778 "Channel (%u)"
2779 "Rssi (%d)"
2780 "RTT (%u)"
2781 "RTT_SD (%u)",
2782 i,
2783 pSirWifiScanResult->ts,
2784 pSirWifiScanResult->ssid,
2785 pSirWifiScanResult->bssid,
2786 pSirWifiScanResult->channel,
2787 pSirWifiScanResult->rssi,
2788 pSirWifiScanResult->rtt,
2789 pSirWifiScanResult->rtt_sd);
2790
2791 ap = nla_nest_start(skb, j + 1);
2792 if (!ap)
2793 {
2794 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2795 goto fail;
2796 }
2797
2798 if (nla_put_u64(skb,
2799 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2800 pSirWifiScanResult->ts) )
2801 {
2802 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2803 goto fail;
2804 }
2805 if (nla_put(skb,
2806 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2807 sizeof(pSirWifiScanResult->ssid),
2808 pSirWifiScanResult->ssid) )
2809 {
2810 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2811 goto fail;
2812 }
2813 if (nla_put(skb,
2814 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2815 sizeof(pSirWifiScanResult->bssid),
2816 pSirWifiScanResult->bssid) )
2817 {
2818 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2819 goto fail;
2820 }
2821 if (nla_put_u32(skb,
2822 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2823 pSirWifiScanResult->channel) )
2824 {
2825 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2826 goto fail;
2827 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302828 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302829 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2830 pSirWifiScanResult->rssi) )
2831 {
2832 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2833 goto fail;
2834 }
2835 if (nla_put_u32(skb,
2836 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2837 pSirWifiScanResult->rtt) )
2838 {
2839 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2840 goto fail;
2841 }
2842 if (nla_put_u32(skb,
2843 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2844 pSirWifiScanResult->rtt_sd))
2845 {
2846 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2847 goto fail;
2848 }
2849
2850 nla_nest_end(skb, ap);
2851 }
2852 nla_nest_end(skb, aps);
2853
2854 }
2855 cfg80211_vendor_event(skb, GFP_KERNEL);
2856 } while (totalResults > 0);
2857
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302858 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302859 return;
2860fail:
2861 kfree_skb(skb);
2862 return;
2863}
2864
2865static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2866 void *pMsg)
2867{
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302868 tpSirEXTScanHotlistMatch pData = (tpSirEXTScanHotlistMatch) pMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302869 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2870 struct sk_buff *skb = NULL;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302871 tANI_U32 i, index;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302872
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302873 ENTER();
2874
2875 if (wlan_hdd_validate_context(pHddCtx)) {
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302876 hddLog(LOGE,
2877 FL("HDD context is not valid or response"));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302878 return;
2879 }
2880 if (!pMsg)
2881 {
2882 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302883 return;
2884 }
2885
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302886 if (pData->bss_found)
2887 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX;
2888 else
2889 index = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_LOST_INDEX;
2890
Dino Mycle6fb96c12014-06-10 11:52:40 +05302891 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302892#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2893 NULL,
2894#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302895 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302896 index, GFP_KERNEL);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302897
2898 if (!skb) {
2899 hddLog(VOS_TRACE_LEVEL_ERROR,
2900 FL("cfg80211_vendor_event_alloc failed"));
2901 return;
2902 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302903
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302904 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2905 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numHotlistBss);
2906 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2907 hddLog(VOS_TRACE_LEVEL_INFO, "ap_found %u", pData->bss_found);
2908
2909 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302910 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2911 "Ssid (%s) "
2912 "Bssid (" MAC_ADDRESS_STR ") "
2913 "Channel (%u) "
2914 "Rssi (%d) "
2915 "RTT (%u) "
2916 "RTT_SD (%u) ",
2917 i,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302918 pData->bssHotlist[i].ts,
2919 pData->bssHotlist[i].ssid,
2920 MAC_ADDR_ARRAY(pData->bssHotlist[i].bssid),
2921 pData->bssHotlist[i].channel,
2922 pData->bssHotlist[i].rssi,
2923 pData->bssHotlist[i].rtt,
2924 pData->bssHotlist[i].rtt_sd);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302925 }
2926
2927 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2928 pData->requestId) ||
2929 nla_put_u32(skb,
2930 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302931 pData->numHotlistBss)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302932 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2933 goto fail;
2934 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302935 if (pData->numHotlistBss) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302936 struct nlattr *aps;
2937
2938 aps = nla_nest_start(skb,
2939 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2940 if (!aps)
2941 goto fail;
2942
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302943 for (i = 0; i < pData->numHotlistBss; i++) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302944 struct nlattr *ap;
2945
2946 ap = nla_nest_start(skb, i + 1);
2947 if (!ap)
2948 goto fail;
2949
2950 if (nla_put_u64(skb,
2951 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302952 pData->bssHotlist[i].ts) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302953 nla_put(skb,
2954 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302955 sizeof(pData->bssHotlist[i].ssid),
2956 pData->bssHotlist[i].ssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302957 nla_put(skb,
2958 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302959 sizeof(pData->bssHotlist[i].bssid),
2960 pData->bssHotlist[i].bssid) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302961 nla_put_u32(skb,
2962 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302963 pData->bssHotlist[i].channel) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302964 nla_put_s32(skb,
2965 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302966 pData->bssHotlist[i].rssi) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302967 nla_put_u32(skb,
2968 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302969 pData->bssHotlist[i].rtt) ||
Dino Mycle6fb96c12014-06-10 11:52:40 +05302970 nla_put_u32(skb,
2971 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05302972 pData->bssHotlist[i].rtt_sd))
Dino Mycle6fb96c12014-06-10 11:52:40 +05302973 goto fail;
2974
2975 nla_nest_end(skb, ap);
2976 }
2977 nla_nest_end(skb, aps);
2978
2979 if (nla_put_u8(skb,
2980 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2981 pData->moreData))
2982 goto fail;
2983 }
2984
2985 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302986 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302987 return;
2988
2989fail:
2990 kfree_skb(skb);
2991 return;
2992
2993}
Dino Mycle6fb96c12014-06-10 11:52:40 +05302994
2995static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
2996 void *pMsg)
2997{
2998 struct sk_buff *skb;
2999 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3000 tpSirWifiFullScanResultEvent pData =
3001 (tpSirWifiFullScanResultEvent) (pMsg);
3002
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303003 ENTER();
3004
3005 if (wlan_hdd_validate_context(pHddCtx)) {
3006 return;
3007 }
3008 if (!pMsg)
3009 {
3010 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303011 return;
3012 }
3013
3014 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303015#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3016 NULL,
3017#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303018 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3019 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3020 GFP_KERNEL);
3021
3022 if (!skb) {
3023 hddLog(VOS_TRACE_LEVEL_ERROR,
3024 FL("cfg80211_vendor_event_alloc failed"));
3025 return;
3026 }
3027
3028 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3029 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3030 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3031 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3032 "Ssid (%s)"
3033 "Bssid (" MAC_ADDRESS_STR ")"
3034 "Channel (%u)"
3035 "Rssi (%d)"
3036 "RTT (%u)"
3037 "RTT_SD (%u)"),
3038 pData->ap.ts,
3039 pData->ap.ssid,
3040 MAC_ADDR_ARRAY(pData->ap.bssid),
3041 pData->ap.channel,
3042 pData->ap.rssi,
3043 pData->ap.rtt,
3044 pData->ap.rtt_sd);
3045 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3046 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3047 pData->requestId) ||
3048 nla_put_u64(skb,
3049 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3050 pData->ap.ts) ||
3051 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3052 sizeof(pData->ap.ssid),
3053 pData->ap.ssid) ||
3054 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3055 WNI_CFG_BSSID_LEN,
3056 pData->ap.bssid) ||
3057 nla_put_u32(skb,
3058 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3059 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303060 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303061 pData->ap.rssi) ||
3062 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3063 pData->ap.rtt) ||
3064 nla_put_u32(skb,
3065 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3066 pData->ap.rtt_sd) ||
3067 nla_put_u16(skb,
3068 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3069 pData->ap.beaconPeriod) ||
3070 nla_put_u16(skb,
3071 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3072 pData->ap.capability) ||
3073 nla_put_u32(skb,
3074 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3075 pData->ieLength))
3076 {
3077 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3078 goto nla_put_failure;
3079 }
3080 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3081 pData->ieLength,
3082 pData->ie))
3083 {
3084 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3085 goto nla_put_failure;
3086 }
3087
3088 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303089 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303090 return;
3091
3092nla_put_failure:
3093 kfree_skb(skb);
3094 return;
3095}
3096
3097static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3098 void *pMsg)
3099{
3100 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3101 struct sk_buff *skb = NULL;
3102 tpSirEXTScanResultsAvailableIndParams pData =
3103 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3104
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303105 ENTER();
3106
3107 if (wlan_hdd_validate_context(pHddCtx)){
3108 return;
3109 }
3110 if (!pMsg)
3111 {
3112 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303113 return;
3114 }
3115
3116 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303117#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3118 NULL,
3119#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303120 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3121 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3122 GFP_KERNEL);
3123
3124 if (!skb) {
3125 hddLog(VOS_TRACE_LEVEL_ERROR,
3126 FL("cfg80211_vendor_event_alloc failed"));
3127 return;
3128 }
3129
3130 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3131 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3132 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3133 pData->numResultsAvailable);
3134 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3135 pData->requestId) ||
3136 nla_put_u32(skb,
3137 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3138 pData->numResultsAvailable)) {
3139 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3140 goto nla_put_failure;
3141 }
3142
3143 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303144 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303145 return;
3146
3147nla_put_failure:
3148 kfree_skb(skb);
3149 return;
3150}
3151
3152static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3153{
3154 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3155 struct sk_buff *skb = NULL;
3156 tpSirEXTScanProgressIndParams pData =
3157 (tpSirEXTScanProgressIndParams) pMsg;
3158
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303159 ENTER();
3160
3161 if (wlan_hdd_validate_context(pHddCtx)){
3162 return;
3163 }
3164 if (!pMsg)
3165 {
3166 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303167 return;
3168 }
3169
3170 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303171#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3172 NULL,
3173#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303174 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3175 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3176 GFP_KERNEL);
3177
3178 if (!skb) {
3179 hddLog(VOS_TRACE_LEVEL_ERROR,
3180 FL("cfg80211_vendor_event_alloc failed"));
3181 return;
3182 }
3183 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3184 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3185 pData->extScanEventType);
3186 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3187 pData->status);
3188
3189 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3190 pData->extScanEventType) ||
3191 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303192 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3193 pData->requestId) ||
3194 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303195 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3196 pData->status)) {
3197 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3198 goto nla_put_failure;
3199 }
3200
3201 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303202 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303203 return;
3204
3205nla_put_failure:
3206 kfree_skb(skb);
3207 return;
3208}
3209
3210void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3211 void *pMsg)
3212{
3213 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3214
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303215 ENTER();
3216
Dino Mycle6fb96c12014-06-10 11:52:40 +05303217 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303218 return;
3219 }
3220
3221 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3222
3223
3224 switch(evType) {
3225 case SIR_HAL_EXTSCAN_START_RSP:
3226 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3227 break;
3228
3229 case SIR_HAL_EXTSCAN_STOP_RSP:
3230 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3231 break;
3232 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3233 /* There is no need to send this response to upper layer
3234 Just log the message */
3235 hddLog(VOS_TRACE_LEVEL_INFO,
3236 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3237 break;
3238 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3239 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3240 break;
3241
3242 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3243 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3244 break;
3245
Dino Mycle6fb96c12014-06-10 11:52:40 +05303246 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303247 wlan_hdd_cfg80211_extscan_get_capabilities_rsp(ctx, pMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303248 break;
3249 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3250 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3251 break;
3252 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3253 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3254 break;
3255 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3256 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3257 break;
3258 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3259 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3260 break;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303261 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3262 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3263 break;
3264 default:
3265 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3266 break;
3267 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303268 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303269}
3270
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303271static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3272 struct wireless_dev *wdev,
3273 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303274{
Dino Myclee8843b32014-07-04 14:21:45 +05303275 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303276 struct net_device *dev = wdev->netdev;
3277 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3278 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3279 struct nlattr
3280 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3281 eHalStatus status;
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303282 struct hdd_ext_scan_context *context;
3283 unsigned long rc;
3284 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303285
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303286 ENTER();
3287
Dino Mycle6fb96c12014-06-10 11:52:40 +05303288 status = wlan_hdd_validate_context(pHddCtx);
3289 if (0 != status)
3290 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303291 return -EINVAL;
3292 }
Dino Myclee8843b32014-07-04 14:21:45 +05303293 /* check the EXTScan Capability */
3294 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3295 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3296 {
3297 hddLog(VOS_TRACE_LEVEL_ERROR,
3298 FL("EXTScan not enabled/supported by Firmware"));
3299 return -EINVAL;
3300 }
3301
Dino Mycle6fb96c12014-06-10 11:52:40 +05303302 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3303 data, dataLen,
3304 wlan_hdd_extscan_config_policy)) {
3305 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3306 return -EINVAL;
3307 }
3308
3309 /* Parse and fetch request Id */
3310 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3311 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3312 return -EINVAL;
3313 }
3314
Dino Myclee8843b32014-07-04 14:21:45 +05303315 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303316 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303317 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303318
Dino Myclee8843b32014-07-04 14:21:45 +05303319 reqMsg.sessionId = pAdapter->sessionId;
3320 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303321
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303322 vos_spin_lock_acquire(&hdd_context_lock);
3323 context = &pHddCtx->ext_scan_context;
3324 context->request_id = reqMsg.requestId;
3325 INIT_COMPLETION(context->response_event);
3326 vos_spin_lock_release(&hdd_context_lock);
3327
Dino Myclee8843b32014-07-04 14:21:45 +05303328 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303329 if (!HAL_STATUS_SUCCESS(status)) {
3330 hddLog(VOS_TRACE_LEVEL_ERROR,
3331 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303332 return -EINVAL;
3333 }
Padma, Santhosh Kumara1aa4a32015-06-19 19:00:46 +05303334
3335 rc = wait_for_completion_timeout(&context->response_event,
3336 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3337 if (!rc) {
3338 hddLog(LOGE, FL("Target response timed out"));
3339 return -ETIMEDOUT;
3340 }
3341
3342 ret = wlan_hdd_send_ext_scan_capability(pHddCtx);
3343 if (ret)
3344 hddLog(LOGE, FL("Failed to send ext scan capability to user space"));
3345
3346 return ret;
3347
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303348 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303349 return 0;
3350}
3351
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303352static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3353 struct wireless_dev *wdev,
3354 const void *data, int dataLen)
3355{
3356 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303357
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303358 vos_ssr_protect(__func__);
3359 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3360 vos_ssr_unprotect(__func__);
3361
3362 return ret;
3363}
3364
3365static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3366 struct wireless_dev *wdev,
3367 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303368{
Dino Myclee8843b32014-07-04 14:21:45 +05303369 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303370 struct net_device *dev = wdev->netdev;
3371 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3372 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3373 struct nlattr
3374 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3375 eHalStatus status;
3376
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303377 ENTER();
3378
Dino Mycle6fb96c12014-06-10 11:52:40 +05303379 status = wlan_hdd_validate_context(pHddCtx);
3380 if (0 != status)
3381 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303382 return -EINVAL;
3383 }
Dino Myclee8843b32014-07-04 14:21:45 +05303384 /* check the EXTScan Capability */
3385 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3386 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3387 {
3388 hddLog(VOS_TRACE_LEVEL_ERROR,
3389 FL("EXTScan not enabled/supported by Firmware"));
3390 return -EINVAL;
3391 }
3392
Dino Mycle6fb96c12014-06-10 11:52:40 +05303393 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3394 data, dataLen,
3395 wlan_hdd_extscan_config_policy)) {
3396 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3397 return -EINVAL;
3398 }
3399 /* Parse and fetch request Id */
3400 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3401 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3402 return -EINVAL;
3403 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303404
Dino Myclee8843b32014-07-04 14:21:45 +05303405 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303406 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3407
Dino Myclee8843b32014-07-04 14:21:45 +05303408 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303409
Dino Myclee8843b32014-07-04 14:21:45 +05303410 reqMsg.sessionId = pAdapter->sessionId;
3411 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303412
3413 /* Parse and fetch flush parameter */
3414 if (!tb
3415 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3416 {
3417 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3418 goto failed;
3419 }
Dino Myclee8843b32014-07-04 14:21:45 +05303420 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303421 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3422
Dino Myclee8843b32014-07-04 14:21:45 +05303423 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303424
Dino Myclee8843b32014-07-04 14:21:45 +05303425 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303426 if (!HAL_STATUS_SUCCESS(status)) {
3427 hddLog(VOS_TRACE_LEVEL_ERROR,
3428 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303429 return -EINVAL;
3430 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303431 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303432 return 0;
3433
3434failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303435 return -EINVAL;
3436}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303437static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3438 struct wireless_dev *wdev,
3439 const void *data, int dataLen)
3440{
3441 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303442
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303443 vos_ssr_protect(__func__);
3444 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3445 vos_ssr_unprotect(__func__);
3446
3447 return ret;
3448}
3449
3450static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303451 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303452 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303453{
3454 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3455 struct net_device *dev = wdev->netdev;
3456 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3457 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3458 struct nlattr
3459 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3460 struct nlattr
3461 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3462 struct nlattr *apTh;
3463 eHalStatus status;
3464 tANI_U8 i = 0;
3465 int rem;
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303466 struct hdd_ext_scan_context *context;
3467 tANI_U32 request_id;
3468 unsigned long rc;
3469 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303470
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303471 ENTER();
3472
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303473 if (VOS_FTM_MODE == hdd_get_conparam()) {
3474 hddLog(LOGE, FL("Command not allowed in FTM mode"));
3475 return -EINVAL;
3476 }
3477
Dino Mycle6fb96c12014-06-10 11:52:40 +05303478 status = wlan_hdd_validate_context(pHddCtx);
3479 if (0 != status)
3480 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303481 return -EINVAL;
3482 }
Dino Myclee8843b32014-07-04 14:21:45 +05303483 /* check the EXTScan Capability */
3484 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3485 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3486 {
3487 hddLog(VOS_TRACE_LEVEL_ERROR,
3488 FL("EXTScan not enabled/supported by Firmware"));
3489 return -EINVAL;
3490 }
3491
Dino Mycle6fb96c12014-06-10 11:52:40 +05303492 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3493 data, dataLen,
3494 wlan_hdd_extscan_config_policy)) {
3495 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3496 return -EINVAL;
3497 }
3498
3499 /* Parse and fetch request Id */
3500 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3501 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3502 return -EINVAL;
3503 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303504 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3505 vos_mem_malloc(sizeof(*pReqMsg));
3506 if (!pReqMsg) {
3507 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3508 return -ENOMEM;
3509 }
3510
Dino Myclee8843b32014-07-04 14:21:45 +05303511
Dino Mycle6fb96c12014-06-10 11:52:40 +05303512 pReqMsg->requestId = nla_get_u32(
3513 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3514 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3515
3516 /* Parse and fetch number of APs */
3517 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3518 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3519 goto fail;
3520 }
3521
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303522 /* Parse and fetch lost ap sample size */
3523 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]) {
3524 hddLog(LOGE, FL("attr lost ap sample size failed"));
3525 goto fail;
3526 }
3527
3528 pReqMsg->lostBssidSampleSize = nla_get_u32(
3529 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_LOST_AP_SAMPLE_SIZE]);
3530 hddLog(LOG1, FL("Lost ap sample size %d"), pReqMsg->lostBssidSampleSize);
3531
Dino Mycle6fb96c12014-06-10 11:52:40 +05303532 pReqMsg->sessionId = pAdapter->sessionId;
3533 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3534
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303535 pReqMsg->numBssid = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303536 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303537 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numBssid);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303538
3539 nla_for_each_nested(apTh,
3540 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3541 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3542 nla_data(apTh), nla_len(apTh),
3543 NULL)) {
3544 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3545 goto fail;
3546 }
3547
3548 /* Parse and fetch MAC address */
3549 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3550 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3551 goto fail;
3552 }
3553 memcpy(pReqMsg->ap[i].bssid, nla_data(
3554 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3555 sizeof(tSirMacAddr));
3556 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3557
3558 /* Parse and fetch low RSSI */
3559 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3560 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3561 goto fail;
3562 }
3563 pReqMsg->ap[i].low = nla_get_s32(
3564 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3565 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3566
3567 /* Parse and fetch high RSSI */
3568 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3569 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3570 goto fail;
3571 }
3572 pReqMsg->ap[i].high = nla_get_s32(
3573 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3574 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3575 pReqMsg->ap[i].high);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303576 i++;
3577 }
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303578
3579 context = &pHddCtx->ext_scan_context;
3580 spin_lock(&hdd_context_lock);
3581 INIT_COMPLETION(context->response_event);
3582 context->request_id = request_id = pReqMsg->requestId;
3583 spin_unlock(&hdd_context_lock);
3584
Dino Mycle6fb96c12014-06-10 11:52:40 +05303585 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3586 if (!HAL_STATUS_SUCCESS(status)) {
3587 hddLog(VOS_TRACE_LEVEL_ERROR,
3588 FL("sme_SetBssHotlist failed(err=%d)"), status);
3589 vos_mem_free(pReqMsg);
3590 return -EINVAL;
3591 }
3592
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303593 /* request was sent -- wait for the response */
3594 rc = wait_for_completion_timeout(&context->response_event,
3595 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
3596
3597 if (!rc) {
3598 hddLog(LOGE, FL("sme_SetBssHotlist timed out"));
3599 retval = -ETIMEDOUT;
3600 } else {
3601 spin_lock(&hdd_context_lock);
3602 if (context->request_id == request_id)
3603 retval = context->response_status;
3604 else
3605 retval = -EINVAL;
3606 spin_unlock(&hdd_context_lock);
3607 }
3608
Dino Myclee8843b32014-07-04 14:21:45 +05303609 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303610 EXIT();
Padma, Santhosh Kumar37f4fd12015-08-19 14:37:37 +05303611 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303612
3613fail:
3614 vos_mem_free(pReqMsg);
3615 return -EINVAL;
3616}
3617
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303618static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3619 struct wireless_dev *wdev,
3620 const void *data, int dataLen)
3621{
3622 int ret = 0;
3623
3624 vos_ssr_protect(__func__);
3625 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3626 dataLen);
3627 vos_ssr_unprotect(__func__);
3628
3629 return ret;
3630}
3631
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303632static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303633 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303634 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303635{
3636 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3637 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3638 tANI_U8 numChannels = 0;
3639 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05303640 tANI_U32 requestId, maxChannels;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303641 tWifiBand wifiBand;
3642 eHalStatus status;
3643 struct sk_buff *replySkb;
3644 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303645 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303646
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303647 ENTER();
3648
Dino Mycle6fb96c12014-06-10 11:52:40 +05303649 status = wlan_hdd_validate_context(pHddCtx);
3650 if (0 != status)
3651 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303652 return -EINVAL;
3653 }
Dino Myclee8843b32014-07-04 14:21:45 +05303654
Dino Mycle6fb96c12014-06-10 11:52:40 +05303655 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3656 data, dataLen,
3657 wlan_hdd_extscan_config_policy)) {
3658 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3659 return -EINVAL;
3660 }
3661
3662 /* Parse and fetch request Id */
3663 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3664 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3665 return -EINVAL;
3666 }
3667 requestId = nla_get_u32(
3668 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3669 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3670
3671 /* Parse and fetch wifi band */
3672 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3673 {
3674 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3675 return -EINVAL;
3676 }
3677 wifiBand = nla_get_u32(
3678 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3679 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3680
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05303681 /* Parse and fetch max channels */
3682 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS])
3683 {
3684 hddLog(LOGE, FL("attr max channels failed"));
3685 return -EINVAL;
3686 }
3687 maxChannels = nla_get_u32(
3688 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS]);
3689 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max channels %d"), maxChannels);
3690
Dino Mycle6fb96c12014-06-10 11:52:40 +05303691 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
3692 wifiBand, ChannelList,
3693 &numChannels);
3694 if (eHAL_STATUS_SUCCESS != status) {
3695 hddLog(VOS_TRACE_LEVEL_ERROR,
3696 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
3697 return -EINVAL;
3698 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05303699
3700 numChannels = VOS_MIN(numChannels, maxChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303701 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05303702
Dino Mycle6fb96c12014-06-10 11:52:40 +05303703 for (i = 0; i < numChannels; i++)
3704 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
3705
3706 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
3707 sizeof(u32) * numChannels +
3708 NLMSG_HDRLEN);
3709
3710 if (!replySkb) {
3711 hddLog(VOS_TRACE_LEVEL_ERROR,
3712 FL("valid channels: buffer alloc fail"));
3713 return -EINVAL;
3714 }
3715 if (nla_put_u32(replySkb,
3716 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
3717 numChannels) ||
3718 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
3719 sizeof(u32) * numChannels, ChannelList)) {
3720
3721 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3722 kfree_skb(replySkb);
3723 return -EINVAL;
3724 }
3725
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303726 ret = cfg80211_vendor_cmd_reply(replySkb);
3727
3728 EXIT();
3729 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303730}
3731
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303732static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
3733 struct wireless_dev *wdev,
3734 const void *data, int dataLen)
3735{
3736 int ret = 0;
3737
3738 vos_ssr_protect(__func__);
3739 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
3740 dataLen);
3741 vos_ssr_unprotect(__func__);
3742
3743 return ret;
3744}
3745
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05303746static int hdd_extscan_start_fill_bucket_channel_spec(
3747 hdd_context_t *pHddCtx,
3748 tpSirEXTScanStartReqParams pReqMsg,
3749 struct nlattr **tb)
3750{
3751 struct nlattr *bucket[
3752 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3753 struct nlattr *channel[
3754 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3755 struct nlattr *buckets;
3756 struct nlattr *channels;
3757 int rem1, rem2;
3758 eHalStatus status;
3759 tANI_U8 bktIndex, j, numChannels;
3760 tANI_U32 chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3761 tANI_U32 passive_max_chn_time, active_max_chn_time;
3762
3763 bktIndex = 0;
3764
3765 nla_for_each_nested(buckets,
3766 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
3767 if (nla_parse(bucket,
3768 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3769 nla_data(buckets), nla_len(buckets), NULL)) {
3770 hddLog(LOGE, FL("nla_parse failed"));
3771 return -EINVAL;
3772 }
3773
3774 /* Parse and fetch bucket spec */
3775 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
3776 hddLog(LOGE, FL("attr bucket index failed"));
3777 return -EINVAL;
3778 }
3779 pReqMsg->buckets[bktIndex].bucket = nla_get_u8(
3780 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
3781 hddLog(LOG1, FL("Bucket spec Index %d"),
3782 pReqMsg->buckets[bktIndex].bucket);
3783
3784 /* Parse and fetch wifi band */
3785 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
3786 hddLog(LOGE, FL("attr wifi band failed"));
3787 return -EINVAL;
3788 }
3789 pReqMsg->buckets[bktIndex].band = nla_get_u8(
3790 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
3791 hddLog(LOG1, FL("Wifi band %d"),
3792 pReqMsg->buckets[bktIndex].band);
3793
3794 /* Parse and fetch period */
3795 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
3796 hddLog(LOGE, FL("attr period failed"));
3797 return -EINVAL;
3798 }
3799 pReqMsg->buckets[bktIndex].period = nla_get_u32(
3800 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
3801 hddLog(LOG1, FL("period %d"),
3802 pReqMsg->buckets[bktIndex].period);
3803
3804 /* Parse and fetch report events */
3805 if (!bucket[
3806 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
3807 hddLog(LOGE, FL("attr report events failed"));
3808 return -EINVAL;
3809 }
3810 pReqMsg->buckets[bktIndex].reportEvents = nla_get_u8(
3811 bucket[
3812 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
3813 hddLog(LOG1, FL("report events %d"),
3814 pReqMsg->buckets[bktIndex].reportEvents);
3815
3816 /* Parse and fetch max period */
3817 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]) {
3818 hddLog(LOGE, FL("attr max period failed"));
3819 return -EINVAL;
3820 }
3821 pReqMsg->buckets[bktIndex].max_period = nla_get_u32(
3822 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_MAX_PERIOD]);
3823 hddLog(LOG1, FL("max period %u"),
3824 pReqMsg->buckets[bktIndex].max_period);
3825
3826 /* Parse and fetch exponent */
3827 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]) {
3828 hddLog(LOGE, FL("attr exponent failed"));
3829 return -EINVAL;
3830 }
3831 pReqMsg->buckets[bktIndex].exponent = nla_get_u32(
3832 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_EXPONENT]);
3833 hddLog(LOG1, FL("exponent %u"),
3834 pReqMsg->buckets[bktIndex].exponent);
3835
3836 /* Parse and fetch step count */
3837 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]) {
3838 hddLog(LOGE, FL("attr step count failed"));
3839 return -EINVAL;
3840 }
3841 pReqMsg->buckets[bktIndex].step_count = nla_get_u32(
3842 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_STEP_COUNT]);
3843 hddLog(LOG1, FL("Step count %u"),
3844 pReqMsg->buckets[bktIndex].step_count);
3845
3846 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &passive_max_chn_time);
3847 ccmCfgGetInt(pHddCtx->hHal, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &active_max_chn_time);
3848
3849 /* Framework shall pass the channel list if the input WiFi band is
3850 * WIFI_BAND_UNSPECIFIED.
3851 * If the input WiFi band is specified (any value other than
3852 * WIFI_BAND_UNSPECIFIED) then driver populates the channel list
3853 */
3854 if (pReqMsg->buckets[bktIndex].band != WIFI_BAND_UNSPECIFIED) {
3855 numChannels = 0;
3856 hddLog(LOG1, "WiFi band is specified, driver to fill channel list");
3857 status = sme_GetValidChannelsByBand(pHddCtx->hHal,
3858 pReqMsg->buckets[bktIndex].band,
3859 chanList, &numChannels);
3860 if (!HAL_STATUS_SUCCESS(status)) {
3861 hddLog(LOGE,
3862 FL("sme_GetValidChannelsByBand failed (err=%d)"),
3863 status);
3864 return -EINVAL;
3865 }
3866
3867 pReqMsg->buckets[bktIndex].numChannels =
3868 VOS_MIN(numChannels, WLAN_EXTSCAN_MAX_CHANNELS);
3869 hddLog(LOG1, FL("Num channels %d"),
3870 pReqMsg->buckets[bktIndex].numChannels);
3871
3872 for (j = 0; j < pReqMsg->buckets[bktIndex].numChannels;
3873 j++) {
3874 pReqMsg->buckets[bktIndex].channels[j].channel =
3875 chanList[j];
3876 pReqMsg->buckets[bktIndex].channels[j].
3877 chnlClass = 0;
3878 if (CSR_IS_CHANNEL_DFS(
3879 vos_freq_to_chan(chanList[j]))) {
3880 pReqMsg->buckets[bktIndex].channels[j].
3881 passive = 1;
3882 pReqMsg->buckets[bktIndex].channels[j].
3883 dwellTimeMs = passive_max_chn_time;
3884 } else {
3885 pReqMsg->buckets[bktIndex].channels[j].
3886 passive = 0;
3887 pReqMsg->buckets[bktIndex].channels[j].
3888 dwellTimeMs = active_max_chn_time;
3889 }
3890
3891 hddLog(LOG1,
3892 "Channel %u Passive %u Dwell time %u ms",
3893 pReqMsg->buckets[bktIndex].channels[j].channel,
3894 pReqMsg->buckets[bktIndex].channels[j].passive,
3895 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
3896 }
3897
3898 bktIndex++;
3899 continue;
3900 }
3901
3902 /* Parse and fetch number of channels */
3903 if (!bucket[
3904 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]) {
3905 hddLog(LOGE, FL("attr num channels failed"));
3906 return -EINVAL;
3907 }
3908
3909 pReqMsg->buckets[bktIndex].numChannels =
3910 nla_get_u32(bucket[
3911 QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
3912 hddLog(LOG1, FL("num channels %d"),
3913 pReqMsg->buckets[bktIndex].numChannels);
3914
3915 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
3916 hddLog(LOGE, FL("attr channel spec failed"));
3917 return -EINVAL;
3918 }
3919
3920 j = 0;
3921 nla_for_each_nested(channels,
3922 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
3923 if (nla_parse(channel,
3924 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3925 nla_data(channels), nla_len(channels),
3926 wlan_hdd_extscan_config_policy)) {
3927 hddLog(LOGE, FL("nla_parse failed"));
3928 return -EINVAL;
3929 }
3930
3931 /* Parse and fetch channel */
3932 if (!channel[
3933 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
3934 hddLog(LOGE, FL("attr channel failed"));
3935 return -EINVAL;
3936 }
3937 pReqMsg->buckets[bktIndex].channels[j].channel =
3938 nla_get_u32(channel[
3939 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
3940 hddLog(LOG1, FL("channel %u"),
3941 pReqMsg->buckets[bktIndex].channels[j].channel);
3942
3943 /* Parse and fetch dwell time */
3944 if (!channel[
3945 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
3946 hddLog(LOGE, FL("attr dwelltime failed"));
3947 return -EINVAL;
3948 }
3949 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs =
3950 nla_get_u32(channel[
3951 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
3952
3953 hddLog(LOG1, FL("Dwell time (%u ms)"),
3954 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
3955
3956
3957 /* Parse and fetch channel spec passive */
3958 if (!channel[
3959 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
3960 hddLog(LOGE,
3961 FL("attr channel spec passive failed"));
3962 return -EINVAL;
3963 }
3964 pReqMsg->buckets[bktIndex].channels[j].passive =
3965 nla_get_u8(channel[
3966 QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
3967 hddLog(LOG1, FL("Chnl spec passive %u"),
3968 pReqMsg->buckets[bktIndex].channels[j].passive);
3969
3970 j++;
3971 }
3972
3973 bktIndex++;
3974 }
3975
3976 return 0;
3977}
3978
3979
3980/*
3981 * define short names for the global vendor params
3982 * used by wlan_hdd_cfg80211_extscan_start()
3983 */
3984#define PARAM_MAX \
3985QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
3986#define PARAM_REQUEST_ID \
3987QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
3988#define PARAM_BASE_PERIOD \
3989QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD
3990#define PARAM_MAX_AP_PER_SCAN \
3991QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN
3992#define PARAM_RPT_THRHLD_PERCENT \
3993QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_PERCENT
3994#define PARAM_RPT_THRHLD_NUM_SCANS \
3995QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD_NUM_SCANS
3996#define PARAM_NUM_BUCKETS \
3997QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS
3998
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303999static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304000 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304001 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304002{
Dino Myclee8843b32014-07-04 14:21:45 +05304003 tpSirEXTScanStartReqParams pReqMsg = NULL;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304004 struct net_device *dev = wdev->netdev;
4005 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4006 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4007 struct nlattr *tb[PARAM_MAX + 1];
4008 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304009 eHalStatus status;
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304010 tANI_U32 request_id;
4011 struct hdd_ext_scan_context *context;
4012 unsigned long rc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304013
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304014 ENTER();
4015
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304016 if (VOS_FTM_MODE == hdd_get_conparam()) {
4017 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4018 return -EINVAL;
4019 }
4020
Dino Mycle6fb96c12014-06-10 11:52:40 +05304021 status = wlan_hdd_validate_context(pHddCtx);
4022 if (0 != status)
4023 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304024 return -EINVAL;
4025 }
Dino Myclee8843b32014-07-04 14:21:45 +05304026 /* check the EXTScan Capability */
4027 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4028 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4029 {
4030 hddLog(VOS_TRACE_LEVEL_ERROR,
4031 FL("EXTScan not enabled/supported by Firmware"));
4032 return -EINVAL;
4033 }
4034
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304035 if (nla_parse(tb, PARAM_MAX,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304036 data, dataLen,
4037 wlan_hdd_extscan_config_policy)) {
4038 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4039 return -EINVAL;
4040 }
4041
4042 /* Parse and fetch request Id */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304043 if (!tb[PARAM_REQUEST_ID]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304044 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4045 return -EINVAL;
4046 }
4047
Dino Myclee8843b32014-07-04 14:21:45 +05304048 pReqMsg = (tpSirEXTScanStartReqParams)
4049 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304050 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304051 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4052 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304053 }
4054
4055 pReqMsg->requestId = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304056 tb[PARAM_REQUEST_ID]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304057 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4058
4059 pReqMsg->sessionId = pAdapter->sessionId;
4060 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4061
4062 /* Parse and fetch base period */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304063 if (!tb[PARAM_BASE_PERIOD]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304064 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4065 goto fail;
4066 }
4067 pReqMsg->basePeriod = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304068 tb[PARAM_BASE_PERIOD]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304069 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4070 pReqMsg->basePeriod);
4071
4072 /* Parse and fetch max AP per scan */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304073 if (!tb[PARAM_MAX_AP_PER_SCAN]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304074 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4075 goto fail;
4076 }
4077 pReqMsg->maxAPperScan = nla_get_u32(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304078 tb[PARAM_MAX_AP_PER_SCAN]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304079 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4080 pReqMsg->maxAPperScan);
4081
4082 /* Parse and fetch report threshold */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304083 if (!tb[PARAM_RPT_THRHLD_PERCENT]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304084 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4085 goto fail;
4086 }
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304087 pReqMsg->reportThresholdPercent = nla_get_u8(
4088 tb[PARAM_RPT_THRHLD_PERCENT]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304089 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304090 pReqMsg->reportThresholdPercent);
4091
4092 /* Parse and fetch report threshold num scans */
4093 if (!tb[PARAM_RPT_THRHLD_NUM_SCANS]) {
4094 hddLog(LOGE, FL("attr report_threshold num scans failed"));
4095 goto fail;
4096 }
4097 pReqMsg->reportThresholdNumScans = nla_get_u8(
4098 tb[PARAM_RPT_THRHLD_NUM_SCANS]);
4099 hddLog(LOG1, FL("Report Threshold num scans %d"),
4100 pReqMsg->reportThresholdNumScans);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304101
4102 /* Parse and fetch number of buckets */
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304103 if (!tb[PARAM_NUM_BUCKETS]) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304104 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4105 goto fail;
4106 }
4107 pReqMsg->numBuckets = nla_get_u8(
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304108 tb[PARAM_NUM_BUCKETS]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304109 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4110 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4111 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4112 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4113 }
4114 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4115 pReqMsg->numBuckets);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304116
Dino Mycle6fb96c12014-06-10 11:52:40 +05304117 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4118 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4119 goto fail;
4120 }
4121
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304122 pReqMsg->homeAwayTime = pHddCtx->cfg_ini->nRestTimeConc;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304123
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304124 if (hdd_extscan_start_fill_bucket_channel_spec(pHddCtx, pReqMsg, tb))
4125 goto fail;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304126
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304127 context = &pHddCtx->ext_scan_context;
4128 spin_lock(&hdd_context_lock);
4129 INIT_COMPLETION(context->response_event);
4130 context->request_id = request_id = pReqMsg->requestId;
4131 spin_unlock(&hdd_context_lock);
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304132
Dino Mycle6fb96c12014-06-10 11:52:40 +05304133 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4134 if (!HAL_STATUS_SUCCESS(status)) {
4135 hddLog(VOS_TRACE_LEVEL_ERROR,
4136 FL("sme_EXTScanStart failed(err=%d)"), status);
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304137 goto fail;
4138 }
4139
4140 /* request was sent -- wait for the response */
4141 rc = wait_for_completion_timeout(&context->response_event,
4142 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4143
4144 if (!rc) {
4145 hddLog(LOGE, FL("sme_ExtScanStart timed out"));
4146 retval = -ETIMEDOUT;
4147 } else {
4148 spin_lock(&hdd_context_lock);
4149 if (context->request_id == request_id)
4150 retval = context->response_status;
4151 else
4152 retval = -EINVAL;
4153 spin_unlock(&hdd_context_lock);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304154 }
4155
Dino Myclee8843b32014-07-04 14:21:45 +05304156 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304157 EXIT();
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304158 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304159
4160fail:
4161 vos_mem_free(pReqMsg);
4162 return -EINVAL;
4163}
4164
Padma, Santhosh Kumar7b9190d2015-08-17 17:45:29 +05304165/*
4166 * done with short names for the global vendor params
4167 * used by wlan_hdd_cfg80211_extscan_start()
4168 */
4169#undef PARAM_MAX
4170#undef PARAM_REQUEST_ID
4171#undef PARAM_BASE_PERIOD
4172#undef PARAMS_MAX_AP_PER_SCAN
4173#undef PARAMS_RPT_THRHLD_PERCENT
4174#undef PARAMS_RPT_THRHLD_NUM_SCANS
4175#undef PARAMS_NUM_BUCKETS
4176
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304177static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4178 struct wireless_dev *wdev,
4179 const void *data, int dataLen)
4180{
4181 int ret = 0;
4182
4183 vos_ssr_protect(__func__);
4184 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4185 vos_ssr_unprotect(__func__);
4186
4187 return ret;
4188}
4189
4190static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304191 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304192 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304193{
Dino Myclee8843b32014-07-04 14:21:45 +05304194 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304195 struct net_device *dev = wdev->netdev;
4196 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4197 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4198 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4199 eHalStatus status;
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304200 int retval;
4201 unsigned long rc;
4202 struct hdd_ext_scan_context *context;
4203 tANI_U32 request_id;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304204
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304205 ENTER();
4206
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304207 if (VOS_FTM_MODE == hdd_get_conparam()) {
4208 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4209 return -EINVAL;
4210 }
4211
Dino Mycle6fb96c12014-06-10 11:52:40 +05304212 status = wlan_hdd_validate_context(pHddCtx);
4213 if (0 != status)
4214 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304215 return -EINVAL;
4216 }
Dino Myclee8843b32014-07-04 14:21:45 +05304217 /* check the EXTScan Capability */
4218 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4219 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4220 {
4221 hddLog(VOS_TRACE_LEVEL_ERROR,
4222 FL("EXTScan not enabled/supported by Firmware"));
4223 return -EINVAL;
4224 }
4225
Dino Mycle6fb96c12014-06-10 11:52:40 +05304226 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4227 data, dataLen,
4228 wlan_hdd_extscan_config_policy)) {
4229 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4230 return -EINVAL;
4231 }
4232
4233 /* Parse and fetch request Id */
4234 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4235 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4236 return -EINVAL;
4237 }
4238
Dino Myclee8843b32014-07-04 14:21:45 +05304239 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304240 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304241 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304242
Dino Myclee8843b32014-07-04 14:21:45 +05304243 reqMsg.sessionId = pAdapter->sessionId;
4244 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304245
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304246 context = &pHddCtx->ext_scan_context;
4247 spin_lock(&hdd_context_lock);
4248 INIT_COMPLETION(context->response_event);
4249 context->request_id = request_id = reqMsg.sessionId;
4250 spin_unlock(&hdd_context_lock);
4251
Dino Myclee8843b32014-07-04 14:21:45 +05304252 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304253 if (!HAL_STATUS_SUCCESS(status)) {
4254 hddLog(VOS_TRACE_LEVEL_ERROR,
4255 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304256 return -EINVAL;
4257 }
4258
Padma, Santhosh Kumar57cff7f2015-08-17 18:33:14 +05304259 /* request was sent -- wait for the response */
4260 rc = wait_for_completion_timeout(&context->response_event,
4261 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4262
4263 if (!rc) {
4264 hddLog(LOGE, FL("sme_ExtScanStop timed out"));
4265 retval = -ETIMEDOUT;
4266 } else {
4267 spin_lock(&hdd_context_lock);
4268 if (context->request_id == request_id)
4269 retval = context->response_status;
4270 else
4271 retval = -EINVAL;
4272 spin_unlock(&hdd_context_lock);
4273 }
4274
4275 return retval;
4276
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304277 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304278 return 0;
4279}
4280
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304281static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4282 struct wireless_dev *wdev,
4283 const void *data, int dataLen)
4284{
4285 int ret = 0;
4286
4287 vos_ssr_protect(__func__);
4288 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4289 vos_ssr_unprotect(__func__);
4290
4291 return ret;
4292}
4293
4294static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304295 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304296 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304297{
Dino Myclee8843b32014-07-04 14:21:45 +05304298 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304299 struct net_device *dev = wdev->netdev;
4300 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4301 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4302 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4303 eHalStatus status;
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304304 struct hdd_ext_scan_context *context;
4305 tANI_U32 request_id;
4306 unsigned long rc;
4307 int retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304308
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304309 ENTER();
4310
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304311 if (VOS_FTM_MODE == hdd_get_conparam()) {
4312 hddLog(LOGE, FL("Command not allowed in FTM mode"));
4313 return -EINVAL;
4314 }
4315
Dino Mycle6fb96c12014-06-10 11:52:40 +05304316 status = wlan_hdd_validate_context(pHddCtx);
4317 if (0 != status)
4318 {
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304319 hddLog(LOGE, FL("HDD context is not valid"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304320 return -EINVAL;
4321 }
Dino Myclee8843b32014-07-04 14:21:45 +05304322 /* check the EXTScan Capability */
4323 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4324 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4325 {
4326 hddLog(VOS_TRACE_LEVEL_ERROR,
4327 FL("EXTScan not enabled/supported by Firmware"));
4328 return -EINVAL;
4329 }
4330
Dino Mycle6fb96c12014-06-10 11:52:40 +05304331 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4332 data, dataLen,
4333 wlan_hdd_extscan_config_policy)) {
4334 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4335 return -EINVAL;
4336 }
4337
4338 /* Parse and fetch request Id */
4339 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4340 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4341 return -EINVAL;
4342 }
4343
Dino Myclee8843b32014-07-04 14:21:45 +05304344 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304345 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304346 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304347
Dino Myclee8843b32014-07-04 14:21:45 +05304348 reqMsg.sessionId = pAdapter->sessionId;
4349 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304350
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304351 context = &pHddCtx->ext_scan_context;
4352 spin_lock(&hdd_context_lock);
4353 INIT_COMPLETION(context->response_event);
4354 context->request_id = request_id = reqMsg.requestId;
4355 spin_unlock(&hdd_context_lock);
4356
Dino Myclee8843b32014-07-04 14:21:45 +05304357 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304358 if (!HAL_STATUS_SUCCESS(status)) {
4359 hddLog(VOS_TRACE_LEVEL_ERROR,
4360 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304361 return -EINVAL;
4362 }
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304363
4364 /* request was sent -- wait for the response */
4365 rc = wait_for_completion_timeout(&context->response_event,
4366 msecs_to_jiffies(WLAN_WAIT_TIME_EXTSCAN));
4367 if (!rc) {
4368 hddLog(LOGE, FL("sme_ResetBssHotlist timed out"));
4369 retval = -ETIMEDOUT;
4370 } else {
4371 spin_lock(&hdd_context_lock);
4372 if (context->request_id == request_id)
4373 retval = context->response_status;
4374 else
4375 retval = -EINVAL;
4376 spin_unlock(&hdd_context_lock);
4377 }
4378
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304379 EXIT();
Padma, Santhosh Kumar04a3bab2015-08-20 13:09:35 +05304380 return retval;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304381}
4382
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304383static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4384 struct wireless_dev *wdev,
4385 const void *data, int dataLen)
4386{
4387 int ret = 0;
4388
4389 vos_ssr_protect(__func__);
4390 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4391 vos_ssr_unprotect(__func__);
4392
4393 return ret;
4394}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304395#endif /* WLAN_FEATURE_EXTSCAN */
4396
Atul Mittal115287b2014-07-08 13:26:33 +05304397/*EXT TDLS*/
4398static const struct nla_policy
4399wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4400{
4401 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4402 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4403 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4404 {.type = NLA_S32 },
4405 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4406 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4407
4408};
4409
4410static const struct nla_policy
4411wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4412{
4413 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4414
4415};
4416
4417static const struct nla_policy
4418wlan_hdd_tdls_config_state_change_policy[
4419 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4420{
4421 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4422 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4423 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304424 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4425 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4426 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304427
4428};
4429
4430static const struct nla_policy
4431wlan_hdd_tdls_config_get_status_policy[
4432 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4433{
4434 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4435 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4436 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304437 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4438 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4439 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304440
4441};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304442
4443static const struct nla_policy
4444wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4445{
4446 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4447};
4448
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304449static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304450 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304451 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304452 int data_len)
4453{
4454
4455 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4456 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4457
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304458 ENTER();
4459
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304460 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304461 return -EINVAL;
4462 }
4463 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05304464 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304465 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304466 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304467 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05304468 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304469 return -ENOTSUPP;
4470 }
4471
4472 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4473 data, data_len, wlan_hdd_mac_config)) {
4474 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4475 return -EINVAL;
4476 }
4477
4478 /* Parse and fetch mac address */
4479 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4480 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4481 return -EINVAL;
4482 }
4483
4484 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4485 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4486 VOS_MAC_ADDR_LAST_3_BYTES);
4487
Siddharth Bhal76972212014-10-15 16:22:51 +05304488 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4489
4490 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304491 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4492 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304493 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4494 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4495 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4496 {
4497 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4498 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4499 VOS_MAC_ADDRESS_LEN);
4500 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304501 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304502
Siddharth Bhal76972212014-10-15 16:22:51 +05304503 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
4504 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304505 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4506 }
4507
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304508 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304509 return 0;
4510}
4511
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304512static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4513 struct wireless_dev *wdev,
4514 const void *data,
4515 int data_len)
4516{
4517 int ret = 0;
4518
4519 vos_ssr_protect(__func__);
4520 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
4521 vos_ssr_unprotect(__func__);
4522
4523 return ret;
4524}
4525
4526static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304527 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304528 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304529 int data_len)
4530{
4531 u8 peer[6] = {0};
4532 struct net_device *dev = wdev->netdev;
4533 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4534 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4535 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4536 eHalStatus ret;
4537 tANI_S32 state;
4538 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304539 tANI_S32 global_operating_class = 0;
4540 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304541 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304542 int retVal;
4543
4544 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304545
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304546 if (!pAdapter) {
4547 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4548 return -EINVAL;
4549 }
4550
Atul Mittal115287b2014-07-08 13:26:33 +05304551 ret = wlan_hdd_validate_context(pHddCtx);
4552 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304553 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304554 return -EINVAL;
4555 }
4556 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304557 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304558 return -ENOTSUPP;
4559 }
4560 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4561 data, data_len,
4562 wlan_hdd_tdls_config_get_status_policy)) {
4563 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4564 return -EINVAL;
4565 }
4566
4567 /* Parse and fetch mac address */
4568 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4569 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4570 return -EINVAL;
4571 }
4572
4573 memcpy(peer, nla_data(
4574 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4575 sizeof(peer));
4576 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4577
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05304578 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05304579
Atul Mittal115287b2014-07-08 13:26:33 +05304580 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304581 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304582 NLMSG_HDRLEN);
4583
4584 if (!skb) {
4585 hddLog(VOS_TRACE_LEVEL_ERROR,
4586 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4587 return -EINVAL;
4588 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304589 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 +05304590 reason,
4591 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304592 global_operating_class,
4593 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304594 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304595 if (nla_put_s32(skb,
4596 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4597 state) ||
4598 nla_put_s32(skb,
4599 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4600 reason) ||
4601 nla_put_s32(skb,
4602 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4603 global_operating_class) ||
4604 nla_put_s32(skb,
4605 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4606 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304607
4608 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4609 goto nla_put_failure;
4610 }
4611
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304612 retVal = cfg80211_vendor_cmd_reply(skb);
4613 EXIT();
4614 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05304615
4616nla_put_failure:
4617 kfree_skb(skb);
4618 return -EINVAL;
4619}
4620
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304621static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4622 struct wireless_dev *wdev,
4623 const void *data,
4624 int data_len)
4625{
4626 int ret = 0;
4627
4628 vos_ssr_protect(__func__);
4629 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
4630 vos_ssr_unprotect(__func__);
4631
4632 return ret;
4633}
4634
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05304635static int wlan_hdd_cfg80211_exttdls_callback(
4636#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
4637 const tANI_U8* mac,
4638#else
4639 tANI_U8* mac,
4640#endif
Atul Mittal115287b2014-07-08 13:26:33 +05304641 tANI_S32 state,
4642 tANI_S32 reason,
4643 void *ctx)
4644{
4645 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05304646 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304647 tANI_S32 global_operating_class = 0;
4648 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304649 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05304650
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304651 ENTER();
4652
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304653 if (!pAdapter) {
4654 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4655 return -EINVAL;
4656 }
4657
4658 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05304659 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304660 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304661 return -EINVAL;
4662 }
4663
4664 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304665 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304666 return -ENOTSUPP;
4667 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05304668 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
4669#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
4670 NULL,
4671#endif
Atul Mittal115287b2014-07-08 13:26:33 +05304672 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4673 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4674 GFP_KERNEL);
4675
4676 if (!skb) {
4677 hddLog(VOS_TRACE_LEVEL_ERROR,
4678 FL("cfg80211_vendor_event_alloc failed"));
4679 return -EINVAL;
4680 }
4681 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304682 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4683 reason,
4684 state,
4685 global_operating_class,
4686 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304687 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4688 MAC_ADDR_ARRAY(mac));
4689
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304690 if (nla_put(skb,
4691 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4692 VOS_MAC_ADDR_SIZE, mac) ||
4693 nla_put_s32(skb,
4694 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4695 state) ||
4696 nla_put_s32(skb,
4697 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4698 reason) ||
4699 nla_put_s32(skb,
4700 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4701 channel) ||
4702 nla_put_s32(skb,
4703 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4704 global_operating_class)
4705 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304706 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4707 goto nla_put_failure;
4708 }
4709
4710 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304711 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05304712 return (0);
4713
4714nla_put_failure:
4715 kfree_skb(skb);
4716 return -EINVAL;
4717}
4718
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304719static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304720 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304721 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304722 int data_len)
4723{
4724 u8 peer[6] = {0};
4725 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304726 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4727 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4728 eHalStatus status;
4729 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304730 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304731 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304732
4733 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304734
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304735 if (!dev) {
4736 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4737 return -EINVAL;
4738 }
4739
4740 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4741 if (!pAdapter) {
4742 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4743 return -EINVAL;
4744 }
4745
Atul Mittal115287b2014-07-08 13:26:33 +05304746 status = wlan_hdd_validate_context(pHddCtx);
4747 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304748 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304749 return -EINVAL;
4750 }
4751 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304752 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304753 return -ENOTSUPP;
4754 }
4755 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4756 data, data_len,
4757 wlan_hdd_tdls_config_enable_policy)) {
4758 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4759 return -EINVAL;
4760 }
4761
4762 /* Parse and fetch mac address */
4763 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4764 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4765 return -EINVAL;
4766 }
4767
4768 memcpy(peer, nla_data(
4769 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4770 sizeof(peer));
4771 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4772
4773 /* Parse and fetch channel */
4774 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4775 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4776 return -EINVAL;
4777 }
4778 pReqMsg.channel = nla_get_s32(
4779 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4780 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4781
4782 /* Parse and fetch global operating class */
4783 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4784 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4785 return -EINVAL;
4786 }
4787 pReqMsg.global_operating_class = nla_get_s32(
4788 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4789 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4790 pReqMsg.global_operating_class);
4791
4792 /* Parse and fetch latency ms */
4793 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4794 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4795 return -EINVAL;
4796 }
4797 pReqMsg.max_latency_ms = nla_get_s32(
4798 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4799 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4800 pReqMsg.max_latency_ms);
4801
4802 /* Parse and fetch required bandwidth kbps */
4803 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4804 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4805 return -EINVAL;
4806 }
4807
4808 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4809 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4810 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4811 pReqMsg.min_bandwidth_kbps);
4812
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304813 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05304814 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05304815 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304816 wlan_hdd_cfg80211_exttdls_callback);
4817
4818 EXIT();
4819 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304820}
4821
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304822static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4823 struct wireless_dev *wdev,
4824 const void *data,
4825 int data_len)
4826{
4827 int ret = 0;
4828
4829 vos_ssr_protect(__func__);
4830 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
4831 vos_ssr_unprotect(__func__);
4832
4833 return ret;
4834}
4835
4836static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304837 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304838 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304839 int data_len)
4840{
4841 u8 peer[6] = {0};
4842 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304843 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4844 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4845 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304846 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304847 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304848
4849 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304850
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304851 if (!dev) {
4852 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4853 return -EINVAL;
4854 }
4855
4856 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4857 if (!pAdapter) {
4858 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
4859 return -EINVAL;
4860 }
4861
Atul Mittal115287b2014-07-08 13:26:33 +05304862 status = wlan_hdd_validate_context(pHddCtx);
4863 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304864 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304865 return -EINVAL;
4866 }
4867 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304868 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304869 return -ENOTSUPP;
4870 }
4871 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4872 data, data_len,
4873 wlan_hdd_tdls_config_disable_policy)) {
4874 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4875 return -EINVAL;
4876 }
4877 /* Parse and fetch mac address */
4878 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
4879 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4880 return -EINVAL;
4881 }
4882
4883 memcpy(peer, nla_data(
4884 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
4885 sizeof(peer));
4886 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4887
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304888 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
4889
4890 EXIT();
4891 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304892}
4893
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304894static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
4895 struct wireless_dev *wdev,
4896 const void *data,
4897 int data_len)
4898{
4899 int ret = 0;
4900
4901 vos_ssr_protect(__func__);
4902 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
4903 vos_ssr_unprotect(__func__);
4904
4905 return ret;
4906}
4907
Dasari Srinivas7875a302014-09-26 17:50:57 +05304908static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304909__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05304910 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304911 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05304912{
4913 struct net_device *dev = wdev->netdev;
4914 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4915 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4916 struct sk_buff *skb = NULL;
4917 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304918 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05304919
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304920 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304921
4922 ret = wlan_hdd_validate_context(pHddCtx);
4923 if (0 != ret)
4924 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304925 return ret;
4926 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304927 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
4928 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
4929 fset |= WIFI_FEATURE_INFRA;
4930 }
4931
4932 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
4933 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
4934 fset |= WIFI_FEATURE_INFRA_5G;
4935 }
4936
4937#ifdef WLAN_FEATURE_P2P
4938 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
4939 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
4940 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
4941 fset |= WIFI_FEATURE_P2P;
4942 }
4943#endif
4944
4945 /* Soft-AP is supported currently by default */
4946 fset |= WIFI_FEATURE_SOFT_AP;
4947
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05304948 /* HOTSPOT is a supplicant feature, enable it by default */
4949 fset |= WIFI_FEATURE_HOTSPOT;
4950
Dasari Srinivas7875a302014-09-26 17:50:57 +05304951#ifdef WLAN_FEATURE_EXTSCAN
4952 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
4953 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
4954 hddLog(LOG1, FL("EXTScan is supported by firmware"));
4955 fset |= WIFI_FEATURE_EXTSCAN;
4956 }
4957#endif
4958
Dasari Srinivas7875a302014-09-26 17:50:57 +05304959 if (sme_IsFeatureSupportedByFW(NAN)) {
4960 hddLog(LOG1, FL("NAN is supported by firmware"));
4961 fset |= WIFI_FEATURE_NAN;
4962 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304963
4964 /* D2D RTT is not supported currently by default */
4965 if (sme_IsFeatureSupportedByFW(RTT)) {
4966 hddLog(LOG1, FL("RTT is supported by firmware"));
4967 fset |= WIFI_FEATURE_D2AP_RTT;
4968 }
4969
4970#ifdef FEATURE_WLAN_BATCH_SCAN
4971 if (fset & WIFI_FEATURE_EXTSCAN) {
4972 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
4973 fset &= ~WIFI_FEATURE_BATCH_SCAN;
4974 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
4975 hddLog(LOG1, FL("Batch scan is supported by firmware"));
4976 fset |= WIFI_FEATURE_BATCH_SCAN;
4977 }
4978#endif
4979
4980#ifdef FEATURE_WLAN_SCAN_PNO
4981 if (pHddCtx->cfg_ini->configPNOScanSupport &&
4982 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
4983 hddLog(LOG1, FL("PNO is supported by firmware"));
4984 fset |= WIFI_FEATURE_PNO;
4985 }
4986#endif
4987
4988 /* STA+STA is supported currently by default */
4989 fset |= WIFI_FEATURE_ADDITIONAL_STA;
4990
4991#ifdef FEATURE_WLAN_TDLS
4992 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
4993 sme_IsFeatureSupportedByFW(TDLS)) {
4994 hddLog(LOG1, FL("TDLS is supported by firmware"));
4995 fset |= WIFI_FEATURE_TDLS;
4996 }
4997
4998 /* TDLS_OFFCHANNEL is not supported currently by default */
4999#endif
5000
5001#ifdef WLAN_AP_STA_CONCURRENCY
5002 /* AP+STA concurrency is supported currently by default */
5003 fset |= WIFI_FEATURE_AP_STA;
5004#endif
5005
Mukul Sharma5add0532015-08-17 15:57:47 +05305006#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5007 fset |= WIFI_FEATURE_LINK_LAYER_STATS;
5008 hddLog(LOG1, FL("Link layer stats is supported by driver"));
5009#endif
5010
Dasari Srinivas7875a302014-09-26 17:50:57 +05305011 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5012 NLMSG_HDRLEN);
5013
5014 if (!skb) {
5015 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5016 return -EINVAL;
5017 }
5018 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5019
5020 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5021 hddLog(LOGE, FL("nla put fail"));
5022 goto nla_put_failure;
5023 }
5024
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305025 ret = cfg80211_vendor_cmd_reply(skb);
5026 EXIT();
5027 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305028
5029nla_put_failure:
5030 kfree_skb(skb);
5031 return -EINVAL;
5032}
5033
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305034static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305035wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5036 struct wireless_dev *wdev,
5037 const void *data, int data_len)
5038{
5039 int ret = 0;
5040
5041 vos_ssr_protect(__func__);
5042 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5043 vos_ssr_unprotect(__func__);
5044
5045 return ret;
5046}
5047
5048static int
5049__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305050 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305051 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305052{
5053 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5054 uint8_t i, feature_sets, max_feature_sets;
5055 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5056 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305057 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5058 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305059
5060 ENTER();
5061
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305062 ret = wlan_hdd_validate_context(pHddCtx);
5063 if (0 != ret)
5064 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305065 return ret;
5066 }
5067
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305068 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5069 data, data_len, NULL)) {
5070 hddLog(LOGE, FL("Invalid ATTR"));
5071 return -EINVAL;
5072 }
5073
5074 /* Parse and fetch max feature set */
5075 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5076 hddLog(LOGE, FL("Attr max feature set size failed"));
5077 return -EINVAL;
5078 }
5079 max_feature_sets = nla_get_u32(
5080 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5081 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5082
5083 /* Fill feature combination matrix */
5084 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305085 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5086 WIFI_FEATURE_P2P;
5087
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305088 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5089 WIFI_FEATURE_SOFT_AP;
5090
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305091 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5092 WIFI_FEATURE_SOFT_AP;
5093
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305094 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5095 WIFI_FEATURE_SOFT_AP |
5096 WIFI_FEATURE_P2P;
5097
5098 /* Add more feature combinations here */
5099
5100 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5101 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5102 hddLog(LOG1, "Feature set matrix");
5103 for (i = 0; i < feature_sets; i++)
5104 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5105
5106 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5107 sizeof(u32) * feature_sets +
5108 NLMSG_HDRLEN);
5109
5110 if (reply_skb) {
5111 if (nla_put_u32(reply_skb,
5112 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5113 feature_sets) ||
5114 nla_put(reply_skb,
5115 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5116 sizeof(u32) * feature_sets, feature_set_matrix)) {
5117 hddLog(LOGE, FL("nla put fail"));
5118 kfree_skb(reply_skb);
5119 return -EINVAL;
5120 }
5121
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305122 ret = cfg80211_vendor_cmd_reply(reply_skb);
5123 EXIT();
5124 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305125 }
5126 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5127 return -ENOMEM;
5128
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305129}
5130
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305131static int
5132wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5133 struct wireless_dev *wdev,
5134 const void *data, int data_len)
5135{
5136 int ret = 0;
5137
5138 vos_ssr_protect(__func__);
5139 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5140 data_len);
5141 vos_ssr_unprotect(__func__);
5142
5143 return ret;
5144}
5145
Agarwal Ashish738843c2014-09-25 12:27:56 +05305146static const struct nla_policy
5147wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5148 +1] =
5149{
5150 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5151};
5152
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305153static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305154 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305155 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305156 int data_len)
5157{
5158 struct net_device *dev = wdev->netdev;
5159 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5160 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5161 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5162 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5163 eHalStatus status;
5164 u32 dfsFlag = 0;
5165
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305166 ENTER();
5167
Agarwal Ashish738843c2014-09-25 12:27:56 +05305168 status = wlan_hdd_validate_context(pHddCtx);
5169 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305170 return -EINVAL;
5171 }
5172 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5173 data, data_len,
5174 wlan_hdd_set_no_dfs_flag_config_policy)) {
5175 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5176 return -EINVAL;
5177 }
5178
5179 /* Parse and fetch required bandwidth kbps */
5180 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5181 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5182 return -EINVAL;
5183 }
5184
5185 dfsFlag = nla_get_u32(
5186 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5187 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
5188 dfsFlag);
5189
5190 pHddCtx->disable_dfs_flag = dfsFlag;
5191
5192 sme_disable_dfs_channel(hHal, dfsFlag);
5193 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305194
5195 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05305196 return 0;
5197}
Atul Mittal115287b2014-07-08 13:26:33 +05305198
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305199static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
5200 struct wireless_dev *wdev,
5201 const void *data,
5202 int data_len)
5203{
5204 int ret = 0;
5205
5206 vos_ssr_protect(__func__);
5207 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
5208 vos_ssr_unprotect(__func__);
5209
5210 return ret;
5211
5212}
5213
Mukul Sharma2a271632014-10-13 14:59:01 +05305214const struct
5215nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
5216{
5217 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
5218 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
5219};
5220
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305221static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05305222 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05305223{
5224
5225 u8 bssid[6] = {0};
5226 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5227 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5228 eHalStatus status = eHAL_STATUS_SUCCESS;
5229 v_U32_t isFwrRoamEnabled = FALSE;
5230 int ret;
5231
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305232 ENTER();
5233
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305234 ret = wlan_hdd_validate_context(pHddCtx);
5235 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305236 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05305237 }
5238
5239 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
5240 data, data_len,
5241 qca_wlan_vendor_attr);
5242 if (ret){
5243 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5244 return -EINVAL;
5245 }
5246
5247 /* Parse and fetch Enable flag */
5248 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
5249 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
5250 return -EINVAL;
5251 }
5252
5253 isFwrRoamEnabled = nla_get_u32(
5254 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
5255
5256 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
5257
5258 /* Parse and fetch bssid */
5259 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
5260 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
5261 return -EINVAL;
5262 }
5263
5264 memcpy(bssid, nla_data(
5265 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
5266 sizeof(bssid));
5267 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
5268
5269 //Update roaming
5270 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305271 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05305272 return status;
5273}
5274
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305275static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
5276 struct wireless_dev *wdev, const void *data, int data_len)
5277{
5278 int ret = 0;
5279
5280 vos_ssr_protect(__func__);
5281 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
5282 vos_ssr_unprotect(__func__);
5283
5284 return ret;
5285}
5286
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305287/**
5288 * __wlan_hdd_cfg80211_setband() - set band
5289 * @wiphy: Pointer to wireless phy
5290 * @wdev: Pointer to wireless device
5291 * @data: Pointer to data
5292 * @data_len: Data length
5293 *
5294 * Return: 0 on success, negative errno on failure
5295 */
5296static int
5297__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5298 struct wireless_dev *wdev,
5299 const void *data,
5300 int data_len)
5301{
5302 struct net_device *dev = wdev->netdev;
5303 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5304 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5305 int ret;
5306 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
5307 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
5308
5309 ENTER();
5310
5311 ret = wlan_hdd_validate_context(hdd_ctx);
5312 if (0 != ret) {
5313 hddLog(LOGE, FL("HDD context is not valid"));
5314 return ret;
5315 }
5316
5317 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
5318 policy)) {
5319 hddLog(LOGE, FL("Invalid ATTR"));
5320 return -EINVAL;
5321 }
5322
5323 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
5324 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
5325 return -EINVAL;
5326 }
5327
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05305328 hdd_ctx->isSetBandByNL = TRUE;
5329 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305330 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05305331 hdd_ctx->isSetBandByNL = FALSE;
5332
5333 EXIT();
5334 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305335}
5336
5337/**
5338 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
5339 * @wiphy: wiphy structure pointer
5340 * @wdev: Wireless device structure pointer
5341 * @data: Pointer to the data received
5342 * @data_len: Length of @data
5343 *
5344 * Return: 0 on success; errno on failure
5345 */
5346static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5347 struct wireless_dev *wdev,
5348 const void *data,
5349 int data_len)
5350{
5351 int ret = 0;
5352
5353 vos_ssr_protect(__func__);
5354 ret = __wlan_hdd_cfg80211_setband(wiphy,
5355 wdev, data, data_len);
5356 vos_ssr_unprotect(__func__);
5357
5358 return ret;
5359}
5360
Sunil Duttc69bccb2014-05-26 21:30:20 +05305361const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
5362{
Mukul Sharma2a271632014-10-13 14:59:01 +05305363 {
5364 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5365 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
5366 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5367 WIPHY_VENDOR_CMD_NEED_NETDEV |
5368 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305369 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05305370 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305371
5372 {
5373 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5374 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
5375 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5376 WIPHY_VENDOR_CMD_NEED_NETDEV |
5377 WIPHY_VENDOR_CMD_NEED_RUNNING,
5378 .doit = wlan_hdd_cfg80211_nan_request
5379 },
5380
Sunil Duttc69bccb2014-05-26 21:30:20 +05305381#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5382 {
5383 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5384 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
5385 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5386 WIPHY_VENDOR_CMD_NEED_NETDEV |
5387 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305388 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05305389 },
5390
5391 {
5392 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5393 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
5394 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5395 WIPHY_VENDOR_CMD_NEED_NETDEV |
5396 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305397 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05305398 },
5399
5400 {
5401 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5402 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
5403 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5404 WIPHY_VENDOR_CMD_NEED_NETDEV |
5405 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305406 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05305407 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305408#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305409#ifdef WLAN_FEATURE_EXTSCAN
5410 {
5411 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5412 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
5413 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5414 WIPHY_VENDOR_CMD_NEED_NETDEV |
5415 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305416 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05305417 },
5418 {
5419 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5420 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
5421 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5422 WIPHY_VENDOR_CMD_NEED_NETDEV |
5423 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305424 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05305425 },
5426 {
5427 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5428 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
5429 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5430 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305431 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05305432 },
5433 {
5434 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5435 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
5436 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5437 WIPHY_VENDOR_CMD_NEED_NETDEV |
5438 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305439 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05305440 },
5441 {
5442 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5443 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
5444 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5445 WIPHY_VENDOR_CMD_NEED_NETDEV |
5446 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305447 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05305448 },
5449 {
5450 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5451 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
5452 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5453 WIPHY_VENDOR_CMD_NEED_NETDEV |
5454 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305455 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305456 },
5457 {
5458 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5459 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
5460 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5461 WIPHY_VENDOR_CMD_NEED_NETDEV |
5462 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305463 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305464 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05305465#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305466/*EXT TDLS*/
5467 {
5468 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5469 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
5470 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5471 WIPHY_VENDOR_CMD_NEED_NETDEV |
5472 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305473 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05305474 },
5475 {
5476 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5477 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
5478 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5479 WIPHY_VENDOR_CMD_NEED_NETDEV |
5480 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305481 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05305482 },
5483 {
5484 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5485 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
5486 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5487 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305488 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05305489 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05305490 {
5491 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5492 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
5493 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5494 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305495 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05305496 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05305497 {
5498 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5499 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
5500 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5501 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305502 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05305503 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305504 {
5505 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5506 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
5507 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5508 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305509 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305510 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305511 {
5512 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5513 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
5514 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5515 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305516 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305517 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305518 {
5519 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5520 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
5521 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5522 WIPHY_VENDOR_CMD_NEED_NETDEV |
5523 WIPHY_VENDOR_CMD_NEED_RUNNING,
5524 .doit = wlan_hdd_cfg80211_setband
5525 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05305526};
5527
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005528/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05305529static const
5530struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005531{
5532#ifdef FEATURE_WLAN_CH_AVOID
5533 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05305534 .vendor_id = QCA_NL80211_VENDOR_ID,
5535 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005536 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305537#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
5538#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5539 {
5540 /* Index = 1*/
5541 .vendor_id = QCA_NL80211_VENDOR_ID,
5542 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
5543 },
5544 {
5545 /* Index = 2*/
5546 .vendor_id = QCA_NL80211_VENDOR_ID,
5547 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
5548 },
5549 {
5550 /* Index = 3*/
5551 .vendor_id = QCA_NL80211_VENDOR_ID,
5552 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
5553 },
5554 {
5555 /* Index = 4*/
5556 .vendor_id = QCA_NL80211_VENDOR_ID,
5557 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
5558 },
5559 {
5560 /* Index = 5*/
5561 .vendor_id = QCA_NL80211_VENDOR_ID,
5562 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
5563 },
5564 {
5565 /* Index = 6*/
5566 .vendor_id = QCA_NL80211_VENDOR_ID,
5567 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
5568 },
5569#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305570#ifdef WLAN_FEATURE_EXTSCAN
5571 {
5572 .vendor_id = QCA_NL80211_VENDOR_ID,
5573 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
5574 },
5575 {
5576 .vendor_id = QCA_NL80211_VENDOR_ID,
5577 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
5578 },
5579 {
5580 .vendor_id = QCA_NL80211_VENDOR_ID,
5581 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
5582 },
5583 {
5584 .vendor_id = QCA_NL80211_VENDOR_ID,
5585 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
5586 },
5587 {
5588 .vendor_id = QCA_NL80211_VENDOR_ID,
5589 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
5590 },
5591 {
5592 .vendor_id = QCA_NL80211_VENDOR_ID,
5593 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
5594 },
5595 {
5596 .vendor_id = QCA_NL80211_VENDOR_ID,
5597 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
5598 },
5599 {
5600 .vendor_id = QCA_NL80211_VENDOR_ID,
5601 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
5602 },
5603 {
5604 .vendor_id = QCA_NL80211_VENDOR_ID,
5605 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
5606 },
5607 {
5608 .vendor_id = QCA_NL80211_VENDOR_ID,
5609 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
5610 },
Dino Mycle6fb96c12014-06-10 11:52:40 +05305611#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305612/*EXT TDLS*/
5613 {
5614 .vendor_id = QCA_NL80211_VENDOR_ID,
5615 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
5616 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305617
5618 {
5619 .vendor_id = QCA_NL80211_VENDOR_ID,
5620 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
5621 },
5622
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005623};
5624
Jeff Johnson295189b2012-06-20 16:38:30 -07005625/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305626 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305627 * This function is called by hdd_wlan_startup()
5628 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305629 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07005630 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305631struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07005632{
5633 struct wiphy *wiphy;
5634 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305635 /*
5636 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07005637 */
5638 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
5639
5640 if (!wiphy)
5641 {
5642 /* Print error and jump into err label and free the memory */
5643 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
5644 return NULL;
5645 }
5646
Sunil Duttc69bccb2014-05-26 21:30:20 +05305647
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 return wiphy;
5649}
5650
5651/*
5652 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305653 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 * private ioctl to change the band value
5655 */
5656int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
5657{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305658 int i, j;
5659 eNVChannelEnabledType channelEnabledState;
5660
Jeff Johnsone7245742012-09-05 17:12:55 -07005661 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305662
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305663 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305665
5666 if (NULL == wiphy->bands[i])
5667 {
5668 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5669 __func__, i);
5670 continue;
5671 }
5672
5673 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5674 {
5675 struct ieee80211_supported_band *band = wiphy->bands[i];
5676
5677 channelEnabledState = vos_nv_getChannelEnabledState(
5678 band->channels[j].hw_value);
5679
5680 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
5681 {
Abhishek Singh678227a2014-11-04 10:52:38 +05305682 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305683 continue;
5684 }
5685 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
5686 {
5687 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5688 continue;
5689 }
5690
5691 if (NV_CHANNEL_DISABLE == channelEnabledState ||
5692 NV_CHANNEL_INVALID == channelEnabledState)
5693 {
5694 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5695 }
5696 else if (NV_CHANNEL_DFS == channelEnabledState)
5697 {
5698 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5699 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
5700 }
5701 else
5702 {
5703 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
5704 |IEEE80211_CHAN_RADAR);
5705 }
5706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005707 }
5708 return 0;
5709}
5710/*
5711 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305712 * This function is called by hdd_wlan_startup()
5713 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07005714 * This function is used to initialize and register wiphy structure.
5715 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305716int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005717 struct wiphy *wiphy,
5718 hdd_config_t *pCfg
5719 )
5720{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305721 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305722 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5723
Jeff Johnsone7245742012-09-05 17:12:55 -07005724 ENTER();
5725
Jeff Johnson295189b2012-06-20 16:38:30 -07005726 /* Now bind the underlying wlan device with wiphy */
5727 set_wiphy_dev(wiphy, dev);
5728
5729 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005730
Kiet Lam6c583332013-10-14 05:37:09 +05305731#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07005732 /* the flag for the other case would be initialzed in
5733 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07005734 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05305735#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005736
Amar Singhalfddc28c2013-09-05 13:03:40 -07005737 /* This will disable updating of NL channels from passive to
5738 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305739#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
5740 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
5741#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07005742 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305743#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07005744
Amar Singhala49cbc52013-10-08 18:37:44 -07005745
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005746#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07005747 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
5748 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
5749 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07005750 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305751#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
5752 wiphy->regulatory_flags = REGULATORY_COUNTRY_IE_IGNORE;
5753#else
5754 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
5755#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005756#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005757
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005758#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005759 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08005760#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005761 || pCfg->isFastRoamIniFeatureEnabled
5762#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005763#ifdef FEATURE_WLAN_ESE
5764 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005765#endif
5766 )
5767 {
5768 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
5769 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08005770#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005771#ifdef FEATURE_WLAN_TDLS
5772 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
5773 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
5774#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305775#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05305776 if (pCfg->configPNOScanSupport)
5777 {
5778 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
5779 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
5780 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
5781 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
5782 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305783#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005784
Abhishek Singh10d85972015-04-17 10:27:23 +05305785#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5786 wiphy->features |= NL80211_FEATURE_HT_IBSS;
5787#endif
5788
Amar Singhalfddc28c2013-09-05 13:03:40 -07005789#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005790 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
5791 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07005792 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005793 driver need to determine what to do with both
5794 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07005795
5796 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07005797#else
5798 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005799#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005800
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305801 wiphy->max_scan_ssids = MAX_SCAN_SSID;
5802
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05305803 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07005804
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305805 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
5806
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05305808 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
5809 | BIT(NL80211_IFTYPE_ADHOC)
5810 | BIT(NL80211_IFTYPE_P2P_CLIENT)
5811 | BIT(NL80211_IFTYPE_P2P_GO)
5812 | BIT(NL80211_IFTYPE_AP);
5813
5814 if (VOS_MONITOR_MODE == hdd_get_conparam())
5815 {
5816 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
5817 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005818
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305819 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005820 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305821#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5822 if( pCfg->enableMCC )
5823 {
5824 /* Currently, supports up to two channels */
5825 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005826
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305827 if( !pCfg->allowMCCGODiffBI )
5828 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005829
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305830 }
5831 wiphy->iface_combinations = &wlan_hdd_iface_combination;
5832 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005833#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305834 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005835
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 /* Before registering we need to update the ht capabilitied based
5837 * on ini values*/
5838 if( !pCfg->ShortGI20MhzEnable )
5839 {
5840 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5841 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5842 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5843 }
5844
5845 if( !pCfg->ShortGI40MhzEnable )
5846 {
5847 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
5848 }
5849
5850 if( !pCfg->nChannelBondingMode5GHz )
5851 {
5852 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5853 }
5854
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305855 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305856 if (true == hdd_is_5g_supported(pHddCtx))
5857 {
5858 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
5859 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305860
5861 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
5862 {
5863
5864 if (NULL == wiphy->bands[i])
5865 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05305866 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305867 __func__, i);
5868 continue;
5869 }
5870
5871 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5872 {
5873 struct ieee80211_supported_band *band = wiphy->bands[i];
5874
5875 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
5876 {
5877 // Enable social channels for P2P
5878 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
5879 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5880 else
5881 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5882 continue;
5883 }
5884 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
5885 {
5886 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5887 continue;
5888 }
5889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005890 }
5891 /*Initialise the supported cipher suite details*/
5892 wiphy->cipher_suites = hdd_cipher_suites;
5893 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
5894
5895 /*signal strength in mBm (100*dBm) */
5896 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
5897
5898#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05305899 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07005900#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005901
Sunil Duttc69bccb2014-05-26 21:30:20 +05305902 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
5903 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005904 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
5905 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
5906
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305907 EXIT();
5908 return 0;
5909}
5910
5911/* In this function we are registering wiphy. */
5912int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
5913{
5914 ENTER();
5915 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 if (0 > wiphy_register(wiphy))
5917 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305918 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
5920 return -EIO;
5921 }
5922
5923 EXIT();
5924 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305925}
Jeff Johnson295189b2012-06-20 16:38:30 -07005926
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305927/* In this function we are updating channel list when,
5928 regulatory domain is FCC and country code is US.
5929 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
5930 As per FCC smart phone is not a indoor device.
5931 GO should not opeate on indoor channels */
5932void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
5933{
5934 int j;
5935 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5936 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
5937 //Default counrtycode from NV at the time of wiphy initialization.
5938 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
5939 &defaultCountryCode[0]))
5940 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005941 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305942 }
5943 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
5944 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305945 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
5946 {
5947 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
5948 return;
5949 }
5950 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
5951 {
5952 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
5953 // Mark UNII -1 band channel as passive
5954 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
5955 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
5956 }
5957 }
5958}
5959
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305960/* This function registers for all frame which supplicant is interested in */
5961void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005962{
Jeff Johnson295189b2012-06-20 16:38:30 -07005963 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5964 /* Register for all P2P action, public action etc frames */
5965 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5966
Jeff Johnsone7245742012-09-05 17:12:55 -07005967 ENTER();
5968
Jeff Johnson295189b2012-06-20 16:38:30 -07005969 /* Right now we are registering these frame when driver is getting
5970 initialized. Once we will move to 2.6.37 kernel, in which we have
5971 frame register ops, we will move this code as a part of that */
5972 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305973 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07005974 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5975
5976 /* GAS Initial Response */
5977 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5978 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305979
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 /* GAS Comeback Request */
5981 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5982 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
5983
5984 /* GAS Comeback Response */
5985 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5986 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
5987
5988 /* P2P Public Action */
5989 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305990 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07005991 P2P_PUBLIC_ACTION_FRAME_SIZE );
5992
5993 /* P2P Action */
5994 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5995 (v_U8_t*)P2P_ACTION_FRAME,
5996 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07005997
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05305998 /* WNM BSS Transition Request frame */
5999 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6000 (v_U8_t*)WNM_BSS_ACTION_FRAME,
6001 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006002
6003 /* WNM-Notification */
6004 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6005 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6006 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006007}
6008
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05306009void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07006010{
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6012 /* Register for all P2P action, public action etc frames */
6013 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
6014
Jeff Johnsone7245742012-09-05 17:12:55 -07006015 ENTER();
6016
Jeff Johnson295189b2012-06-20 16:38:30 -07006017 /* Right now we are registering these frame when driver is getting
6018 initialized. Once we will move to 2.6.37 kernel, in which we have
6019 frame register ops, we will move this code as a part of that */
6020 /* GAS Initial Request */
6021
6022 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6023 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6024
6025 /* GAS Initial Response */
6026 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6027 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306028
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 /* GAS Comeback Request */
6030 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6031 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6032
6033 /* GAS Comeback Response */
6034 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6035 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6036
6037 /* P2P Public Action */
6038 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306039 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006040 P2P_PUBLIC_ACTION_FRAME_SIZE );
6041
6042 /* P2P Action */
6043 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6044 (v_U8_t*)P2P_ACTION_FRAME,
6045 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006046 /* WNM-Notification */
6047 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6048 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6049 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006050}
6051
6052#ifdef FEATURE_WLAN_WAPI
6053void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05306054 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006055{
6056 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6057 tCsrRoamSetKey setKey;
6058 v_BOOL_t isConnected = TRUE;
6059 int status = 0;
6060 v_U32_t roamId= 0xFF;
6061 tANI_U8 *pKeyPtr = NULL;
6062 int n = 0;
6063
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306064 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
6065 __func__, hdd_device_modetoString(pAdapter->device_mode),
6066 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006067
Gopichand Nakkalae7480202013-02-11 15:24:22 +05306068 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 setKey.keyId = key_index; // Store Key ID
6070 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
6071 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
6072 setKey.paeRole = 0 ; // the PAE role
6073 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
6074 {
6075 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
6076 }
6077 else
6078 {
6079 isConnected = hdd_connIsConnected(pHddStaCtx);
6080 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
6081 }
6082 setKey.keyLength = key_Len;
6083 pKeyPtr = setKey.Key;
6084 memcpy( pKeyPtr, key, key_Len);
6085
Arif Hussain6d2a3322013-11-17 19:50:10 -08006086 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006087 __func__, key_Len);
6088 for (n = 0 ; n < key_Len; n++)
6089 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
6090 __func__,n,setKey.Key[n]);
6091
6092 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6093 if ( isConnected )
6094 {
6095 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
6096 pAdapter->sessionId, &setKey, &roamId );
6097 }
6098 if ( status != 0 )
6099 {
6100 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6101 "[%4d] sme_RoamSetKey returned ERROR status= %d",
6102 __LINE__, status );
6103 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6104 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05306105 /* Need to clear any trace of key value in the memory.
6106 * Thus zero out the memory even though it is local
6107 * variable.
6108 */
6109 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006110}
6111#endif /* FEATURE_WLAN_WAPI*/
6112
6113#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306114int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 beacon_data_t **ppBeacon,
6116 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006117#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306118int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006119 beacon_data_t **ppBeacon,
6120 struct cfg80211_beacon_data *params,
6121 int dtim_period)
6122#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306123{
Jeff Johnson295189b2012-06-20 16:38:30 -07006124 int size;
6125 beacon_data_t *beacon = NULL;
6126 beacon_data_t *old = NULL;
6127 int head_len,tail_len;
6128
Jeff Johnsone7245742012-09-05 17:12:55 -07006129 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006130 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306131 {
6132 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6133 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306135 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006136
6137 old = pAdapter->sessionCtx.ap.beacon;
6138
6139 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306140 {
6141 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6142 FL("session(%d) old and new heads points to NULL"),
6143 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006144 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306145 }
6146
6147 if (params->tail && !params->tail_len)
6148 {
6149 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6150 FL("tail_len is zero but tail is not NULL"));
6151 return -EINVAL;
6152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006153
Jeff Johnson295189b2012-06-20 16:38:30 -07006154#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
6155 /* Kernel 3.0 is not updating dtim_period for set beacon */
6156 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306157 {
6158 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6159 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006160 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306161 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006162#endif
6163
6164 if(params->head)
6165 head_len = params->head_len;
6166 else
6167 head_len = old->head_len;
6168
6169 if(params->tail || !old)
6170 tail_len = params->tail_len;
6171 else
6172 tail_len = old->tail_len;
6173
6174 size = sizeof(beacon_data_t) + head_len + tail_len;
6175
6176 beacon = kzalloc(size, GFP_KERNEL);
6177
6178 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306179 {
6180 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6181 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006182 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306183 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006184
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006185#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 if(params->dtim_period || !old )
6187 beacon->dtim_period = params->dtim_period;
6188 else
6189 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006190#else
6191 if(dtim_period || !old )
6192 beacon->dtim_period = dtim_period;
6193 else
6194 beacon->dtim_period = old->dtim_period;
6195#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306196
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
6198 beacon->tail = beacon->head + head_len;
6199 beacon->head_len = head_len;
6200 beacon->tail_len = tail_len;
6201
6202 if(params->head) {
6203 memcpy (beacon->head,params->head,beacon->head_len);
6204 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306205 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07006206 if(old)
6207 memcpy (beacon->head,old->head,beacon->head_len);
6208 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306209
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 if(params->tail) {
6211 memcpy (beacon->tail,params->tail,beacon->tail_len);
6212 }
6213 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306214 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07006215 memcpy (beacon->tail,old->tail,beacon->tail_len);
6216 }
6217
6218 *ppBeacon = beacon;
6219
6220 kfree(old);
6221
6222 return 0;
6223
6224}
Jeff Johnson295189b2012-06-20 16:38:30 -07006225
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05306226v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
6227#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
6228 const v_U8_t *pIes,
6229#else
6230 v_U8_t *pIes,
6231#endif
6232 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006233{
6234 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05306235 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306237
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306239 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 elem_id = ptr[0];
6241 elem_len = ptr[1];
6242 left -= 2;
6243 if(elem_len > left)
6244 {
6245 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006246 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006247 eid,elem_len,left);
6248 return NULL;
6249 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306250 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006251 {
6252 return ptr;
6253 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306254
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 left -= elem_len;
6256 ptr += (elem_len + 2);
6257 }
6258 return NULL;
6259}
6260
Jeff Johnson295189b2012-06-20 16:38:30 -07006261/* Check if rate is 11g rate or not */
6262static int wlan_hdd_rate_is_11g(u8 rate)
6263{
Sanjay Devnani28322e22013-06-21 16:13:40 -07006264 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006265 u8 i;
6266 for (i = 0; i < 8; i++)
6267 {
6268 if(rate == gRateArray[i])
6269 return TRUE;
6270 }
6271 return FALSE;
6272}
6273
6274/* Check for 11g rate and set proper 11g only mode */
6275static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
6276 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
6277{
6278 u8 i, num_rates = pIe[0];
6279
6280 pIe += 1;
6281 for ( i = 0; i < num_rates; i++)
6282 {
6283 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
6284 {
6285 /* If rate set have 11g rate than change the mode to 11G */
6286 *pSapHw_mode = eSAP_DOT11_MODE_11g;
6287 if (pIe[i] & BASIC_RATE_MASK)
6288 {
6289 /* If we have 11g rate as basic rate, it means mode
6290 is 11g only mode.
6291 */
6292 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
6293 *pCheckRatesfor11g = FALSE;
6294 }
6295 }
6296 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
6297 {
6298 *require_ht = TRUE;
6299 }
6300 }
6301 return;
6302}
6303
6304static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
6305{
6306 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6307 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6308 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6309 u8 checkRatesfor11g = TRUE;
6310 u8 require_ht = FALSE;
6311 u8 *pIe=NULL;
6312
6313 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
6314
6315 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
6316 pBeacon->head_len, WLAN_EID_SUPP_RATES);
6317 if (pIe != NULL)
6318 {
6319 pIe += 1;
6320 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6321 &pConfig->SapHw_mode);
6322 }
6323
6324 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6325 WLAN_EID_EXT_SUPP_RATES);
6326 if (pIe != NULL)
6327 {
6328
6329 pIe += 1;
6330 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6331 &pConfig->SapHw_mode);
6332 }
6333
6334 if( pConfig->channel > 14 )
6335 {
6336 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
6337 }
6338
6339 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6340 WLAN_EID_HT_CAPABILITY);
6341
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306342 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 {
6344 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
6345 if(require_ht)
6346 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
6347 }
6348}
6349
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306350static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
6351 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
6352{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006353 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306354 v_U8_t *pIe = NULL;
6355 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6356
6357 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
6358 pBeacon->tail, pBeacon->tail_len);
6359
6360 if (pIe)
6361 {
6362 ielen = pIe[1] + 2;
6363 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6364 {
6365 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
6366 }
6367 else
6368 {
6369 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
6370 return -EINVAL;
6371 }
6372 *total_ielen += ielen;
6373 }
6374 return 0;
6375}
6376
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006377static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
6378 v_U8_t *genie, v_U8_t *total_ielen)
6379{
6380 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6381 int left = pBeacon->tail_len;
6382 v_U8_t *ptr = pBeacon->tail;
6383 v_U8_t elem_id, elem_len;
6384 v_U16_t ielen = 0;
6385
6386 if ( NULL == ptr || 0 == left )
6387 return;
6388
6389 while (left >= 2)
6390 {
6391 elem_id = ptr[0];
6392 elem_len = ptr[1];
6393 left -= 2;
6394 if (elem_len > left)
6395 {
6396 hddLog( VOS_TRACE_LEVEL_ERROR,
6397 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
6398 elem_id, elem_len, left);
6399 return;
6400 }
6401 if (IE_EID_VENDOR == elem_id)
6402 {
6403 /* skipping the VSIE's which we don't want to include or
6404 * it will be included by existing code
6405 */
6406 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
6407#ifdef WLAN_FEATURE_WFD
6408 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
6409#endif
6410 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6411 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6412 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
6413 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6414 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
6415 {
6416 ielen = ptr[1] + 2;
6417 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6418 {
6419 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
6420 *total_ielen += ielen;
6421 }
6422 else
6423 {
6424 hddLog( VOS_TRACE_LEVEL_ERROR,
6425 "IE Length is too big "
6426 "IEs eid=%d elem_len=%d total_ie_lent=%d",
6427 elem_id, elem_len, *total_ielen);
6428 }
6429 }
6430 }
6431
6432 left -= elem_len;
6433 ptr += (elem_len + 2);
6434 }
6435 return;
6436}
6437
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006438#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006439static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6440 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006441#else
6442static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6443 struct cfg80211_beacon_data *params)
6444#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006445{
6446 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306447 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006448 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07006449 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006450
6451 genie = vos_mem_malloc(MAX_GENIE_LEN);
6452
6453 if(genie == NULL) {
6454
6455 return -ENOMEM;
6456 }
6457
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306458 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6459 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006460 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306461 hddLog(LOGE,
6462 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306463 ret = -EINVAL;
6464 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006465 }
6466
6467#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306468 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6469 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
6470 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306471 hddLog(LOGE,
6472 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306473 ret = -EINVAL;
6474 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 }
6476#endif
6477
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306478 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6479 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006480 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306481 hddLog(LOGE,
6482 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306483 ret = -EINVAL;
6484 goto done;
6485 }
6486
6487 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
6488 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006489 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006491
6492 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6493 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
6494 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6495 {
6496 hddLog(LOGE,
6497 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006498 ret = -EINVAL;
6499 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006500 }
6501
6502 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6503 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6504 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6505 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6506 ==eHAL_STATUS_FAILURE)
6507 {
6508 hddLog(LOGE,
6509 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006510 ret = -EINVAL;
6511 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006512 }
6513
6514 // Added for ProResp IE
6515 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
6516 {
6517 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
6518 u8 probe_rsp_ie_len[3] = {0};
6519 u8 counter = 0;
6520 /* Check Probe Resp Length if it is greater then 255 then Store
6521 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
6522 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
6523 Store More then 255 bytes into One Variable.
6524 */
6525 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6526 {
6527 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6528 {
6529 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6530 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6531 }
6532 else
6533 {
6534 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6535 rem_probe_resp_ie_len = 0;
6536 }
6537 }
6538
6539 rem_probe_resp_ie_len = 0;
6540
6541 if (probe_rsp_ie_len[0] > 0)
6542 {
6543 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6544 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6545 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6546 probe_rsp_ie_len[0], NULL,
6547 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6548 {
6549 hddLog(LOGE,
6550 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006551 ret = -EINVAL;
6552 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006553 }
6554 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6555 }
6556
6557 if (probe_rsp_ie_len[1] > 0)
6558 {
6559 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6560 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6561 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6562 probe_rsp_ie_len[1], NULL,
6563 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6564 {
6565 hddLog(LOGE,
6566 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006567 ret = -EINVAL;
6568 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006569 }
6570 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6571 }
6572
6573 if (probe_rsp_ie_len[2] > 0)
6574 {
6575 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6576 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6577 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6578 probe_rsp_ie_len[2], NULL,
6579 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6580 {
6581 hddLog(LOGE,
6582 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006583 ret = -EINVAL;
6584 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006585 }
6586 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6587 }
6588
6589 if (probe_rsp_ie_len[1] == 0 )
6590 {
6591 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6592 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
6593 eANI_BOOLEAN_FALSE) )
6594 {
6595 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006596 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006597 }
6598 }
6599
6600 if (probe_rsp_ie_len[2] == 0 )
6601 {
6602 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6603 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
6604 eANI_BOOLEAN_FALSE) )
6605 {
6606 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006607 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 }
6609 }
6610
6611 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6612 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6613 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6614 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6615 == eHAL_STATUS_FAILURE)
6616 {
6617 hddLog(LOGE,
6618 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006619 ret = -EINVAL;
6620 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006621 }
6622 }
6623 else
6624 {
6625 // Reset WNI_CFG_PROBE_RSP Flags
6626 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
6627
6628 hddLog(VOS_TRACE_LEVEL_INFO,
6629 "%s: No Probe Response IE received in set beacon",
6630 __func__);
6631 }
6632
6633 // Added for AssocResp IE
6634 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
6635 {
6636 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6637 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
6638 params->assocresp_ies_len, NULL,
6639 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6640 {
6641 hddLog(LOGE,
6642 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006643 ret = -EINVAL;
6644 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 }
6646
6647 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6648 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
6649 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6650 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6651 == eHAL_STATUS_FAILURE)
6652 {
6653 hddLog(LOGE,
6654 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006655 ret = -EINVAL;
6656 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006657 }
6658 }
6659 else
6660 {
6661 hddLog(VOS_TRACE_LEVEL_INFO,
6662 "%s: No Assoc Response IE received in set beacon",
6663 __func__);
6664
6665 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6666 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6667 eANI_BOOLEAN_FALSE) )
6668 {
6669 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006670 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006671 }
6672 }
6673
Jeff Johnsone7245742012-09-05 17:12:55 -07006674done:
Jeff Johnson295189b2012-06-20 16:38:30 -07006675 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306676 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006677}
Jeff Johnson295189b2012-06-20 16:38:30 -07006678
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306679/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 * FUNCTION: wlan_hdd_validate_operation_channel
6681 * called by wlan_hdd_cfg80211_start_bss() and
6682 * wlan_hdd_cfg80211_set_channel()
6683 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306684 * channel list.
6685 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07006686VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006687{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306688
Jeff Johnson295189b2012-06-20 16:38:30 -07006689 v_U32_t num_ch = 0;
6690 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6691 u32 indx = 0;
6692 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306693 v_U8_t fValidChannel = FALSE, count = 0;
6694 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306695
Jeff Johnson295189b2012-06-20 16:38:30 -07006696 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6697
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306698 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006699 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306700 /* Validate the channel */
6701 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006702 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306703 if ( channel == rfChannels[count].channelNum )
6704 {
6705 fValidChannel = TRUE;
6706 break;
6707 }
6708 }
6709 if (fValidChannel != TRUE)
6710 {
6711 hddLog(VOS_TRACE_LEVEL_ERROR,
6712 "%s: Invalid Channel [%d]", __func__, channel);
6713 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006714 }
6715 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306716 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006717 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306718 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6719 valid_ch, &num_ch))
6720 {
6721 hddLog(VOS_TRACE_LEVEL_ERROR,
6722 "%s: failed to get valid channel list", __func__);
6723 return VOS_STATUS_E_FAILURE;
6724 }
6725 for (indx = 0; indx < num_ch; indx++)
6726 {
6727 if (channel == valid_ch[indx])
6728 {
6729 break;
6730 }
6731 }
6732
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306733 if (indx >= num_ch)
6734 {
6735 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6736 {
6737 eCsrBand band;
6738 unsigned int freq;
6739
6740 sme_GetFreqBand(hHal, &band);
6741
6742 if (eCSR_BAND_5G == band)
6743 {
6744#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
6745 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
6746 {
6747 freq = ieee80211_channel_to_frequency(channel,
6748 IEEE80211_BAND_2GHZ);
6749 }
6750 else
6751 {
6752 freq = ieee80211_channel_to_frequency(channel,
6753 IEEE80211_BAND_5GHZ);
6754 }
6755#else
6756 freq = ieee80211_channel_to_frequency(channel);
6757#endif
6758 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
6759 return VOS_STATUS_SUCCESS;
6760 }
6761 }
6762
6763 hddLog(VOS_TRACE_LEVEL_ERROR,
6764 "%s: Invalid Channel [%d]", __func__, channel);
6765 return VOS_STATUS_E_FAILURE;
6766 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006767 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306768
Jeff Johnson295189b2012-06-20 16:38:30 -07006769 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306770
Jeff Johnson295189b2012-06-20 16:38:30 -07006771}
6772
Viral Modi3a32cc52013-02-08 11:14:52 -08006773/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306774 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08006775 * This function is used to set the channel number
6776 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306777static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08006778 struct ieee80211_channel *chan,
6779 enum nl80211_channel_type channel_type
6780 )
6781{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306782 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08006783 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07006784 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08006785 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306786 hdd_context_t *pHddCtx;
6787 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006788
6789 ENTER();
6790
6791 if( NULL == dev )
6792 {
6793 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006794 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006795 return -ENODEV;
6796 }
6797 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306798
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306799 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6800 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
6801 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08006802 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306803 "%s: device_mode = %s (%d) freq = %d", __func__,
6804 hdd_device_modetoString(pAdapter->device_mode),
6805 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306806
6807 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6808 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306809 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08006810 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306811 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006812 }
6813
6814 /*
6815 * Do freq to chan conversion
6816 * TODO: for 11a
6817 */
6818
6819 channel = ieee80211_frequency_to_channel(freq);
6820
6821 /* Check freq range */
6822 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
6823 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
6824 {
6825 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006826 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08006827 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
6828 WNI_CFG_CURRENT_CHANNEL_STAMAX);
6829 return -EINVAL;
6830 }
6831
6832 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6833
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05306834 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
6835 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08006836 {
6837 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
6838 {
6839 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006840 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08006841 return -EINVAL;
6842 }
6843 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6844 "%s: set channel to [%d] for device mode =%d",
6845 __func__, channel,pAdapter->device_mode);
6846 }
6847 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08006848 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08006849 )
6850 {
6851 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6852 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
6853 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6854
6855 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
6856 {
6857 /* Link is up then return cant set channel*/
6858 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006859 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006860 return -EINVAL;
6861 }
6862
6863 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
6864 pHddStaCtx->conn_info.operationChannel = channel;
6865 pRoamProfile->ChannelInfo.ChannelList =
6866 &pHddStaCtx->conn_info.operationChannel;
6867 }
6868 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08006869 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08006870 )
6871 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306872 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6873 {
6874 if(VOS_STATUS_SUCCESS !=
6875 wlan_hdd_validate_operation_channel(pAdapter,channel))
6876 {
6877 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006878 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306879 return -EINVAL;
6880 }
6881 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6882 }
6883 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08006884 {
6885 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
6886
6887 /* If auto channel selection is configured as enable/ 1 then ignore
6888 channel set by supplicant
6889 */
6890 if ( cfg_param->apAutoChannelSelection )
6891 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306892 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
6893 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08006894 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306895 "%s: set channel to auto channel (0) for device mode =%s (%d)",
6896 __func__, hdd_device_modetoString(pAdapter->device_mode),
6897 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08006898 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306899 else
6900 {
6901 if(VOS_STATUS_SUCCESS !=
6902 wlan_hdd_validate_operation_channel(pAdapter,channel))
6903 {
6904 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006905 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306906 return -EINVAL;
6907 }
6908 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6909 }
Viral Modi3a32cc52013-02-08 11:14:52 -08006910 }
6911 }
6912 else
6913 {
6914 hddLog(VOS_TRACE_LEVEL_FATAL,
6915 "%s: Invalid device mode failed to set valid channel", __func__);
6916 return -EINVAL;
6917 }
6918 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306919 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006920}
6921
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306922static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
6923 struct net_device *dev,
6924 struct ieee80211_channel *chan,
6925 enum nl80211_channel_type channel_type
6926 )
6927{
6928 int ret;
6929
6930 vos_ssr_protect(__func__);
6931 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
6932 vos_ssr_unprotect(__func__);
6933
6934 return ret;
6935}
6936
Jeff Johnson295189b2012-06-20 16:38:30 -07006937#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
6938static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6939 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006940#else
6941static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6942 struct cfg80211_beacon_data *params,
6943 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05306944 enum nl80211_hidden_ssid hidden_ssid,
6945 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006946#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006947{
6948 tsap_Config_t *pConfig;
6949 beacon_data_t *pBeacon = NULL;
6950 struct ieee80211_mgmt *pMgmt_frame;
6951 v_U8_t *pIe=NULL;
6952 v_U16_t capab_info;
6953 eCsrAuthType RSNAuthType;
6954 eCsrEncryptionType RSNEncryptType;
6955 eCsrEncryptionType mcRSNEncryptType;
6956 int status = VOS_STATUS_SUCCESS;
6957 tpWLAN_SAPEventCB pSapEventCallback;
6958 hdd_hostapd_state_t *pHostapdState;
6959 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
6960 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306961 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006962 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306963 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006964 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08006965 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05306966 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07006967 v_BOOL_t MFPCapable = VOS_FALSE;
6968 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05306969 v_BOOL_t sapEnable11AC =
6970 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07006971 ENTER();
6972
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306973 iniConfig = pHddCtx->cfg_ini;
6974
Jeff Johnson295189b2012-06-20 16:38:30 -07006975 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
6976
6977 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6978
6979 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6980
6981 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6982
6983 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
6984
6985 //channel is already set in the set_channel Call back
6986 //pConfig->channel = pCommitConfig->channel;
6987
6988 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306989 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07006990 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
6991
6992 pConfig->dtim_period = pBeacon->dtim_period;
6993
Arif Hussain6d2a3322013-11-17 19:50:10 -08006994 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07006995 pConfig->dtim_period);
6996
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08006997 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07006998 {
6999 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007000 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05307001 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
7002 {
7003 tANI_BOOLEAN restartNeeded;
7004 pConfig->ieee80211d = 1;
7005 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
7006 sme_setRegInfo(hHal, pConfig->countryCode);
7007 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
7008 }
7009 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07007010 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07007011 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007012 pConfig->ieee80211d = 1;
7013 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
7014 sme_setRegInfo(hHal, pConfig->countryCode);
7015 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007017 else
7018 {
7019 pConfig->ieee80211d = 0;
7020 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307021 /*
7022 * If auto channel is configured i.e. channel is 0,
7023 * so skip channel validation.
7024 */
7025 if( AUTO_CHANNEL_SELECT != pConfig->channel )
7026 {
7027 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
7028 {
7029 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007030 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307031 return -EINVAL;
7032 }
7033 }
7034 else
7035 {
7036 if(1 != pHddCtx->is_dynamic_channel_range_set)
7037 {
7038 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
7039 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
7040 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
7041 }
7042 pHddCtx->is_dynamic_channel_range_set = 0;
7043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007044 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007045 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007046 {
7047 pConfig->ieee80211d = 0;
7048 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307049
7050#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7051 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7052 pConfig->authType = eSAP_OPEN_SYSTEM;
7053 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7054 pConfig->authType = eSAP_SHARED_KEY;
7055 else
7056 pConfig->authType = eSAP_AUTO_SWITCH;
7057#else
7058 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7059 pConfig->authType = eSAP_OPEN_SYSTEM;
7060 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7061 pConfig->authType = eSAP_SHARED_KEY;
7062 else
7063 pConfig->authType = eSAP_AUTO_SWITCH;
7064#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007065
7066 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307067
7068 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07007069 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
7070
7071 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
7072
7073 /*Set wps station to configured*/
7074 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
7075
7076 if(pIe)
7077 {
7078 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
7079 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007080 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07007081 return -EINVAL;
7082 }
7083 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
7084 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007085 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07007086 /* Check 15 bit of WPS IE as it contain information for wps state
7087 * WPS state
7088 */
7089 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
7090 {
7091 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
7092 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
7093 {
7094 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
7095 }
7096 }
7097 }
7098 else
7099 {
7100 pConfig->wps_state = SAP_WPS_DISABLED;
7101 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307102 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07007103
c_hpothufe599e92014-06-16 11:38:55 +05307104 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7105 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7106 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
7107 eCSR_ENCRYPT_TYPE_NONE;
7108
Jeff Johnson295189b2012-06-20 16:38:30 -07007109 pConfig->RSNWPAReqIELength = 0;
7110 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307111 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007112 WLAN_EID_RSN);
7113 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307114 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007115 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7116 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7117 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307118 /* The actual processing may eventually be more extensive than
7119 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07007120 * by the app.
7121 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307122 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007123 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7124 &RSNEncryptType,
7125 &mcRSNEncryptType,
7126 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007127 &MFPCapable,
7128 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007129 pConfig->pRSNWPAReqIE[1]+2,
7130 pConfig->pRSNWPAReqIE );
7131
7132 if( VOS_STATUS_SUCCESS == status )
7133 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307134 /* Now copy over all the security attributes you have
7135 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007136 * */
7137 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7138 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7139 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7140 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307141 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007142 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007143 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7144 }
7145 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307146
Jeff Johnson295189b2012-06-20 16:38:30 -07007147 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7148 pBeacon->tail, pBeacon->tail_len);
7149
7150 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
7151 {
7152 if (pConfig->pRSNWPAReqIE)
7153 {
7154 /*Mixed mode WPA/WPA2*/
7155 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
7156 pConfig->RSNWPAReqIELength += pIe[1] + 2;
7157 }
7158 else
7159 {
7160 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7161 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7162 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307163 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007164 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7165 &RSNEncryptType,
7166 &mcRSNEncryptType,
7167 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007168 &MFPCapable,
7169 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007170 pConfig->pRSNWPAReqIE[1]+2,
7171 pConfig->pRSNWPAReqIE );
7172
7173 if( VOS_STATUS_SUCCESS == status )
7174 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307175 /* Now copy over all the security attributes you have
7176 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007177 * */
7178 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7179 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7180 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7181 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307182 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007183 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007184 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7185 }
7186 }
7187 }
7188
Jeff Johnson4416a782013-03-25 14:17:50 -07007189 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
7190 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
7191 return -EINVAL;
7192 }
7193
Jeff Johnson295189b2012-06-20 16:38:30 -07007194 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
7195
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007196#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007197 if (params->ssid != NULL)
7198 {
7199 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
7200 pConfig->SSIDinfo.ssid.length = params->ssid_len;
7201 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7202 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7203 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007204#else
7205 if (ssid != NULL)
7206 {
7207 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
7208 pConfig->SSIDinfo.ssid.length = ssid_len;
7209 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7210 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7211 }
7212#endif
7213
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307214 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07007215 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307216
Jeff Johnson295189b2012-06-20 16:38:30 -07007217 /* default value */
7218 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
7219 pConfig->num_accept_mac = 0;
7220 pConfig->num_deny_mac = 0;
7221
7222 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7223 pBeacon->tail, pBeacon->tail_len);
7224
7225 /* pIe for black list is following form:
7226 type : 1 byte
7227 length : 1 byte
7228 OUI : 4 bytes
7229 acl type : 1 byte
7230 no of mac addr in black list: 1 byte
7231 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307232 */
7233 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007234 {
7235 pConfig->SapMacaddr_acl = pIe[6];
7236 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007237 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007238 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307239 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
7240 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007241 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7242 for (i = 0; i < pConfig->num_deny_mac; i++)
7243 {
7244 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7245 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307246 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007247 }
7248 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7249 pBeacon->tail, pBeacon->tail_len);
7250
7251 /* pIe for white list is following form:
7252 type : 1 byte
7253 length : 1 byte
7254 OUI : 4 bytes
7255 acl type : 1 byte
7256 no of mac addr in white list: 1 byte
7257 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307258 */
7259 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007260 {
7261 pConfig->SapMacaddr_acl = pIe[6];
7262 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007263 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007264 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307265 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
7266 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007267 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7268 for (i = 0; i < pConfig->num_accept_mac; i++)
7269 {
7270 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7271 acl_entry++;
7272 }
7273 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307274
Jeff Johnson295189b2012-06-20 16:38:30 -07007275 wlan_hdd_set_sapHwmode(pHostapdAdapter);
7276
Jeff Johnsone7245742012-09-05 17:12:55 -07007277#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007278 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307279 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
7280 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05307281 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
7282 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007283 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
7284 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307285 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
7286 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07007287 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307288 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007289 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307290 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007291
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307292 /* If ACS disable and selected channel <= 14
7293 * OR
7294 * ACS enabled and ACS operating band is choosen as 2.4
7295 * AND
7296 * VHT in 2.4G Disabled
7297 * THEN
7298 * Fallback to 11N mode
7299 */
7300 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
7301 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05307302 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307303 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007304 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307305 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
7306 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007307 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
7308 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007309 }
7310#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307311
Jeff Johnson295189b2012-06-20 16:38:30 -07007312 // ht_capab is not what the name conveys,this is used for protection bitmap
7313 pConfig->ht_capab =
7314 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
7315
7316 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
7317 {
7318 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
7319 return -EINVAL;
7320 }
7321
7322 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307323 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07007324 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
7325 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307326 pConfig->obssProtEnabled =
7327 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07007328
Chet Lanctot8cecea22014-02-11 19:09:36 -08007329#ifdef WLAN_FEATURE_11W
7330 pConfig->mfpCapable = MFPCapable;
7331 pConfig->mfpRequired = MFPRequired;
7332 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
7333 pConfig->mfpCapable, pConfig->mfpRequired);
7334#endif
7335
Arif Hussain6d2a3322013-11-17 19:50:10 -08007336 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07007337 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007338 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
7339 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
7340 (int)pConfig->channel);
7341 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
7342 pConfig->SapHw_mode, pConfig->privacy,
7343 pConfig->authType);
7344 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
7345 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
7346 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
7347 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07007348
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307349 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007350 {
7351 //Bss already started. just return.
7352 //TODO Probably it should update some beacon params.
7353 hddLog( LOGE, "Bss Already started...Ignore the request");
7354 EXIT();
7355 return 0;
7356 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307357
Agarwal Ashish51325b52014-06-16 16:50:49 +05307358 if (vos_max_concurrent_connections_reached()) {
7359 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7360 return -EINVAL;
7361 }
7362
Jeff Johnson295189b2012-06-20 16:38:30 -07007363 pConfig->persona = pHostapdAdapter->device_mode;
7364
Peng Xu2446a892014-09-05 17:21:18 +05307365 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
7366 if ( NULL != psmeConfig)
7367 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307368 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05307369 sme_GetConfigParam(hHal, psmeConfig);
7370 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307371#ifdef WLAN_FEATURE_AP_HT40_24G
7372 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
7373 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
7374 && pHddCtx->cfg_ini->apHT40_24GEnabled)
7375 {
7376 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
7377 sme_UpdateConfig (hHal, psmeConfig);
7378 }
7379#endif
Peng Xu2446a892014-09-05 17:21:18 +05307380 vos_mem_free(psmeConfig);
7381 }
Peng Xuafc34e32014-09-25 13:23:55 +05307382 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05307383
Jeff Johnson295189b2012-06-20 16:38:30 -07007384 pSapEventCallback = hdd_hostapd_SAPEventCB;
7385 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
7386 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
7387 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007388 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007389 return -EINVAL;
7390 }
7391
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307392 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07007393 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
7394
7395 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307396
Jeff Johnson295189b2012-06-20 16:38:30 -07007397 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307398 {
7399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007400 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07007401 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007402 VOS_ASSERT(0);
7403 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307404
Jeff Johnson295189b2012-06-20 16:38:30 -07007405 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05307406 /* Initialize WMM configuation */
7407 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307408 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007409
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007410#ifdef WLAN_FEATURE_P2P_DEBUG
7411 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
7412 {
7413 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
7414 {
7415 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7416 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007417 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007418 }
7419 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
7420 {
7421 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7422 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007423 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007424 }
7425 }
7426#endif
7427
Jeff Johnson295189b2012-06-20 16:38:30 -07007428 pHostapdState->bCommit = TRUE;
7429 EXIT();
7430
7431 return 0;
7432}
7433
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007434#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307435static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307436 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007437 struct beacon_parameters *params)
7438{
7439 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307440 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307441 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007442
7443 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307444
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307445 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7446 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
7447 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307448 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
7449 hdd_device_modetoString(pAdapter->device_mode),
7450 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007451
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307452 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7453 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307454 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007455 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307456 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007457 }
7458
Agarwal Ashish51325b52014-06-16 16:50:49 +05307459 if (vos_max_concurrent_connections_reached()) {
7460 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7461 return -EINVAL;
7462 }
7463
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307464 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007465 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007466 )
7467 {
7468 beacon_data_t *old,*new;
7469
7470 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307471
Jeff Johnson295189b2012-06-20 16:38:30 -07007472 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307473 {
7474 hddLog(VOS_TRACE_LEVEL_WARN,
7475 FL("already beacon info added to session(%d)"),
7476 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007477 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007479
7480 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7481
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307482 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07007483 {
7484 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007485 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 return -EINVAL;
7487 }
7488
7489 pAdapter->sessionCtx.ap.beacon = new;
7490
7491 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7492 }
7493
7494 EXIT();
7495 return status;
7496}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307497
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307498static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
7499 struct net_device *dev,
7500 struct beacon_parameters *params)
7501{
7502 int ret;
7503
7504 vos_ssr_protect(__func__);
7505 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
7506 vos_ssr_unprotect(__func__);
7507
7508 return ret;
7509}
7510
7511static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007512 struct net_device *dev,
7513 struct beacon_parameters *params)
7514{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307515 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307516 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7517 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307518 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007519
7520 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307521
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307522 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7523 TRACE_CODE_HDD_CFG80211_SET_BEACON,
7524 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
7525 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7526 __func__, hdd_device_modetoString(pAdapter->device_mode),
7527 pAdapter->device_mode);
7528
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307529 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7530 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307531 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007532 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307533 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007534 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307535
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307536 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007537 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307538 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007539 {
7540 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307541
Jeff Johnson295189b2012-06-20 16:38:30 -07007542 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307543
Jeff Johnson295189b2012-06-20 16:38:30 -07007544 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307545 {
7546 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7547 FL("session(%d) old and new heads points to NULL"),
7548 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007549 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007551
7552 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7553
7554 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307555 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007556 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007557 return -EINVAL;
7558 }
7559
7560 pAdapter->sessionCtx.ap.beacon = new;
7561
7562 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7563 }
7564
7565 EXIT();
7566 return status;
7567}
7568
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307569static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
7570 struct net_device *dev,
7571 struct beacon_parameters *params)
7572{
7573 int ret;
7574
7575 vos_ssr_protect(__func__);
7576 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
7577 vos_ssr_unprotect(__func__);
7578
7579 return ret;
7580}
7581
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007582#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7583
7584#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307585static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007586 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007587#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307588static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007589 struct net_device *dev)
7590#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007591{
7592 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07007593 hdd_context_t *pHddCtx = NULL;
7594 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307595 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307596 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007597
7598 ENTER();
7599
7600 if (NULL == pAdapter)
7601 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307602 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007603 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007604 return -ENODEV;
7605 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007606
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307607 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7608 TRACE_CODE_HDD_CFG80211_STOP_AP,
7609 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307610 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7611 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307612 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007613 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307614 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07007615 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007616
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007617 pScanInfo = &pHddCtx->scan_info;
7618
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307619 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7620 __func__, hdd_device_modetoString(pAdapter->device_mode),
7621 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007622
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307623 ret = wlan_hdd_scan_abort(pAdapter);
7624
Girish Gowli4bf7a632014-06-12 13:42:11 +05307625 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07007626 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307627 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7628 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307629
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307630 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07007631 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7633 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08007634
Jeff Johnsone7245742012-09-05 17:12:55 -07007635 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307636 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07007637 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307638 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07007639 }
7640
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05307641 /* Delete all associated STAs before stopping AP/P2P GO */
7642 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05307643 hdd_hostapd_stop(dev);
7644
Jeff Johnson295189b2012-06-20 16:38:30 -07007645 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007646 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 )
7648 {
7649 beacon_data_t *old;
7650
7651 old = pAdapter->sessionCtx.ap.beacon;
7652
7653 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307654 {
7655 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7656 FL("session(%d) beacon data points to NULL"),
7657 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007658 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307659 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007660
Jeff Johnson295189b2012-06-20 16:38:30 -07007661 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007662
7663 mutex_lock(&pHddCtx->sap_lock);
7664 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7665 {
Jeff Johnson4416a782013-03-25 14:17:50 -07007666 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007667 {
7668 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7669
7670 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
7671
7672 if (!VOS_IS_STATUS_SUCCESS(status))
7673 {
7674 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007675 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007676 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307677 }
7678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007679 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307680 /* BSS stopped, clear the active sessions for this device mode */
7681 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007682 }
7683 mutex_unlock(&pHddCtx->sap_lock);
7684
7685 if(status != VOS_STATUS_SUCCESS)
7686 {
7687 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007688 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007689 return -EINVAL;
7690 }
7691
Jeff Johnson4416a782013-03-25 14:17:50 -07007692 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007693 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
7694 ==eHAL_STATUS_FAILURE)
7695 {
7696 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007697 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007698 }
7699
Jeff Johnson4416a782013-03-25 14:17:50 -07007700 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007701 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7702 eANI_BOOLEAN_FALSE) )
7703 {
7704 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007705 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007706 }
7707
7708 // Reset WNI_CFG_PROBE_RSP Flags
7709 wlan_hdd_reset_prob_rspies(pAdapter);
7710
7711 pAdapter->sessionCtx.ap.beacon = NULL;
7712 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007713#ifdef WLAN_FEATURE_P2P_DEBUG
7714 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
7715 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
7716 {
7717 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
7718 "GO got removed");
7719 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
7720 }
7721#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007722 }
7723 EXIT();
7724 return status;
7725}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007726
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307727#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7728static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
7729 struct net_device *dev)
7730{
7731 int ret;
7732
7733 vos_ssr_protect(__func__);
7734 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
7735 vos_ssr_unprotect(__func__);
7736
7737 return ret;
7738}
7739#else
7740static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
7741 struct net_device *dev)
7742{
7743 int ret;
7744
7745 vos_ssr_protect(__func__);
7746 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
7747 vos_ssr_unprotect(__func__);
7748
7749 return ret;
7750}
7751#endif
7752
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007753#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
7754
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307755static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307756 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007757 struct cfg80211_ap_settings *params)
7758{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307759 hdd_adapter_t *pAdapter;
7760 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307761 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007762
7763 ENTER();
7764
Girish Gowlib143d7a2015-02-18 19:39:55 +05307765 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007766 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307767 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05307768 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307769 return -ENODEV;
7770 }
7771
7772 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7773 if (NULL == pAdapter)
7774 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307775 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307776 "%s: HDD adapter is Null", __func__);
7777 return -ENODEV;
7778 }
7779
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307780 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7781 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
7782 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307783 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
7784 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307785 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307786 "%s: HDD adapter magic is invalid", __func__);
7787 return -ENODEV;
7788 }
7789
7790 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307791 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307792 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307793 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307794 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307795 }
7796
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307797 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
7798 __func__, hdd_device_modetoString(pAdapter->device_mode),
7799 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307800
7801 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007802 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007803 )
7804 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307805 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007806
7807 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307808
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007809 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307810 {
7811 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7812 FL("already beacon info added to session(%d)"),
7813 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007814 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307815 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007816
Girish Gowlib143d7a2015-02-18 19:39:55 +05307817#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7818 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7819 &new,
7820 &params->beacon);
7821#else
7822 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7823 &new,
7824 &params->beacon,
7825 params->dtim_period);
7826#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007827
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307828 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007829 {
7830 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307831 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007832 return -EINVAL;
7833 }
7834 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08007835#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07007836 wlan_hdd_cfg80211_set_channel(wiphy, dev,
7837#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
7838 params->channel, params->channel_type);
7839#else
7840 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
7841#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08007842#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007843 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307844 params->ssid_len, params->hidden_ssid,
7845 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007846 }
7847
7848 EXIT();
7849 return status;
7850}
7851
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307852static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
7853 struct net_device *dev,
7854 struct cfg80211_ap_settings *params)
7855{
7856 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007857
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307858 vos_ssr_protect(__func__);
7859 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
7860 vos_ssr_unprotect(__func__);
7861
7862 return ret;
7863}
7864
7865static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007866 struct net_device *dev,
7867 struct cfg80211_beacon_data *params)
7868{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307869 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307870 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307871 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007872
7873 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307874
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307875 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7876 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
7877 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007878 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007879 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307880
7881 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7882 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307883 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007884 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307885 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007886 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007887
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307888 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007889 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307890 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007891 {
7892 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307893
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007894 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307895
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007896 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307897 {
7898 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7899 FL("session(%d) beacon data points to NULL"),
7900 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007901 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307902 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007903
7904 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
7905
7906 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307907 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007908 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007909 return -EINVAL;
7910 }
7911
7912 pAdapter->sessionCtx.ap.beacon = new;
7913
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307914 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
7915 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007916 }
7917
7918 EXIT();
7919 return status;
7920}
7921
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307922static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
7923 struct net_device *dev,
7924 struct cfg80211_beacon_data *params)
7925{
7926 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007927
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307928 vos_ssr_protect(__func__);
7929 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
7930 vos_ssr_unprotect(__func__);
7931
7932 return ret;
7933}
7934
7935#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007936
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307937static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007938 struct net_device *dev,
7939 struct bss_parameters *params)
7940{
7941 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307942 hdd_context_t *pHddCtx;
7943 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007944
7945 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307946
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307947 if (NULL == pAdapter)
7948 {
7949 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7950 "%s: HDD adapter is Null", __func__);
7951 return -ENODEV;
7952 }
7953 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307954 ret = wlan_hdd_validate_context(pHddCtx);
7955 if (0 != ret)
7956 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307957 return ret;
7958 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307959 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7960 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
7961 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307962 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7963 __func__, hdd_device_modetoString(pAdapter->device_mode),
7964 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007965
7966 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007967 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307968 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007969 {
7970 /* ap_isolate == -1 means that in change bss, upper layer doesn't
7971 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307972 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07007973 {
7974 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307975 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007976 }
7977
7978 EXIT();
7979 return 0;
7980}
7981
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307982static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
7983 struct net_device *dev,
7984 struct bss_parameters *params)
7985{
7986 int ret;
7987
7988 vos_ssr_protect(__func__);
7989 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
7990 vos_ssr_unprotect(__func__);
7991
7992 return ret;
7993}
Kiet Lam10841362013-11-01 11:36:50 +05307994/* FUNCTION: wlan_hdd_change_country_code_cd
7995* to wait for contry code completion
7996*/
7997void* wlan_hdd_change_country_code_cb(void *pAdapter)
7998{
7999 hdd_adapter_t *call_back_pAdapter = pAdapter;
8000 complete(&call_back_pAdapter->change_country_code);
8001 return NULL;
8002}
8003
Jeff Johnson295189b2012-06-20 16:38:30 -07008004/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308005 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07008006 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
8007 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308008int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008009 struct net_device *ndev,
8010 enum nl80211_iftype type,
8011 u32 *flags,
8012 struct vif_params *params
8013 )
8014{
8015 struct wireless_dev *wdev;
8016 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008017 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07008018 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008019 tCsrRoamProfile *pRoamProfile = NULL;
8020 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308021 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008022 eMib_dot11DesiredBssType connectedBssType;
8023 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308024 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008025
8026 ENTER();
8027
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308028 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008029 {
8030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8031 "%s: Adapter context is null", __func__);
8032 return VOS_STATUS_E_FAILURE;
8033 }
8034
8035 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8036 if (!pHddCtx)
8037 {
8038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8039 "%s: HDD context is null", __func__);
8040 return VOS_STATUS_E_FAILURE;
8041 }
8042
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308043 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8044 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
8045 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308046 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308047 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07008048 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308049 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008050 }
8051
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308052 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8053 __func__, hdd_device_modetoString(pAdapter->device_mode),
8054 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008055
Agarwal Ashish51325b52014-06-16 16:50:49 +05308056 if (vos_max_concurrent_connections_reached()) {
8057 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
8058 return -EINVAL;
8059 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308060 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07008061 wdev = ndev->ieee80211_ptr;
8062
8063#ifdef WLAN_BTAMP_FEATURE
8064 if((NL80211_IFTYPE_P2P_CLIENT == type)||
8065 (NL80211_IFTYPE_ADHOC == type)||
8066 (NL80211_IFTYPE_AP == type)||
8067 (NL80211_IFTYPE_P2P_GO == type))
8068 {
8069 pHddCtx->isAmpAllowed = VOS_FALSE;
8070 // stop AMP traffic
8071 status = WLANBAP_StopAmp();
8072 if(VOS_STATUS_SUCCESS != status )
8073 {
8074 pHddCtx->isAmpAllowed = VOS_TRUE;
8075 hddLog(VOS_TRACE_LEVEL_FATAL,
8076 "%s: Failed to stop AMP", __func__);
8077 return -EINVAL;
8078 }
8079 }
8080#endif //WLAN_BTAMP_FEATURE
8081 /* Reset the current device mode bit mask*/
8082 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
8083
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05308084 if ((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
8085 ((type == NL80211_IFTYPE_P2P_CLIENT) ||
8086 (type == NL80211_IFTYPE_P2P_GO)))
8087 {
8088 /* Notify Mode change in case of concurrency.
8089 * Below function invokes TDLS teardown Functionality Since TDLS is
8090 * not Supported in case of concurrency i.e Once P2P session
8091 * is detected disable offchannel and teardown TDLS links
8092 */
8093 hddLog(LOG1,
8094 FL("Device mode = %d Interface type = %d"),
8095 pAdapter->device_mode, type);
8096 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
8097 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05308098
Jeff Johnson295189b2012-06-20 16:38:30 -07008099 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008100 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07008101 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07008102 )
8103 {
8104 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008105 if (!pWextState)
8106 {
8107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8108 "%s: pWextState is null", __func__);
8109 return VOS_STATUS_E_FAILURE;
8110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008111 pRoamProfile = &pWextState->roamProfile;
8112 LastBSSType = pRoamProfile->BSSType;
8113
8114 switch (type)
8115 {
8116 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008117 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008118 hddLog(VOS_TRACE_LEVEL_INFO,
8119 "%s: setting interface Type to INFRASTRUCTURE", __func__);
8120 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07008121#ifdef WLAN_FEATURE_11AC
8122 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
8123 {
8124 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
8125 }
8126#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308127 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07008128 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008129 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008130 //Check for sub-string p2p to confirm its a p2p interface
8131 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308132 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +05308133#ifdef FEATURE_WLAN_TDLS
8134 mutex_lock(&pHddCtx->tdls_lock);
8135 wlan_hdd_tdls_exit(pAdapter, TRUE);
8136 mutex_unlock(&pHddCtx->tdls_lock);
8137#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008138 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8139 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8140 }
8141 else
8142 {
8143 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008144 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008146 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05308147
Jeff Johnson295189b2012-06-20 16:38:30 -07008148 case NL80211_IFTYPE_ADHOC:
8149 hddLog(VOS_TRACE_LEVEL_INFO,
8150 "%s: setting interface Type to ADHOC", __func__);
8151 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
8152 pRoamProfile->phyMode =
8153 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07008154 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008155 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +05308156 hdd_set_ibss_ops( pAdapter );
8157 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +05308158
8159 status = hdd_sta_id_hash_attach(pAdapter);
8160 if (VOS_STATUS_SUCCESS != status) {
8161 hddLog(VOS_TRACE_LEVEL_ERROR,
8162 FL("Failed to initialize hash for IBSS"));
8163 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008164 break;
8165
8166 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008167 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008168 {
8169 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8170 "%s: setting interface Type to %s", __func__,
8171 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
8172
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008173 //Cancel any remain on channel for GO mode
8174 if (NL80211_IFTYPE_P2P_GO == type)
8175 {
8176 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
8177 }
Mohit Khanna0f232092012-09-11 14:46:08 -07008178 if (NL80211_IFTYPE_AP == type)
8179 {
8180 /* As Loading WLAN Driver one interface being created for p2p device
8181 * address. This will take one HW STA and the max number of clients
8182 * that can connect to softAP will be reduced by one. so while changing
8183 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
8184 * interface as it is not required in SoftAP mode.
8185 */
8186
8187 // Get P2P Adapter
8188 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
8189
8190 if (pP2pAdapter)
8191 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05308192 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +05308193 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07008194 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
8195 }
8196 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05308197 //Disable IMPS & BMPS for SAP/GO
8198 if(VOS_STATUS_E_FAILURE ==
8199 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
8200 {
8201 //Fail to Exit BMPS
8202 VOS_ASSERT(0);
8203 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05308204
8205 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
8206
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308207#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07008208
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308209 /* A Mutex Lock is introduced while changing the mode to
8210 * protect the concurrent access for the Adapters by TDLS
8211 * module.
8212 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308213 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308214#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008215 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +05308216 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008217 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07008218 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8219 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308220#ifdef FEATURE_WLAN_TDLS
8221 mutex_unlock(&pHddCtx->tdls_lock);
8222#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008223 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
8224 (pConfig->apRandomBssidEnabled))
8225 {
8226 /* To meet Android requirements create a randomized
8227 MAC address of the form 02:1A:11:Fx:xx:xx */
8228 get_random_bytes(&ndev->dev_addr[3], 3);
8229 ndev->dev_addr[0] = 0x02;
8230 ndev->dev_addr[1] = 0x1A;
8231 ndev->dev_addr[2] = 0x11;
8232 ndev->dev_addr[3] |= 0xF0;
8233 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
8234 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08008235 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
8236 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008237 }
8238
Jeff Johnson295189b2012-06-20 16:38:30 -07008239 hdd_set_ap_ops( pAdapter->dev );
8240
Kiet Lam10841362013-11-01 11:36:50 +05308241 /* This is for only SAP mode where users can
8242 * control country through ini.
8243 * P2P GO follows station country code
8244 * acquired during the STA scanning. */
8245 if((NL80211_IFTYPE_AP == type) &&
8246 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
8247 {
8248 int status = 0;
8249 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
8250 "%s: setting country code from INI ", __func__);
8251 init_completion(&pAdapter->change_country_code);
8252 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
8253 (void *)(tSmeChangeCountryCallback)
8254 wlan_hdd_change_country_code_cb,
8255 pConfig->apCntryCode, pAdapter,
8256 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05308257 eSIR_FALSE,
8258 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05308259 if (eHAL_STATUS_SUCCESS == status)
8260 {
8261 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308262 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05308263 &pAdapter->change_country_code,
8264 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308265 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05308266 {
8267 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308268 FL("SME Timed out while setting country code %ld"),
8269 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08008270
8271 if (pHddCtx->isLogpInProgress)
8272 {
8273 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8274 "%s: LOGP in Progress. Ignore!!!", __func__);
8275 return -EAGAIN;
8276 }
Kiet Lam10841362013-11-01 11:36:50 +05308277 }
8278 }
8279 else
8280 {
8281 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008282 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05308283 return -EINVAL;
8284 }
8285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008286 status = hdd_init_ap_mode(pAdapter);
8287 if(status != VOS_STATUS_SUCCESS)
8288 {
8289 hddLog(VOS_TRACE_LEVEL_FATAL,
8290 "%s: Error initializing the ap mode", __func__);
8291 return -EINVAL;
8292 }
8293 hdd_set_conparam(1);
8294
Nirav Shah7e3c8132015-06-22 23:51:42 +05308295 status = hdd_sta_id_hash_attach(pAdapter);
8296 if (VOS_STATUS_SUCCESS != status)
8297 {
8298 hddLog(VOS_TRACE_LEVEL_ERROR,
8299 FL("Failed to initialize hash for AP"));
8300 return -EINVAL;
8301 }
8302
Jeff Johnson295189b2012-06-20 16:38:30 -07008303 /*interface type changed update in wiphy structure*/
8304 if(wdev)
8305 {
8306 wdev->iftype = type;
8307 pHddCtx->change_iface = type;
8308 }
8309 else
8310 {
8311 hddLog(VOS_TRACE_LEVEL_ERROR,
8312 "%s: ERROR !!!! Wireless dev is NULL", __func__);
8313 return -EINVAL;
8314 }
8315 goto done;
8316 }
8317
8318 default:
8319 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8320 __func__);
8321 return -EOPNOTSUPP;
8322 }
8323 }
8324 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008325 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07008326 )
8327 {
8328 switch(type)
8329 {
8330 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008331 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008332 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05308333
8334 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308335#ifdef FEATURE_WLAN_TDLS
8336
8337 /* A Mutex Lock is introduced while changing the mode to
8338 * protect the concurrent access for the Adapters by TDLS
8339 * module.
8340 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308341 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308342#endif
c_hpothu002231a2015-02-05 14:58:51 +05308343 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008344 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008345 //Check for sub-string p2p to confirm its a p2p interface
8346 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008347 {
8348 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8349 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8350 }
8351 else
8352 {
8353 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008354 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008356 hdd_set_conparam(0);
8357 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008358 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
8359 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308360#ifdef FEATURE_WLAN_TDLS
8361 mutex_unlock(&pHddCtx->tdls_lock);
8362#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05308363 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008364 if( VOS_STATUS_SUCCESS != status )
8365 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07008366 /* In case of JB, for P2P-GO, only change interface will be called,
8367 * This is the right place to enable back bmps_imps()
8368 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308369 if (pHddCtx->hdd_wlan_suspended)
8370 {
8371 hdd_set_pwrparams(pHddCtx);
8372 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008373 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008374 goto done;
8375 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008376 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008377 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008378 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8379 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008380 goto done;
8381 default:
8382 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8383 __func__);
8384 return -EOPNOTSUPP;
8385
8386 }
8387
8388 }
8389 else
8390 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308391 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
8392 __func__, hdd_device_modetoString(pAdapter->device_mode),
8393 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008394 return -EOPNOTSUPP;
8395 }
8396
8397
8398 if(pRoamProfile)
8399 {
8400 if ( LastBSSType != pRoamProfile->BSSType )
8401 {
8402 /*interface type changed update in wiphy structure*/
8403 wdev->iftype = type;
8404
8405 /*the BSS mode changed, We need to issue disconnect
8406 if connected or in IBSS disconnect state*/
8407 if ( hdd_connGetConnectedBssType(
8408 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
8409 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
8410 {
8411 /*need to issue a disconnect to CSR.*/
8412 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8413 if( eHAL_STATUS_SUCCESS ==
8414 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8415 pAdapter->sessionId,
8416 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
8417 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308418 ret = wait_for_completion_interruptible_timeout(
8419 &pAdapter->disconnect_comp_var,
8420 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8421 if (ret <= 0)
8422 {
8423 hddLog(VOS_TRACE_LEVEL_ERROR,
8424 FL("wait on disconnect_comp_var failed %ld"), ret);
8425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008426 }
8427 }
8428 }
8429 }
8430
8431done:
8432 /*set bitmask based on updated value*/
8433 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07008434
8435 /* Only STA mode support TM now
8436 * all other mode, TM feature should be disabled */
8437 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
8438 (~VOS_STA & pHddCtx->concurrency_mode) )
8439 {
8440 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
8441 }
8442
Jeff Johnson295189b2012-06-20 16:38:30 -07008443#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308444 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05308445 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07008446 {
8447 //we are ok to do AMP
8448 pHddCtx->isAmpAllowed = VOS_TRUE;
8449 }
8450#endif //WLAN_BTAMP_FEATURE
8451 EXIT();
8452 return 0;
8453}
8454
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308455/*
8456 * FUNCTION: wlan_hdd_cfg80211_change_iface
8457 * wrapper function to protect the actual implementation from SSR.
8458 */
8459int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
8460 struct net_device *ndev,
8461 enum nl80211_iftype type,
8462 u32 *flags,
8463 struct vif_params *params
8464 )
8465{
8466 int ret;
8467
8468 vos_ssr_protect(__func__);
8469 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
8470 vos_ssr_unprotect(__func__);
8471
8472 return ret;
8473}
8474
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008475#ifdef FEATURE_WLAN_TDLS
8476static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308477 struct net_device *dev,
8478#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
8479 const u8 *mac,
8480#else
8481 u8 *mac,
8482#endif
8483 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008484{
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008485 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008486 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308487 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308488 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308489 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308490 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008491
8492 ENTER();
8493
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308494 if (!dev) {
8495 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
8496 return -EINVAL;
8497 }
8498
8499 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8500 if (!pAdapter) {
8501 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
8502 return -EINVAL;
8503 }
8504
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308505 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008506 {
8507 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8508 "Invalid arguments");
8509 return -EINVAL;
8510 }
Hoonki Lee27511902013-03-14 18:19:06 -07008511
8512 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
8513 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
8514 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308515 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -07008516 "%s: TDLS mode is disabled OR not enabled in FW."
8517 MAC_ADDRESS_STR " Request declined.",
8518 __func__, MAC_ADDR_ARRAY(mac));
8519 return -ENOTSUPP;
8520 }
8521
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008522 if (pHddCtx->isLogpInProgress)
8523 {
8524 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8525 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05308526 wlan_hdd_tdls_set_link_status(pAdapter,
8527 mac,
8528 eTDLS_LINK_IDLE,
8529 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008530 return -EBUSY;
8531 }
8532
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308533 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05308534 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008535
8536 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308537 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008538 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
8539 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308540 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008541 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008542 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308543 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008544
8545 /* in add station, we accept existing valid staId if there is */
8546 if ((0 == update) &&
8547 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
8548 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008549 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308550 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008551 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008552 " link_status %d. staId %d. add station ignored.",
8553 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
8554 return 0;
8555 }
8556 /* in change station, we accept only when staId is valid */
8557 if ((1 == update) &&
8558 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
8559 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
8560 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308561 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008562 "%s: " MAC_ADDRESS_STR
8563 " link status %d. staId %d. change station %s.",
8564 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
8565 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
8566 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008567 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008568
8569 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05308570 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008571 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008572 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8573 "%s: " MAC_ADDRESS_STR
8574 " TDLS setup is ongoing. Request declined.",
8575 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07008576 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008577 }
8578
8579 /* first to check if we reached to maximum supported TDLS peer.
8580 TODO: for now, return -EPERM looks working fine,
8581 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308582 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
8583 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008584 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008585 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8586 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308587 " TDLS Max peer already connected. Request declined."
8588 " Num of peers (%d), Max allowed (%d).",
8589 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
8590 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008591 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008592 }
8593 else
8594 {
8595 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308596 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008597 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008598 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008599 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8600 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
8601 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008602 return -EPERM;
8603 }
8604 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008605 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05308606 wlan_hdd_tdls_set_link_status(pAdapter,
8607 mac,
8608 eTDLS_LINK_CONNECTING,
8609 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008610
Jeff Johnsond75fe012013-04-06 10:53:06 -07008611 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308612 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008613 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308614 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008615 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008616 if(StaParams->htcap_present)
8617 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008619 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008621 "ht_capa->extended_capabilities: %0x",
8622 StaParams->HTCap.extendedHtCapInfo);
8623 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008625 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008627 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008628 if(StaParams->vhtcap_present)
8629 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008631 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
8632 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
8633 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
8634 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008635 {
8636 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008637 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008638 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308639 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008640 "[%d]: %x ", i, StaParams->supported_rates[i]);
8641 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07008642 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308643 else if ((1 == update) && (NULL == StaParams))
8644 {
8645 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8646 "%s : update is true, but staParams is NULL. Error!", __func__);
8647 return -EPERM;
8648 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008649
8650 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
8651
8652 if (!update)
8653 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308654 /*Before adding sta make sure that device exited from BMPS*/
8655 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8656 {
8657 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8658 "%s: Adding tdls peer sta. Disable BMPS", __func__);
8659 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8660 if (status != VOS_STATUS_SUCCESS) {
8661 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
8662 }
8663 }
8664
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308665 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008666 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308667 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308668 hddLog(VOS_TRACE_LEVEL_ERROR,
8669 FL("Failed to add TDLS peer STA. Enable Bmps"));
8670 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308671 return -EPERM;
8672 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008673 }
8674 else
8675 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308676 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008677 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308678 if (ret != eHAL_STATUS_SUCCESS) {
8679 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
8680 return -EPERM;
8681 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008682 }
8683
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308684 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008685 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
8686
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308687 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008688 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308690 "%s: timeout waiting for tdls add station indication %ld",
8691 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008692 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008693 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308694
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008695 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
8696 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008698 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008699 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008700 }
8701
8702 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008703
8704error:
Atul Mittal115287b2014-07-08 13:26:33 +05308705 wlan_hdd_tdls_set_link_status(pAdapter,
8706 mac,
8707 eTDLS_LINK_IDLE,
8708 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008709 return -EPERM;
8710
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008711}
8712#endif
8713
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308714static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008715 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308716#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
8717 const u8 *mac,
8718#else
Jeff Johnson295189b2012-06-20 16:38:30 -07008719 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308720#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008721 struct station_parameters *params)
8722{
8723 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308724 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308725 hdd_context_t *pHddCtx;
8726 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008727 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308728 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008729#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008730 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008731 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308732 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008733#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008734
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308735 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308736
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308737 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308738 if ((NULL == pAdapter))
8739 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308740 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308741 "invalid adapter ");
8742 return -EINVAL;
8743 }
8744
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308745 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8746 TRACE_CODE_HDD_CHANGE_STATION,
8747 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05308748 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308749
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308750 ret = wlan_hdd_validate_context(pHddCtx);
8751 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +05308752 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308753 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308754 }
8755
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308756 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8757
8758 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008759 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8761 "invalid HDD station context");
8762 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008764 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
8765
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008766 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
8767 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07008768 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008769 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07008770 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308771 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008772 WLANTL_STA_AUTHENTICATED);
8773
Gopichand Nakkala29149562013-05-10 21:43:41 +05308774 if (status != VOS_STATUS_SUCCESS)
8775 {
8776 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8777 "%s: Not able to change TL state to AUTHENTICATED", __func__);
8778 return -EINVAL;
8779 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008780 }
8781 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07008782 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
8783 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308784#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008785 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
8786 StaParams.capability = params->capability;
8787 StaParams.uapsd_queues = params->uapsd_queues;
8788 StaParams.max_sp = params->max_sp;
8789
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308790 /* Convert (first channel , number of channels) tuple to
8791 * the total list of channels. This goes with the assumption
8792 * that if the first channel is < 14, then the next channels
8793 * are an incremental of 1 else an incremental of 4 till the number
8794 * of channels.
8795 */
8796 if (0 != params->supported_channels_len) {
8797 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
8798 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
8799 {
8800 int wifi_chan_index;
8801 StaParams.supported_channels[j] = params->supported_channels[i];
8802 wifi_chan_index =
8803 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
8804 no_of_channels = params->supported_channels[i+1];
8805 for(k=1; k <= no_of_channels; k++)
8806 {
8807 StaParams.supported_channels[j+1] =
8808 StaParams.supported_channels[j] + wifi_chan_index;
8809 j+=1;
8810 }
8811 }
8812 StaParams.supported_channels_len = j;
8813 }
8814 vos_mem_copy(StaParams.supported_oper_classes,
8815 params->supported_oper_classes,
8816 params->supported_oper_classes_len);
8817 StaParams.supported_oper_classes_len =
8818 params->supported_oper_classes_len;
8819
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008820 if (0 != params->ext_capab_len)
8821 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
8822 sizeof(StaParams.extn_capability));
8823
8824 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008825 {
8826 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008827 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008828 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008829
8830 StaParams.supported_rates_len = params->supported_rates_len;
8831
8832 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
8833 * The supported_rates array , for all the structures propogating till Add Sta
8834 * to the firmware has to be modified , if the supplicant (ieee80211) is
8835 * modified to send more rates.
8836 */
8837
8838 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
8839 */
8840 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
8841 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
8842
8843 if (0 != StaParams.supported_rates_len) {
8844 int i = 0;
8845 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
8846 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008847 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008848 "Supported Rates with Length %d", StaParams.supported_rates_len);
8849 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008850 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008851 "[%d]: %0x", i, StaParams.supported_rates[i]);
8852 }
8853
8854 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008855 {
8856 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008857 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008858 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008859
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008860 if (0 != params->ext_capab_len ) {
8861 /*Define A Macro : TODO Sunil*/
8862 if ((1<<4) & StaParams.extn_capability[3]) {
8863 isBufSta = 1;
8864 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308865 /* TDLS Channel Switching Support */
8866 if ((1<<6) & StaParams.extn_capability[3]) {
8867 isOffChannelSupported = 1;
8868 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008869 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308870 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
8871 &StaParams, isBufSta,
8872 isOffChannelSupported);
8873
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308874 if (VOS_STATUS_SUCCESS != status) {
8875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8876 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
8877 return -EINVAL;
8878 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008879 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
8880
8881 if (VOS_STATUS_SUCCESS != status) {
8882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8883 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
8884 return -EINVAL;
8885 }
8886 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008887#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05308888 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008889 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008890 return status;
8891}
8892
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308893#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
8894static int wlan_hdd_change_station(struct wiphy *wiphy,
8895 struct net_device *dev,
8896 const u8 *mac,
8897 struct station_parameters *params)
8898#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308899static int wlan_hdd_change_station(struct wiphy *wiphy,
8900 struct net_device *dev,
8901 u8 *mac,
8902 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308903#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308904{
8905 int ret;
8906
8907 vos_ssr_protect(__func__);
8908 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
8909 vos_ssr_unprotect(__func__);
8910
8911 return ret;
8912}
8913
Jeff Johnson295189b2012-06-20 16:38:30 -07008914/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308915 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008916 * This function is used to initialize the key information
8917 */
8918#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308919static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008920 struct net_device *ndev,
8921 u8 key_index, bool pairwise,
8922 const u8 *mac_addr,
8923 struct key_params *params
8924 )
8925#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308926static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008927 struct net_device *ndev,
8928 u8 key_index, const u8 *mac_addr,
8929 struct key_params *params
8930 )
8931#endif
8932{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008933 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07008934 tCsrRoamSetKey setKey;
8935 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308936 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008937 v_U32_t roamId= 0xFF;
8938 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008939 hdd_hostapd_state_t *pHostapdState;
8940 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008941 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308942 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008943
8944 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308945
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308946 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8947 TRACE_CODE_HDD_CFG80211_ADD_KEY,
8948 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308949 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8950 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308951 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008952 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308953 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008954 }
8955
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308956 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8957 __func__, hdd_device_modetoString(pAdapter->device_mode),
8958 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008959
8960 if (CSR_MAX_NUM_KEY <= key_index)
8961 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008962 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008963 key_index);
8964
8965 return -EINVAL;
8966 }
8967
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008968 if (CSR_MAX_KEY_LEN < params->key_len)
8969 {
8970 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
8971 params->key_len);
8972
8973 return -EINVAL;
8974 }
8975
8976 hddLog(VOS_TRACE_LEVEL_INFO,
8977 "%s: called with key index = %d & key length %d",
8978 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07008979
8980 /*extract key idx, key len and key*/
8981 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8982 setKey.keyId = key_index;
8983 setKey.keyLength = params->key_len;
8984 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
8985
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008986 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07008987 {
8988 case WLAN_CIPHER_SUITE_WEP40:
8989 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
8990 break;
8991
8992 case WLAN_CIPHER_SUITE_WEP104:
8993 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
8994 break;
8995
8996 case WLAN_CIPHER_SUITE_TKIP:
8997 {
8998 u8 *pKey = &setKey.Key[0];
8999 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
9000
9001 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
9002
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009003 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07009004
9005 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009006 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07009007 |--------------|----------|----------|
9008 <---16bytes---><--8bytes--><--8bytes-->
9009
9010 */
9011 /*Sme expects the 32 bytes key to be in the below order
9012
9013 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009014 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07009015 |--------------|----------|----------|
9016 <---16bytes---><--8bytes--><--8bytes-->
9017 */
9018 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009019 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07009020
9021 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009022 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009023
9024 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009025 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009026
9027
9028 break;
9029 }
9030
9031 case WLAN_CIPHER_SUITE_CCMP:
9032 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
9033 break;
9034
9035#ifdef FEATURE_WLAN_WAPI
9036 case WLAN_CIPHER_SUITE_SMS4:
9037 {
9038 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9039 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
9040 params->key, params->key_len);
9041 return 0;
9042 }
9043#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009044
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009045#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009046 case WLAN_CIPHER_SUITE_KRK:
9047 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
9048 break;
9049#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009050
9051#ifdef WLAN_FEATURE_11W
9052 case WLAN_CIPHER_SUITE_AES_CMAC:
9053 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07009054 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07009055#endif
9056
Jeff Johnson295189b2012-06-20 16:38:30 -07009057 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009058 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07009059 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309060 status = -EOPNOTSUPP;
9061 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009062 }
9063
9064 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
9065 __func__, setKey.encType);
9066
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009067 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07009068#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9069 (!pairwise)
9070#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009071 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07009072#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009073 )
9074 {
9075 /* set group key*/
9076 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9077 "%s- %d: setting Broadcast key",
9078 __func__, __LINE__);
9079 setKey.keyDirection = eSIR_RX_ONLY;
9080 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9081 }
9082 else
9083 {
9084 /* set pairwise key*/
9085 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9086 "%s- %d: setting pairwise key",
9087 __func__, __LINE__);
9088 setKey.keyDirection = eSIR_TX_RX;
9089 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9090 }
9091 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
9092 {
9093 setKey.keyDirection = eSIR_TX_RX;
9094 /*Set the group key*/
9095 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9096 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009097
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009098 if ( 0 != status )
9099 {
9100 hddLog(VOS_TRACE_LEVEL_ERROR,
9101 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309102 status = -EINVAL;
9103 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009104 }
9105 /*Save the keys here and call sme_RoamSetKey for setting
9106 the PTK after peer joins the IBSS network*/
9107 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
9108 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309109 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009110 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05309111 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
9112 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
9113 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009114 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009115 if( pHostapdState->bssState == BSS_START )
9116 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009117 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9118 vos_status = wlan_hdd_check_ula_done(pAdapter);
9119
9120 if ( vos_status != VOS_STATUS_SUCCESS )
9121 {
9122 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9123 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9124 __LINE__, vos_status );
9125
9126 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9127
9128 status = -EINVAL;
9129 goto end;
9130 }
9131
Jeff Johnson295189b2012-06-20 16:38:30 -07009132 status = WLANSAP_SetKeySta( pVosContext, &setKey);
9133
9134 if ( status != eHAL_STATUS_SUCCESS )
9135 {
9136 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9137 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9138 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309139 status = -EINVAL;
9140 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009141 }
9142 }
9143
9144 /* Saving WEP keys */
9145 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
9146 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
9147 {
9148 //Save the wep key in ap context. Issue setkey after the BSS is started.
9149 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9150 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
9151 }
9152 else
9153 {
9154 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009155 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009156 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
9157 }
9158 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009159 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9160 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 {
9162 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9163 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9164
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309165#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9166 if (!pairwise)
9167#else
9168 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9169#endif
9170 {
9171 /* set group key*/
9172 if (pHddStaCtx->roam_info.deferKeyComplete)
9173 {
9174 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9175 "%s- %d: Perform Set key Complete",
9176 __func__, __LINE__);
9177 hdd_PerformRoamSetKeyComplete(pAdapter);
9178 }
9179 }
9180
Jeff Johnson295189b2012-06-20 16:38:30 -07009181 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
9182
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08009183 pWextState->roamProfile.Keys.defaultIndex = key_index;
9184
9185
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009186 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009187 params->key, params->key_len);
9188
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309189
Jeff Johnson295189b2012-06-20 16:38:30 -07009190 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9191
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309192 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009193 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309194 __func__, setKey.peerMac[0], setKey.peerMac[1],
9195 setKey.peerMac[2], setKey.peerMac[3],
9196 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009197 setKey.keyDirection);
9198
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009199 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +05309200
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009201 if ( vos_status != VOS_STATUS_SUCCESS )
9202 {
9203 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009204 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9205 __LINE__, vos_status );
9206
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009207 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009208
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009209 status = -EINVAL;
9210 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009211
9212 }
9213
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009214#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309215 /* The supplicant may attempt to set the PTK once pre-authentication
9216 is done. Save the key in the UMAC and include it in the ADD BSS
9217 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009218 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309219 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009220 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309221 hddLog(VOS_TRACE_LEVEL_INFO_MED,
9222 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309223 status = 0;
9224 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309225 }
9226 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
9227 {
9228 hddLog(VOS_TRACE_LEVEL_ERROR,
9229 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309230 status = -EINVAL;
9231 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009232 }
9233#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07009234
9235 /* issue set key request to SME*/
9236 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9237 pAdapter->sessionId, &setKey, &roamId );
9238
9239 if ( 0 != status )
9240 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309241 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009242 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
9243 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309244 status = -EINVAL;
9245 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009246 }
9247
9248
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309249 /* in case of IBSS as there was no information available about WEP keys during
9250 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07009251 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309252 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
9253 !( ( IW_AUTH_KEY_MGMT_802_1X
9254 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07009255 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
9256 )
9257 &&
9258 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
9259 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
9260 )
9261 )
9262 {
9263 setKey.keyDirection = eSIR_RX_ONLY;
9264 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9265
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309266 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009267 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309268 __func__, setKey.peerMac[0], setKey.peerMac[1],
9269 setKey.peerMac[2], setKey.peerMac[3],
9270 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009271 setKey.keyDirection);
9272
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309273 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009274 pAdapter->sessionId, &setKey, &roamId );
9275
9276 if ( 0 != status )
9277 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309278 hddLog(VOS_TRACE_LEVEL_ERROR,
9279 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009280 __func__, status);
9281 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
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
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309288end:
9289 /* Need to clear any trace of key value in the memory.
9290 * Thus zero out the memory even though it is local
9291 * variable.
9292 */
9293 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309294 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309295 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009296}
9297
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309298#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9299static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9300 struct net_device *ndev,
9301 u8 key_index, bool pairwise,
9302 const u8 *mac_addr,
9303 struct key_params *params
9304 )
9305#else
9306static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9307 struct net_device *ndev,
9308 u8 key_index, const u8 *mac_addr,
9309 struct key_params *params
9310 )
9311#endif
9312{
9313 int ret;
9314 vos_ssr_protect(__func__);
9315#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9316 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
9317 mac_addr, params);
9318#else
9319 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
9320 params);
9321#endif
9322 vos_ssr_unprotect(__func__);
9323
9324 return ret;
9325}
9326
Jeff Johnson295189b2012-06-20 16:38:30 -07009327/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309328 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009329 * This function is used to get the key information
9330 */
9331#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309332static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309333 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009334 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309335 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009336 const u8 *mac_addr, void *cookie,
9337 void (*callback)(void *cookie, struct key_params*)
9338 )
9339#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309340static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309341 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009342 struct net_device *ndev,
9343 u8 key_index, const u8 *mac_addr, void *cookie,
9344 void (*callback)(void *cookie, struct key_params*)
9345 )
9346#endif
9347{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309348 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309349 hdd_wext_state_t *pWextState = NULL;
9350 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009351 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309352 hdd_context_t *pHddCtx;
9353 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009354
9355 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309356
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309357 if (NULL == pAdapter)
9358 {
9359 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9360 "%s: HDD adapter is Null", __func__);
9361 return -ENODEV;
9362 }
9363
9364 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9365 ret = wlan_hdd_validate_context(pHddCtx);
9366 if (0 != ret)
9367 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309368 return ret;
9369 }
9370
9371 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9372 pRoamProfile = &(pWextState->roamProfile);
9373
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309374 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9375 __func__, hdd_device_modetoString(pAdapter->device_mode),
9376 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309377
Jeff Johnson295189b2012-06-20 16:38:30 -07009378 memset(&params, 0, sizeof(params));
9379
9380 if (CSR_MAX_NUM_KEY <= key_index)
9381 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309382 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07009383 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309384 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009385
9386 switch(pRoamProfile->EncryptionType.encryptionType[0])
9387 {
9388 case eCSR_ENCRYPT_TYPE_NONE:
9389 params.cipher = IW_AUTH_CIPHER_NONE;
9390 break;
9391
9392 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
9393 case eCSR_ENCRYPT_TYPE_WEP40:
9394 params.cipher = WLAN_CIPHER_SUITE_WEP40;
9395 break;
9396
9397 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
9398 case eCSR_ENCRYPT_TYPE_WEP104:
9399 params.cipher = WLAN_CIPHER_SUITE_WEP104;
9400 break;
9401
9402 case eCSR_ENCRYPT_TYPE_TKIP:
9403 params.cipher = WLAN_CIPHER_SUITE_TKIP;
9404 break;
9405
9406 case eCSR_ENCRYPT_TYPE_AES:
9407 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
9408 break;
9409
9410 default:
9411 params.cipher = IW_AUTH_CIPHER_NONE;
9412 break;
9413 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309414
c_hpothuaaf19692014-05-17 17:01:48 +05309415 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9416 TRACE_CODE_HDD_CFG80211_GET_KEY,
9417 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309418
Jeff Johnson295189b2012-06-20 16:38:30 -07009419 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
9420 params.seq_len = 0;
9421 params.seq = NULL;
9422 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
9423 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309424 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009425 return 0;
9426}
9427
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309428#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9429static int wlan_hdd_cfg80211_get_key(
9430 struct wiphy *wiphy,
9431 struct net_device *ndev,
9432 u8 key_index, bool pairwise,
9433 const u8 *mac_addr, void *cookie,
9434 void (*callback)(void *cookie, struct key_params*)
9435 )
9436#else
9437static int wlan_hdd_cfg80211_get_key(
9438 struct wiphy *wiphy,
9439 struct net_device *ndev,
9440 u8 key_index, const u8 *mac_addr, void *cookie,
9441 void (*callback)(void *cookie, struct key_params*)
9442 )
9443#endif
9444{
9445 int ret;
9446
9447 vos_ssr_protect(__func__);
9448#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9449 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
9450 mac_addr, cookie, callback);
9451#else
9452 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
9453 callback);
9454#endif
9455 vos_ssr_unprotect(__func__);
9456
9457 return ret;
9458}
9459
Jeff Johnson295189b2012-06-20 16:38:30 -07009460/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309461 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009462 * This function is used to delete the key information
9463 */
9464#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309465static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009466 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309467 u8 key_index,
9468 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009469 const u8 *mac_addr
9470 )
9471#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309472static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009473 struct net_device *ndev,
9474 u8 key_index,
9475 const u8 *mac_addr
9476 )
9477#endif
9478{
9479 int status = 0;
9480
9481 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309482 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009483 //it is observed that this is invalidating peer
9484 //key index whenever re-key is done. This is affecting data link.
9485 //It should be ok to ignore del_key.
9486#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309487 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
9488 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009489 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
9490 tCsrRoamSetKey setKey;
9491 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309492
Jeff Johnson295189b2012-06-20 16:38:30 -07009493 ENTER();
9494
9495 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
9496 __func__,pAdapter->device_mode);
9497
9498 if (CSR_MAX_NUM_KEY <= key_index)
9499 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309500 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009501 key_index);
9502
9503 return -EINVAL;
9504 }
9505
9506 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9507 setKey.keyId = key_index;
9508
9509 if (mac_addr)
9510 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9511 else
9512 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
9513
9514 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
9515
9516 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009517 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309518 )
9519 {
9520
9521 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07009522 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9523 if( pHostapdState->bssState == BSS_START)
9524 {
9525 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309526
Jeff Johnson295189b2012-06-20 16:38:30 -07009527 if ( status != eHAL_STATUS_SUCCESS )
9528 {
9529 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9530 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9531 __LINE__, status );
9532 }
9533 }
9534 }
9535 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309536 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07009537 )
9538 {
9539 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9540
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309541 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9542
9543 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009544 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309545 __func__, setKey.peerMac[0], setKey.peerMac[1],
9546 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07009547 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309548 if(pAdapter->sessionCtx.station.conn_info.connState ==
9549 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07009550 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309551 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009552 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309553
Jeff Johnson295189b2012-06-20 16:38:30 -07009554 if ( 0 != status )
9555 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309556 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009557 "%s: sme_RoamSetKey failure, returned %d",
9558 __func__, status);
9559 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9560 return -EINVAL;
9561 }
9562 }
9563 }
9564#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07009565 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009566 return status;
9567}
9568
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309569#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9570static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9571 struct net_device *ndev,
9572 u8 key_index,
9573 bool pairwise,
9574 const u8 *mac_addr
9575 )
9576#else
9577static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9578 struct net_device *ndev,
9579 u8 key_index,
9580 const u8 *mac_addr
9581 )
9582#endif
9583{
9584 int ret;
9585
9586 vos_ssr_protect(__func__);
9587#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9588 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
9589 mac_addr);
9590#else
9591 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
9592#endif
9593 vos_ssr_unprotect(__func__);
9594
9595 return ret;
9596}
9597
Jeff Johnson295189b2012-06-20 16:38:30 -07009598/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309599 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009600 * This function is used to set the default tx key index
9601 */
9602#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309603static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009604 struct net_device *ndev,
9605 u8 key_index,
9606 bool unicast, bool multicast)
9607#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309608static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009609 struct net_device *ndev,
9610 u8 key_index)
9611#endif
9612{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309613 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309614 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05309615 hdd_wext_state_t *pWextState;
9616 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309617 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009618
9619 ENTER();
9620
Gopichand Nakkala29149562013-05-10 21:43:41 +05309621 if ((NULL == pAdapter))
9622 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05309624 "invalid adapter");
9625 return -EINVAL;
9626 }
9627
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309628 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9629 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
9630 pAdapter->sessionId, key_index));
9631
Gopichand Nakkala29149562013-05-10 21:43:41 +05309632 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9633 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9634
9635 if ((NULL == pWextState) || (NULL == pHddStaCtx))
9636 {
9637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9638 "invalid Wext state or HDD context");
9639 return -EINVAL;
9640 }
9641
Arif Hussain6d2a3322013-11-17 19:50:10 -08009642 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009643 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309644
Jeff Johnson295189b2012-06-20 16:38:30 -07009645 if (CSR_MAX_NUM_KEY <= key_index)
9646 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309647 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 key_index);
9649
9650 return -EINVAL;
9651 }
9652
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309653 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9654 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309655 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009656 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309657 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009658 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309659
Jeff Johnson295189b2012-06-20 16:38:30 -07009660 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07009661 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309662 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009663 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05309664 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08009665 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309666 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08009667 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009668 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309669 {
9670 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07009671 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309672
Jeff Johnson295189b2012-06-20 16:38:30 -07009673 tCsrRoamSetKey setKey;
9674 v_U32_t roamId= 0xFF;
9675 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309676
9677 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009678 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309679
Jeff Johnson295189b2012-06-20 16:38:30 -07009680 Keys->defaultIndex = (u8)key_index;
9681 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9682 setKey.keyId = key_index;
9683 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309684
9685 vos_mem_copy(&setKey.Key[0],
9686 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309688
Gopichand Nakkala29149562013-05-10 21:43:41 +05309689 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309690
9691 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07009692 &pHddStaCtx->conn_info.bssId[0],
9693 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309694
Gopichand Nakkala29149562013-05-10 21:43:41 +05309695 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
9696 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
9697 eCSR_ENCRYPT_TYPE_WEP104)
9698 {
9699 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
9700 even though ap is configured for WEP-40 encryption. In this canse the key length
9701 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
9702 type(104) and switching encryption type to 40*/
9703 pWextState->roamProfile.EncryptionType.encryptionType[0] =
9704 eCSR_ENCRYPT_TYPE_WEP40;
9705 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
9706 eCSR_ENCRYPT_TYPE_WEP40;
9707 }
9708
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309709 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07009710 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309711
Jeff Johnson295189b2012-06-20 16:38:30 -07009712 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309713 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009714 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309715
Jeff Johnson295189b2012-06-20 16:38:30 -07009716 if ( 0 != status )
9717 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309718 hddLog(VOS_TRACE_LEVEL_ERROR,
9719 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009720 status);
9721 return -EINVAL;
9722 }
9723 }
9724 }
9725
9726 /* In SoftAp mode setting key direction for default mode */
9727 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
9728 {
9729 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
9730 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
9731 (eCSR_ENCRYPT_TYPE_AES !=
9732 pWextState->roamProfile.EncryptionType.encryptionType[0])
9733 )
9734 {
9735 /* Saving key direction for default key index to TX default */
9736 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9737 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
9738 }
9739 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309740 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009741 return status;
9742}
9743
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309744#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9745static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9746 struct net_device *ndev,
9747 u8 key_index,
9748 bool unicast, bool multicast)
9749#else
9750static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9751 struct net_device *ndev,
9752 u8 key_index)
9753#endif
9754{
9755 int ret;
9756 vos_ssr_protect(__func__);
9757#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9758 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
9759 multicast);
9760#else
9761 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
9762#endif
9763 vos_ssr_unprotect(__func__);
9764
9765 return ret;
9766}
9767
Jeff Johnson295189b2012-06-20 16:38:30 -07009768/*
9769 * FUNCTION: wlan_hdd_cfg80211_inform_bss
9770 * This function is used to inform the BSS details to nl80211 interface.
9771 */
9772static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
9773 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
9774{
9775 struct net_device *dev = pAdapter->dev;
9776 struct wireless_dev *wdev = dev->ieee80211_ptr;
9777 struct wiphy *wiphy = wdev->wiphy;
9778 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
9779 int chan_no;
9780 int ie_length;
9781 const char *ie;
9782 unsigned int freq;
9783 struct ieee80211_channel *chan;
9784 int rssi = 0;
9785 struct cfg80211_bss *bss = NULL;
9786
Jeff Johnson295189b2012-06-20 16:38:30 -07009787 if( NULL == pBssDesc )
9788 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009789 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009790 return bss;
9791 }
9792
9793 chan_no = pBssDesc->channelId;
9794 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
9795 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
9796
9797 if( NULL == ie )
9798 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009799 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009800 return bss;
9801 }
9802
9803#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
9804 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
9805 {
9806 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9807 }
9808 else
9809 {
9810 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9811 }
9812#else
9813 freq = ieee80211_channel_to_frequency(chan_no);
9814#endif
9815
9816 chan = __ieee80211_get_channel(wiphy, freq);
9817
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05309818 if (!chan) {
9819 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
9820 return NULL;
9821 }
9822
Abhishek Singhaee43942014-06-16 18:55:47 +05309823 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07009824
Anand N Sunkad9f80b742015-07-30 20:05:51 +05309825 return cfg80211_inform_bss(wiphy, chan,
9826#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
9827 CFG80211_BSS_FTYPE_UNKNOWN,
9828#endif
9829 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309830 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07009831 pBssDesc->capabilityInfo,
9832 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05309833 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07009834}
9835
9836
9837
9838/*
9839 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
9840 * This function is used to inform the BSS details to nl80211 interface.
9841 */
9842struct cfg80211_bss*
9843wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
9844 tSirBssDescription *bss_desc
9845 )
9846{
9847 /*
9848 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
9849 already exists in bss data base of cfg80211 for that particular BSS ID.
9850 Using cfg80211_inform_bss_frame to update the bss entry instead of
9851 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
9852 now there is no possibility to get the mgmt(probe response) frame from PE,
9853 converting bss_desc to ieee80211_mgmt(probe response) and passing to
9854 cfg80211_inform_bss_frame.
9855 */
9856 struct net_device *dev = pAdapter->dev;
9857 struct wireless_dev *wdev = dev->ieee80211_ptr;
9858 struct wiphy *wiphy = wdev->wiphy;
9859 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009860#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9861 qcom_ie_age *qie_age = NULL;
9862 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
9863#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009864 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009865#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009866 const char *ie =
9867 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
9868 unsigned int freq;
9869 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309870 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009871 struct cfg80211_bss *bss_status = NULL;
9872 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
9873 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07009874 hdd_context_t *pHddCtx;
9875 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07009876#ifdef WLAN_OPEN_SOURCE
9877 struct timespec ts;
9878#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009879
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309880
Wilson Yangf80a0542013-10-07 13:02:37 -07009881 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9882 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -07009883 if (0 != status)
9884 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009885 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009886 }
9887
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309888 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07009889 if (!mgmt)
9890 {
9891 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9892 "%s: memory allocation failed ", __func__);
9893 return NULL;
9894 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009895
Jeff Johnson295189b2012-06-20 16:38:30 -07009896 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07009897
9898#ifdef WLAN_OPEN_SOURCE
9899 /* Android does not want the timestamp from the frame.
9900 Instead it wants a monotonic increasing value */
9901 get_monotonic_boottime(&ts);
9902 mgmt->u.probe_resp.timestamp =
9903 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
9904#else
9905 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07009906 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
9907 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07009908
9909#endif
9910
Jeff Johnson295189b2012-06-20 16:38:30 -07009911 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
9912 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009913
9914#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9915 /* GPS Requirement: need age ie per entry. Using vendor specific. */
9916 /* Assuming this is the last IE, copy at the end */
9917 ie_length -=sizeof(qcom_ie_age);
9918 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
9919 qie_age->element_id = QCOM_VENDOR_IE_ID;
9920 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
9921 qie_age->oui_1 = QCOM_OUI1;
9922 qie_age->oui_2 = QCOM_OUI2;
9923 qie_age->oui_3 = QCOM_OUI3;
9924 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
9925 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
9926#endif
9927
Jeff Johnson295189b2012-06-20 16:38:30 -07009928 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05309929 if (bss_desc->fProbeRsp)
9930 {
9931 mgmt->frame_control |=
9932 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
9933 }
9934 else
9935 {
9936 mgmt->frame_control |=
9937 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
9938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009939
9940#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309941 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009942 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
9943 {
9944 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9945 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309946 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009947 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
9948
9949 {
9950 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9951 }
9952 else
9953 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309954 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
9955 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07009956 kfree(mgmt);
9957 return NULL;
9958 }
9959#else
9960 freq = ieee80211_channel_to_frequency(chan_no);
9961#endif
9962 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009963 /*when the band is changed on the fly using the GUI, three things are done
9964 * 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)
9965 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
9966 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
9967 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
9968 * and discards the channels correponding to previous band and calls back with zero bss results.
9969 * 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
9970 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
9971 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
9972 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
9973 * So drop the bss and continue to next bss.
9974 */
9975 if(chan == NULL)
9976 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309977 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07009978 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009979 return NULL;
9980 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +05309981 /*To keep the rssi icon of the connected AP in the scan window
9982 *and the rssi icon of the wireless networks in sync
9983 * */
9984 if (( eConnectionState_Associated ==
9985 pAdapter->sessionCtx.station.conn_info.connState ) &&
9986 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
9987 pAdapter->sessionCtx.station.conn_info.bssId,
9988 WNI_CFG_BSSID_LEN)) &&
9989 (pHddCtx->hdd_wlan_suspended == FALSE))
9990 {
9991 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
9992 rssi = (pAdapter->rssi * 100);
9993 }
9994 else
9995 {
9996 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
9997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009998
Nirav Shah20ac06f2013-12-12 18:14:06 +05309999 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053010000 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
10001 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053010002
Jeff Johnson295189b2012-06-20 16:38:30 -070010003 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
10004 frame_len, rssi, GFP_KERNEL);
10005 kfree(mgmt);
10006 return bss_status;
10007}
10008
10009/*
10010 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
10011 * This function is used to update the BSS data base of CFG8011
10012 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010013struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070010014 tCsrRoamInfo *pRoamInfo
10015 )
10016{
10017 tCsrRoamConnectedProfile roamProfile;
10018 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10019 struct cfg80211_bss *bss = NULL;
10020
10021 ENTER();
10022
10023 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
10024 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
10025
10026 if (NULL != roamProfile.pBssDesc)
10027 {
Girish Gowlif4b68022014-08-28 23:18:57 +053010028 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10029 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010030
10031 if (NULL == bss)
10032 {
10033 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
10034 __func__);
10035 }
10036
10037 sme_RoamFreeConnectProfile(hHal, &roamProfile);
10038 }
10039 else
10040 {
10041 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
10042 __func__);
10043 }
10044 return bss;
10045}
10046
10047/*
10048 * FUNCTION: wlan_hdd_cfg80211_update_bss
10049 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010050static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
10051 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070010052 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010053{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010054 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010055 tCsrScanResultInfo *pScanResult;
10056 eHalStatus status = 0;
10057 tScanResultHandle pResult;
10058 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070010059 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010060 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070010061 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010062
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010063 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10064 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
10065 NO_SESSION, pAdapter->sessionId));
10066
Wilson Yangf80a0542013-10-07 13:02:37 -070010067 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10068
10069 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -070010070 {
Wilson Yangf80a0542013-10-07 13:02:37 -070010071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10072 "%s:LOGP in Progress. Ignore!!!",__func__);
10073 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010074 }
10075
Wilson Yangf80a0542013-10-07 13:02:37 -070010076
10077 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +053010078 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -070010079 {
10080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10081 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
10082 return VOS_STATUS_E_PERM;
10083 }
10084
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010085 if (pAdapter->request != NULL)
10086 {
10087 if ((pAdapter->request->n_ssids == 1)
10088 && (pAdapter->request->ssids != NULL)
10089 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
10090 is_p2p_scan = true;
10091 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010092 /*
10093 * start getting scan results and populate cgf80211 BSS database
10094 */
10095 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
10096
10097 /* no scan results */
10098 if (NULL == pResult)
10099 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010100 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
10101 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053010102 wlan_hdd_get_frame_logs(pAdapter,
10103 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070010104 return status;
10105 }
10106
10107 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
10108
10109 while (pScanResult)
10110 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010111 /*
10112 * cfg80211_inform_bss() is not updating ie field of bss entry, if
10113 * entry already exists in bss data base of cfg80211 for that
10114 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
10115 * bss entry instead of cfg80211_inform_bss, But this call expects
10116 * mgmt packet as input. As of now there is no possibility to get
10117 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070010118 * ieee80211_mgmt(probe response) and passing to c
10119 * fg80211_inform_bss_frame.
10120 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010121 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
10122 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
10123 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010124 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10125 continue; //Skip the non p2p bss entries
10126 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010127 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10128 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010129
Jeff Johnson295189b2012-06-20 16:38:30 -070010130
10131 if (NULL == bss_status)
10132 {
10133 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010134 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010135 }
10136 else
10137 {
Yue Maf49ba872013-08-19 12:04:25 -070010138 cfg80211_put_bss(
10139#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10140 wiphy,
10141#endif
10142 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010143 }
10144
10145 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10146 }
10147
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010148 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010149 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010150 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010151}
10152
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010153void
10154hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
10155{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010156 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080010157 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010158} /****** end hddPrintMacAddr() ******/
10159
10160void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010161hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010162{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010163 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010164 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010165 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
10166 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
10167 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010168} /****** end hddPrintPmkId() ******/
10169
10170//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
10171//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
10172
10173//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
10174//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
10175
10176#define dump_bssid(bssid) \
10177 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010178 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
10179 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010180 }
10181
10182#define dump_pmkid(pMac, pmkid) \
10183 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010184 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
10185 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010186 }
10187
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070010188#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010189/*
10190 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
10191 * This function is used to notify the supplicant of a new PMKSA candidate.
10192 */
10193int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010194 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010195 int index, bool preauth )
10196{
Jeff Johnsone7245742012-09-05 17:12:55 -070010197#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010198 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010199 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010200
10201 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070010202 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010203
10204 if( NULL == pRoamInfo )
10205 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010206 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010207 return -EINVAL;
10208 }
10209
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010210 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
10211 {
10212 dump_bssid(pRoamInfo->bssid);
10213 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010214 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010215 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010216#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010217 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010218}
10219#endif //FEATURE_WLAN_LFR
10220
Yue Maef608272013-04-08 23:09:17 -070010221#ifdef FEATURE_WLAN_LFR_METRICS
10222/*
10223 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
10224 * 802.11r/LFR metrics reporting function to report preauth initiation
10225 *
10226 */
10227#define MAX_LFR_METRICS_EVENT_LENGTH 100
10228VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
10229 tCsrRoamInfo *pRoamInfo)
10230{
10231 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10232 union iwreq_data wrqu;
10233
10234 ENTER();
10235
10236 if (NULL == pAdapter)
10237 {
10238 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10239 return VOS_STATUS_E_FAILURE;
10240 }
10241
10242 /* create the event */
10243 memset(&wrqu, 0, sizeof(wrqu));
10244 memset(metrics_notification, 0, sizeof(metrics_notification));
10245
10246 wrqu.data.pointer = metrics_notification;
10247 wrqu.data.length = scnprintf(metrics_notification,
10248 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
10249 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10250
10251 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10252
10253 EXIT();
10254
10255 return VOS_STATUS_SUCCESS;
10256}
10257
10258/*
10259 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
10260 * 802.11r/LFR metrics reporting function to report preauth completion
10261 * or failure
10262 */
10263VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
10264 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
10265{
10266 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10267 union iwreq_data wrqu;
10268
10269 ENTER();
10270
10271 if (NULL == pAdapter)
10272 {
10273 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10274 return VOS_STATUS_E_FAILURE;
10275 }
10276
10277 /* create the event */
10278 memset(&wrqu, 0, sizeof(wrqu));
10279 memset(metrics_notification, 0, sizeof(metrics_notification));
10280
10281 scnprintf(metrics_notification, sizeof(metrics_notification),
10282 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
10283 MAC_ADDR_ARRAY(pRoamInfo->bssid));
10284
10285 if (1 == preauth_status)
10286 strncat(metrics_notification, " TRUE", 5);
10287 else
10288 strncat(metrics_notification, " FALSE", 6);
10289
10290 wrqu.data.pointer = metrics_notification;
10291 wrqu.data.length = strlen(metrics_notification);
10292
10293 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10294
10295 EXIT();
10296
10297 return VOS_STATUS_SUCCESS;
10298}
10299
10300/*
10301 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
10302 * 802.11r/LFR metrics reporting function to report handover initiation
10303 *
10304 */
10305VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
10306 tCsrRoamInfo *pRoamInfo)
10307{
10308 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10309 union iwreq_data wrqu;
10310
10311 ENTER();
10312
10313 if (NULL == pAdapter)
10314 {
10315 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10316 return VOS_STATUS_E_FAILURE;
10317 }
10318
10319 /* create the event */
10320 memset(&wrqu, 0, sizeof(wrqu));
10321 memset(metrics_notification, 0, sizeof(metrics_notification));
10322
10323 wrqu.data.pointer = metrics_notification;
10324 wrqu.data.length = scnprintf(metrics_notification,
10325 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
10326 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10327
10328 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10329
10330 EXIT();
10331
10332 return VOS_STATUS_SUCCESS;
10333}
10334#endif
10335
Jeff Johnson295189b2012-06-20 16:38:30 -070010336/*
10337 * FUNCTION: hdd_cfg80211_scan_done_callback
10338 * scanning callback function, called after finishing scan
10339 *
10340 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010341static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070010342 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
10343{
10344 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010345 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070010346 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010347 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010348 struct cfg80211_scan_request *req = NULL;
10349 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010350 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010351 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010352 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010353 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010354
10355 ENTER();
10356
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010357 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053010358 if (NULL == pHddCtx) {
10359 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010360 goto allow_suspend;
10361 }
10362
10363 pScanInfo = &pHddCtx->scan_info;
10364
Jeff Johnson295189b2012-06-20 16:38:30 -070010365 hddLog(VOS_TRACE_LEVEL_INFO,
10366 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080010367 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010368 __func__, halHandle, pContext, (int) scanId, (int) status);
10369
Kiet Lamac06e2c2013-10-23 16:25:07 +053010370 pScanInfo->mScanPendingCounter = 0;
10371
Jeff Johnson295189b2012-06-20 16:38:30 -070010372 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010373 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070010374 &pScanInfo->scan_req_completion_event,
10375 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010376 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070010377 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010378 hddLog(VOS_TRACE_LEVEL_ERROR,
10379 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070010380 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010381 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010382 }
10383
Yue Maef608272013-04-08 23:09:17 -070010384 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010385 {
10386 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010387 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010388 }
10389
10390 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010391 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070010392 {
10393 hddLog(VOS_TRACE_LEVEL_INFO,
10394 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010395 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070010396 (int) scanId);
10397 }
10398
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010399 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010400 pAdapter);
10401
10402 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010403 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010404
10405
10406 /* If any client wait scan result through WEXT
10407 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010408 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070010409 {
10410 /* The other scan request waiting for current scan finish
10411 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010412 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010413 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010414 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070010415 }
10416 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010417 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010418 {
10419 struct net_device *dev = pAdapter->dev;
10420 union iwreq_data wrqu;
10421 int we_event;
10422 char *msg;
10423
10424 memset(&wrqu, '\0', sizeof(wrqu));
10425 we_event = SIOCGIWSCAN;
10426 msg = NULL;
10427 wireless_send_event(dev, we_event, &wrqu, msg);
10428 }
10429 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010430 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010431
10432 /* Get the Scan Req */
10433 req = pAdapter->request;
10434
10435 if (!req)
10436 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010437 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010438 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010439 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010440 }
10441
Jeff Johnson295189b2012-06-20 16:38:30 -070010442 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070010443 /* Scan is no longer pending */
10444 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010445
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010446 /* last_scan_timestamp is used to decide if new scan
10447 * is needed or not on station interface. If last station
10448 * scan time and new station scan time is less then
10449 * last_scan_timestamp ; driver will return cached scan.
10450 */
10451 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
10452 {
10453 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
10454
10455 if ( req->n_channels )
10456 {
10457 for (i = 0; i < req->n_channels ; i++ )
10458 {
10459 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
10460 }
10461 /* store no of channel scanned */
10462 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
10463 }
10464
10465 }
10466
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070010467 /*
10468 * cfg80211_scan_done informing NL80211 about completion
10469 * of scanning
10470 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010471 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
10472 {
10473 aborted = true;
10474 }
10475 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080010476 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070010477
Siddharth Bhal76972212014-10-15 16:22:51 +053010478 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
10479 /* Generate new random mac addr for next scan */
10480 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
10481 hdd_processSpoofMacAddrRequest(pHddCtx);
10482 }
10483
Jeff Johnsone7245742012-09-05 17:12:55 -070010484allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010485 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010486 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070010487
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010488 /* Acquire wakelock to handle the case where APP's tries to suspend
10489 * immediatly after the driver gets connect request(i.e after scan)
10490 * from supplicant, this result in app's is suspending and not able
10491 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010492 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010493
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010494#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010495 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010496#endif
10497
Jeff Johnson295189b2012-06-20 16:38:30 -070010498 EXIT();
10499 return 0;
10500}
10501
10502/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053010503 * FUNCTION: hdd_isConnectionInProgress
10504 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010505 *
10506 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010507v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010508{
10509 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10510 hdd_station_ctx_t *pHddStaCtx = NULL;
10511 hdd_adapter_t *pAdapter = NULL;
10512 VOS_STATUS status = 0;
10513 v_U8_t staId = 0;
10514 v_U8_t *staMac = NULL;
10515
c_hpothu9b781ba2013-12-30 20:57:45 +053010516 if (TRUE == pHddCtx->btCoexModeSet)
10517 {
10518 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053010519 FL("BTCoex Mode operation in progress"));
10520 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053010521 }
10522
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010523 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10524
10525 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10526 {
10527 pAdapter = pAdapterNode->pAdapter;
10528
10529 if( pAdapter )
10530 {
10531 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010532 "%s: Adapter with device mode %s (%d) exists",
10533 __func__, hdd_device_modetoString(pAdapter->device_mode),
10534 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010535 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053010536 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10537 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
10538 (eConnectionState_Connecting ==
10539 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
10540 {
10541 hddLog(VOS_TRACE_LEVEL_ERROR,
10542 "%s: %p(%d) Connection is in progress", __func__,
10543 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10544 return VOS_TRUE;
10545 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010546 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053010547 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010548 {
10549 hddLog(VOS_TRACE_LEVEL_ERROR,
10550 "%s: %p(%d) Reassociation is in progress", __func__,
10551 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10552 return VOS_TRUE;
10553 }
10554 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010555 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10556 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010557 {
10558 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10559 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010560 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010561 {
10562 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
10563 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010564 "%s: client " MAC_ADDRESS_STR
10565 " is in the middle of WPS/EAPOL exchange.", __func__,
10566 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010567 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010568 }
10569 }
10570 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
10571 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
10572 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010573 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10574 ptSapContext pSapCtx = NULL;
10575 pSapCtx = VOS_GET_SAP_CB(pVosContext);
10576 if(pSapCtx == NULL){
10577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10578 FL("psapCtx is NULL"));
10579 return VOS_FALSE;
10580 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010581 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
10582 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010583 if ((pSapCtx->aStaInfo[staId].isUsed) &&
10584 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010585 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010586 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010587
10588 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010589 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
10590 "middle of WPS/EAPOL exchange.", __func__,
10591 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010592 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010593 }
10594 }
10595 }
10596 }
10597 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10598 pAdapterNode = pNext;
10599 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053010600 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010601}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010602
10603/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010604 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070010605 * this scan respond to scan trigger and update cfg80211 scan database
10606 * later, scan dump command can be used to recieve scan results
10607 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010608int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010609#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10610 struct net_device *dev,
10611#endif
10612 struct cfg80211_scan_request *request)
10613{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010614 hdd_adapter_t *pAdapter = NULL;
10615 hdd_context_t *pHddCtx = NULL;
10616 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010617 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010618 tCsrScanRequest scanRequest;
10619 tANI_U8 *channelList = NULL, i;
10620 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010621 int status;
10622 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010623 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010624 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053010625 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010626 bool is_p2p_scan = false;
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010627 v_S7_t rssi=0;
10628 hdd_station_ctx_t *pHddStaCtx=NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010629
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010630#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
10631 struct net_device *dev = NULL;
10632 if (NULL == request)
10633 {
10634 hddLog(VOS_TRACE_LEVEL_ERROR,
10635 "%s: scan req param null", __func__);
10636 return -EINVAL;
10637 }
10638 dev = request->wdev->netdev;
10639#endif
10640
10641 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
10642 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
10643 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10644
Jeff Johnson295189b2012-06-20 16:38:30 -070010645 ENTER();
10646
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010647 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10648 __func__, hdd_device_modetoString(pAdapter->device_mode),
10649 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010650
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010651 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010652 if (0 != status)
10653 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010654 return status;
10655 }
10656
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010657 if (NULL == pwextBuf)
10658 {
10659 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
10660 __func__);
10661 return -EIO;
10662 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010663 cfg_param = pHddCtx->cfg_ini;
10664 pScanInfo = &pHddCtx->scan_info;
10665
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010666 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10667 if ( (pHddStaCtx != NULL) && (TRUE == hdd_connIsConnected(pHddStaCtx)))
10668 {
10669 wlan_hdd_get_roam_rssi(pAdapter, &rssi);
10670 hddLog(VOS_TRACE_LEVEL_INFO, FL("rssi: %d"), rssi);
10671 }
10672
Jeff Johnson295189b2012-06-20 16:38:30 -070010673#ifdef WLAN_BTAMP_FEATURE
10674 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010675 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070010676 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010677 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010678 "%s: No scanning when AMP is on", __func__);
10679 return -EOPNOTSUPP;
10680 }
10681#endif
10682 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010683 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010684 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010685 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010686 "%s: Not scanning on device_mode = %s (%d)",
10687 __func__, hdd_device_modetoString(pAdapter->device_mode),
10688 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010689 return -EOPNOTSUPP;
10690 }
10691
10692 if (TRUE == pScanInfo->mScanPending)
10693 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010694 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
10695 {
10696 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
10697 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010698 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010699 }
10700
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053010701 // Don't allow scan if PNO scan is going on.
10702 if (pHddCtx->isPnoEnable)
10703 {
10704 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10705 FL("pno scan in progress"));
10706 return -EBUSY;
10707 }
10708
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010709 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070010710 //Channel and action frame is pending
10711 //Otherwise Cancel Remain On Channel and allow Scan
10712 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010713 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070010714 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010715 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010716 return -EBUSY;
10717 }
10718
Jeff Johnson295189b2012-06-20 16:38:30 -070010719 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
10720 {
10721 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080010722 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010723 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010724 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010725 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
10726 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010727 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010728 "%s: MAX TM Level Scan not allowed", __func__);
10729 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010730 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010731 }
10732 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
10733
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010734 /* Check if scan is allowed at this point of time.
10735 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010736 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010737 {
10738 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
10739 return -EBUSY;
10740 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010741
Jeff Johnson295189b2012-06-20 16:38:30 -070010742 vos_mem_zero( &scanRequest, sizeof(scanRequest));
10743
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010744 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
10745 * Becasue of this, driver is assuming that this is not wildcard scan and so
10746 * is not aging out the scan results.
10747 */
10748 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070010749 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010750 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010751 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010752
10753 if ((request->ssids) && (0 < request->n_ssids))
10754 {
10755 tCsrSSIDInfo *SsidInfo;
10756 int j;
10757 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
10758 /* Allocate num_ssid tCsrSSIDInfo structure */
10759 SsidInfo = scanRequest.SSIDs.SSIDList =
10760 ( tCsrSSIDInfo *)vos_mem_malloc(
10761 request->n_ssids*sizeof(tCsrSSIDInfo));
10762
10763 if(NULL == scanRequest.SSIDs.SSIDList)
10764 {
10765 hddLog(VOS_TRACE_LEVEL_ERROR,
10766 "%s: memory alloc failed SSIDInfo buffer", __func__);
10767 return -ENOMEM;
10768 }
10769
10770 /* copy all the ssid's and their length */
10771 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
10772 {
10773 /* get the ssid length */
10774 SsidInfo->SSID.length = request->ssids[j].ssid_len;
10775 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
10776 SsidInfo->SSID.length);
10777 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
10778 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
10779 j, SsidInfo->SSID.ssId);
10780 }
10781 /* set the scan type to active */
10782 scanRequest.scanType = eSIR_ACTIVE_SCAN;
10783 }
10784 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070010785 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010786 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10787 TRACE_CODE_HDD_CFG80211_SCAN,
10788 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070010789 /* set the scan type to active */
10790 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010791 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010792 else
10793 {
10794 /*Set the scan type to default type, in this case it is ACTIVE*/
10795 scanRequest.scanType = pScanInfo->scan_mode;
10796 }
10797 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
10798 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070010799
10800 /* set BSSType to default type */
10801 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
10802
10803 /*TODO: scan the requested channels only*/
10804
10805 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010806 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070010807 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010808 hddLog(VOS_TRACE_LEVEL_WARN,
10809 "No of Scan Channels exceeded limit: %d", request->n_channels);
10810 request->n_channels = MAX_CHANNEL;
10811 }
10812
10813 hddLog(VOS_TRACE_LEVEL_INFO,
10814 "No of Scan Channels: %d", request->n_channels);
10815
10816
10817 if( request->n_channels )
10818 {
10819 char chList [(request->n_channels*5)+1];
10820 int len;
10821 channelList = vos_mem_malloc( request->n_channels );
10822 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053010823 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010824 hddLog(VOS_TRACE_LEVEL_ERROR,
10825 "%s: memory alloc failed channelList", __func__);
10826 status = -ENOMEM;
10827 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053010828 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010829
10830 for( i = 0, len = 0; i < request->n_channels ; i++ )
10831 {
10832 channelList[i] = request->channels[i]->hw_value;
10833 len += snprintf(chList+len, 5, "%d ", channelList[i]);
10834 }
10835
Nirav Shah20ac06f2013-12-12 18:14:06 +053010836 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010837 "Channel-List: %s ", chList);
10838 }
c_hpothu53512302014-04-15 18:49:53 +053010839
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010840 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
10841 scanRequest.ChannelInfo.ChannelList = channelList;
10842
10843 /* set requestType to full scan */
10844 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
10845
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010846 /* if there is back to back scan happening in driver with in
10847 * nDeferScanTimeInterval interval driver should defer new scan request
10848 * and should provide last cached scan results instead of new channel list.
10849 * This rule is not applicable if scan is p2p scan.
10850 * This condition will work only in case when last request no of channels
10851 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053010852 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053010853 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010854 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010855
Sushant Kaushik86592172015-04-27 16:35:03 +053010856 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
10857 /* if wps ie is NULL , then only defer scan */
10858 if ( pWpsIe == NULL &&
10859 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053010860 {
10861 if ( pScanInfo->last_scan_timestamp !=0 &&
10862 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
10863 {
10864 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
10865 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
10866 vos_mem_compare(pScanInfo->last_scan_channelList,
10867 channelList, pScanInfo->last_scan_numChannels))
10868 {
10869 hddLog(VOS_TRACE_LEVEL_WARN,
10870 " New and old station scan time differ is less then %u",
10871 pHddCtx->cfg_ini->nDeferScanTimeInterval);
10872
10873 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010874 pAdapter);
10875
Agarwal Ashish57e84372014-12-05 18:26:53 +053010876 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010877 "Return old cached scan as all channels and no of channels are same");
10878
Agarwal Ashish57e84372014-12-05 18:26:53 +053010879 if (0 > ret)
10880 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010881
Agarwal Ashish57e84372014-12-05 18:26:53 +053010882 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010883
10884 status = eHAL_STATUS_SUCCESS;
10885 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053010886 }
10887 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010888 }
10889
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010890 /* Flush the scan results(only p2p beacons) for STA scan and P2P
10891 * search (Flush on both full scan and social scan but not on single
10892 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
10893 */
10894
10895 /* Supplicant does single channel scan after 8-way handshake
10896 * and in that case driver shoudnt flush scan results. If
10897 * driver flushes the scan results here and unfortunately if
10898 * the AP doesnt respond to our probe req then association
10899 * fails which is not desired
10900 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010901 if ((request->n_ssids == 1)
10902 && (request->ssids != NULL)
10903 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
10904 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010905
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010906 if( is_p2p_scan ||
10907 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010908 {
10909 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
10910 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
10911 pAdapter->sessionId );
10912 }
10913
10914 if( request->ie_len )
10915 {
10916 /* save this for future association (join requires this) */
10917 /*TODO: Array needs to be converted to dynamic allocation,
10918 * as multiple ie.s can be sent in cfg80211_scan_request structure
10919 * CR 597966
10920 */
10921 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
10922 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
10923 pScanInfo->scanAddIE.length = request->ie_len;
10924
10925 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
10926 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10927 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010928 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053010929 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070010930 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010931 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
10932 memcpy( pwextBuf->roamProfile.addIEScan,
10933 request->ie, request->ie_len);
10934 }
10935 else
10936 {
10937 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
10938 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070010939 }
10940
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010941 }
10942 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
10943 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
10944
10945 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
10946 request->ie_len);
10947 if (pP2pIe != NULL)
10948 {
10949#ifdef WLAN_FEATURE_P2P_DEBUG
10950 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
10951 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
10952 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053010953 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010954 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
10955 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10956 "Go nego completed to Connection is started");
10957 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10958 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053010959 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010960 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
10961 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010962 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010963 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
10964 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10965 "Disconnected state to Connection is started");
10966 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10967 "for 4way Handshake");
10968 }
10969#endif
10970
10971 /* no_cck will be set during p2p find to disable 11b rates */
10972 if(TRUE == request->no_cck)
10973 {
10974 hddLog(VOS_TRACE_LEVEL_INFO,
10975 "%s: This is a P2P Search", __func__);
10976 scanRequest.p2pSearch = 1;
10977
10978 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053010979 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010980 /* set requestType to P2P Discovery */
10981 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
10982 }
10983
10984 /*
10985 Skip Dfs Channel in case of P2P Search
10986 if it is set in ini file
10987 */
10988 if(cfg_param->skipDfsChnlInP2pSearch)
10989 {
10990 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010991 }
10992 else
10993 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010994 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010995 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010996
Agarwal Ashish4f616132013-12-30 23:32:50 +053010997 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010998 }
10999 }
11000
11001 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
11002
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053011003#ifdef FEATURE_WLAN_TDLS
11004 /* if tdls disagree scan right now, return immediately.
11005 tdls will schedule the scan when scan is allowed. (return SUCCESS)
11006 or will reject the scan if any TDLS is in progress. (return -EBUSY)
11007 */
11008 status = wlan_hdd_tdls_scan_callback (pAdapter,
11009 wiphy,
11010#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11011 dev,
11012#endif
11013 request);
11014 if(status <= 0)
11015 {
11016 if(!status)
11017 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
11018 "scan rejected %d", __func__, status);
11019 else
11020 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
11021 __func__, status);
11022
11023 return status;
11024 }
11025#endif
11026
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070011027 /* acquire the wakelock to avoid the apps suspend during the scan. To
11028 * address the following issues.
11029 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
11030 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
11031 * for long time, this result in apps running at full power for long time.
11032 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
11033 * be stuck in full power because of resume BMPS
11034 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011035 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070011036
Nirav Shah20ac06f2013-12-12 18:14:06 +053011037 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
11038 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011039 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
11040 scanRequest.requestType, scanRequest.scanType,
11041 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053011042 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
11043
Siddharth Bhal76972212014-10-15 16:22:51 +053011044 if (pHddCtx->spoofMacAddr.isEnabled)
11045 {
11046 hddLog(VOS_TRACE_LEVEL_INFO,
11047 "%s: MAC Spoofing enabled for current scan", __func__);
11048 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
11049 * to fill TxBds for probe request during current scan
11050 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011051 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053011052 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011053
11054 if(status != VOS_STATUS_SUCCESS)
11055 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011056 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011057 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053011058#ifdef FEATURE_WLAN_TDLS
11059 wlan_hdd_tdls_scan_done_callback(pAdapter);
11060#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011061 goto free_mem;
11062 }
Siddharth Bhal76972212014-10-15 16:22:51 +053011063 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053011064 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070011065 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011066 pAdapter->sessionId, &scanRequest, &scanId,
11067 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070011068
Jeff Johnson295189b2012-06-20 16:38:30 -070011069 if (eHAL_STATUS_SUCCESS != status)
11070 {
11071 hddLog(VOS_TRACE_LEVEL_ERROR,
11072 "%s: sme_ScanRequest returned error %d", __func__, status);
11073 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011074 if(eHAL_STATUS_RESOURCES == status)
11075 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053011076 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
11077 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011078 status = -EBUSY;
11079 } else {
11080 status = -EIO;
11081 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011082 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053011083
11084#ifdef FEATURE_WLAN_TDLS
11085 wlan_hdd_tdls_scan_done_callback(pAdapter);
11086#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011087 goto free_mem;
11088 }
11089
11090 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053011091 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011092 pAdapter->request = request;
11093 pScanInfo->scanId = scanId;
11094
11095 complete(&pScanInfo->scan_req_completion_event);
11096
11097free_mem:
11098 if( scanRequest.SSIDs.SSIDList )
11099 {
11100 vos_mem_free(scanRequest.SSIDs.SSIDList);
11101 }
11102
11103 if( channelList )
11104 vos_mem_free( channelList );
11105
11106 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011107 return status;
11108}
11109
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011110int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
11111#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11112 struct net_device *dev,
11113#endif
11114 struct cfg80211_scan_request *request)
11115{
11116 int ret;
11117
11118 vos_ssr_protect(__func__);
11119 ret = __wlan_hdd_cfg80211_scan(wiphy,
11120#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11121 dev,
11122#endif
11123 request);
11124 vos_ssr_unprotect(__func__);
11125
11126 return ret;
11127}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011128
11129void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
11130{
11131 v_U8_t iniDot11Mode =
11132 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
11133 eHddDot11Mode hddDot11Mode = iniDot11Mode;
11134
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011135 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
11136 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011137 switch ( iniDot11Mode )
11138 {
11139 case eHDD_DOT11_MODE_AUTO:
11140 case eHDD_DOT11_MODE_11ac:
11141 case eHDD_DOT11_MODE_11ac_ONLY:
11142#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053011143 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
11144 sme_IsFeatureSupportedByFW(DOT11AC) )
11145 hddDot11Mode = eHDD_DOT11_MODE_11ac;
11146 else
11147 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011148#else
11149 hddDot11Mode = eHDD_DOT11_MODE_11n;
11150#endif
11151 break;
11152 case eHDD_DOT11_MODE_11n:
11153 case eHDD_DOT11_MODE_11n_ONLY:
11154 hddDot11Mode = eHDD_DOT11_MODE_11n;
11155 break;
11156 default:
11157 hddDot11Mode = iniDot11Mode;
11158 break;
11159 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011160#ifdef WLAN_FEATURE_AP_HT40_24G
11161 if (operationChannel > SIR_11B_CHANNEL_END)
11162#endif
11163 {
11164 /* This call decides required channel bonding mode */
11165 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011166 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
11167 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011168 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011169}
11170
Jeff Johnson295189b2012-06-20 16:38:30 -070011171/*
11172 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011173 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011174 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011175int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011176 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070011177{
11178 int status = 0;
11179 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080011180 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011181 v_U32_t roamId;
11182 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070011183 eCsrAuthType RSNAuthType;
11184
11185 ENTER();
11186
11187 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080011188 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11189
11190 status = wlan_hdd_validate_context(pHddCtx);
11191 if (status)
11192 {
Yue Mae36e3552014-03-05 17:06:20 -080011193 return status;
11194 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011195
Jeff Johnson295189b2012-06-20 16:38:30 -070011196 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
11197 {
11198 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
11199 return -EINVAL;
11200 }
11201
11202 pRoamProfile = &pWextState->roamProfile;
11203
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011204 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070011205 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011206 hdd_station_ctx_t *pHddStaCtx;
11207 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011208
Siddharth Bhalda0d1622015-04-24 15:47:49 +053011209 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
11210
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011211 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070011212 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
11213 {
11214 /*QoS not enabled in cfg file*/
11215 pRoamProfile->uapsd_mask = 0;
11216 }
11217 else
11218 {
11219 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011220 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070011221 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
11222 }
11223
11224 pRoamProfile->SSIDs.numOfSSIDs = 1;
11225 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
11226 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011227 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070011228 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
11229 ssid, ssid_len);
11230
11231 if (bssid)
11232 {
11233 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
11234 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
11235 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011236 /* Save BSSID in seperate variable as well, as RoamProfile
11237 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070011238 case of join failure we should send valid BSSID to supplicant
11239 */
11240 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
11241 WNI_CFG_BSSID_LEN);
11242 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070011243 else
11244 {
11245 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
11246 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011247
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011248 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
11249 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011250 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
11251 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011252 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011253 /*set gen ie*/
11254 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
11255 /*set auth*/
11256 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
11257 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011258#ifdef FEATURE_WLAN_WAPI
11259 if (pAdapter->wapi_info.nWapiMode)
11260 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011261 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011262 switch (pAdapter->wapi_info.wapiAuthMode)
11263 {
11264 case WAPI_AUTH_MODE_PSK:
11265 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011266 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011267 pAdapter->wapi_info.wapiAuthMode);
11268 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
11269 break;
11270 }
11271 case WAPI_AUTH_MODE_CERT:
11272 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011273 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011274 pAdapter->wapi_info.wapiAuthMode);
11275 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
11276 break;
11277 }
11278 } // End of switch
11279 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
11280 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
11281 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011282 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011283 pRoamProfile->AuthType.numEntries = 1;
11284 pRoamProfile->EncryptionType.numEntries = 1;
11285 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11286 pRoamProfile->mcEncryptionType.numEntries = 1;
11287 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11288 }
11289 }
11290#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011291#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011292 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011293 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11294 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
11295 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011296 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
11297 sizeof (tSirGtkOffloadParams));
11298 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011299 }
11300#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011301 pRoamProfile->csrPersona = pAdapter->device_mode;
11302
Jeff Johnson32d95a32012-09-10 13:15:23 -070011303 if( operatingChannel )
11304 {
11305 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
11306 pRoamProfile->ChannelInfo.numOfChannels = 1;
11307 }
Chet Lanctot186b5732013-03-18 10:26:30 -070011308 else
11309 {
11310 pRoamProfile->ChannelInfo.ChannelList = NULL;
11311 pRoamProfile->ChannelInfo.numOfChannels = 0;
11312 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011313 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
11314 {
11315 hdd_select_cbmode(pAdapter,operatingChannel);
11316 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011317
Agarwal Ashish40f9b872015-09-01 16:17:35 +053011318 /*
11319 * Change conn_state to connecting before sme_RoamConnect(),
11320 * because sme_RoamConnect() has a direct path to call
11321 * hdd_smeRoamCallback(), which will change the conn_state
11322 * If direct path, conn_state will be accordingly changed
11323 * to NotConnected or Associated by either
11324 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
11325 * in sme_RoamCallback()
11326 * if sme_RomConnect is to be queued,
11327 * Connecting state will remain until it is completed.
11328 * If connection state is not changed,
11329 * connection state will remain in eConnectionState_NotConnected state.
11330 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
11331 * if conn state is eConnectionState_NotConnected.
11332 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
11333 * informed of connect result indication which is an issue.
11334 */
11335
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011336 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11337 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053011338 {
11339 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053011340 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011341 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
11342 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053011343 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011344 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011345 pAdapter->sessionId, pRoamProfile, &roamId);
11346
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011347 if ((eHAL_STATUS_SUCCESS != status) &&
11348 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11349 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011350
11351 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053011352 hddLog(VOS_TRACE_LEVEL_ERROR,
11353 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
11354 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011355 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011356 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011357 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011358 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011359
11360 pRoamProfile->ChannelInfo.ChannelList = NULL;
11361 pRoamProfile->ChannelInfo.numOfChannels = 0;
11362
Jeff Johnson295189b2012-06-20 16:38:30 -070011363 }
11364 else
11365 {
11366 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
11367 return -EINVAL;
11368 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080011369 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011370 return status;
11371}
11372
11373/*
11374 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
11375 * This function is used to set the authentication type (OPEN/SHARED).
11376 *
11377 */
11378static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
11379 enum nl80211_auth_type auth_type)
11380{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011381 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011382 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11383
11384 ENTER();
11385
11386 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011387 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070011388 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011389 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011390 hddLog(VOS_TRACE_LEVEL_INFO,
11391 "%s: set authentication type to AUTOSWITCH", __func__);
11392 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
11393 break;
11394
11395 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011396#ifdef WLAN_FEATURE_VOWIFI_11R
11397 case NL80211_AUTHTYPE_FT:
11398#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011399 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011400 "%s: set authentication type to OPEN", __func__);
11401 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11402 break;
11403
11404 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011405 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011406 "%s: set authentication type to SHARED", __func__);
11407 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
11408 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011409#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011410 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011411 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011412 "%s: set authentication type to CCKM WPA", __func__);
11413 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
11414 break;
11415#endif
11416
11417
11418 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011419 hddLog(VOS_TRACE_LEVEL_ERROR,
11420 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011421 auth_type);
11422 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
11423 return -EINVAL;
11424 }
11425
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011426 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011427 pHddStaCtx->conn_info.authType;
11428 return 0;
11429}
11430
11431/*
11432 * FUNCTION: wlan_hdd_set_akm_suite
11433 * This function is used to set the key mgmt type(PSK/8021x).
11434 *
11435 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011436static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011437 u32 key_mgmt
11438 )
11439{
11440 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11441 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053011442 /* Should be in ieee802_11_defs.h */
11443#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
11444#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070011445 /*set key mgmt type*/
11446 switch(key_mgmt)
11447 {
11448 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053011449 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011450#ifdef WLAN_FEATURE_VOWIFI_11R
11451 case WLAN_AKM_SUITE_FT_PSK:
11452#endif
11453 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070011454 __func__);
11455 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
11456 break;
11457
11458 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053011459 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011460#ifdef WLAN_FEATURE_VOWIFI_11R
11461 case WLAN_AKM_SUITE_FT_8021X:
11462#endif
11463 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011464 __func__);
11465 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11466 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011467#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011468#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
11469#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
11470 case WLAN_AKM_SUITE_CCKM:
11471 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
11472 __func__);
11473 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
11474 break;
11475#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070011476#ifndef WLAN_AKM_SUITE_OSEN
11477#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
11478 case WLAN_AKM_SUITE_OSEN:
11479 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
11480 __func__);
11481 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11482 break;
11483#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011484
11485 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011486 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011487 __func__, key_mgmt);
11488 return -EINVAL;
11489
11490 }
11491 return 0;
11492}
11493
11494/*
11495 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011496 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070011497 * (NONE/WEP40/WEP104/TKIP/CCMP).
11498 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011499static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
11500 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070011501 bool ucast
11502 )
11503{
11504 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011505 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011506 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11507
11508 ENTER();
11509
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011510 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011511 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053011512 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070011513 __func__, cipher);
11514 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11515 }
11516 else
11517 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011518
Jeff Johnson295189b2012-06-20 16:38:30 -070011519 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011520 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011521 {
11522 case IW_AUTH_CIPHER_NONE:
11523 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11524 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011525
Jeff Johnson295189b2012-06-20 16:38:30 -070011526 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011527 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070011528 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011529
Jeff Johnson295189b2012-06-20 16:38:30 -070011530 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011531 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070011532 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011533
Jeff Johnson295189b2012-06-20 16:38:30 -070011534 case WLAN_CIPHER_SUITE_TKIP:
11535 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
11536 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011537
Jeff Johnson295189b2012-06-20 16:38:30 -070011538 case WLAN_CIPHER_SUITE_CCMP:
11539 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11540 break;
11541#ifdef FEATURE_WLAN_WAPI
11542 case WLAN_CIPHER_SUITE_SMS4:
11543 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
11544 break;
11545#endif
11546
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011547#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011548 case WLAN_CIPHER_SUITE_KRK:
11549 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
11550 break;
11551#endif
11552 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011553 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011554 __func__, cipher);
11555 return -EOPNOTSUPP;
11556 }
11557 }
11558
11559 if (ucast)
11560 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011561 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011562 __func__, encryptionType);
11563 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11564 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011565 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011566 encryptionType;
11567 }
11568 else
11569 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011570 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011571 __func__, encryptionType);
11572 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
11573 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
11574 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
11575 }
11576
11577 return 0;
11578}
11579
11580
11581/*
11582 * FUNCTION: wlan_hdd_cfg80211_set_ie
11583 * This function is used to parse WPA/RSN IE's.
11584 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011585int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011586#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11587 const u8 *ie,
11588#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011589 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011590#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011591 size_t ie_len
11592 )
11593{
11594 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011595#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11596 const u8 *genie = ie;
11597#else
Jeff Johnson295189b2012-06-20 16:38:30 -070011598 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011599#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011600 v_U16_t remLen = ie_len;
11601#ifdef FEATURE_WLAN_WAPI
11602 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
11603 u16 *tmp;
11604 v_U16_t akmsuiteCount;
11605 int *akmlist;
11606#endif
11607 ENTER();
11608
11609 /* clear previous assocAddIE */
11610 pWextState->assocAddIE.length = 0;
11611 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011612 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011613
11614 while (remLen >= 2)
11615 {
11616 v_U16_t eLen = 0;
11617 v_U8_t elementId;
11618 elementId = *genie++;
11619 eLen = *genie++;
11620 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011621
Arif Hussain6d2a3322013-11-17 19:50:10 -080011622 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070011623 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011624
11625 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070011626 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011627 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011628 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 -070011629 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011630 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011631 "%s: Invalid WPA IE", __func__);
11632 return -EINVAL;
11633 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011634 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070011635 {
11636 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011637 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011638 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011639
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011640 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011641 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011642 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
11643 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011644 VOS_ASSERT(0);
11645 return -ENOMEM;
11646 }
11647 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11648 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11649 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011650
Jeff Johnson295189b2012-06-20 16:38:30 -070011651 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
11652 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11653 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11654 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011655 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
11656 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011657 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
11658 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11659 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
11660 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
11661 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
11662 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011663 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053011664 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070011665 {
11666 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011667 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011668 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011669
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011670 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011671 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011672 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11673 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011674 VOS_ASSERT(0);
11675 return -ENOMEM;
11676 }
11677 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11678 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11679 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011680
Jeff Johnson295189b2012-06-20 16:38:30 -070011681 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11682 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11683 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011684#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011685 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
11686 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011687 /*Consider WFD IE, only for P2P Client */
11688 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
11689 {
11690 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011691 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011692 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011693
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011694 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011695 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011696 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11697 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011698 VOS_ASSERT(0);
11699 return -ENOMEM;
11700 }
11701 // WFD IE is saved to Additional IE ; it should be accumulated to handle
11702 // WPS IE + P2P IE + WFD IE
11703 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11704 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011705
Jeff Johnson295189b2012-06-20 16:38:30 -070011706 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11707 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11708 }
11709#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011710 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011711 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011712 HS20_OUI_TYPE_SIZE)) )
11713 {
11714 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011715 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011716 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011717
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011718 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011719 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011720 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11721 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011722 VOS_ASSERT(0);
11723 return -ENOMEM;
11724 }
11725 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11726 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011727
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011728 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11729 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11730 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011731 /* Appending OSEN Information Element in Assiciation Request */
11732 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
11733 OSEN_OUI_TYPE_SIZE)) )
11734 {
11735 v_U16_t curAddIELen = pWextState->assocAddIE.length;
11736 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
11737 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011738
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011739 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011740 {
11741 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11742 "Need bigger buffer space");
11743 VOS_ASSERT(0);
11744 return -ENOMEM;
11745 }
11746 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11747 pWextState->assocAddIE.length += eLen + 2;
11748
11749 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
11750 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11751 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11752 }
11753
Abhishek Singh4322e622015-06-10 15:42:54 +053011754 /* Update only for WPA IE */
11755 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
11756 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011757
11758 /* populating as ADDIE in beacon frames */
11759 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011760 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011761 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
11762 {
11763 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11764 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
11765 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11766 {
11767 hddLog(LOGE,
11768 "Coldn't pass "
11769 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
11770 }
11771 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
11772 else
11773 hddLog(LOGE,
11774 "Could not pass on "
11775 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
11776
11777 /* IBSS mode doesn't contain params->proberesp_ies still
11778 beaconIE's need to be populated in probe response frames */
11779 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
11780 {
11781 u16 rem_probe_resp_ie_len = eLen + 2;
11782 u8 probe_rsp_ie_len[3] = {0};
11783 u8 counter = 0;
11784
11785 /* Check Probe Resp Length if it is greater then 255 then
11786 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
11787 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
11788 not able Store More then 255 bytes into One Variable */
11789
11790 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
11791 {
11792 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
11793 {
11794 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
11795 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
11796 }
11797 else
11798 {
11799 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
11800 rem_probe_resp_ie_len = 0;
11801 }
11802 }
11803
11804 rem_probe_resp_ie_len = 0;
11805
11806 if (probe_rsp_ie_len[0] > 0)
11807 {
11808 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11809 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
11810 (tANI_U8*)(genie - 2),
11811 probe_rsp_ie_len[0], NULL,
11812 eANI_BOOLEAN_FALSE)
11813 == eHAL_STATUS_FAILURE)
11814 {
11815 hddLog(LOGE,
11816 "Could not pass"
11817 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
11818 }
11819 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
11820 }
11821
11822 if (probe_rsp_ie_len[1] > 0)
11823 {
11824 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11825 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
11826 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11827 probe_rsp_ie_len[1], NULL,
11828 eANI_BOOLEAN_FALSE)
11829 == eHAL_STATUS_FAILURE)
11830 {
11831 hddLog(LOGE,
11832 "Could not pass"
11833 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
11834 }
11835 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
11836 }
11837
11838 if (probe_rsp_ie_len[2] > 0)
11839 {
11840 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11841 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
11842 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11843 probe_rsp_ie_len[2], NULL,
11844 eANI_BOOLEAN_FALSE)
11845 == eHAL_STATUS_FAILURE)
11846 {
11847 hddLog(LOGE,
11848 "Could not pass"
11849 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
11850 }
11851 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
11852 }
11853
11854 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11855 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
11856 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11857 {
11858 hddLog(LOGE,
11859 "Could not pass"
11860 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
11861 }
11862 }
11863 else
11864 {
11865 // Reset WNI_CFG_PROBE_RSP Flags
11866 wlan_hdd_reset_prob_rspies(pAdapter);
11867
11868 hddLog(VOS_TRACE_LEVEL_INFO,
11869 "%s: No Probe Response IE received in set beacon",
11870 __func__);
11871 }
11872 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070011873 break;
11874 case DOT11F_EID_RSN:
11875 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
11876 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11877 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
11878 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
11879 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
11880 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053011881
11882 /* Appending Extended Capabilities with Interworking bit set
11883 * in Assoc Req.
11884 *
11885 * In assoc req this EXT Cap will only be taken into account if
11886 * interworkingService bit is set to 1. Currently
11887 * driver is only interested in interworkingService capability
11888 * from supplicant. If in future any other EXT Cap info is
11889 * required from supplicat, it needs to be handled while
11890 * sending Assoc Req in LIM.
11891 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011892 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011893 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011894 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011895 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011896 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011897
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011898 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011899 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011900 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11901 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011902 VOS_ASSERT(0);
11903 return -ENOMEM;
11904 }
11905 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11906 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011907
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011908 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11909 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11910 break;
11911 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011912#ifdef FEATURE_WLAN_WAPI
11913 case WLAN_EID_WAPI:
11914 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011915 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070011916 pAdapter->wapi_info.nWapiMode);
11917 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011918 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070011919 akmsuiteCount = WPA_GET_LE16(tmp);
11920 tmp = tmp + 1;
11921 akmlist = (int *)(tmp);
11922 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
11923 {
11924 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
11925 }
11926 else
11927 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011928 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070011929 VOS_ASSERT(0);
11930 return -EINVAL;
11931 }
11932
11933 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
11934 {
11935 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011936 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011937 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011938 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011939 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011940 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011941 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011942 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011943 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
11944 }
11945 break;
11946#endif
11947 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011948 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011949 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011950 /* when Unknown IE is received we should break and continue
11951 * to the next IE in the buffer instead we were returning
11952 * so changing this to break */
11953 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011954 }
11955 genie += eLen;
11956 remLen -= eLen;
11957 }
11958 EXIT();
11959 return 0;
11960}
11961
11962/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053011963 * FUNCTION: hdd_isWPAIEPresent
11964 * Parse the received IE to find the WPA IE
11965 *
11966 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011967static bool hdd_isWPAIEPresent(
11968#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
11969 const u8 *ie,
11970#else
11971 u8 *ie,
11972#endif
11973 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053011974{
11975 v_U8_t eLen = 0;
11976 v_U16_t remLen = ie_len;
11977 v_U8_t elementId = 0;
11978
11979 while (remLen >= 2)
11980 {
11981 elementId = *ie++;
11982 eLen = *ie++;
11983 remLen -= 2;
11984 if (eLen > remLen)
11985 {
11986 hddLog(VOS_TRACE_LEVEL_ERROR,
11987 "%s: IE length is wrong %d", __func__, eLen);
11988 return FALSE;
11989 }
11990 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
11991 {
11992 /* OUI - 0x00 0X50 0XF2
11993 WPA Information Element - 0x01
11994 WPA version - 0x01*/
11995 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
11996 return TRUE;
11997 }
11998 ie += eLen;
11999 remLen -= eLen;
12000 }
12001 return FALSE;
12002}
12003
12004/*
Jeff Johnson295189b2012-06-20 16:38:30 -070012005 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012006 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012007 * parameters during connect operation.
12008 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012009int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012010 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012011 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012012{
12013 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012014 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012015 ENTER();
12016
12017 /*set wpa version*/
12018 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
12019
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012020 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070012021 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053012022 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070012023 {
12024 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12025 }
12026 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
12027 {
12028 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12029 }
12030 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012031
12032 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012033 pWextState->wpaVersion);
12034
12035 /*set authentication type*/
12036 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
12037
12038 if (0 > status)
12039 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012040 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012041 "%s: failed to set authentication type ", __func__);
12042 return status;
12043 }
12044
12045 /*set key mgmt type*/
12046 if (req->crypto.n_akm_suites)
12047 {
12048 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
12049 if (0 > status)
12050 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012051 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070012052 __func__);
12053 return status;
12054 }
12055 }
12056
12057 /*set pairwise cipher type*/
12058 if (req->crypto.n_ciphers_pairwise)
12059 {
12060 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
12061 req->crypto.ciphers_pairwise[0], true);
12062 if (0 > status)
12063 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012064 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012065 "%s: failed to set unicast cipher type", __func__);
12066 return status;
12067 }
12068 }
12069 else
12070 {
12071 /*Reset previous cipher suite to none*/
12072 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
12073 if (0 > status)
12074 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012075 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012076 "%s: failed to set unicast cipher type", __func__);
12077 return status;
12078 }
12079 }
12080
12081 /*set group cipher type*/
12082 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
12083 false);
12084
12085 if (0 > status)
12086 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012087 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070012088 __func__);
12089 return status;
12090 }
12091
Chet Lanctot186b5732013-03-18 10:26:30 -070012092#ifdef WLAN_FEATURE_11W
12093 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
12094#endif
12095
Jeff Johnson295189b2012-06-20 16:38:30 -070012096 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
12097 if (req->ie_len)
12098 {
12099 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
12100 if ( 0 > status)
12101 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012102 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012103 __func__);
12104 return status;
12105 }
12106 }
12107
12108 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012109 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012110 {
12111 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
12112 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
12113 )
12114 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012115 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070012116 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
12117 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012118 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012119 __func__);
12120 return -EOPNOTSUPP;
12121 }
12122 else
12123 {
12124 u8 key_len = req->key_len;
12125 u8 key_idx = req->key_idx;
12126
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012127 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012128 && (CSR_MAX_NUM_KEY > key_idx)
12129 )
12130 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012131 hddLog(VOS_TRACE_LEVEL_INFO,
12132 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012133 __func__, key_idx, key_len);
12134 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012135 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012136 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012137 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070012138 (u8)key_len;
12139 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
12140 }
12141 }
12142 }
12143 }
12144
12145 return status;
12146}
12147
12148/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012149 * FUNCTION: wlan_hdd_try_disconnect
12150 * This function is used to disconnect from previous
12151 * connection
12152 */
12153static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
12154{
12155 long ret = 0;
12156 hdd_station_ctx_t *pHddStaCtx;
12157 eMib_dot11DesiredBssType connectedBssType;
12158
12159 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12160
12161 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
12162
12163 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
12164 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
12165 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
12166 {
12167 /* Issue disconnect to CSR */
12168 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12169 if( eHAL_STATUS_SUCCESS ==
12170 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12171 pAdapter->sessionId,
12172 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
12173 {
12174 ret = wait_for_completion_interruptible_timeout(
12175 &pAdapter->disconnect_comp_var,
12176 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12177 if (0 >= ret)
12178 {
12179 hddLog(LOGE, FL("Failed to receive disconnect event"));
12180 return -EALREADY;
12181 }
12182 }
12183 }
12184 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
12185 {
12186 ret = wait_for_completion_interruptible_timeout(
12187 &pAdapter->disconnect_comp_var,
12188 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12189 if (0 >= ret)
12190 {
12191 hddLog(LOGE, FL("Failed to receive disconnect event"));
12192 return -EALREADY;
12193 }
12194 }
12195
12196 return 0;
12197}
12198
12199/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053012200 * FUNCTION: __wlan_hdd_cfg80211_connect
12201 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070012202 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012203static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012204 struct net_device *ndev,
12205 struct cfg80211_connect_params *req
12206 )
12207{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012208 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012209 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012210 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053012211 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012212
12213 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012214
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012215 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12216 TRACE_CODE_HDD_CFG80211_CONNECT,
12217 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012218 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012219 "%s: device_mode = %s (%d)", __func__,
12220 hdd_device_modetoString(pAdapter->device_mode),
12221 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012222
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012223 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012224 if (!pHddCtx)
12225 {
12226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12227 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053012228 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012229 }
12230
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012231 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012232 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012233 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012234 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012235 }
12236
Agarwal Ashish51325b52014-06-16 16:50:49 +053012237 if (vos_max_concurrent_connections_reached()) {
12238 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12239 return -ECONNREFUSED;
12240 }
12241
Jeff Johnson295189b2012-06-20 16:38:30 -070012242#ifdef WLAN_BTAMP_FEATURE
12243 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012244 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070012245 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012246 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012247 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080012248 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012249 }
12250#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012251
12252 //If Device Mode is Station Concurrent Sessions Exit BMps
12253 //P2P Mode will be taken care in Open/close adapter
12254 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012255 (vos_concurrent_open_sessions_running())) {
12256 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
12257 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012258 }
12259
12260 /*Try disconnecting if already in connected state*/
12261 status = wlan_hdd_try_disconnect(pAdapter);
12262 if ( 0 > status)
12263 {
12264 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12265 " connection"));
12266 return -EALREADY;
12267 }
12268
Jeff Johnson295189b2012-06-20 16:38:30 -070012269 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012270 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070012271
12272 if ( 0 > status)
12273 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012274 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070012275 __func__);
12276 return status;
12277 }
Mohit Khanna765234a2012-09-11 15:08:35 -070012278 if ( req->channel )
12279 {
12280 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
12281 req->ssid_len, req->bssid,
12282 req->channel->hw_value);
12283 }
12284 else
12285 {
12286 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012287 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070012288 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012289
Sushant Kaushikd7083982015-03-18 14:33:24 +053012290 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012291 {
12292 //ReEnable BMPS if disabled
12293 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
12294 (NULL != pHddCtx))
12295 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012296 if (pHddCtx->hdd_wlan_suspended)
12297 {
12298 hdd_set_pwrparams(pHddCtx);
12299 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012300 //ReEnable Bmps and Imps back
12301 hdd_enable_bmps_imps(pHddCtx);
12302 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053012303 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012304 return status;
12305 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012306 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012307 EXIT();
12308 return status;
12309}
12310
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012311static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
12312 struct net_device *ndev,
12313 struct cfg80211_connect_params *req)
12314{
12315 int ret;
12316 vos_ssr_protect(__func__);
12317 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
12318 vos_ssr_unprotect(__func__);
12319
12320 return ret;
12321}
Jeff Johnson295189b2012-06-20 16:38:30 -070012322
12323/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012324 * FUNCTION: wlan_hdd_disconnect
12325 * This function is used to issue a disconnect request to SME
12326 */
12327int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
12328{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012329 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012330 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012331 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012332 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012333
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012334 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012335
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012336 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012337 if (0 != status)
12338 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012339 return status;
12340 }
12341
Sushant Kaushikb4834d22015-07-15 15:29:05 +053012342 if (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)
12343 {
12344 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
12345 pAdapter->sessionId);
12346 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012347 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012348
Agarwal Ashish47d18112014-08-04 19:55:07 +053012349 /* Need to apply spin lock before decreasing active sessions
12350 * as there can be chance for double decrement if context switch
12351 * Calls hdd_DisConnectHandler.
12352 */
12353
12354 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012355 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
12356 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012357 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
12358 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053012359 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
12360 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012361
Abhishek Singhf4669da2014-05-26 15:07:49 +053012362 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053012363 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
12364
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012365 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012366
Mihir Shete182a0b22014-08-18 16:08:48 +053012367 /*
12368 * stop tx queues before deleting STA/BSS context from the firmware.
12369 * tx has to be disabled because the firmware can get busy dropping
12370 * the tx frames after BSS/STA has been deleted and will not send
12371 * back a response resulting in WDI timeout
12372 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053012373 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053012374 netif_tx_disable(pAdapter->dev);
12375 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012376
Mihir Shete182a0b22014-08-18 16:08:48 +053012377 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012378 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12379 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012380 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
12381 {
12382 hddLog(VOS_TRACE_LEVEL_INFO,
12383 FL("status = %d, already disconnected"),
12384 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012385
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012386 }
12387 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012388 {
12389 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012390 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012391 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012392 result = -EINVAL;
12393 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012394 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012395 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012396 &pAdapter->disconnect_comp_var,
12397 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012398 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012399 {
12400 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012401 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012402 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012403 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012404 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012405 {
12406 hddLog(VOS_TRACE_LEVEL_ERROR,
12407 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012408 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012409 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012410disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012411 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12412 FL("Set HDD connState to eConnectionState_NotConnected"));
12413 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
12414
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012415 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012416 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012417}
12418
12419
12420/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012421 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070012422 * This function is used to issue a disconnect request to SME
12423 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012424static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012425 struct net_device *dev,
12426 u16 reason
12427 )
12428{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012429 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012430 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012431 tCsrRoamProfile *pRoamProfile;
12432 hdd_station_ctx_t *pHddStaCtx;
12433 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012434#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012435 tANI_U8 staIdx;
12436#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012437
Jeff Johnson295189b2012-06-20 16:38:30 -070012438 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012439
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012440 if (!pAdapter) {
12441 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
12442 return -EINVAL;
12443 }
12444
12445 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12446 if (!pHddStaCtx) {
12447 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
12448 return -EINVAL;
12449 }
12450
12451 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12452 status = wlan_hdd_validate_context(pHddCtx);
12453 if (0 != status)
12454 {
12455 return status;
12456 }
12457
12458 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
12459
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012460 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12461 TRACE_CODE_HDD_CFG80211_DISCONNECT,
12462 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012463 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
12464 __func__, hdd_device_modetoString(pAdapter->device_mode),
12465 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012466
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012467 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
12468 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070012469
Jeff Johnson295189b2012-06-20 16:38:30 -070012470 if (NULL != pRoamProfile)
12471 {
12472 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012473 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
12474 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070012475 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012476 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070012477 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012478 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012479 switch(reason)
12480 {
12481 case WLAN_REASON_MIC_FAILURE:
12482 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
12483 break;
12484
12485 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
12486 case WLAN_REASON_DISASSOC_AP_BUSY:
12487 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
12488 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
12489 break;
12490
12491 case WLAN_REASON_PREV_AUTH_NOT_VALID:
12492 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053012493 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070012494 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
12495 break;
12496
Jeff Johnson295189b2012-06-20 16:38:30 -070012497 default:
12498 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
12499 break;
12500 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012501 pScanInfo = &pHddCtx->scan_info;
12502 if (pScanInfo->mScanPending)
12503 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012504 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012505 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053012506 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012507 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012508 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053012509 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012510#ifdef FEATURE_WLAN_TDLS
12511 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012512 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012513 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012514 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
12515 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012516 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012517 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012518 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012519 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012520 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012521 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012522 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012523 status = sme_DeleteTdlsPeerSta(
12524 WLAN_HDD_GET_HAL_CTX(pAdapter),
12525 pAdapter->sessionId,
12526 mac);
12527 if (status != eHAL_STATUS_SUCCESS) {
12528 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
12529 return -EPERM;
12530 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012531 }
12532 }
12533#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012534 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012535 status = wlan_hdd_disconnect(pAdapter, reasonCode);
12536 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070012537 {
12538 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012539 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012540 __func__, (int)status );
12541 return -EINVAL;
12542 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012543 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012544 else
12545 {
12546 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
12547 "called while in %d state", __func__,
12548 pHddStaCtx->conn_info.connState);
12549 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012550 }
12551 else
12552 {
12553 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
12554 }
12555
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012556 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012557 return status;
12558}
12559
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012560static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
12561 struct net_device *dev,
12562 u16 reason
12563 )
12564{
12565 int ret;
12566 vos_ssr_protect(__func__);
12567 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
12568 vos_ssr_unprotect(__func__);
12569
12570 return ret;
12571}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012572
Jeff Johnson295189b2012-06-20 16:38:30 -070012573/*
12574 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012575 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012576 * settings in IBSS mode.
12577 */
12578static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012579 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012580 struct cfg80211_ibss_params *params
12581 )
12582{
12583 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012584 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012585 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
12586 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012587
Jeff Johnson295189b2012-06-20 16:38:30 -070012588 ENTER();
12589
12590 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070012591 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070012592
12593 if (params->ie_len && ( NULL != params->ie) )
12594 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012595 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12596 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012597 {
12598 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12599 encryptionType = eCSR_ENCRYPT_TYPE_AES;
12600 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012601 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012602 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012603 tDot11fIEWPA dot11WPAIE;
12604 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012605 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012606
Wilson Yang00256342013-10-10 23:13:38 -070012607 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012608 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12609 params->ie_len, DOT11F_EID_WPA);
12610 if ( NULL != ie )
12611 {
12612 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12613 // Unpack the WPA IE
12614 //Skip past the EID byte and length byte - and four byte WiFi OUI
12615 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
12616 &ie[2+4],
12617 ie[1] - 4,
12618 &dot11WPAIE);
12619 /*Extract the multicast cipher, the encType for unicast
12620 cipher for wpa-none is none*/
12621 encryptionType =
12622 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
12623 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012624 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012625
Jeff Johnson295189b2012-06-20 16:38:30 -070012626 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
12627
12628 if (0 > status)
12629 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012630 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012631 __func__);
12632 return status;
12633 }
12634 }
12635
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012636 pWextState->roamProfile.AuthType.authType[0] =
12637 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012638 eCSR_AUTH_TYPE_OPEN_SYSTEM;
12639
12640 if (params->privacy)
12641 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012642 /* Security enabled IBSS, At this time there is no information available
12643 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070012644 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012645 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070012646 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012647 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070012648 *enable privacy bit in beacons */
12649
12650 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
12651 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012652 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
12653 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012654 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
12655 pWextState->roamProfile.EncryptionType.numEntries = 1;
12656 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012657 return status;
12658}
12659
12660/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012661 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012662 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012663 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012664static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012665 struct net_device *dev,
12666 struct cfg80211_ibss_params *params
12667 )
12668{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012669 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012670 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12671 tCsrRoamProfile *pRoamProfile;
12672 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012673 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12674 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012675 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070012676
12677 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012678
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012679 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12680 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
12681 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012682 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012683 "%s: device_mode = %s (%d)", __func__,
12684 hdd_device_modetoString(pAdapter->device_mode),
12685 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012686
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012687 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012688 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012689 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012690 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012691 }
12692
12693 if (NULL == pWextState)
12694 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012695 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012696 __func__);
12697 return -EIO;
12698 }
12699
Agarwal Ashish51325b52014-06-16 16:50:49 +053012700 if (vos_max_concurrent_connections_reached()) {
12701 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12702 return -ECONNREFUSED;
12703 }
12704
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012705 /*Try disconnecting if already in connected state*/
12706 status = wlan_hdd_try_disconnect(pAdapter);
12707 if ( 0 > status)
12708 {
12709 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12710 " IBSS connection"));
12711 return -EALREADY;
12712 }
12713
Jeff Johnson295189b2012-06-20 16:38:30 -070012714 pRoamProfile = &pWextState->roamProfile;
12715
12716 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
12717 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012718 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012719 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012720 return -EINVAL;
12721 }
12722
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012723 /* BSSID is provided by upper layers hence no need to AUTO generate */
12724 if (NULL != params->bssid) {
12725 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12726 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
12727 hddLog (VOS_TRACE_LEVEL_ERROR,
12728 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12729 return -EIO;
12730 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012731 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012732 }
krunal sonie9002db2013-11-25 14:24:17 -080012733 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
12734 {
12735 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12736 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
12737 {
12738 hddLog (VOS_TRACE_LEVEL_ERROR,
12739 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12740 return -EIO;
12741 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012742
12743 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080012744 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012745 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080012746 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012747
Jeff Johnson295189b2012-06-20 16:38:30 -070012748 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070012749 if (NULL !=
12750#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12751 params->chandef.chan)
12752#else
12753 params->channel)
12754#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012755 {
12756 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012757 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12758 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
12759 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12760 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012761
12762 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012763 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070012764 ieee80211_frequency_to_channel(
12765#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12766 params->chandef.chan->center_freq);
12767#else
12768 params->channel->center_freq);
12769#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012770
12771 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
12772 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070012773 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012774 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
12775 __func__);
12776 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070012777 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012778
12779 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012780 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012781 if (channelNum == validChan[indx])
12782 {
12783 break;
12784 }
12785 }
12786 if (indx >= numChans)
12787 {
12788 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012789 __func__, channelNum);
12790 return -EINVAL;
12791 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012792 /* Set the Operational Channel */
12793 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
12794 channelNum);
12795 pRoamProfile->ChannelInfo.numOfChannels = 1;
12796 pHddStaCtx->conn_info.operationChannel = channelNum;
12797 pRoamProfile->ChannelInfo.ChannelList =
12798 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070012799 }
12800
12801 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012802 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070012803 if (status < 0)
12804 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012805 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070012806 __func__);
12807 return status;
12808 }
12809
12810 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012811 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012812 params->ssid_len, params->bssid,
12813 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070012814
12815 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012816 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012817
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012818 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012819 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012820}
12821
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012822static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
12823 struct net_device *dev,
12824 struct cfg80211_ibss_params *params
12825 )
12826{
12827 int ret = 0;
12828
12829 vos_ssr_protect(__func__);
12830 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
12831 vos_ssr_unprotect(__func__);
12832
12833 return ret;
12834}
12835
Jeff Johnson295189b2012-06-20 16:38:30 -070012836/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012837 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012838 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012839 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012840static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012841 struct net_device *dev
12842 )
12843{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012844 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012845 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12846 tCsrRoamProfile *pRoamProfile;
12847 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012848 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012849
12850 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012851
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012852 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12853 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
12854 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012855 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012856 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012857 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012858 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012859 }
12860
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012861 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
12862 hdd_device_modetoString(pAdapter->device_mode),
12863 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012864 if (NULL == pWextState)
12865 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012866 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012867 __func__);
12868 return -EIO;
12869 }
12870
12871 pRoamProfile = &pWextState->roamProfile;
12872
12873 /* Issue disconnect only if interface type is set to IBSS */
12874 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
12875 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012876 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070012877 __func__);
12878 return -EINVAL;
12879 }
12880
12881 /* Issue Disconnect request */
12882 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12883 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
12884 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
12885
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012886 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012887 return 0;
12888}
12889
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012890static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
12891 struct net_device *dev
12892 )
12893{
12894 int ret = 0;
12895
12896 vos_ssr_protect(__func__);
12897 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
12898 vos_ssr_unprotect(__func__);
12899
12900 return ret;
12901}
12902
Jeff Johnson295189b2012-06-20 16:38:30 -070012903/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012904 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070012905 * This function is used to set the phy parameters
12906 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
12907 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012908static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012909 u32 changed)
12910{
12911 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
12912 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012913 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012914
12915 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012916
12917 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012918 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
12919 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012920
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012921 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012922 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012923 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012924 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012925 }
12926
Jeff Johnson295189b2012-06-20 16:38:30 -070012927 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
12928 {
12929 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
12930 WNI_CFG_RTS_THRESHOLD_STAMAX :
12931 wiphy->rts_threshold;
12932
12933 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012934 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070012935 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012936 hddLog(VOS_TRACE_LEVEL_ERROR,
12937 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012938 __func__, rts_threshold);
12939 return -EINVAL;
12940 }
12941
12942 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
12943 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012944 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012945 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012946 hddLog(VOS_TRACE_LEVEL_ERROR,
12947 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012948 __func__, rts_threshold);
12949 return -EIO;
12950 }
12951
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012952 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012953 rts_threshold);
12954 }
12955
12956 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
12957 {
12958 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
12959 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
12960 wiphy->frag_threshold;
12961
12962 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012963 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012964 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012965 hddLog(VOS_TRACE_LEVEL_ERROR,
12966 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012967 frag_threshold);
12968 return -EINVAL;
12969 }
12970
12971 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
12972 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012973 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012974 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012975 hddLog(VOS_TRACE_LEVEL_ERROR,
12976 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012977 __func__, frag_threshold);
12978 return -EIO;
12979 }
12980
12981 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
12982 frag_threshold);
12983 }
12984
12985 if ((changed & WIPHY_PARAM_RETRY_SHORT)
12986 || (changed & WIPHY_PARAM_RETRY_LONG))
12987 {
12988 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
12989 wiphy->retry_short :
12990 wiphy->retry_long;
12991
12992 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
12993 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
12994 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012995 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012996 __func__, retry_value);
12997 return -EINVAL;
12998 }
12999
13000 if (changed & WIPHY_PARAM_RETRY_SHORT)
13001 {
13002 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
13003 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013004 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013005 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013006 hddLog(VOS_TRACE_LEVEL_ERROR,
13007 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013008 __func__, retry_value);
13009 return -EIO;
13010 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013011 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013012 __func__, retry_value);
13013 }
13014 else if (changed & WIPHY_PARAM_RETRY_SHORT)
13015 {
13016 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
13017 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013018 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013019 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013020 hddLog(VOS_TRACE_LEVEL_ERROR,
13021 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013022 __func__, retry_value);
13023 return -EIO;
13024 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013025 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013026 __func__, retry_value);
13027 }
13028 }
13029
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013030 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013031 return 0;
13032}
13033
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013034static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
13035 u32 changed)
13036{
13037 int ret;
13038
13039 vos_ssr_protect(__func__);
13040 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
13041 vos_ssr_unprotect(__func__);
13042
13043 return ret;
13044}
13045
Jeff Johnson295189b2012-06-20 16:38:30 -070013046/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013047 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013048 * This function is used to set the txpower
13049 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013050static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013051#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13052 struct wireless_dev *wdev,
13053#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013054#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013055 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013056#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013057 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013058#endif
13059 int dbm)
13060{
13061 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013062 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013063 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
13064 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013065 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013066
13067 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013068
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013069 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13070 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
13071 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013072 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013073 if (0 != status)
13074 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013075 return status;
13076 }
13077
13078 hHal = pHddCtx->hHal;
13079
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013080 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
13081 dbm, ccmCfgSetCallback,
13082 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013083 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013084 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013085 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
13086 return -EIO;
13087 }
13088
13089 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
13090 dbm);
13091
13092 switch(type)
13093 {
13094 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
13095 /* Fall through */
13096 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
13097 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
13098 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013099 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
13100 __func__);
13101 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070013102 }
13103 break;
13104 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013105 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070013106 __func__);
13107 return -EOPNOTSUPP;
13108 break;
13109 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013110 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
13111 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070013112 return -EIO;
13113 }
13114
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013115 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013116 return 0;
13117}
13118
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013119static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
13120#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13121 struct wireless_dev *wdev,
13122#endif
13123#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13124 enum tx_power_setting type,
13125#else
13126 enum nl80211_tx_power_setting type,
13127#endif
13128 int dbm)
13129{
13130 int ret;
13131 vos_ssr_protect(__func__);
13132 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
13133#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13134 wdev,
13135#endif
13136#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13137 type,
13138#else
13139 type,
13140#endif
13141 dbm);
13142 vos_ssr_unprotect(__func__);
13143
13144 return ret;
13145}
13146
Jeff Johnson295189b2012-06-20 16:38:30 -070013147/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013148 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013149 * This function is used to read the txpower
13150 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013151static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013152#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13153 struct wireless_dev *wdev,
13154#endif
13155 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070013156{
13157
13158 hdd_adapter_t *pAdapter;
13159 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013160 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013161
Jeff Johnsone7245742012-09-05 17:12:55 -070013162 ENTER();
13163
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013164 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013165 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013166 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013167 *dbm = 0;
13168 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013169 }
13170
Jeff Johnson295189b2012-06-20 16:38:30 -070013171 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
13172 if (NULL == pAdapter)
13173 {
13174 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
13175 return -ENOENT;
13176 }
13177
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053013178 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13179 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
13180 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070013181 wlan_hdd_get_classAstats(pAdapter);
13182 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
13183
Jeff Johnsone7245742012-09-05 17:12:55 -070013184 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013185 return 0;
13186}
13187
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013188static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
13189#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13190 struct wireless_dev *wdev,
13191#endif
13192 int *dbm)
13193{
13194 int ret;
13195
13196 vos_ssr_protect(__func__);
13197 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
13198#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13199 wdev,
13200#endif
13201 dbm);
13202 vos_ssr_unprotect(__func__);
13203
13204 return ret;
13205}
13206
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013207static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013208#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13209 const u8* mac,
13210#else
13211 u8* mac,
13212#endif
13213 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070013214{
13215 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13216 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13217 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053013218 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013219
13220 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
13221 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070013222
13223 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
13224 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
13225 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
13226 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
13227 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
13228 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
13229 tANI_U16 maxRate = 0;
13230 tANI_U16 myRate;
13231 tANI_U16 currentRate = 0;
13232 tANI_U8 maxSpeedMCS = 0;
13233 tANI_U8 maxMCSIdx = 0;
13234 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053013235 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013236 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013237 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013238
Leo Chang6f8870f2013-03-26 18:11:36 -070013239#ifdef WLAN_FEATURE_11AC
13240 tANI_U32 vht_mcs_map;
13241 eDataRate11ACMaxMcs vhtMaxMcs;
13242#endif /* WLAN_FEATURE_11AC */
13243
Jeff Johnsone7245742012-09-05 17:12:55 -070013244 ENTER();
13245
Jeff Johnson295189b2012-06-20 16:38:30 -070013246 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
13247 (0 == ssidlen))
13248 {
13249 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
13250 " Invalid ssidlen, %d", __func__, ssidlen);
13251 /*To keep GUI happy*/
13252 return 0;
13253 }
13254
Mukul Sharma811205f2014-07-09 21:07:30 +053013255 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
13256 {
13257 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13258 "%s: Roaming in progress, so unable to proceed this request", __func__);
13259 return 0;
13260 }
13261
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013262 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013263 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013264 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013265 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013266 }
13267
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053013268 wlan_hdd_get_station_stats(pAdapter);
13269 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013270
Kiet Lam3b17fc82013-09-27 05:24:08 +053013271 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
13272 sinfo->filled |= STATION_INFO_SIGNAL;
13273
c_hpothu09f19542014-05-30 21:53:31 +053013274 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053013275 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
13276 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053013277 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053013278 {
13279 rate_flags = pAdapter->maxRateFlags;
13280 }
c_hpothu44ff4e02014-05-08 00:13:57 +053013281
Jeff Johnson295189b2012-06-20 16:38:30 -070013282 //convert to the UI units of 100kbps
13283 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
13284
13285#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070013286 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 -070013287 sinfo->signal,
13288 pCfg->reportMaxLinkSpeed,
13289 myRate,
13290 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013291 (int) pCfg->linkSpeedRssiMid,
13292 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070013293 (int) rate_flags,
13294 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013295#endif //LINKSPEED_DEBUG_ENABLED
13296
13297 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
13298 {
13299 // we do not want to necessarily report the current speed
13300 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
13301 {
13302 // report the max possible speed
13303 rssidx = 0;
13304 }
13305 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
13306 {
13307 // report the max possible speed with RSSI scaling
13308 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
13309 {
13310 // report the max possible speed
13311 rssidx = 0;
13312 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013313 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070013314 {
13315 // report middle speed
13316 rssidx = 1;
13317 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013318 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
13319 {
13320 // report middle speed
13321 rssidx = 2;
13322 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 else
13324 {
13325 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013326 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070013327 }
13328 }
13329 else
13330 {
13331 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
13332 hddLog(VOS_TRACE_LEVEL_ERROR,
13333 "%s: Invalid value for reportMaxLinkSpeed: %u",
13334 __func__, pCfg->reportMaxLinkSpeed);
13335 rssidx = 0;
13336 }
13337
13338 maxRate = 0;
13339
13340 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013341 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
13342 OperationalRates, &ORLeng))
13343 {
13344 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13345 /*To keep GUI happy*/
13346 return 0;
13347 }
13348
Jeff Johnson295189b2012-06-20 16:38:30 -070013349 for (i = 0; i < ORLeng; i++)
13350 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013351 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013352 {
13353 /* Validate Rate Set */
13354 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
13355 {
13356 currentRate = supported_data_rate[j].supported_rate[rssidx];
13357 break;
13358 }
13359 }
13360 /* Update MAX rate */
13361 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13362 }
13363
13364 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013365 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
13366 ExtendedRates, &ERLeng))
13367 {
13368 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13369 /*To keep GUI happy*/
13370 return 0;
13371 }
13372
Jeff Johnson295189b2012-06-20 16:38:30 -070013373 for (i = 0; i < ERLeng; i++)
13374 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013375 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013376 {
13377 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
13378 {
13379 currentRate = supported_data_rate[j].supported_rate[rssidx];
13380 break;
13381 }
13382 }
13383 /* Update MAX rate */
13384 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13385 }
c_hpothu79aab322014-07-14 21:11:01 +053013386
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013387 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053013388 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013389 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053013390 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070013391 {
c_hpothu79aab322014-07-14 21:11:01 +053013392 if (rate_flags & eHAL_TX_RATE_VHT80)
13393 mode = 2;
13394 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
13395 mode = 1;
13396 else
13397 mode = 0;
13398
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013399 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
13400 MCSRates, &MCSLeng))
13401 {
13402 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13403 /*To keep GUI happy*/
13404 return 0;
13405 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013406 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070013407#ifdef WLAN_FEATURE_11AC
13408 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013409 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070013410 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013411 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013412 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070013413 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070013414 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013415 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013416 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013417 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070013418 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013419 maxMCSIdx = 7;
13420 }
13421 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
13422 {
13423 maxMCSIdx = 8;
13424 }
13425 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
13426 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013427 //VHT20 is supporting 0~8
13428 if (rate_flags & eHAL_TX_RATE_VHT20)
13429 maxMCSIdx = 8;
13430 else
13431 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070013432 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013433
c_hpothu79aab322014-07-14 21:11:01 +053013434 if (0 != rssidx)/*check for scaled */
13435 {
13436 //get middle rate MCS index if rssi=1/2
13437 for (i=0; i <= maxMCSIdx; i++)
13438 {
13439 if (sinfo->signal <= rssiMcsTbl[mode][i])
13440 {
13441 maxMCSIdx = i;
13442 break;
13443 }
13444 }
13445 }
13446
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013447 if (rate_flags & eHAL_TX_RATE_VHT80)
13448 {
13449 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
13450 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
13451 }
13452 else if (rate_flags & eHAL_TX_RATE_VHT40)
13453 {
13454 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
13455 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
13456 }
13457 else if (rate_flags & eHAL_TX_RATE_VHT20)
13458 {
13459 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
13460 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
13461 }
13462
Leo Chang6f8870f2013-03-26 18:11:36 -070013463 maxSpeedMCS = 1;
13464 if (currentRate > maxRate)
13465 {
13466 maxRate = currentRate;
13467 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013468
Leo Chang6f8870f2013-03-26 18:11:36 -070013469 }
13470 else
13471#endif /* WLAN_FEATURE_11AC */
13472 {
13473 if (rate_flags & eHAL_TX_RATE_HT40)
13474 {
13475 rateFlag |= 1;
13476 }
13477 if (rate_flags & eHAL_TX_RATE_SGI)
13478 {
13479 rateFlag |= 2;
13480 }
13481
Girish Gowli01abcee2014-07-31 20:18:55 +053013482 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053013483 if (rssidx == 1 || rssidx == 2)
13484 {
13485 //get middle rate MCS index if rssi=1/2
13486 for (i=0; i <= 7; i++)
13487 {
13488 if (sinfo->signal <= rssiMcsTbl[mode][i])
13489 {
13490 temp = i+1;
13491 break;
13492 }
13493 }
13494 }
c_hpothu79aab322014-07-14 21:11:01 +053013495
13496 for (i = 0; i < MCSLeng; i++)
13497 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013498 for (j = 0; j < temp; j++)
13499 {
13500 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
13501 {
13502 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013503 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013504 break;
13505 }
13506 }
13507 if ((j < temp) && (currentRate > maxRate))
13508 {
13509 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070013510 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013511 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013512 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013513 }
13514 }
13515
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013516 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
13517 {
13518 maxRate = myRate;
13519 maxSpeedMCS = 1;
13520 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13521 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013522 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053013523 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070013524 {
13525 maxRate = myRate;
13526 if (rate_flags & eHAL_TX_RATE_LEGACY)
13527 {
13528 maxSpeedMCS = 0;
13529 }
13530 else
13531 {
13532 maxSpeedMCS = 1;
13533 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13534 }
13535 }
13536
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013537 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 {
13539 sinfo->txrate.legacy = maxRate;
13540#ifdef LINKSPEED_DEBUG_ENABLED
13541 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
13542#endif //LINKSPEED_DEBUG_ENABLED
13543 }
13544 else
13545 {
13546 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070013547#ifdef WLAN_FEATURE_11AC
13548 sinfo->txrate.nss = 1;
13549 if (rate_flags & eHAL_TX_RATE_VHT80)
13550 {
13551 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013552 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070013553 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013554 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070013555 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013556 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13557 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13558 }
13559 else if (rate_flags & eHAL_TX_RATE_VHT20)
13560 {
13561 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13562 }
13563#endif /* WLAN_FEATURE_11AC */
13564 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
13565 {
13566 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13567 if (rate_flags & eHAL_TX_RATE_HT40)
13568 {
13569 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13570 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013571 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013572 if (rate_flags & eHAL_TX_RATE_SGI)
13573 {
13574 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13575 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013576
Jeff Johnson295189b2012-06-20 16:38:30 -070013577#ifdef LINKSPEED_DEBUG_ENABLED
13578 pr_info("Reporting MCS rate %d flags %x\n",
13579 sinfo->txrate.mcs,
13580 sinfo->txrate.flags );
13581#endif //LINKSPEED_DEBUG_ENABLED
13582 }
13583 }
13584 else
13585 {
13586 // report current rate instead of max rate
13587
13588 if (rate_flags & eHAL_TX_RATE_LEGACY)
13589 {
13590 //provide to the UI in units of 100kbps
13591 sinfo->txrate.legacy = myRate;
13592#ifdef LINKSPEED_DEBUG_ENABLED
13593 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
13594#endif //LINKSPEED_DEBUG_ENABLED
13595 }
13596 else
13597 {
13598 //must be MCS
13599 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013600#ifdef WLAN_FEATURE_11AC
13601 sinfo->txrate.nss = 1;
13602 if (rate_flags & eHAL_TX_RATE_VHT80)
13603 {
13604 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13605 }
13606 else
13607#endif /* WLAN_FEATURE_11AC */
13608 {
13609 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13610 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013611 if (rate_flags & eHAL_TX_RATE_SGI)
13612 {
13613 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13614 }
13615 if (rate_flags & eHAL_TX_RATE_HT40)
13616 {
13617 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13618 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013619#ifdef WLAN_FEATURE_11AC
13620 else if (rate_flags & eHAL_TX_RATE_VHT80)
13621 {
13622 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
13623 }
13624#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070013625#ifdef LINKSPEED_DEBUG_ENABLED
13626 pr_info("Reporting actual MCS rate %d flags %x\n",
13627 sinfo->txrate.mcs,
13628 sinfo->txrate.flags );
13629#endif //LINKSPEED_DEBUG_ENABLED
13630 }
13631 }
13632 sinfo->filled |= STATION_INFO_TX_BITRATE;
13633
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013634 sinfo->tx_packets =
13635 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
13636 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
13637 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
13638 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
13639
13640 sinfo->tx_retries =
13641 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
13642 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
13643 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
13644 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
13645
13646 sinfo->tx_failed =
13647 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
13648 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
13649 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
13650 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
13651
13652 sinfo->filled |=
13653 STATION_INFO_TX_PACKETS |
13654 STATION_INFO_TX_RETRIES |
13655 STATION_INFO_TX_FAILED;
13656
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013657 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13658 TRACE_CODE_HDD_CFG80211_GET_STA,
13659 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013660 EXIT();
13661 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013662}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013663#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
13664static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13665 const u8* mac, struct station_info *sinfo)
13666#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013667static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13668 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013669#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013670{
13671 int ret;
13672
13673 vos_ssr_protect(__func__);
13674 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
13675 vos_ssr_unprotect(__func__);
13676
13677 return ret;
13678}
13679
13680static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070013681 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070013682{
13683 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013684 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013685 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013686 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013687
Jeff Johnsone7245742012-09-05 17:12:55 -070013688 ENTER();
13689
Jeff Johnson295189b2012-06-20 16:38:30 -070013690 if (NULL == pAdapter)
13691 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013692 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013693 return -ENODEV;
13694 }
13695
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013696 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13697 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
13698 pAdapter->sessionId, timeout));
13699
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013700 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013701 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013702 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013703 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013704 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013705 }
13706
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013707 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
13708 (TRUE == pHddCtx->hdd_wlan_suspended) &&
13709 (pHddCtx->cfg_ini->fhostArpOffload) &&
13710 (eConnectionState_Associated ==
13711 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13712 {
Amar Singhald53568e2013-09-26 11:03:45 -070013713
13714 hddLog(VOS_TRACE_LEVEL_INFO,
13715 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053013716 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013717 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13718 {
13719 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013720 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013721 __func__, vos_status);
13722 }
13723 }
13724
Jeff Johnson295189b2012-06-20 16:38:30 -070013725 /**The get power cmd from the supplicant gets updated by the nl only
13726 *on successful execution of the function call
13727 *we are oppositely mapped w.r.t mode in the driver
13728 **/
13729 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
13730
13731 if (VOS_STATUS_E_FAILURE == vos_status)
13732 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013733 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13734 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013735 return -EINVAL;
13736 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013737 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013738 return 0;
13739}
13740
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013741static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
13742 struct net_device *dev, bool mode, int timeout)
13743{
13744 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013745
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013746 vos_ssr_protect(__func__);
13747 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
13748 vos_ssr_unprotect(__func__);
13749
13750 return ret;
13751}
Jeff Johnson295189b2012-06-20 16:38:30 -070013752#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013753static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
13754 struct net_device *netdev,
13755 u8 key_index)
13756{
13757 ENTER();
13758 return 0;
13759}
13760
Jeff Johnson295189b2012-06-20 16:38:30 -070013761static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013762 struct net_device *netdev,
13763 u8 key_index)
13764{
13765 int ret;
13766 vos_ssr_protect(__func__);
13767 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
13768 vos_ssr_unprotect(__func__);
13769 return ret;
13770}
13771#endif //LINUX_VERSION_CODE
13772
13773#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13774static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13775 struct net_device *dev,
13776 struct ieee80211_txq_params *params)
13777{
13778 ENTER();
13779 return 0;
13780}
13781#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13782static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13783 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013784{
Jeff Johnsone7245742012-09-05 17:12:55 -070013785 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070013786 return 0;
13787}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013788#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070013789
13790#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13791static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013792 struct net_device *dev,
13793 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013794{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013795 int ret;
13796
13797 vos_ssr_protect(__func__);
13798 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
13799 vos_ssr_unprotect(__func__);
13800 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013801}
13802#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13803static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
13804 struct ieee80211_txq_params *params)
13805{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013806 int ret;
13807
13808 vos_ssr_protect(__func__);
13809 ret = __wlan_hdd_set_txq_params(wiphy, params);
13810 vos_ssr_unprotect(__func__);
13811 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013812}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013813#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013814
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013815static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013816 struct net_device *dev,
13817 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070013818{
13819 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013820 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013821 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013822 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013823 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013824 v_CONTEXT_t pVosContext = NULL;
13825 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013826
Jeff Johnsone7245742012-09-05 17:12:55 -070013827 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013828
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013829 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070013830 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013831 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013832 return -EINVAL;
13833 }
13834
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013835 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13836 TRACE_CODE_HDD_CFG80211_DEL_STA,
13837 pAdapter->sessionId, pAdapter->device_mode));
13838
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013839 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13840 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013841 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013842 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013843 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013844 }
13845
Jeff Johnson295189b2012-06-20 16:38:30 -070013846 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013847 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013848 )
13849 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013850 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13851 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13852 if(pSapCtx == NULL){
13853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13854 FL("psapCtx is NULL"));
13855 return -ENOENT;
13856 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013857 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070013858 {
13859 v_U16_t i;
13860 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
13861 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013862 if ((pSapCtx->aStaInfo[i].isUsed) &&
13863 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070013864 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013865 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013866 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013867 ETHER_ADDR_LEN);
13868
Jeff Johnson295189b2012-06-20 16:38:30 -070013869 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013870 "%s: Delete STA with MAC::"
13871 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013872 __func__,
13873 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
13874 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070013875 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013876 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013877 }
13878 }
13879 }
13880 else
13881 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013882
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013883 vos_status = hdd_softap_GetStaId(pAdapter,
13884 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013885 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13886 {
13887 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013888 "%s: Skip this DEL STA as this is not used::"
13889 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013890 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013891 return -ENOENT;
13892 }
13893
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013894 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013895 {
13896 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013897 "%s: Skip this DEL STA as deauth is in progress::"
13898 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013899 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013900 return -ENOENT;
13901 }
13902
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013903 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013904
Jeff Johnson295189b2012-06-20 16:38:30 -070013905 hddLog(VOS_TRACE_LEVEL_INFO,
13906 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013907 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013908 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013909 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013910
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013911 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013912 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13913 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013914 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013915 hddLog(VOS_TRACE_LEVEL_INFO,
13916 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013917 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013918 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013919 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013920 return -ENOENT;
13921 }
13922
Jeff Johnson295189b2012-06-20 16:38:30 -070013923 }
13924 }
13925
13926 EXIT();
13927
13928 return 0;
13929}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013930
13931#ifdef CFG80211_DEL_STA_V2
13932static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13933 struct net_device *dev,
13934 struct station_del_parameters *param)
13935#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013936#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
13937static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13938 struct net_device *dev, const u8 *mac)
13939#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013940static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13941 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013942#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013943#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013944{
13945 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013946 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070013947
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013948 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013949
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013950#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013951 if (NULL == param) {
13952 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013953 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013954 return -EINVAL;
13955 }
13956
13957 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
13958 param->subtype, &delStaParams);
13959
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013960#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053013961 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013962 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013963#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013964 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
13965
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013966 vos_ssr_unprotect(__func__);
13967
13968 return ret;
13969}
13970
13971static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013972 struct net_device *dev,
13973#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13974 const u8 *mac,
13975#else
13976 u8 *mac,
13977#endif
13978 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013979{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013980 hdd_adapter_t *pAdapter;
13981 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013982 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013983#ifdef FEATURE_WLAN_TDLS
13984 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013985
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013986 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013987
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013988 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13989 if (NULL == pAdapter)
13990 {
13991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13992 "%s: Adapter is NULL",__func__);
13993 return -EINVAL;
13994 }
13995 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13996 status = wlan_hdd_validate_context(pHddCtx);
13997 if (0 != status)
13998 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013999 return status;
14000 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014001
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014002 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14003 TRACE_CODE_HDD_CFG80211_ADD_STA,
14004 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014005 mask = params->sta_flags_mask;
14006
14007 set = params->sta_flags_set;
14008
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014009 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014010 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
14011 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014012
14013 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
14014 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080014015 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014016 }
14017 }
14018#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014019 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014020 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014021}
14022
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014023#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
14024static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
14025 struct net_device *dev, const u8 *mac,
14026 struct station_parameters *params)
14027#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014028static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
14029 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014030#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014031{
14032 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014033
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014034 vos_ssr_protect(__func__);
14035 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
14036 vos_ssr_unprotect(__func__);
14037
14038 return ret;
14039}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014040#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070014041
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014042static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070014043 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014044{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014045 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14046 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014047 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014048 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014049 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014050 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070014051
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014052 ENTER();
14053
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014054 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014055 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014056 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014057 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014058 return -EINVAL;
14059 }
14060
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014061 if (!pmksa) {
14062 hddLog(LOGE, FL("pmksa is NULL"));
14063 return -EINVAL;
14064 }
14065
14066 if (!pmksa->bssid || !pmksa->pmkid) {
14067 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
14068 pmksa->bssid, pmksa->pmkid);
14069 return -EINVAL;
14070 }
14071
14072 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
14073 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14074
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014075 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14076 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014077 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014078 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014079 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014080 }
14081
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014082 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014083 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14084
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014085 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
14086 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014087
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014088 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014089 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014090 &pmk_id, 1, FALSE);
14091
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014092 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14093 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
14094 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014095
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014096 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014097 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014098}
14099
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014100static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
14101 struct cfg80211_pmksa *pmksa)
14102{
14103 int ret;
14104
14105 vos_ssr_protect(__func__);
14106 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
14107 vos_ssr_unprotect(__func__);
14108
14109 return ret;
14110}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014111
Wilson Yang6507c4e2013-10-01 20:11:19 -070014112
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014113static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070014114 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014115{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014116 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14117 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014118 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014119 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014120
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014121 ENTER();
14122
Wilson Yang6507c4e2013-10-01 20:11:19 -070014123 /* Validate pAdapter */
14124 if (NULL == pAdapter)
14125 {
14126 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
14127 return -EINVAL;
14128 }
14129
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014130 if (!pmksa) {
14131 hddLog(LOGE, FL("pmksa is NULL"));
14132 return -EINVAL;
14133 }
14134
14135 if (!pmksa->bssid) {
14136 hddLog(LOGE, FL("pmksa->bssid is NULL"));
14137 return -EINVAL;
14138 }
14139
Kiet Lam98c46a12014-10-31 15:34:57 -070014140 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
14141 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14142
Wilson Yang6507c4e2013-10-01 20:11:19 -070014143 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14144 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014145 if (0 != status)
14146 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014147 return status;
14148 }
14149
14150 /*Retrieve halHandle*/
14151 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14152
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014153 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14154 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
14155 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014156 /* Delete the PMKID CSR cache */
14157 if (eHAL_STATUS_SUCCESS !=
14158 sme_RoamDelPMKIDfromCache(halHandle,
14159 pAdapter->sessionId, pmksa->bssid, FALSE)) {
14160 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
14161 MAC_ADDR_ARRAY(pmksa->bssid));
14162 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014163 }
14164
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014165 EXIT();
14166 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014167}
14168
Wilson Yang6507c4e2013-10-01 20:11:19 -070014169
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014170static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
14171 struct cfg80211_pmksa *pmksa)
14172{
14173 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014174
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014175 vos_ssr_protect(__func__);
14176 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
14177 vos_ssr_unprotect(__func__);
14178
14179 return ret;
14180
14181}
14182
14183static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014184{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014185 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14186 tHalHandle halHandle;
14187 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014188 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014189
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014190 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070014191
14192 /* Validate pAdapter */
14193 if (NULL == pAdapter)
14194 {
14195 hddLog(VOS_TRACE_LEVEL_ERROR,
14196 "%s: Invalid Adapter" ,__func__);
14197 return -EINVAL;
14198 }
14199
14200 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14201 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014202 if (0 != status)
14203 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014204 return status;
14205 }
14206
14207 /*Retrieve halHandle*/
14208 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14209
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014210 /* Flush the PMKID cache in CSR */
14211 if (eHAL_STATUS_SUCCESS !=
14212 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
14213 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
14214 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014215 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014216 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080014217 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014218}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014219
14220static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
14221{
14222 int ret;
14223
14224 vos_ssr_protect(__func__);
14225 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
14226 vos_ssr_unprotect(__func__);
14227
14228 return ret;
14229}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014230#endif
14231
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014232#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014233static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14234 struct net_device *dev,
14235 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014236{
14237 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14238 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014239 hdd_context_t *pHddCtx;
14240 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014241
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014242 ENTER();
14243
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014244 if (NULL == pAdapter)
14245 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014246 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014247 return -ENODEV;
14248 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014249 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14250 ret = wlan_hdd_validate_context(pHddCtx);
14251 if (0 != ret)
14252 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014253 return ret;
14254 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014255 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014256 if (NULL == pHddStaCtx)
14257 {
14258 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
14259 return -EINVAL;
14260 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014261
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014262 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14263 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
14264 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014265 // Added for debug on reception of Re-assoc Req.
14266 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
14267 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014268 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014269 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080014270 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014271 }
14272
14273#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080014274 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014275 ftie->ie_len);
14276#endif
14277
14278 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014279 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14280 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014281 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014282
14283 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014284 return 0;
14285}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014286
14287static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14288 struct net_device *dev,
14289 struct cfg80211_update_ft_ies_params *ftie)
14290{
14291 int ret;
14292
14293 vos_ssr_protect(__func__);
14294 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
14295 vos_ssr_unprotect(__func__);
14296
14297 return ret;
14298}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014299#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014300
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014301#ifdef FEATURE_WLAN_SCAN_PNO
14302
14303void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
14304 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
14305{
14306 int ret;
14307 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
14308 hdd_context_t *pHddCtx;
14309
Nirav Shah80830bf2013-12-31 16:35:12 +053014310 ENTER();
14311
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014312 if (NULL == pAdapter)
14313 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014314 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014315 "%s: HDD adapter is Null", __func__);
14316 return ;
14317 }
14318
14319 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14320 if (NULL == pHddCtx)
14321 {
14322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14323 "%s: HDD context is Null!!!", __func__);
14324 return ;
14325 }
14326
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014327 spin_lock(&pHddCtx->schedScan_lock);
14328 if (TRUE == pHddCtx->isWiphySuspended)
14329 {
14330 pHddCtx->isSchedScanUpdatePending = TRUE;
14331 spin_unlock(&pHddCtx->schedScan_lock);
14332 hddLog(VOS_TRACE_LEVEL_INFO,
14333 "%s: Update cfg80211 scan database after it resume", __func__);
14334 return ;
14335 }
14336 spin_unlock(&pHddCtx->schedScan_lock);
14337
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014338 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
14339
14340 if (0 > ret)
14341 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
14342
14343 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14345 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014346}
14347
14348/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014349 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014350 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014351 */
14352static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
14353{
14354 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
14355 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014356 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014357 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14358 int status = 0;
14359 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
14360
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014361 /* The current firmware design does not allow PNO during any
14362 * active sessions. Hence, determine the active sessions
14363 * and return a failure.
14364 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014365 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
14366 {
14367 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014368 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014369
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014370 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
14371 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
14372 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
14373 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
14374 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053014375 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014376 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014377 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014378 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014379 }
14380 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14381 pAdapterNode = pNext;
14382 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014383 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014384}
14385
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014386void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
14387{
14388 hdd_adapter_t *pAdapter = callbackContext;
14389 hdd_context_t *pHddCtx;
14390
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014391 ENTER();
14392
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014393 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
14394 {
14395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14396 FL("Invalid adapter or adapter has invalid magic"));
14397 return;
14398 }
14399
14400 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14401 if (0 != wlan_hdd_validate_context(pHddCtx))
14402 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014403 return;
14404 }
14405
c_hpothub53c45d2014-08-18 16:53:14 +053014406 if (VOS_STATUS_SUCCESS != status)
14407 {
14408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014409 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053014410 pHddCtx->isPnoEnable = FALSE;
14411 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014412
14413 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
14414 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014415 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014416}
14417
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014418/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014419 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
14420 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014421 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014422static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014423 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14424{
14425 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014426 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014427 hdd_context_t *pHddCtx;
14428 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014429 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053014430 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
14431 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014432 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14433 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014434 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014435 hdd_config_t *pConfig = NULL;
14436 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014437
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014438 ENTER();
14439
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014440 if (NULL == pAdapter)
14441 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014442 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014443 "%s: HDD adapter is Null", __func__);
14444 return -ENODEV;
14445 }
14446
14447 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014448 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014449
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014450 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014451 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014452 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014453 }
14454
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014455 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014456 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14457 if (NULL == hHal)
14458 {
14459 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14460 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014461 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014462 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014463 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14464 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
14465 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053014466 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014467 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053014468 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014469 {
14470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14471 "%s: aborting the existing scan is unsuccessfull", __func__);
14472 return -EBUSY;
14473 }
14474
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014475 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014476 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014478 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014479 return -EBUSY;
14480 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014481
c_hpothu37f21312014-04-09 21:49:54 +053014482 if (TRUE == pHddCtx->isPnoEnable)
14483 {
14484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14485 FL("already PNO is enabled"));
14486 return -EBUSY;
14487 }
c_hpothu225aa7c2014-10-22 17:45:13 +053014488
14489 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
14490 {
14491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14492 "%s: abort ROC failed ", __func__);
14493 return -EBUSY;
14494 }
14495
c_hpothu37f21312014-04-09 21:49:54 +053014496 pHddCtx->isPnoEnable = TRUE;
14497
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014498 pnoRequest.enable = 1; /*Enable PNO */
14499 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014500
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014501 if (( !pnoRequest.ucNetworksCount ) ||
14502 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014503 {
14504 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014505 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014506 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014507 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014508 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014509 goto error;
14510 }
14511
14512 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
14513 {
14514 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014515 "%s: Incorrect number of channels %d",
14516 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014517 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014518 goto error;
14519 }
14520
14521 /* Framework provides one set of channels(all)
14522 * common for all saved profile */
14523 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14524 channels_allowed, &num_channels_allowed))
14525 {
14526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14527 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014528 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014529 goto error;
14530 }
14531 /* Checking each channel against allowed channel list */
14532 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053014533 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014534 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014535 char chList [(request->n_channels*5)+1];
14536 int len;
14537 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014538 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014539 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014540 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014541 if (request->channels[i]->hw_value == channels_allowed[indx])
14542 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014543 if ((!pConfig->enableDFSPnoChnlScan) &&
14544 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
14545 {
14546 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14547 "%s : Dropping DFS channel : %d",
14548 __func__,channels_allowed[indx]);
14549 num_ignore_dfs_ch++;
14550 break;
14551 }
14552
Nirav Shah80830bf2013-12-31 16:35:12 +053014553 valid_ch[num_ch++] = request->channels[i]->hw_value;
14554 len += snprintf(chList+len, 5, "%d ",
14555 request->channels[i]->hw_value);
14556 break ;
14557 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014558 }
14559 }
Nirav Shah80830bf2013-12-31 16:35:12 +053014560 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014561
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014562 /*If all channels are DFS and dropped, then ignore the PNO request*/
14563 if (num_ignore_dfs_ch == request->n_channels)
14564 {
14565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14566 "%s : All requested channels are DFS channels", __func__);
14567 ret = -EINVAL;
14568 goto error;
14569 }
14570 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014571
14572 pnoRequest.aNetworks =
14573 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14574 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014575 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014576 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14577 FL("failed to allocate memory aNetworks %u"),
14578 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14579 goto error;
14580 }
14581 vos_mem_zero(pnoRequest.aNetworks,
14582 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14583
14584 /* Filling per profile params */
14585 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
14586 {
14587 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014588 request->match_sets[i].ssid.ssid_len;
14589
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014590 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
14591 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014592 {
14593 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014594 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014595 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014596 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014597 goto error;
14598 }
14599
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014600 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014601 request->match_sets[i].ssid.ssid,
14602 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14604 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014605 i, pnoRequest.aNetworks[i].ssId.ssId);
14606 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
14607 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
14608 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014609
14610 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014611 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
14612 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014613
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014614 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014615 }
14616
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014617 for (i = 0; i < request->n_ssids; i++)
14618 {
14619 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014620 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014621 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014622 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014623 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014624 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014625 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014626 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014627 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014628 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014629 break;
14630 }
14631 j++;
14632 }
14633 }
14634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14635 "Number of hidden networks being Configured = %d",
14636 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080014638 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014639
14640 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14641 if (pnoRequest.p24GProbeTemplate == NULL)
14642 {
14643 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14644 FL("failed to allocate memory p24GProbeTemplate %u"),
14645 SIR_PNO_MAX_PB_REQ_SIZE);
14646 goto error;
14647 }
14648
14649 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14650 if (pnoRequest.p5GProbeTemplate == NULL)
14651 {
14652 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14653 FL("failed to allocate memory p5GProbeTemplate %u"),
14654 SIR_PNO_MAX_PB_REQ_SIZE);
14655 goto error;
14656 }
14657
14658 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14659 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14660
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053014661 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
14662 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014663 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014664 pnoRequest.us24GProbeTemplateLen = request->ie_len;
14665 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
14666 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014667
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014668 pnoRequest.us5GProbeTemplateLen = request->ie_len;
14669 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
14670 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014671 }
14672
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014673 /* Driver gets only one time interval which is hardcoded in
14674 * supplicant for 10000ms. Taking power consumption into account 6 timers
14675 * will be used, Timervalue is increased exponentially i.e 10,20,40,
14676 * 80,160,320 secs. And number of scan cycle for each timer
14677 * is configurable through INI param gPNOScanTimerRepeatValue.
14678 * If it is set to 0 only one timer will be used and PNO scan cycle
14679 * will be repeated after each interval specified by supplicant
14680 * till PNO is disabled.
14681 */
14682 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014683 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014684 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014685 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014686 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
14687
14688 tempInterval = (request->interval)/1000;
14689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14690 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
14691 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014692 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014693 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014694 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014695 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014696 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014697 tempInterval *= 2;
14698 }
14699 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014700 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014701
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014702 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014703
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014704 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014705 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
14706 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014707 pAdapter->pno_req_status = 0;
14708
Nirav Shah80830bf2013-12-31 16:35:12 +053014709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14710 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014711 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
14712 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053014713
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014714 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014715 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014716 hdd_cfg80211_sched_scan_done_callback, pAdapter);
14717 if (eHAL_STATUS_SUCCESS != status)
14718 {
14719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014720 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014721 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014722 goto error;
14723 }
14724
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014725 ret = wait_for_completion_timeout(
14726 &pAdapter->pno_comp_var,
14727 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
14728 if (0 >= ret)
14729 {
14730 // Did not receive the response for PNO enable in time.
14731 // Assuming the PNO enable was success.
14732 // Returning error from here, because we timeout, results
14733 // in side effect of Wifi (Wifi Setting) not to work.
14734 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14735 FL("Timed out waiting for PNO to be Enabled"));
14736 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014737 }
14738
14739 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053014740 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014741
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014742error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14744 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053014745 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014746 if (pnoRequest.aNetworks)
14747 vos_mem_free(pnoRequest.aNetworks);
14748 if (pnoRequest.p24GProbeTemplate)
14749 vos_mem_free(pnoRequest.p24GProbeTemplate);
14750 if (pnoRequest.p5GProbeTemplate)
14751 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014752
14753 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014754 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014755}
14756
14757/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014758 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
14759 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014760 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014761static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
14762 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14763{
14764 int ret;
14765
14766 vos_ssr_protect(__func__);
14767 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
14768 vos_ssr_unprotect(__func__);
14769
14770 return ret;
14771}
14772
14773/*
14774 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
14775 * Function to disable PNO
14776 */
14777static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014778 struct net_device *dev)
14779{
14780 eHalStatus status = eHAL_STATUS_FAILURE;
14781 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14782 hdd_context_t *pHddCtx;
14783 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014784 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014785 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014786
14787 ENTER();
14788
14789 if (NULL == pAdapter)
14790 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014792 "%s: HDD adapter is Null", __func__);
14793 return -ENODEV;
14794 }
14795
14796 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014797
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014798 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014799 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014800 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014801 "%s: HDD context is Null", __func__);
14802 return -ENODEV;
14803 }
14804
14805 /* The return 0 is intentional when isLogpInProgress and
14806 * isLoadUnloadInProgress. We did observe a crash due to a return of
14807 * failure in sched_scan_stop , especially for a case where the unload
14808 * of the happens at the same time. The function __cfg80211_stop_sched_scan
14809 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
14810 * success. If it returns a failure , then its next invocation due to the
14811 * clean up of the second interface will have the dev pointer corresponding
14812 * to the first one leading to a crash.
14813 */
14814 if (pHddCtx->isLogpInProgress)
14815 {
14816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14817 "%s: LOGP in Progress. Ignore!!!", __func__);
14818 return ret;
14819 }
14820
Mihir Shete18156292014-03-11 15:38:30 +053014821 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014822 {
14823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14824 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14825 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014826 }
14827
14828 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14829 if (NULL == hHal)
14830 {
14831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14832 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014833 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014834 }
14835
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014836 pnoRequest.enable = 0; /* Disable PNO */
14837 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014838
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014839 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14840 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
14841 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014842 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014843 pAdapter->sessionId,
14844 NULL, pAdapter);
14845 if (eHAL_STATUS_SUCCESS != status)
14846 {
14847 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14848 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014849 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014850 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014851 }
c_hpothu37f21312014-04-09 21:49:54 +053014852 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014853
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014854error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014855 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014856 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014857
14858 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014859 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014860}
14861
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014862/*
14863 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
14864 * NL interface to disable PNO
14865 */
14866static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
14867 struct net_device *dev)
14868{
14869 int ret;
14870
14871 vos_ssr_protect(__func__);
14872 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
14873 vos_ssr_unprotect(__func__);
14874
14875 return ret;
14876}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014877#endif /*FEATURE_WLAN_SCAN_PNO*/
14878
14879
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014880#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014881#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053014882static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
14883 struct net_device *dev,
14884 u8 *peer, u8 action_code,
14885 u8 dialog_token,
14886 u16 status_code, u32 peer_capability,
14887 const u8 *buf, size_t len)
14888#else /* TDLS_MGMT_VERSION2 */
14889#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
14890static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
14891 struct net_device *dev,
14892 const u8 *peer, u8 action_code,
14893 u8 dialog_token, u16 status_code,
14894 u32 peer_capability, bool initiator,
14895 const u8 *buf, size_t len)
14896#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
14897static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
14898 struct net_device *dev,
14899 const u8 *peer, u8 action_code,
14900 u8 dialog_token, u16 status_code,
14901 u32 peer_capability, const u8 *buf,
14902 size_t len)
14903#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
14904static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
14905 struct net_device *dev,
14906 u8 *peer, u8 action_code,
14907 u8 dialog_token,
14908 u16 status_code, u32 peer_capability,
14909 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014910#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053014911static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
14912 struct net_device *dev,
14913 u8 *peer, u8 action_code,
14914 u8 dialog_token,
14915 u16 status_code, const u8 *buf,
14916 size_t len)
14917#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014918#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014919{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014920 hdd_adapter_t *pAdapter;
14921 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014922 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070014923 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080014924 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070014925 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014926 int ret;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053014927#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014928 u32 peer_capability = 0;
14929#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014930 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053014931 hdd_station_ctx_t *pHddStaCtx = NULL;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014932
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014933 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14934 if (NULL == pAdapter)
14935 {
14936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14937 "%s: Adapter is NULL",__func__);
14938 return -EINVAL;
14939 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014940 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14941 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
14942 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053014943
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014944 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014945 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014946 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014947 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014948 "Invalid arguments");
14949 return -EINVAL;
14950 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053014951
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014952 if (pHddCtx->isLogpInProgress)
14953 {
14954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14955 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053014956 wlan_hdd_tdls_set_link_status(pAdapter,
14957 peer,
14958 eTDLS_LINK_IDLE,
14959 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014960 return -EBUSY;
14961 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053014962
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014963 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
14964 {
14965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14966 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14967 return -EAGAIN;
14968 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053014969
Hoonki Lee27511902013-03-14 18:19:06 -070014970 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014971 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014972 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070014973 "%s: TDLS mode is disabled OR not enabled in FW."
14974 MAC_ADDRESS_STR " action %d declined.",
14975 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014976 return -ENOTSUPP;
14977 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014978
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053014979 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
14980
14981 if( NULL == pHddStaCtx )
14982 {
14983 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14984 "%s: HDD station context NULL ",__func__);
14985 return -EINVAL;
14986 }
14987
14988 /* STA should be connected and authenticated
14989 * before sending any TDLS frames
14990 */
14991 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
14992 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
14993 {
14994 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14995 "STA is not connected or unauthenticated. "
14996 "connState %u, uIsAuthenticated %u",
14997 pHddStaCtx->conn_info.connState,
14998 pHddStaCtx->conn_info.uIsAuthenticated);
14999 return -EAGAIN;
15000 }
15001
Hoonki Lee27511902013-03-14 18:19:06 -070015002 /* other than teardown frame, other mgmt frames are not sent if disabled */
15003 if (SIR_MAC_TDLS_TEARDOWN != action_code)
15004 {
15005 /* if tdls_mode is disabled to respond to peer's request */
15006 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
15007 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015008 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070015009 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015010 " TDLS mode is disabled. action %d declined.",
15011 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070015012
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015013 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070015014 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053015015
15016 if (vos_max_concurrent_connections_reached())
15017 {
15018 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15019 return -EINVAL;
15020 }
Hoonki Lee27511902013-03-14 18:19:06 -070015021 }
15022
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015023 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
15024 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053015025 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015026 {
15027 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015028 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015029 " TDLS setup is ongoing. action %d declined.",
15030 __func__, MAC_ADDR_ARRAY(peer), action_code);
15031 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015032 }
15033 }
15034
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015035 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
15036 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080015037 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015038 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15039 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080015040 {
15041 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
15042 we return error code at 'add_station()'. Hence we have this
15043 check again in addtion to add_station().
15044 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015045 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080015046 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015047 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15048 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015049 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
15050 __func__, MAC_ADDR_ARRAY(peer), action_code,
15051 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053015052 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080015053 }
15054 else
15055 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015056 /* maximum reached. tweak to send error code to peer and return
15057 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080015058 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015059 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15060 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015061 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
15062 __func__, MAC_ADDR_ARRAY(peer), status_code,
15063 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070015064 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015065 /* fall through to send setup resp with failure status
15066 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080015067 }
15068 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015069 else
15070 {
15071 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053015072 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015073 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015074 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015075 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015076 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
15077 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015078 return -EPERM;
15079 }
15080 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015081 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015082
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015083 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053015084 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015085 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
15086 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015087
Hoonki Leea34dd892013-02-05 22:56:02 -080015088 /*Except teardown responder will not be used so just make 0*/
15089 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015090 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080015091 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015092
15093 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015094 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015095
15096 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
15097 responder = pTdlsPeer->is_responder;
15098 else
Hoonki Leea34dd892013-02-05 22:56:02 -080015099 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015100 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053015101 "%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 -070015102 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
15103 dialog_token, status_code, len);
15104 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080015105 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015106 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015107
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015108 /* For explicit trigger of DIS_REQ come out of BMPS for
15109 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070015110 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015111 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
15112 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070015113 {
15114 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
15115 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015116 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015117 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015118 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
15119 if (status != VOS_STATUS_SUCCESS) {
15120 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
15121 }
Hoonki Lee14621352013-04-16 17:51:19 -070015122 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015123 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015124 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015125 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
15126 }
15127 }
Hoonki Lee14621352013-04-16 17:51:19 -070015128 }
15129
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015130 /* make sure doesn't call send_mgmt() while it is pending */
15131 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
15132 {
15133 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015134 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015135 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015136 ret = -EBUSY;
15137 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015138 }
15139
15140 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015141 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
15142
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015143 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
15144 pAdapter->sessionId, peer, action_code, dialog_token,
15145 status_code, peer_capability, (tANI_U8 *)buf, len,
15146 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015147
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015148 if (VOS_STATUS_SUCCESS != status)
15149 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015150 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15151 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015152 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015153 ret = -EINVAL;
15154 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015155 }
15156
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015157 if ((SIR_MAC_TDLS_DIS_REQ == action_code) ||
15158 (SIR_MAC_TDLS_DIS_RSP == action_code))
15159 {
15160 /* for DIS_REQ/DIS_RSP, supplicant don't consider the return status.
15161 * So we no need to wait for tdls_mgmt_comp for sending ack status.
15162 */
15163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15164 "%s: tx done for frm %u", __func__, action_code);
15165 return 0;
15166 }
15167
15168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15169 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
15170 WAIT_TIME_TDLS_MGMT);
15171
Hoonki Leed37cbb32013-04-20 00:31:14 -070015172 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
15173 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
15174
15175 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015176 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070015177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070015178 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070015179 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015180 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080015181
15182 if (pHddCtx->isLogpInProgress)
15183 {
15184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15185 "%s: LOGP in Progress. Ignore!!!", __func__);
15186 return -EAGAIN;
15187 }
15188
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015189 ret = -EINVAL;
15190 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015191 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015192 else
15193 {
15194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15195 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
15196 __func__, rc, pAdapter->mgmtTxCompletionStatus);
15197 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015198
Gopichand Nakkala05922802013-03-14 12:23:19 -070015199 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070015200 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015201 ret = max_sta_failed;
15202 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070015203 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015204
Hoonki Leea34dd892013-02-05 22:56:02 -080015205 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
15206 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015207 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015208 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15209 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015210 }
15211 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
15212 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015213 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015214 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15215 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015216 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015217
15218 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015219
15220tx_failed:
15221 /* add_station will be called before sending TDLS_SETUP_REQ and
15222 * TDLS_SETUP_RSP and as part of add_station driver will enable
15223 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
15224 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
15225 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
15226 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
15227 */
15228
15229 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
15230 (SIR_MAC_TDLS_SETUP_RSP == action_code))
15231 wlan_hdd_tdls_check_bmps(pAdapter);
15232 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015233}
15234
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015235#if TDLS_MGMT_VERSION2
15236static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15237 u8 *peer, u8 action_code, u8 dialog_token,
15238 u16 status_code, u32 peer_capability,
15239 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015240#else /* TDLS_MGMT_VERSION2 */
15241#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
15242static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15243 struct net_device *dev,
15244 const u8 *peer, u8 action_code,
15245 u8 dialog_token, u16 status_code,
15246 u32 peer_capability, bool initiator,
15247 const u8 *buf, size_t len)
15248#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
15249static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15250 struct net_device *dev,
15251 const u8 *peer, u8 action_code,
15252 u8 dialog_token, u16 status_code,
15253 u32 peer_capability, const u8 *buf,
15254 size_t len)
15255#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
15256static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15257 struct net_device *dev,
15258 u8 *peer, u8 action_code,
15259 u8 dialog_token,
15260 u16 status_code, u32 peer_capability,
15261 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015262#else
15263static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15264 u8 *peer, u8 action_code, u8 dialog_token,
15265 u16 status_code, const u8 *buf, size_t len)
15266#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015267#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015268{
15269 int ret;
15270
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015271 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015272#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015273 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15274 dialog_token, status_code,
15275 peer_capability, buf, len);
15276#else /* TDLS_MGMT_VERSION2 */
15277#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
15278 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15279 dialog_token, status_code,
15280 peer_capability, initiator,
15281 buf, len);
15282#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
15283 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15284 dialog_token, status_code,
15285 peer_capability, buf, len);
15286#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
15287 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15288 dialog_token, status_code,
15289 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015290#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015291 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15292 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015293#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015294#endif
15295 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015296
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015297 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015298}
Atul Mittal115287b2014-07-08 13:26:33 +053015299
15300int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015301#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15302 const u8 *peer,
15303#else
Atul Mittal115287b2014-07-08 13:26:33 +053015304 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015305#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015306 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053015307 cfg80211_exttdls_callback callback)
15308{
15309
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015310 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053015311 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015312 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053015313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15314 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
15315 __func__, MAC_ADDR_ARRAY(peer));
15316
15317 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15318 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15319
15320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015321 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15322 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15323 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015324 return -ENOTSUPP;
15325 }
15326
15327 /* To cater the requirement of establishing the TDLS link
15328 * irrespective of the data traffic , get an entry of TDLS peer.
15329 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015330 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015331 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
15332 if (pTdlsPeer == NULL) {
15333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15334 "%s: peer " MAC_ADDRESS_STR " not existing",
15335 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015336 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015337 return -EINVAL;
15338 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015339 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015340
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015341 /* check FW TDLS Off Channel capability */
15342 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015343 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015344 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015345 {
15346 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
15347 pTdlsPeer->peerParams.global_operating_class =
15348 tdls_peer_params->global_operating_class;
15349 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
15350 pTdlsPeer->peerParams.min_bandwidth_kbps =
15351 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015352 /* check configured channel is valid, non dfs and
15353 * not current operating channel */
15354 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
15355 tdls_peer_params->channel)) &&
15356 (pHddStaCtx) &&
15357 (tdls_peer_params->channel !=
15358 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015359 {
15360 pTdlsPeer->isOffChannelConfigured = TRUE;
15361 }
15362 else
15363 {
15364 pTdlsPeer->isOffChannelConfigured = FALSE;
15365 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15366 "%s: Configured Tdls Off Channel is not valid", __func__);
15367
15368 }
15369 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015370 "%s: tdls_off_channel %d isOffChannelConfigured %d "
15371 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015372 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015373 pTdlsPeer->isOffChannelConfigured,
15374 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015375 }
15376 else
15377 {
15378 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015379 "%s: TDLS off channel FW capability %d, "
15380 "host capab %d or Invalid TDLS Peer Params", __func__,
15381 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
15382 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015383 }
15384
Atul Mittal115287b2014-07-08 13:26:33 +053015385 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
15386
15387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15388 " %s TDLS Add Force Peer Failed",
15389 __func__);
15390 return -EINVAL;
15391 }
15392 /*EXT TDLS*/
15393
15394 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
15395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15396 " %s TDLS set callback Failed",
15397 __func__);
15398 return -EINVAL;
15399 }
15400
15401 return(0);
15402
15403}
15404
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015405int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
15406#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15407 const u8 *peer
15408#else
15409 u8 *peer
15410#endif
15411)
Atul Mittal115287b2014-07-08 13:26:33 +053015412{
15413
15414 hddTdlsPeer_t *pTdlsPeer;
15415 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15417 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
15418 __func__, MAC_ADDR_ARRAY(peer));
15419
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015420 if (0 != wlan_hdd_validate_context(pHddCtx)) {
15421 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
15422 return -EINVAL;
15423 }
15424
Atul Mittal115287b2014-07-08 13:26:33 +053015425 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15426 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15427
15428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015429 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15430 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15431 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015432 return -ENOTSUPP;
15433 }
15434
15435
15436 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15437
15438 if ( NULL == pTdlsPeer ) {
15439 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015440 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053015441 __func__, MAC_ADDR_ARRAY(peer));
15442 return -EINVAL;
15443 }
15444 else {
15445 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
15446 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015447 /* if channel switch is configured, reset
15448 the channel for this peer */
15449 if (TRUE == pTdlsPeer->isOffChannelConfigured)
15450 {
15451 pTdlsPeer->peerParams.channel = 0;
15452 pTdlsPeer->isOffChannelConfigured = FALSE;
15453 }
Atul Mittal115287b2014-07-08 13:26:33 +053015454 }
15455
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015456 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
15457 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053015458 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015459 }
Atul Mittal115287b2014-07-08 13:26:33 +053015460
15461 /*EXT TDLS*/
15462
15463 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
15464
15465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15466 " %s TDLS set callback Failed",
15467 __func__);
15468 return -EINVAL;
15469 }
15470 return(0);
15471
15472}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015473static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015474#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15475 const u8 *peer,
15476#else
15477 u8 *peer,
15478#endif
15479 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015480{
15481 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15482 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015483 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015484 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015485
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015486 ENTER();
15487
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015488 if (!pAdapter) {
15489 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15490 return -EINVAL;
15491 }
15492
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015493 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15494 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
15495 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015496 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015497 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015498 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070015499 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015500 return -EINVAL;
15501 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015502
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015503 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015504 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015505 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015506 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015507 }
15508
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015509
15510 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015511 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015512 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015513 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015514 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
15515 "Cannot process TDLS commands",
15516 pHddCtx->cfg_ini->fEnableTDLSSupport,
15517 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015518 return -ENOTSUPP;
15519 }
15520
15521 switch (oper) {
15522 case NL80211_TDLS_ENABLE_LINK:
15523 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015524 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015525 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015526 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053015527 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015528 tANI_U16 numCurrTdlsPeers = 0;
15529 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015530 tANI_U8 suppChannelLen = 0;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015531
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15533 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
15534 __func__, MAC_ADDR_ARRAY(peer));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015535 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015536 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015537 if ( NULL == pTdlsPeer ) {
15538 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15539 " (oper %d) not exsting. ignored",
15540 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15541 return -EINVAL;
15542 }
15543
15544 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15545 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15546 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15547 "NL80211_TDLS_ENABLE_LINK");
15548
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070015549 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
15550 {
15551 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
15552 MAC_ADDRESS_STR " failed",
15553 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
15554 return -EINVAL;
15555 }
15556
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015557 /* before starting tdls connection, set tdls
15558 * off channel established status to default value */
15559 pTdlsPeer->isOffChannelEstablished = FALSE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015560 /* TDLS Off Channel, Disable tdls channel switch,
15561 when there are more than one tdls link */
15562 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053015563 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015564 {
15565 /* get connected peer and send disable tdls off chan */
15566 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015567 if ((connPeer) &&
15568 (connPeer->isOffChannelSupported == TRUE) &&
15569 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015570 {
15571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15572 "%s: More then one peer connected, Disable "
15573 "TDLS channel switch", __func__);
15574
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015575 connPeer->isOffChannelEstablished = FALSE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015576 ret = sme_SendTdlsChanSwitchReq(
15577 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015578 pAdapter->sessionId,
15579 connPeer->peerMac,
15580 connPeer->peerParams.channel,
15581 TDLS_OFF_CHANNEL_BW_OFFSET,
15582 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015583 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015584 hddLog(VOS_TRACE_LEVEL_ERROR,
15585 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015586 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015587 }
15588 else
15589 {
15590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15591 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015592 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015593 "isOffChannelConfigured %d",
15594 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015595 (connPeer ? (connPeer->isOffChannelSupported)
15596 : -1),
15597 (connPeer ? (connPeer->isOffChannelConfigured)
15598 : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015599 }
15600 }
15601
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015602 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015603 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015604 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053015605
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015606 if (0 != wlan_hdd_tdls_get_link_establish_params(
15607 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015608 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015609 return -EINVAL;
15610 }
15611 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015612
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015613 ret = sme_SendTdlsLinkEstablishParams(
15614 WLAN_HDD_GET_HAL_CTX(pAdapter),
15615 pAdapter->sessionId, peer,
15616 &tdlsLinkEstablishParams);
15617 if (ret != VOS_STATUS_SUCCESS) {
15618 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
15619 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015620 /* Send TDLS peer UAPSD capabilities to the firmware and
15621 * register with the TL on after the response for this operation
15622 * is received .
15623 */
15624 ret = wait_for_completion_interruptible_timeout(
15625 &pAdapter->tdls_link_establish_req_comp,
15626 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
15627 if (ret <= 0)
15628 {
15629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015630 FL("Link Establish Request Failed Status %ld"),
15631 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015632 return -EINVAL;
15633 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015634 }
Atul Mittal115287b2014-07-08 13:26:33 +053015635 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15636 eTDLS_LINK_CONNECTED,
15637 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015638 staDesc.ucSTAId = pTdlsPeer->staId;
15639 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015640 ret = WLANTL_UpdateTdlsSTAClient(
15641 pHddCtx->pvosContext,
15642 &staDesc);
15643 if (ret != VOS_STATUS_SUCCESS) {
15644 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
15645 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053015646
Gopichand Nakkala471708b2013-06-04 20:03:01 +053015647 /* Mark TDLS client Authenticated .*/
15648 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
15649 pTdlsPeer->staId,
15650 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015651 if (VOS_STATUS_SUCCESS == status)
15652 {
Hoonki Lee14621352013-04-16 17:51:19 -070015653 if (pTdlsPeer->is_responder == 0)
15654 {
15655 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
15656
15657 wlan_hdd_tdls_timer_restart(pAdapter,
15658 &pTdlsPeer->initiatorWaitTimeoutTimer,
15659 WAIT_TIME_TDLS_INITIATOR);
15660 /* suspend initiator TX until it receives direct packet from the
15661 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015662 ret = WLANTL_SuspendDataTx(
15663 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15664 &staId, NULL);
15665 if (ret != VOS_STATUS_SUCCESS) {
15666 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
15667 }
Hoonki Lee14621352013-04-16 17:51:19 -070015668 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015669
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015670 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015671 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015672 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015673 suppChannelLen =
15674 tdlsLinkEstablishParams.supportedChannelsLen;
15675
15676 if ((suppChannelLen > 0) &&
15677 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
15678 {
15679 tANI_U8 suppPeerChannel = 0;
15680 int i = 0;
15681 for (i = 0U; i < suppChannelLen; i++)
15682 {
15683 suppPeerChannel =
15684 tdlsLinkEstablishParams.supportedChannels[i];
15685
15686 pTdlsPeer->isOffChannelSupported = FALSE;
15687 if (suppPeerChannel ==
15688 pTdlsPeer->peerParams.channel)
15689 {
15690 pTdlsPeer->isOffChannelSupported = TRUE;
15691 break;
15692 }
15693 }
15694 }
15695 else
15696 {
15697 pTdlsPeer->isOffChannelSupported = FALSE;
15698 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015699 }
15700 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15701 "%s: TDLS channel switch request for channel "
15702 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015703 "%d isOffChannelSupported %d", __func__,
15704 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015705 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015706 suppChannelLen,
15707 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015708
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015709 /* TDLS Off Channel, Enable tdls channel switch,
15710 when their is only one tdls link and it supports */
15711 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15712 if ((numCurrTdlsPeers == 1) &&
15713 (TRUE == pTdlsPeer->isOffChannelSupported) &&
15714 (TRUE == pTdlsPeer->isOffChannelConfigured))
15715 {
15716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15717 "%s: Send TDLS channel switch request for channel %d",
15718 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015719
15720 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015721 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
15722 pAdapter->sessionId,
15723 pTdlsPeer->peerMac,
15724 pTdlsPeer->peerParams.channel,
15725 TDLS_OFF_CHANNEL_BW_OFFSET,
15726 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015727 if (ret != VOS_STATUS_SUCCESS) {
15728 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
15729 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015730 }
15731 else
15732 {
15733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15734 "%s: TDLS channel switch request not sent"
15735 " numCurrTdlsPeers %d "
15736 "isOffChannelSupported %d "
15737 "isOffChannelConfigured %d",
15738 __func__, numCurrTdlsPeers,
15739 pTdlsPeer->isOffChannelSupported,
15740 pTdlsPeer->isOffChannelConfigured);
15741 }
15742
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015743 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015744 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015745
15746 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015747 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
15748 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015749 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015750 int ac;
15751 uint8 ucAc[4] = { WLANTL_AC_VO,
15752 WLANTL_AC_VI,
15753 WLANTL_AC_BK,
15754 WLANTL_AC_BE };
15755 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
15756 for(ac=0; ac < 4; ac++)
15757 {
15758 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15759 pTdlsPeer->staId, ucAc[ac],
15760 tlTid[ac], tlTid[ac], 0, 0,
15761 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015762 if (status != VOS_STATUS_SUCCESS) {
15763 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
15764 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015765 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015766 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015767 }
15768
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015769 }
15770 break;
15771 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080015772 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015773 tANI_U16 numCurrTdlsPeers = 0;
15774 hddTdlsPeer_t *connPeer = NULL;
15775
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015776 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15777 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
15778 __func__, MAC_ADDR_ARRAY(peer));
15779
Sunil Dutt41de4e22013-11-14 18:09:02 +053015780 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15781
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015782
Sunil Dutt41de4e22013-11-14 18:09:02 +053015783 if ( NULL == pTdlsPeer ) {
15784 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15785 " (oper %d) not exsting. ignored",
15786 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15787 return -EINVAL;
15788 }
15789
15790 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15791 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15792 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15793 "NL80211_TDLS_DISABLE_LINK");
15794
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015795 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080015796 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015797 long status;
15798
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015799 /* set tdls off channel status to false for this peer */
15800 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053015801 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15802 eTDLS_LINK_TEARING,
15803 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
15804 eTDLS_LINK_UNSPECIFIED:
15805 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015806 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
15807
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015808 status = sme_DeleteTdlsPeerSta(
15809 WLAN_HDD_GET_HAL_CTX(pAdapter),
15810 pAdapter->sessionId, peer );
15811 if (status != VOS_STATUS_SUCCESS) {
15812 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15813 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015814
15815 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
15816 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053015817 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053015818 eTDLS_LINK_IDLE,
15819 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015820 if (status <= 0)
15821 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15823 "%s: Del station failed status %ld",
15824 __func__, status);
15825 return -EPERM;
15826 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015827
15828 /* TDLS Off Channel, Enable tdls channel switch,
15829 when their is only one tdls link and it supports */
15830 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15831 if (numCurrTdlsPeers == 1)
15832 {
15833 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15834 if ((connPeer) &&
15835 (connPeer->isOffChannelSupported == TRUE) &&
15836 (connPeer->isOffChannelConfigured == TRUE))
15837 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015838 connPeer->isOffChannelEstablished = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015839 status = sme_SendTdlsChanSwitchReq(
15840 WLAN_HDD_GET_HAL_CTX(pAdapter),
15841 pAdapter->sessionId,
15842 connPeer->peerMac,
15843 connPeer->peerParams.channel,
15844 TDLS_OFF_CHANNEL_BW_OFFSET,
15845 TDLS_CHANNEL_SWITCH_ENABLE);
15846 if (status != VOS_STATUS_SUCCESS) {
15847 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
15848 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015849 }
15850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15851 "%s: TDLS channel switch "
15852 "isOffChannelSupported %d "
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015853 "isOffChannelConfigured %d "
15854 "isOffChannelEstablished %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015855 __func__,
15856 (connPeer ? connPeer->isOffChannelSupported : -1),
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015857 (connPeer ? connPeer->isOffChannelConfigured : -1),
15858 (connPeer ? connPeer->isOffChannelEstablished : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015859 }
15860 else
15861 {
15862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15863 "%s: TDLS channel switch request not sent "
15864 "numCurrTdlsPeers %d ",
15865 __func__, numCurrTdlsPeers);
15866 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015867 }
15868 else
15869 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15871 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080015872 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015873 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015874 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015875 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015876 {
Atul Mittal115287b2014-07-08 13:26:33 +053015877 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015878
Atul Mittal115287b2014-07-08 13:26:33 +053015879 if (0 != status)
15880 {
15881 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015882 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053015883 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015884 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053015885 break;
15886 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015887 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015888 {
Atul Mittal115287b2014-07-08 13:26:33 +053015889 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
15890 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015891 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053015892 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015893
Atul Mittal115287b2014-07-08 13:26:33 +053015894 if (0 != status)
15895 {
15896 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015897 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053015898 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053015899 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053015900 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015901 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015902 case NL80211_TDLS_DISCOVERY_REQ:
15903 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015905 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015906 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015907 return -ENOTSUPP;
15908 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15910 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015911 return -ENOTSUPP;
15912 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015913
15914 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015915 return 0;
15916}
Chilam NG571c65a2013-01-19 12:27:36 +053015917
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015918static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015919#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15920 const u8 *peer,
15921#else
15922 u8 *peer,
15923#endif
15924 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015925{
15926 int ret;
15927
15928 vos_ssr_protect(__func__);
15929 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
15930 vos_ssr_unprotect(__func__);
15931
15932 return ret;
15933}
15934
Chilam NG571c65a2013-01-19 12:27:36 +053015935int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
15936 struct net_device *dev, u8 *peer)
15937{
Arif Hussaina7c8e412013-11-20 11:06:42 -080015938 hddLog(VOS_TRACE_LEVEL_INFO,
15939 "tdls send discover req: "MAC_ADDRESS_STR,
15940 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053015941
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015942#if TDLS_MGMT_VERSION2
15943 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15944 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
15945#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015946#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
15947 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15948 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
15949#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
15950 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15951 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
15952#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
15953 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15954 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
15955#else
Chilam NG571c65a2013-01-19 12:27:36 +053015956 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15957 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015958#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015959#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053015960}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015961#endif
15962
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015963#ifdef WLAN_FEATURE_GTK_OFFLOAD
15964/*
15965 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
15966 * Callback rountine called upon receiving response for
15967 * get offload info
15968 */
15969void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
15970 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
15971{
15972
15973 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015974 tANI_U8 tempReplayCounter[8];
15975 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015976
15977 ENTER();
15978
15979 if (NULL == pAdapter)
15980 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053015981 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015982 "%s: HDD adapter is Null", __func__);
15983 return ;
15984 }
15985
15986 if (NULL == pGtkOffloadGetInfoRsp)
15987 {
15988 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15989 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
15990 return ;
15991 }
15992
15993 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
15994 {
15995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15996 "%s: wlan Failed to get replay counter value",
15997 __func__);
15998 return ;
15999 }
16000
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016001 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16002 /* Update replay counter */
16003 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
16004 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
16005
16006 {
16007 /* changing from little to big endian since supplicant
16008 * works on big endian format
16009 */
16010 int i;
16011 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
16012
16013 for (i = 0; i < 8; i++)
16014 {
16015 tempReplayCounter[7-i] = (tANI_U8)p[i];
16016 }
16017 }
16018
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016019 /* Update replay counter to NL */
16020 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016021 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016022}
16023
16024/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016025 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016026 * This function is used to offload GTK rekeying job to the firmware.
16027 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016028int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016029 struct cfg80211_gtk_rekey_data *data)
16030{
16031 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16032 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16033 hdd_station_ctx_t *pHddStaCtx;
16034 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016035 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016036 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016037 eHalStatus status = eHAL_STATUS_FAILURE;
16038
16039 ENTER();
16040
16041 if (NULL == pAdapter)
16042 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016043 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016044 "%s: HDD adapter is Null", __func__);
16045 return -ENODEV;
16046 }
16047
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016048 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16049 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
16050 pAdapter->sessionId, pAdapter->device_mode));
16051
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016052 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016053 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016054 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016055 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016056 }
16057
16058 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16059 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
16060 if (NULL == hHal)
16061 {
16062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16063 "%s: HAL context is Null!!!", __func__);
16064 return -EAGAIN;
16065 }
16066
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016067 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
16068 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
16069 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
16070 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016071 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016072 {
16073 /* changing from big to little endian since driver
16074 * works on little endian format
16075 */
16076 tANI_U8 *p =
16077 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
16078 int i;
16079
16080 for (i = 0; i < 8; i++)
16081 {
16082 p[7-i] = data->replay_ctr[i];
16083 }
16084 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016085
16086 if (TRUE == pHddCtx->hdd_wlan_suspended)
16087 {
16088 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016089 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
16090 sizeof (tSirGtkOffloadParams));
16091 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016092 pAdapter->sessionId);
16093
16094 if (eHAL_STATUS_SUCCESS != status)
16095 {
16096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16097 "%s: sme_SetGTKOffload failed, returned %d",
16098 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053016099
16100 /* Need to clear any trace of key value in the memory.
16101 * Thus zero out the memory even though it is local
16102 * variable.
16103 */
16104 vos_mem_zero(&hddGtkOffloadReqParams,
16105 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016106 return status;
16107 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16109 "%s: sme_SetGTKOffload successfull", __func__);
16110 }
16111 else
16112 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16114 "%s: wlan not suspended GTKOffload request is stored",
16115 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016116 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016117
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053016118 /* Need to clear any trace of key value in the memory.
16119 * Thus zero out the memory even though it is local
16120 * variable.
16121 */
16122 vos_mem_zero(&hddGtkOffloadReqParams,
16123 sizeof(hddGtkOffloadReqParams));
16124
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016125 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016126 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016127}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016128
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016129int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
16130 struct cfg80211_gtk_rekey_data *data)
16131{
16132 int ret;
16133
16134 vos_ssr_protect(__func__);
16135 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
16136 vos_ssr_unprotect(__func__);
16137
16138 return ret;
16139}
16140#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016141/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016142 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016143 * This function is used to set access control policy
16144 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016145static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16146 struct net_device *dev,
16147 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016148{
16149 int i;
16150 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16151 hdd_hostapd_state_t *pHostapdState;
16152 tsap_Config_t *pConfig;
16153 v_CONTEXT_t pVosContext = NULL;
16154 hdd_context_t *pHddCtx;
16155 int status;
16156
16157 ENTER();
16158
16159 if (NULL == pAdapter)
16160 {
16161 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16162 "%s: HDD adapter is Null", __func__);
16163 return -ENODEV;
16164 }
16165
16166 if (NULL == params)
16167 {
16168 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16169 "%s: params is Null", __func__);
16170 return -EINVAL;
16171 }
16172
16173 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16174 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016175 if (0 != status)
16176 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016177 return status;
16178 }
16179
16180 pVosContext = pHddCtx->pvosContext;
16181 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
16182
16183 if (NULL == pHostapdState)
16184 {
16185 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16186 "%s: pHostapdState is Null", __func__);
16187 return -EINVAL;
16188 }
16189
16190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
16191 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016192 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16193 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
16194 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016195
16196 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
16197 {
16198 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
16199
16200 /* default value */
16201 pConfig->num_accept_mac = 0;
16202 pConfig->num_deny_mac = 0;
16203
16204 /**
16205 * access control policy
16206 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
16207 * listed in hostapd.deny file.
16208 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
16209 * listed in hostapd.accept file.
16210 */
16211 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
16212 {
16213 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
16214 }
16215 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
16216 {
16217 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
16218 }
16219 else
16220 {
16221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16222 "%s:Acl Policy : %d is not supported",
16223 __func__, params->acl_policy);
16224 return -ENOTSUPP;
16225 }
16226
16227 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
16228 {
16229 pConfig->num_accept_mac = params->n_acl_entries;
16230 for (i = 0; i < params->n_acl_entries; i++)
16231 {
16232 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16233 "** Add ACL MAC entry %i in WhiletList :"
16234 MAC_ADDRESS_STR, i,
16235 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16236
16237 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
16238 sizeof(qcmacaddr));
16239 }
16240 }
16241 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
16242 {
16243 pConfig->num_deny_mac = params->n_acl_entries;
16244 for (i = 0; i < params->n_acl_entries; i++)
16245 {
16246 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16247 "** Add ACL MAC entry %i in BlackList :"
16248 MAC_ADDRESS_STR, i,
16249 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16250
16251 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
16252 sizeof(qcmacaddr));
16253 }
16254 }
16255
16256 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
16257 {
16258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16259 "%s: SAP Set Mac Acl fail", __func__);
16260 return -EINVAL;
16261 }
16262 }
16263 else
16264 {
16265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053016266 "%s: Invalid device_mode = %s (%d)",
16267 __func__, hdd_device_modetoString(pAdapter->device_mode),
16268 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016269 return -EINVAL;
16270 }
16271
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016272 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016273 return 0;
16274}
16275
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016276static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16277 struct net_device *dev,
16278 const struct cfg80211_acl_data *params)
16279{
16280 int ret;
16281 vos_ssr_protect(__func__);
16282 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
16283 vos_ssr_unprotect(__func__);
16284
16285 return ret;
16286}
16287
Leo Chang9056f462013-08-01 19:21:11 -070016288#ifdef WLAN_NL80211_TESTMODE
16289#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070016290void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070016291(
16292 void *pAdapter,
16293 void *indCont
16294)
16295{
Leo Changd9df8aa2013-09-26 13:32:26 -070016296 tSirLPHBInd *lphbInd;
16297 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053016298 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070016299
16300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016301 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070016302
c_hpothu73f35e62014-04-18 13:40:08 +053016303 if (pAdapter == NULL)
16304 {
16305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16306 "%s: pAdapter is NULL\n",__func__);
16307 return;
16308 }
16309
Leo Chang9056f462013-08-01 19:21:11 -070016310 if (NULL == indCont)
16311 {
16312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016313 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070016314 return;
16315 }
16316
c_hpothu73f35e62014-04-18 13:40:08 +053016317 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070016318 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070016319 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053016320 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070016321 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070016322 GFP_ATOMIC);
16323 if (!skb)
16324 {
16325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16326 "LPHB timeout, NL buffer alloc fail");
16327 return;
16328 }
16329
Leo Changac3ba772013-10-07 09:47:04 -070016330 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070016331 {
16332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16333 "WLAN_HDD_TM_ATTR_CMD put fail");
16334 goto nla_put_failure;
16335 }
Leo Changac3ba772013-10-07 09:47:04 -070016336 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070016337 {
16338 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16339 "WLAN_HDD_TM_ATTR_TYPE put fail");
16340 goto nla_put_failure;
16341 }
Leo Changac3ba772013-10-07 09:47:04 -070016342 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070016343 sizeof(tSirLPHBInd), lphbInd))
16344 {
16345 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16346 "WLAN_HDD_TM_ATTR_DATA put fail");
16347 goto nla_put_failure;
16348 }
Leo Chang9056f462013-08-01 19:21:11 -070016349 cfg80211_testmode_event(skb, GFP_ATOMIC);
16350 return;
16351
16352nla_put_failure:
16353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16354 "NLA Put fail");
16355 kfree_skb(skb);
16356
16357 return;
16358}
16359#endif /* FEATURE_WLAN_LPHB */
16360
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016361static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070016362{
16363 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
16364 int err = 0;
16365#ifdef FEATURE_WLAN_LPHB
16366 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070016367 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016368
16369 ENTER();
16370
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016371 err = wlan_hdd_validate_context(pHddCtx);
16372 if (0 != err)
16373 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016374 return err;
16375 }
Leo Chang9056f462013-08-01 19:21:11 -070016376#endif /* FEATURE_WLAN_LPHB */
16377
16378 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
16379 if (err)
16380 {
16381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16382 "%s Testmode INV ATTR", __func__);
16383 return err;
16384 }
16385
16386 if (!tb[WLAN_HDD_TM_ATTR_CMD])
16387 {
16388 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16389 "%s Testmode INV CMD", __func__);
16390 return -EINVAL;
16391 }
16392
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016393 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16394 TRACE_CODE_HDD_CFG80211_TESTMODE,
16395 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070016396 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
16397 {
16398#ifdef FEATURE_WLAN_LPHB
16399 /* Low Power Heartbeat configuration request */
16400 case WLAN_HDD_TM_CMD_WLAN_HB:
16401 {
16402 int buf_len;
16403 void *buf;
16404 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080016405 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070016406
16407 if (!tb[WLAN_HDD_TM_ATTR_DATA])
16408 {
16409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16410 "%s Testmode INV DATA", __func__);
16411 return -EINVAL;
16412 }
16413
16414 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
16415 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080016416
16417 hb_params_temp =(tSirLPHBReq *)buf;
16418 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
16419 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
16420 return -EINVAL;
16421
Leo Chang9056f462013-08-01 19:21:11 -070016422 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
16423 if (NULL == hb_params)
16424 {
16425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16426 "%s Request Buffer Alloc Fail", __func__);
16427 return -EINVAL;
16428 }
16429
16430 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070016431 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
16432 hb_params,
16433 wlan_hdd_cfg80211_lphb_ind_handler);
16434 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070016435 {
Leo Changd9df8aa2013-09-26 13:32:26 -070016436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16437 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070016438 vos_mem_free(hb_params);
16439 }
Leo Chang9056f462013-08-01 19:21:11 -070016440 return 0;
16441 }
16442#endif /* FEATURE_WLAN_LPHB */
16443 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16445 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070016446 return -EOPNOTSUPP;
16447 }
16448
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016449 EXIT();
16450 return err;
Leo Chang9056f462013-08-01 19:21:11 -070016451}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016452
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053016453static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
16454#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
16455 struct wireless_dev *wdev,
16456#endif
16457 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016458{
16459 int ret;
16460
16461 vos_ssr_protect(__func__);
16462 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
16463 vos_ssr_unprotect(__func__);
16464
16465 return ret;
16466}
Leo Chang9056f462013-08-01 19:21:11 -070016467#endif /* CONFIG_NL80211_TESTMODE */
16468
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016469static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016470 struct net_device *dev,
16471 int idx, struct survey_info *survey)
16472{
16473 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16474 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053016475 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016476 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053016477 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016478 v_S7_t snr,rssi;
16479 int status, i, j, filled = 0;
16480
16481 ENTER();
16482
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016483 if (NULL == pAdapter)
16484 {
16485 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16486 "%s: HDD adapter is Null", __func__);
16487 return -ENODEV;
16488 }
16489
16490 if (NULL == wiphy)
16491 {
16492 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16493 "%s: wiphy is Null", __func__);
16494 return -ENODEV;
16495 }
16496
16497 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16498 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016499 if (0 != status)
16500 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016501 return status;
16502 }
16503
Mihir Sheted9072e02013-08-21 17:02:29 +053016504 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16505
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016506 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053016507 0 != pAdapter->survey_idx ||
16508 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016509 {
16510 /* The survey dump ops when implemented completely is expected to
16511 * return a survey of all channels and the ops is called by the
16512 * kernel with incremental values of the argument 'idx' till it
16513 * returns -ENONET. But we can only support the survey for the
16514 * operating channel for now. survey_idx is used to track
16515 * that the ops is called only once and then return -ENONET for
16516 * the next iteration
16517 */
16518 pAdapter->survey_idx = 0;
16519 return -ENONET;
16520 }
16521
Mukul Sharma9d5233b2015-06-11 20:28:20 +053016522 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
16523 {
16524 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16525 "%s: Roaming in progress, hence return ", __func__);
16526 return -ENONET;
16527 }
16528
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016529 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16530
16531 wlan_hdd_get_snr(pAdapter, &snr);
16532 wlan_hdd_get_rssi(pAdapter, &rssi);
16533
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016534 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16535 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
16536 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016537 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
16538 hdd_wlan_get_freq(channel, &freq);
16539
16540
16541 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
16542 {
16543 if (NULL == wiphy->bands[i])
16544 {
16545 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
16546 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
16547 continue;
16548 }
16549
16550 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
16551 {
16552 struct ieee80211_supported_band *band = wiphy->bands[i];
16553
16554 if (band->channels[j].center_freq == (v_U16_t)freq)
16555 {
16556 survey->channel = &band->channels[j];
16557 /* The Rx BDs contain SNR values in dB for the received frames
16558 * while the supplicant expects noise. So we calculate and
16559 * return the value of noise (dBm)
16560 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
16561 */
16562 survey->noise = rssi - snr;
16563 survey->filled = SURVEY_INFO_NOISE_DBM;
16564 filled = 1;
16565 }
16566 }
16567 }
16568
16569 if (filled)
16570 pAdapter->survey_idx = 1;
16571 else
16572 {
16573 pAdapter->survey_idx = 0;
16574 return -ENONET;
16575 }
16576
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016577 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016578 return 0;
16579}
16580
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016581static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
16582 struct net_device *dev,
16583 int idx, struct survey_info *survey)
16584{
16585 int ret;
16586
16587 vos_ssr_protect(__func__);
16588 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
16589 vos_ssr_unprotect(__func__);
16590
16591 return ret;
16592}
16593
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016594/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016595 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016596 * this is called when cfg80211 driver resume
16597 * driver updates latest sched_scan scan result(if any) to cfg80211 database
16598 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016599int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016600{
16601 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16602 hdd_adapter_t *pAdapter;
16603 hdd_adapter_list_node_t *pAdapterNode, *pNext;
16604 VOS_STATUS status = VOS_STATUS_SUCCESS;
16605
16606 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016607
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016608 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016609 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016610 return 0;
16611 }
16612
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016613 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
16614 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016615 spin_lock(&pHddCtx->schedScan_lock);
16616 pHddCtx->isWiphySuspended = FALSE;
16617 if (TRUE != pHddCtx->isSchedScanUpdatePending)
16618 {
16619 spin_unlock(&pHddCtx->schedScan_lock);
16620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16621 "%s: Return resume is not due to PNO indication", __func__);
16622 return 0;
16623 }
16624 // Reset flag to avoid updatating cfg80211 data old results again
16625 pHddCtx->isSchedScanUpdatePending = FALSE;
16626 spin_unlock(&pHddCtx->schedScan_lock);
16627
16628 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
16629
16630 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
16631 {
16632 pAdapter = pAdapterNode->pAdapter;
16633 if ( (NULL != pAdapter) &&
16634 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
16635 {
16636 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016637 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16639 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016640 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016641 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016642 {
16643 /* Acquire wakelock to handle the case where APP's tries to
16644 * suspend immediately after updating the scan results. Whis
16645 * results in app's is in suspended state and not able to
16646 * process the connect request to AP
16647 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053016648 hdd_prevent_suspend_timeout(2000,
16649 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016650 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016651 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016652
16653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16654 "%s : cfg80211 scan result database updated", __func__);
16655
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016656 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016657 return 0;
16658
16659 }
16660 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16661 pAdapterNode = pNext;
16662 }
16663
16664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16665 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016666 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016667 return 0;
16668}
16669
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016670int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
16671{
16672 int ret;
16673
16674 vos_ssr_protect(__func__);
16675 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
16676 vos_ssr_unprotect(__func__);
16677
16678 return ret;
16679}
16680
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016681/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016682 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016683 * this is called when cfg80211 driver suspends
16684 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016685int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016686 struct cfg80211_wowlan *wow)
16687{
16688 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016689 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016690
16691 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016692
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016693 ret = wlan_hdd_validate_context(pHddCtx);
16694 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016695 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016696 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016697 }
16698
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016699
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016700 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16701 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
16702 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016703 pHddCtx->isWiphySuspended = TRUE;
16704
16705 EXIT();
16706
16707 return 0;
16708}
16709
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016710int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
16711 struct cfg80211_wowlan *wow)
16712{
16713 int ret;
16714
16715 vos_ssr_protect(__func__);
16716 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
16717 vos_ssr_unprotect(__func__);
16718
16719 return ret;
16720}
Jeff Johnson295189b2012-06-20 16:38:30 -070016721/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016722static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070016723{
16724 .add_virtual_intf = wlan_hdd_add_virtual_intf,
16725 .del_virtual_intf = wlan_hdd_del_virtual_intf,
16726 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
16727 .change_station = wlan_hdd_change_station,
16728#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
16729 .add_beacon = wlan_hdd_cfg80211_add_beacon,
16730 .del_beacon = wlan_hdd_cfg80211_del_beacon,
16731 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016732#else
16733 .start_ap = wlan_hdd_cfg80211_start_ap,
16734 .change_beacon = wlan_hdd_cfg80211_change_beacon,
16735 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070016736#endif
16737 .change_bss = wlan_hdd_cfg80211_change_bss,
16738 .add_key = wlan_hdd_cfg80211_add_key,
16739 .get_key = wlan_hdd_cfg80211_get_key,
16740 .del_key = wlan_hdd_cfg80211_del_key,
16741 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016742#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070016743 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016744#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016745 .scan = wlan_hdd_cfg80211_scan,
16746 .connect = wlan_hdd_cfg80211_connect,
16747 .disconnect = wlan_hdd_cfg80211_disconnect,
16748 .join_ibss = wlan_hdd_cfg80211_join_ibss,
16749 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
16750 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
16751 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
16752 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070016753 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
16754 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053016755 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070016756#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16757 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
16758 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
16759 .set_txq_params = wlan_hdd_set_txq_params,
16760#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016761 .get_station = wlan_hdd_cfg80211_get_station,
16762 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
16763 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016764 .add_station = wlan_hdd_cfg80211_add_station,
16765#ifdef FEATURE_WLAN_LFR
16766 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
16767 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
16768 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
16769#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016770#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
16771 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
16772#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016773#ifdef FEATURE_WLAN_TDLS
16774 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
16775 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
16776#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016777#ifdef WLAN_FEATURE_GTK_OFFLOAD
16778 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
16779#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016780#ifdef FEATURE_WLAN_SCAN_PNO
16781 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
16782 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
16783#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016784 .resume = wlan_hdd_cfg80211_resume_wlan,
16785 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016786 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070016787#ifdef WLAN_NL80211_TESTMODE
16788 .testmode_cmd = wlan_hdd_cfg80211_testmode,
16789#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016790 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070016791};
16792