blob: 0e1b326a1f9390a7108f5acd62ce00a152722464 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +053026 *
Kiet Lamaa8e15a2014-02-11 23:30:06 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Kiet Lama7f454d2014-07-24 12:04:06 -070030
31
Jeff Johnson295189b2012-06-20 16:38:30 -070032/**========================================================================
33
34 \file wlan_hdd_cfg80211.c
35
36 \brief WLAN Host Device Driver implementation
37
Jeff Johnson295189b2012-06-20 16:38:30 -070038 ========================================================================*/
39
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070040/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070041
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070042 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070043
44
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070045 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070047
48
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070049 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070050
51
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070052 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070053 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070054 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070055
56 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070057 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070058 ==========================================================================*/
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060
61#include <linux/version.h>
62#include <linux/module.h>
63#include <linux/kernel.h>
64#include <linux/init.h>
65#include <linux/wireless.h>
66#include <wlan_hdd_includes.h>
67#include <net/arp.h>
68#include <net/cfg80211.h>
69#include <linux/wireless.h>
70#include <wlan_hdd_wowl.h>
71#include <aniGlobal.h>
72#include "ccmApi.h"
73#include "sirParams.h"
74#include "dot11f.h"
75#include "wlan_hdd_assoc.h"
76#include "wlan_hdd_wext.h"
77#include "sme_Api.h"
78#include "wlan_hdd_p2p.h"
79#include "wlan_hdd_cfg80211.h"
80#include "wlan_hdd_hostapd.h"
81#include "sapInternal.h"
82#include "wlan_hdd_softap_tx_rx.h"
83#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053084#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053085#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053086#include "wlan_hdd_trace.h"
87#include "vos_types.h"
88#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070089#ifdef WLAN_BTAMP_FEATURE
90#include "bap_hdd_misc.h"
91#endif
92#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080093#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053094#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053095#include "wlan_qct_wda.h"
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053096#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070097#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070098
99#define g_mode_rates_size (12)
100#define a_mode_rates_size (8)
101#define FREQ_BASE_80211G (2407)
102#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700103#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530104#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800106 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
108#define HDD2GHZCHAN(freq, chan, flag) { \
109 .band = IEEE80211_BAND_2GHZ, \
110 .center_freq = (freq), \
111 .hw_value = (chan),\
112 .flags = (flag), \
113 .max_antenna_gain = 0 ,\
114 .max_power = 30, \
115}
116
117#define HDD5GHZCHAN(freq, chan, flag) { \
118 .band = IEEE80211_BAND_5GHZ, \
119 .center_freq = (freq), \
120 .hw_value = (chan),\
121 .flags = (flag), \
122 .max_antenna_gain = 0 ,\
123 .max_power = 30, \
124}
125
126#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
127{\
128 .bitrate = rate, \
129 .hw_value = rate_id, \
130 .flags = flag, \
131}
132
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530133#ifdef WLAN_FEATURE_VOWIFI_11R
134#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
135#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
136#endif
137
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530138#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530139#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530140
Sunil Duttc69bccb2014-05-26 21:30:20 +0530141#ifdef WLAN_FEATURE_LINK_LAYER_STATS
142/*
143 * Used to allocate the size of 4096 for the link layer stats.
144 * The size of 4096 is considered assuming that all data per
145 * respective event fit with in the limit.Please take a call
146 * on the limit based on the data requirements on link layer
147 * statistics.
148 */
149#define LL_STATS_EVENT_BUF_SIZE 4096
150#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530151#ifdef WLAN_FEATURE_EXTSCAN
152/*
153 * Used to allocate the size of 4096 for the EXTScan NL data.
154 * The size of 4096 is considered assuming that all data per
155 * respective event fit with in the limit.Please take a call
156 * on the limit based on the data requirements.
157 */
158
159#define EXTSCAN_EVENT_BUF_SIZE 4096
160#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
161#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530162
Atul Mittal115287b2014-07-08 13:26:33 +0530163/*EXT TDLS*/
164/*
165 * Used to allocate the size of 4096 for the TDLS.
166 * The size of 4096 is considered assuming that all data per
167 * respective event fit with in the limit.Please take a call
168 * on the limit based on the data requirements on link layer
169 * statistics.
170 */
171#define EXTTDLS_EVENT_BUF_SIZE 4096
172
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530173static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700174{
175 WLAN_CIPHER_SUITE_WEP40,
176 WLAN_CIPHER_SUITE_WEP104,
177 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800178#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700179#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
180 WLAN_CIPHER_SUITE_KRK,
181 WLAN_CIPHER_SUITE_CCMP,
182#else
183 WLAN_CIPHER_SUITE_CCMP,
184#endif
185#ifdef FEATURE_WLAN_WAPI
186 WLAN_CIPHER_SUITE_SMS4,
187#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700188#ifdef WLAN_FEATURE_11W
189 WLAN_CIPHER_SUITE_AES_CMAC,
190#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700191};
192
193static inline int is_broadcast_ether_addr(const u8 *addr)
194{
195 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
196 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
197}
198
199static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530200{
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 HDD2GHZCHAN(2412, 1, 0) ,
202 HDD2GHZCHAN(2417, 2, 0) ,
203 HDD2GHZCHAN(2422, 3, 0) ,
204 HDD2GHZCHAN(2427, 4, 0) ,
205 HDD2GHZCHAN(2432, 5, 0) ,
206 HDD2GHZCHAN(2437, 6, 0) ,
207 HDD2GHZCHAN(2442, 7, 0) ,
208 HDD2GHZCHAN(2447, 8, 0) ,
209 HDD2GHZCHAN(2452, 9, 0) ,
210 HDD2GHZCHAN(2457, 10, 0) ,
211 HDD2GHZCHAN(2462, 11, 0) ,
212 HDD2GHZCHAN(2467, 12, 0) ,
213 HDD2GHZCHAN(2472, 13, 0) ,
214 HDD2GHZCHAN(2484, 14, 0) ,
215};
216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
218{
219 HDD2GHZCHAN(2412, 1, 0) ,
220 HDD2GHZCHAN(2437, 6, 0) ,
221 HDD2GHZCHAN(2462, 11, 0) ,
222};
Jeff Johnson295189b2012-06-20 16:38:30 -0700223
224static struct ieee80211_channel hdd_channels_5_GHZ[] =
225{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700226 HDD5GHZCHAN(4920, 240, 0) ,
227 HDD5GHZCHAN(4940, 244, 0) ,
228 HDD5GHZCHAN(4960, 248, 0) ,
229 HDD5GHZCHAN(4980, 252, 0) ,
230 HDD5GHZCHAN(5040, 208, 0) ,
231 HDD5GHZCHAN(5060, 212, 0) ,
232 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 HDD5GHZCHAN(5180, 36, 0) ,
234 HDD5GHZCHAN(5200, 40, 0) ,
235 HDD5GHZCHAN(5220, 44, 0) ,
236 HDD5GHZCHAN(5240, 48, 0) ,
237 HDD5GHZCHAN(5260, 52, 0) ,
238 HDD5GHZCHAN(5280, 56, 0) ,
239 HDD5GHZCHAN(5300, 60, 0) ,
240 HDD5GHZCHAN(5320, 64, 0) ,
241 HDD5GHZCHAN(5500,100, 0) ,
242 HDD5GHZCHAN(5520,104, 0) ,
243 HDD5GHZCHAN(5540,108, 0) ,
244 HDD5GHZCHAN(5560,112, 0) ,
245 HDD5GHZCHAN(5580,116, 0) ,
246 HDD5GHZCHAN(5600,120, 0) ,
247 HDD5GHZCHAN(5620,124, 0) ,
248 HDD5GHZCHAN(5640,128, 0) ,
249 HDD5GHZCHAN(5660,132, 0) ,
250 HDD5GHZCHAN(5680,136, 0) ,
251 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800252#ifdef FEATURE_WLAN_CH144
253 HDD5GHZCHAN(5720,144, 0) ,
254#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 HDD5GHZCHAN(5745,149, 0) ,
256 HDD5GHZCHAN(5765,153, 0) ,
257 HDD5GHZCHAN(5785,157, 0) ,
258 HDD5GHZCHAN(5805,161, 0) ,
259 HDD5GHZCHAN(5825,165, 0) ,
260};
261
262static struct ieee80211_rate g_mode_rates[] =
263{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530264 HDD_G_MODE_RATETAB(10, 0x1, 0),
265 HDD_G_MODE_RATETAB(20, 0x2, 0),
266 HDD_G_MODE_RATETAB(55, 0x4, 0),
267 HDD_G_MODE_RATETAB(110, 0x8, 0),
268 HDD_G_MODE_RATETAB(60, 0x10, 0),
269 HDD_G_MODE_RATETAB(90, 0x20, 0),
270 HDD_G_MODE_RATETAB(120, 0x40, 0),
271 HDD_G_MODE_RATETAB(180, 0x80, 0),
272 HDD_G_MODE_RATETAB(240, 0x100, 0),
273 HDD_G_MODE_RATETAB(360, 0x200, 0),
274 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530276};
Jeff Johnson295189b2012-06-20 16:38:30 -0700277
278static struct ieee80211_rate a_mode_rates[] =
279{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530280 HDD_G_MODE_RATETAB(60, 0x10, 0),
281 HDD_G_MODE_RATETAB(90, 0x20, 0),
282 HDD_G_MODE_RATETAB(120, 0x40, 0),
283 HDD_G_MODE_RATETAB(180, 0x80, 0),
284 HDD_G_MODE_RATETAB(240, 0x100, 0),
285 HDD_G_MODE_RATETAB(360, 0x200, 0),
286 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 HDD_G_MODE_RATETAB(540, 0x800, 0),
288};
289
290static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
291{
292 .channels = hdd_channels_2_4_GHZ,
293 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
294 .band = IEEE80211_BAND_2GHZ,
295 .bitrates = g_mode_rates,
296 .n_bitrates = g_mode_rates_size,
297 .ht_cap.ht_supported = 1,
298 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
299 | IEEE80211_HT_CAP_GRN_FLD
300 | IEEE80211_HT_CAP_DSSSCCK40
301 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
302 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
303 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
304 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
305 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
306 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
307};
308
Jeff Johnson295189b2012-06-20 16:38:30 -0700309static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
310{
311 .channels = hdd_social_channels_2_4_GHZ,
312 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
313 .band = IEEE80211_BAND_2GHZ,
314 .bitrates = g_mode_rates,
315 .n_bitrates = g_mode_rates_size,
316 .ht_cap.ht_supported = 1,
317 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
318 | IEEE80211_HT_CAP_GRN_FLD
319 | IEEE80211_HT_CAP_DSSSCCK40
320 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
321 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
322 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
323 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
324 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
325 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
326};
Jeff Johnson295189b2012-06-20 16:38:30 -0700327
328static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
329{
330 .channels = hdd_channels_5_GHZ,
331 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
332 .band = IEEE80211_BAND_5GHZ,
333 .bitrates = a_mode_rates,
334 .n_bitrates = a_mode_rates_size,
335 .ht_cap.ht_supported = 1,
336 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
337 | IEEE80211_HT_CAP_GRN_FLD
338 | IEEE80211_HT_CAP_DSSSCCK40
339 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
340 | IEEE80211_HT_CAP_SGI_40
341 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
342 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
343 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
344 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
345 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
346 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
347};
348
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530349/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700350 TX/RX direction for each kind of interface */
351static const struct ieee80211_txrx_stypes
352wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
353 [NL80211_IFTYPE_STATION] = {
354 .tx = 0xffff,
355 .rx = BIT(SIR_MAC_MGMT_ACTION) |
356 BIT(SIR_MAC_MGMT_PROBE_REQ),
357 },
358 [NL80211_IFTYPE_AP] = {
359 .tx = 0xffff,
360 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
361 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
362 BIT(SIR_MAC_MGMT_PROBE_REQ) |
363 BIT(SIR_MAC_MGMT_DISASSOC) |
364 BIT(SIR_MAC_MGMT_AUTH) |
365 BIT(SIR_MAC_MGMT_DEAUTH) |
366 BIT(SIR_MAC_MGMT_ACTION),
367 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700368 [NL80211_IFTYPE_ADHOC] = {
369 .tx = 0xffff,
370 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
371 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
372 BIT(SIR_MAC_MGMT_PROBE_REQ) |
373 BIT(SIR_MAC_MGMT_DISASSOC) |
374 BIT(SIR_MAC_MGMT_AUTH) |
375 BIT(SIR_MAC_MGMT_DEAUTH) |
376 BIT(SIR_MAC_MGMT_ACTION),
377 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 [NL80211_IFTYPE_P2P_CLIENT] = {
379 .tx = 0xffff,
380 .rx = BIT(SIR_MAC_MGMT_ACTION) |
381 BIT(SIR_MAC_MGMT_PROBE_REQ),
382 },
383 [NL80211_IFTYPE_P2P_GO] = {
384 /* This is also same as for SoftAP */
385 .tx = 0xffff,
386 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
387 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
388 BIT(SIR_MAC_MGMT_PROBE_REQ) |
389 BIT(SIR_MAC_MGMT_DISASSOC) |
390 BIT(SIR_MAC_MGMT_AUTH) |
391 BIT(SIR_MAC_MGMT_DEAUTH) |
392 BIT(SIR_MAC_MGMT_ACTION),
393 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700394};
395
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800396#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800397static const struct ieee80211_iface_limit
398wlan_hdd_iface_limit[] = {
399 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800400 /* max = 3 ; Our driver create two interfaces during driver init
401 * wlan0 and p2p0 interfaces. p2p0 is considered as station
402 * interface until a group is formed. In JB architecture, once the
403 * group is formed, interface type of p2p0 is changed to P2P GO or
404 * Client.
405 * When supplicant remove the group, it first issue a set interface
406 * cmd to change the mode back to Station. In JB this works fine as
407 * we advertize two station type interface during driver init.
408 * Some vendors create separate interface for P2P GO/Client,
409 * after group formation(Third one). But while group remove
410 * supplicant first tries to change the mode(3rd interface) to STATION
411 * But as we advertized only two sta type interfaces nl80211 was
412 * returning error for the third one which was leading to failure in
413 * delete interface. Ideally while removing the group, supplicant
414 * should not try to change the 3rd interface mode to Station type.
415 * Till we get a fix in wpa_supplicant, we advertize max STA
416 * interface type to 3
417 */
418 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800419 .types = BIT(NL80211_IFTYPE_STATION),
420 },
421 {
422 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700423 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800424 },
425 {
426 .max = 1,
427 .types = BIT(NL80211_IFTYPE_P2P_GO) |
428 BIT(NL80211_IFTYPE_P2P_CLIENT),
429 },
430};
431
432/* By default, only single channel concurrency is allowed */
433static struct ieee80211_iface_combination
434wlan_hdd_iface_combination = {
435 .limits = wlan_hdd_iface_limit,
436 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800437 /*
438 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
439 * and p2p0 interfaces during driver init
440 * Some vendors create separate interface for P2P operations.
441 * wlan0: STA interface
442 * p2p0: P2P Device interface, action frames goes
443 * through this interface.
444 * p2p-xx: P2P interface, After GO negotiation this interface is
445 * created for p2p operations(GO/CLIENT interface).
446 */
447 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800448 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
449 .beacon_int_infra_match = false,
450};
451#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800452
Jeff Johnson295189b2012-06-20 16:38:30 -0700453static struct cfg80211_ops wlan_hdd_cfg80211_ops;
454
455/* Data rate 100KBPS based on IE Index */
456struct index_data_rate_type
457{
458 v_U8_t beacon_rate_index;
459 v_U16_t supported_rate[4];
460};
461
462/* 11B, 11G Rate table include Basic rate and Extended rate
463 The IDX field is the rate index
464 The HI field is the rate when RSSI is strong or being ignored
465 (in this case we report actual rate)
466 The MID field is the rate when RSSI is moderate
467 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
468 The LO field is the rate when RSSI is low
469 (in this case we don't report rates, actual current rate used)
470 */
471static const struct
472{
473 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700474 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700475} supported_data_rate[] =
476{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700477/* IDX HI HM LM LO (RSSI-based index */
478 {2, { 10, 10, 10, 0}},
479 {4, { 20, 20, 10, 0}},
480 {11, { 55, 20, 10, 0}},
481 {12, { 60, 55, 20, 0}},
482 {18, { 90, 55, 20, 0}},
483 {22, {110, 55, 20, 0}},
484 {24, {120, 90, 60, 0}},
485 {36, {180, 120, 60, 0}},
486 {44, {220, 180, 60, 0}},
487 {48, {240, 180, 90, 0}},
488 {66, {330, 180, 90, 0}},
489 {72, {360, 240, 90, 0}},
490 {96, {480, 240, 120, 0}},
491 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700492};
493
494/* MCS Based rate table */
495static struct index_data_rate_type supported_mcs_rate[] =
496{
497/* MCS L20 L40 S20 S40 */
498 {0, {65, 135, 72, 150}},
499 {1, {130, 270, 144, 300}},
500 {2, {195, 405, 217, 450}},
501 {3, {260, 540, 289, 600}},
502 {4, {390, 810, 433, 900}},
503 {5, {520, 1080, 578, 1200}},
504 {6, {585, 1215, 650, 1350}},
505 {7, {650, 1350, 722, 1500}}
506};
507
Leo Chang6f8870f2013-03-26 18:11:36 -0700508#ifdef WLAN_FEATURE_11AC
509
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530510#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700511
512struct index_vht_data_rate_type
513{
514 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530515 v_U16_t supported_VHT80_rate[2];
516 v_U16_t supported_VHT40_rate[2];
517 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700518};
519
520typedef enum
521{
522 DATA_RATE_11AC_MAX_MCS_7,
523 DATA_RATE_11AC_MAX_MCS_8,
524 DATA_RATE_11AC_MAX_MCS_9,
525 DATA_RATE_11AC_MAX_MCS_NA
526} eDataRate11ACMaxMcs;
527
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530528/* SSID broadcast type */
529typedef enum eSSIDBcastType
530{
531 eBCAST_UNKNOWN = 0,
532 eBCAST_NORMAL = 1,
533 eBCAST_HIDDEN = 2,
534} tSSIDBcastType;
535
Leo Chang6f8870f2013-03-26 18:11:36 -0700536/* MCS Based VHT rate table */
537static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
538{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530539/* MCS L80 S80 L40 S40 L20 S40*/
540 {0, {293, 325}, {135, 150}, {65, 72}},
541 {1, {585, 650}, {270, 300}, {130, 144}},
542 {2, {878, 975}, {405, 450}, {195, 217}},
543 {3, {1170, 1300}, {540, 600}, {260, 289}},
544 {4, {1755, 1950}, {810, 900}, {390, 433}},
545 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
546 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
547 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
548 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
549 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700550};
551#endif /* WLAN_FEATURE_11AC */
552
c_hpothu79aab322014-07-14 21:11:01 +0530553/*array index points to MCS and array value points respective rssi*/
554static int rssiMcsTbl[][10] =
555{
556/*MCS 0 1 2 3 4 5 6 7 8 9*/
557 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
558 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
559 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
560};
561
Jeff Johnson295189b2012-06-20 16:38:30 -0700562extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530563#ifdef FEATURE_WLAN_SCAN_PNO
564static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
565#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700566
Leo Chang9056f462013-08-01 19:21:11 -0700567#ifdef WLAN_NL80211_TESTMODE
568enum wlan_hdd_tm_attr
569{
570 WLAN_HDD_TM_ATTR_INVALID = 0,
571 WLAN_HDD_TM_ATTR_CMD = 1,
572 WLAN_HDD_TM_ATTR_DATA = 2,
573 WLAN_HDD_TM_ATTR_TYPE = 3,
574 /* keep last */
575 WLAN_HDD_TM_ATTR_AFTER_LAST,
576 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
577};
578
579enum wlan_hdd_tm_cmd
580{
581 WLAN_HDD_TM_CMD_WLAN_HB = 1,
582};
583
584#define WLAN_HDD_TM_DATA_MAX_LEN 5000
585
586static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
587{
588 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
589 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
590 .len = WLAN_HDD_TM_DATA_MAX_LEN },
591};
592#endif /* WLAN_NL80211_TESTMODE */
593
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800594#ifdef FEATURE_WLAN_CH_AVOID
595/*
596 * FUNCTION: wlan_hdd_send_avoid_freq_event
597 * This is called when wlan driver needs to send vendor specific
598 * avoid frequency range event to userspace
599 */
600int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
601 tHddAvoidFreqList *pAvoidFreqList)
602{
603 struct sk_buff *vendor_event;
604
605 ENTER();
606
607 if (!pHddCtx)
608 {
609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
610 "%s: HDD context is null", __func__);
611 return -1;
612 }
613
614 if (!pAvoidFreqList)
615 {
616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
617 "%s: pAvoidFreqList is null", __func__);
618 return -1;
619 }
620
621 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530622#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
623 NULL,
624#endif
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800625 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530626 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800627 GFP_KERNEL);
628 if (!vendor_event)
629 {
630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
631 "%s: cfg80211_vendor_event_alloc failed", __func__);
632 return -1;
633 }
634
635 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
636 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
637
638 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
639
640 EXIT();
641 return 0;
642}
643#endif /* FEATURE_WLAN_CH_AVOID */
644
Srinivas Dasari030bad32015-02-18 23:23:54 +0530645/*
646 * FUNCTION: __wlan_hdd_cfg80211_nan_request
647 * This is called when wlan driver needs to send vendor specific
648 * nan request event.
649 */
650static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
651 struct wireless_dev *wdev,
652 const void *data, int data_len)
653{
654 tNanRequestReq nan_req;
655 VOS_STATUS status;
656 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530657 struct net_device *dev = wdev->netdev;
658 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
659 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530660 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
661
662 if (0 == data_len)
663 {
664 hddLog(VOS_TRACE_LEVEL_ERROR,
665 FL("NAN - Invalid Request, length = 0"));
666 return ret_val;
667 }
668
669 if (NULL == data)
670 {
671 hddLog(VOS_TRACE_LEVEL_ERROR,
672 FL("NAN - Invalid Request, data is NULL"));
673 return ret_val;
674 }
675
676 status = wlan_hdd_validate_context(pHddCtx);
677 if (0 != status)
678 {
679 hddLog(VOS_TRACE_LEVEL_ERROR,
680 FL("HDD context is not valid"));
681 return -EINVAL;
682 }
683
684 hddLog(LOG1, FL("Received NAN command"));
685 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
686 (tANI_U8 *)data, data_len);
687
688 /* check the NAN Capability */
689 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
690 {
691 hddLog(VOS_TRACE_LEVEL_ERROR,
692 FL("NAN is not supported by Firmware"));
693 return -EINVAL;
694 }
695
696 nan_req.request_data_len = data_len;
697 nan_req.request_data = data;
698
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530699 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530700 if (VOS_STATUS_SUCCESS == status)
701 {
702 ret_val = 0;
703 }
704 return ret_val;
705}
706
707/*
708 * FUNCTION: wlan_hdd_cfg80211_nan_request
709 * Wrapper to protect the nan vendor command from ssr
710 */
711static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
712 struct wireless_dev *wdev,
713 const void *data, int data_len)
714{
715 int ret;
716
717 vos_ssr_protect(__func__);
718 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
719 vos_ssr_unprotect(__func__);
720
721 return ret;
722}
723
724/*
725 * FUNCTION: wlan_hdd_cfg80211_nan_callback
726 * This is a callback function and it gets called
727 * when we need to report nan response event to
728 * upper layers.
729 */
730static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
731{
732 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
733 struct sk_buff *vendor_event;
734 int status;
735 tSirNanEvent *data;
736
737 ENTER();
738 if (NULL == msg)
739 {
740 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
741 FL(" msg received here is null"));
742 return;
743 }
744 data = msg;
745
746 status = wlan_hdd_validate_context(pHddCtx);
747
748 if (0 != status)
749 {
750 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
751 FL("HDD context is not valid"));
752 return;
753 }
754
755 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530756#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
757 NULL,
758#endif
Srinivas Dasari030bad32015-02-18 23:23:54 +0530759 data->event_data_len +
760 NLMSG_HDRLEN,
761 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
762 GFP_KERNEL);
763
764 if (!vendor_event)
765 {
766 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
767 FL("cfg80211_vendor_event_alloc failed"));
768 return;
769 }
770 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
771 data->event_data_len, data->event_data))
772 {
773 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
774 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
775 kfree_skb(vendor_event);
776 return;
777 }
778 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
779 EXIT();
780}
781
782/*
783 * FUNCTION: wlan_hdd_cfg80211_nan_init
784 * This function is called to register the callback to sme layer
785 */
786inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
787{
788 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
789}
790
791
Sunil Duttc69bccb2014-05-26 21:30:20 +0530792#ifdef WLAN_FEATURE_LINK_LAYER_STATS
793
794static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
795 struct sk_buff *vendor_event)
796{
797 if (nla_put_u8(vendor_event,
798 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
799 stats->rate.preamble) ||
800 nla_put_u8(vendor_event,
801 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
802 stats->rate.nss) ||
803 nla_put_u8(vendor_event,
804 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
805 stats->rate.bw) ||
806 nla_put_u8(vendor_event,
807 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
808 stats->rate.rateMcsIdx) ||
809 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
810 stats->rate.bitrate ) ||
811 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
812 stats->txMpdu ) ||
813 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
814 stats->rxMpdu ) ||
815 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
816 stats->mpduLost ) ||
817 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
818 stats->retries) ||
819 nla_put_u32(vendor_event,
820 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
821 stats->retriesShort ) ||
822 nla_put_u32(vendor_event,
823 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
824 stats->retriesLong))
825 {
826 hddLog(VOS_TRACE_LEVEL_ERROR,
827 FL("QCA_WLAN_VENDOR_ATTR put fail"));
828 return FALSE;
829 }
830 return TRUE;
831}
832
833static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
834 struct sk_buff *vendor_event)
835{
836 u32 i = 0;
837 struct nlattr *rateInfo;
838 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
839 stats->type) ||
840 nla_put(vendor_event,
841 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
842 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
843 nla_put_u32(vendor_event,
844 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
845 stats->capabilities) ||
846 nla_put_u32(vendor_event,
847 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
848 stats->numRate))
849 {
850 hddLog(VOS_TRACE_LEVEL_ERROR,
851 FL("QCA_WLAN_VENDOR_ATTR put fail"));
852 goto error;
853 }
854
855 rateInfo = nla_nest_start(vendor_event,
856 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530857 if(!rateInfo)
858 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530859 for (i = 0; i < stats->numRate; i++)
860 {
861 struct nlattr *rates;
862 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
863 stats->rateStats +
864 (i * sizeof(tSirWifiRateStat)));
865 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530866 if(!rates)
867 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530868
869 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
870 {
871 hddLog(VOS_TRACE_LEVEL_ERROR,
872 FL("QCA_WLAN_VENDOR_ATTR put fail"));
873 return FALSE;
874 }
875 nla_nest_end(vendor_event, rates);
876 }
877 nla_nest_end(vendor_event, rateInfo);
878
879 return TRUE;
880error:
881 return FALSE;
882}
883
884static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
885 struct sk_buff *vendor_event)
886{
887 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
888 stats->ac ) ||
889 nla_put_u32(vendor_event,
890 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
891 stats->txMpdu ) ||
892 nla_put_u32(vendor_event,
893 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
894 stats->rxMpdu ) ||
895 nla_put_u32(vendor_event,
896 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
897 stats->txMcast ) ||
898 nla_put_u32(vendor_event,
899 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
900 stats->rxMcast ) ||
901 nla_put_u32(vendor_event,
902 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
903 stats->rxAmpdu ) ||
904 nla_put_u32(vendor_event,
905 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
906 stats->txAmpdu ) ||
907 nla_put_u32(vendor_event,
908 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
909 stats->mpduLost )||
910 nla_put_u32(vendor_event,
911 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
912 stats->retries ) ||
913 nla_put_u32(vendor_event,
914 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
915 stats->retriesShort ) ||
916 nla_put_u32(vendor_event,
917 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
918 stats->retriesLong ) ||
919 nla_put_u32(vendor_event,
920 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
921 stats->contentionTimeMin ) ||
922 nla_put_u32(vendor_event,
923 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
924 stats->contentionTimeMax ) ||
925 nla_put_u32(vendor_event,
926 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
927 stats->contentionTimeAvg ) ||
928 nla_put_u32(vendor_event,
929 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
930 stats->contentionNumSamples ))
931 {
932 hddLog(VOS_TRACE_LEVEL_ERROR,
933 FL("QCA_WLAN_VENDOR_ATTR put fail") );
934 return FALSE;
935 }
936 return TRUE;
937}
938
939static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
940 struct sk_buff *vendor_event)
941{
Dino Myclec8f3f332014-07-21 16:48:27 +0530942 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530943 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
944 nla_put(vendor_event,
945 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
946 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
947 nla_put_u32(vendor_event,
948 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
949 stats->state ) ||
950 nla_put_u32(vendor_event,
951 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
952 stats->roaming ) ||
953 nla_put_u32(vendor_event,
954 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
955 stats->capabilities ) ||
956 nla_put(vendor_event,
957 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
958 strlen(stats->ssid), stats->ssid) ||
959 nla_put(vendor_event,
960 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
961 WNI_CFG_BSSID_LEN, stats->bssid) ||
962 nla_put(vendor_event,
963 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
964 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
965 nla_put(vendor_event,
966 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
967 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
968 )
969 {
970 hddLog(VOS_TRACE_LEVEL_ERROR,
971 FL("QCA_WLAN_VENDOR_ATTR put fail") );
972 return FALSE;
973 }
974 return TRUE;
975}
976
Dino Mycle3b9536d2014-07-09 22:05:24 +0530977static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
978 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530979 struct sk_buff *vendor_event)
980{
981 int i = 0;
982 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530983 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
984 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530985 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530986
Sunil Duttc69bccb2014-05-26 21:30:20 +0530987 if (FALSE == put_wifi_interface_info(
988 &pWifiIfaceStat->info,
989 vendor_event))
990 {
991 hddLog(VOS_TRACE_LEVEL_ERROR,
992 FL("QCA_WLAN_VENDOR_ATTR put fail") );
993 return FALSE;
994
995 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530996 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
997 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
998 if (NULL == pWifiIfaceStatTL)
999 {
1000 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
1001 return FALSE;
1002 }
1003
Srinivas Dasaria8a304f2014-11-15 16:13:37 +05301004 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
1005 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
1006 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
1007 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1008
1009 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1010 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1011 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1012 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301013
1014 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1015 {
1016 if (VOS_STATUS_SUCCESS ==
1017 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1018 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1019 {
1020 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1021 * obtained from TL structure
1022 */
1023
1024 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1025 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301026 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1027
Srinivas Dasari98947432014-11-07 19:41:24 +05301028 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1029 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1030 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1031 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1032 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1033 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1034 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1035 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301036
Srinivas Dasari98947432014-11-07 19:41:24 +05301037 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1038 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1039 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1040 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1041 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1042 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1043 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1044 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301045
Srinivas Dasari98947432014-11-07 19:41:24 +05301046 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1047 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1048 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1049 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1050 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1051 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1052 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1053 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301054 }
1055 else
1056 {
1057 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1058 }
1059
Dino Mycle3b9536d2014-07-09 22:05:24 +05301060 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1061 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1062 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1063 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1064 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1065 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1066 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1067 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1068 }
1069 else
1070 {
1071 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1072 }
1073
1074
Sunil Duttc69bccb2014-05-26 21:30:20 +05301075
1076 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301077 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1078 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_IFACE) ||
1079 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301080 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1081 pWifiIfaceStat->beaconRx) ||
1082 nla_put_u32(vendor_event,
1083 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1084 pWifiIfaceStat->mgmtRx) ||
1085 nla_put_u32(vendor_event,
1086 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1087 pWifiIfaceStat->mgmtActionRx) ||
1088 nla_put_u32(vendor_event,
1089 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1090 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301091 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301092 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1093 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301094 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301095 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1096 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301097 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301098 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1099 pWifiIfaceStat->rssiAck))
1100 {
1101 hddLog(VOS_TRACE_LEVEL_ERROR,
1102 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301103 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301104 return FALSE;
1105 }
1106
1107 wmmInfo = nla_nest_start(vendor_event,
1108 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301109 if(!wmmInfo)
1110 {
1111 vos_mem_free(pWifiIfaceStatTL);
1112 return FALSE;
1113 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301114 for (i = 0; i < WIFI_AC_MAX; i++)
1115 {
1116 struct nlattr *wmmStats;
1117 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301118 if(!wmmStats)
1119 {
1120 vos_mem_free(pWifiIfaceStatTL);
1121 return FALSE;
1122 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301123 if (FALSE == put_wifi_wmm_ac_stat(
1124 &pWifiIfaceStat->AccessclassStats[i],
1125 vendor_event))
1126 {
1127 hddLog(VOS_TRACE_LEVEL_ERROR,
1128 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301129 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301130 return FALSE;
1131 }
1132
1133 nla_nest_end(vendor_event, wmmStats);
1134 }
1135 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301136 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301137 return TRUE;
1138}
1139
1140static tSirWifiInterfaceMode
1141 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1142{
1143 switch (deviceMode)
1144 {
1145 case WLAN_HDD_INFRA_STATION:
1146 return WIFI_INTERFACE_STA;
1147 case WLAN_HDD_SOFTAP:
1148 return WIFI_INTERFACE_SOFTAP;
1149 case WLAN_HDD_P2P_CLIENT:
1150 return WIFI_INTERFACE_P2P_CLIENT;
1151 case WLAN_HDD_P2P_GO:
1152 return WIFI_INTERFACE_P2P_GO;
1153 case WLAN_HDD_IBSS:
1154 return WIFI_INTERFACE_IBSS;
1155 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301156 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301157 }
1158}
1159
1160static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1161 tpSirWifiInterfaceInfo pInfo)
1162{
1163 v_U8_t *staMac = NULL;
1164 hdd_station_ctx_t *pHddStaCtx;
1165 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1166 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1167
1168 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1169
1170 vos_mem_copy(pInfo->macAddr,
1171 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1172
1173 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1174 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1175 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1176 {
1177 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1178 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1179 {
1180 pInfo->state = WIFI_DISCONNECTED;
1181 }
1182 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1183 {
1184 hddLog(VOS_TRACE_LEVEL_ERROR,
1185 "%s: Session ID %d, Connection is in progress", __func__,
1186 pAdapter->sessionId);
1187 pInfo->state = WIFI_ASSOCIATING;
1188 }
1189 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1190 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1191 {
1192 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1193 hddLog(VOS_TRACE_LEVEL_ERROR,
1194 "%s: client " MAC_ADDRESS_STR
1195 " is in the middle of WPS/EAPOL exchange.", __func__,
1196 MAC_ADDR_ARRAY(staMac));
1197 pInfo->state = WIFI_AUTHENTICATING;
1198 }
1199 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1200 {
1201 pInfo->state = WIFI_ASSOCIATED;
1202 vos_mem_copy(pInfo->bssid,
1203 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1204 vos_mem_copy(pInfo->ssid,
1205 pHddStaCtx->conn_info.SSID.SSID.ssId,
1206 pHddStaCtx->conn_info.SSID.SSID.length);
1207 //NULL Terminate the string.
1208 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1209 }
1210 }
1211 vos_mem_copy(pInfo->countryStr,
1212 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1213
1214 vos_mem_copy(pInfo->apCountryStr,
1215 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1216
1217 return TRUE;
1218}
1219
1220/*
1221 * hdd_link_layer_process_peer_stats () - This function is called after
1222 * receiving Link Layer Peer statistics from FW.This function converts
1223 * the firmware data to the NL data and sends the same to the kernel/upper
1224 * layers.
1225 */
1226static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1227 v_VOID_t *pData)
1228{
1229 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1230 tpSirWifiRateStat pWifiRateStat;
1231 tpSirWifiPeerStat pWifiPeerStat;
1232 tpSirWifiPeerInfo pWifiPeerInfo;
1233 struct nlattr *peerInfo;
1234 struct sk_buff *vendor_event;
1235 int status, i;
1236
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301237 ENTER();
1238
Sunil Duttc69bccb2014-05-26 21:30:20 +05301239 status = wlan_hdd_validate_context(pHddCtx);
1240 if (0 != status)
1241 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301242 return;
1243 }
1244
1245 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1246
1247 hddLog(VOS_TRACE_LEVEL_INFO,
1248 "LL_STATS_PEER_ALL : numPeers %u",
1249 pWifiPeerStat->numPeers);
1250 {
1251 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1252 {
1253 pWifiPeerInfo = (tpSirWifiPeerInfo)
1254 ((uint8 *)pWifiPeerStat->peerInfo +
1255 ( i * sizeof(tSirWifiPeerInfo)));
1256
Dasari Srinivas1be0c4e2014-10-19 13:03:41 +05301257 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) {
1258 pWifiPeerInfo->type = WIFI_PEER_AP;
1259 }
1260 if (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) {
1261 pWifiPeerInfo->type = WIFI_PEER_P2P_GO;
1262 }
1263
Sunil Duttc69bccb2014-05-26 21:30:20 +05301264 hddLog(VOS_TRACE_LEVEL_INFO,
1265 " %d) LL_STATS Channel Stats "
1266 " Peer Type %u "
1267 " peerMacAddress %pM "
1268 " capabilities 0x%x "
1269 " numRate %u ",
1270 i,
1271 pWifiPeerInfo->type,
1272 pWifiPeerInfo->peerMacAddress,
1273 pWifiPeerInfo->capabilities,
1274 pWifiPeerInfo->numRate);
1275 {
1276 int j;
1277 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1278 {
1279 pWifiRateStat = (tpSirWifiRateStat)
1280 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1281 ( j * sizeof(tSirWifiRateStat)));
1282
1283 hddLog(VOS_TRACE_LEVEL_INFO,
1284 " peer Rate Stats "
1285 " preamble %u "
1286 " nss %u "
1287 " bw %u "
1288 " rateMcsIdx %u "
1289 " reserved %u "
1290 " bitrate %u "
1291 " txMpdu %u "
1292 " rxMpdu %u "
1293 " mpduLost %u "
1294 " retries %u "
1295 " retriesShort %u "
1296 " retriesLong %u",
1297 pWifiRateStat->rate.preamble,
1298 pWifiRateStat->rate.nss,
1299 pWifiRateStat->rate.bw,
1300 pWifiRateStat->rate.rateMcsIdx,
1301 pWifiRateStat->rate.reserved,
1302 pWifiRateStat->rate.bitrate,
1303 pWifiRateStat->txMpdu,
1304 pWifiRateStat->rxMpdu,
1305 pWifiRateStat->mpduLost,
1306 pWifiRateStat->retries,
1307 pWifiRateStat->retriesShort,
1308 pWifiRateStat->retriesLong);
1309 }
1310 }
1311 }
1312 }
1313
1314 /*
1315 * Allocate a size of 4096 for the peer stats comprising
1316 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1317 * sizeof (tSirWifiRateStat).Each field is put with an
1318 * NL attribute.The size of 4096 is considered assuming
1319 * that number of rates shall not exceed beyond 50 with
1320 * the sizeof (tSirWifiRateStat) being 32.
1321 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301322 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1323 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301324 if (!vendor_event)
1325 {
1326 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301327 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301328 __func__);
1329 return;
1330 }
1331 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301332 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1333 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_PEER) ||
1334 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301335 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1336 pWifiPeerStat->numPeers))
1337 {
1338 hddLog(VOS_TRACE_LEVEL_ERROR,
1339 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1340 kfree_skb(vendor_event);
1341 return;
1342 }
1343
1344 peerInfo = nla_nest_start(vendor_event,
1345 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301346 if(!peerInfo)
1347 {
1348 hddLog(VOS_TRACE_LEVEL_ERROR,
1349 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1350 __func__);
1351 kfree_skb(vendor_event);
1352 return;
1353 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301354
1355 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1356 pWifiPeerStat->peerInfo);
1357
1358 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1359 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301360 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301361 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301362
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301363 if(!peers)
1364 {
1365 hddLog(VOS_TRACE_LEVEL_ERROR,
1366 "%s: peer stats put fail",
1367 __func__);
1368 kfree_skb(vendor_event);
1369 return;
1370 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301371 if (FALSE == put_wifi_peer_info(
1372 pWifiPeerInfo, vendor_event))
1373 {
1374 hddLog(VOS_TRACE_LEVEL_ERROR,
1375 "%s: put_wifi_peer_info put fail", __func__);
1376 kfree_skb(vendor_event);
1377 return;
1378 }
1379
1380 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1381 pWifiPeerStat->peerInfo +
1382 (i * sizeof(tSirWifiPeerInfo)) +
1383 (numRate * sizeof (tSirWifiRateStat)));
1384 nla_nest_end(vendor_event, peers);
1385 }
1386 nla_nest_end(vendor_event, peerInfo);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301387 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301388 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301389}
1390
1391/*
1392 * hdd_link_layer_process_iface_stats () - This function is called after
1393 * receiving Link Layer Interface statistics from FW.This function converts
1394 * the firmware data to the NL data and sends the same to the kernel/upper
1395 * layers.
1396 */
1397static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1398 v_VOID_t *pData)
1399{
1400 tpSirWifiIfaceStat pWifiIfaceStat;
1401 struct sk_buff *vendor_event;
1402 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1403 int status;
1404
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301405 ENTER();
1406
Sunil Duttc69bccb2014-05-26 21:30:20 +05301407 status = wlan_hdd_validate_context(pHddCtx);
1408 if (0 != status)
1409 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301410 return;
1411 }
1412 /*
1413 * Allocate a size of 4096 for the interface stats comprising
1414 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1415 * assuming that all these fit with in the limit.Please take
1416 * a call on the limit based on the data requirements on
1417 * interface statistics.
1418 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301419 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1420 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301421 if (!vendor_event)
1422 {
1423 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301424 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301425 return;
1426 }
1427
1428 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1429
Dino Mycle3b9536d2014-07-09 22:05:24 +05301430
1431 if (FALSE == hdd_get_interface_info( pAdapter,
1432 &pWifiIfaceStat->info))
1433 {
1434 hddLog(VOS_TRACE_LEVEL_ERROR,
1435 FL("hdd_get_interface_info get fail") );
1436 kfree_skb(vendor_event);
1437 return;
1438 }
1439
1440 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1441 vendor_event))
1442 {
1443 hddLog(VOS_TRACE_LEVEL_ERROR,
1444 FL("put_wifi_iface_stats fail") );
1445 kfree_skb(vendor_event);
1446 return;
1447 }
1448
Sunil Duttc69bccb2014-05-26 21:30:20 +05301449 hddLog(VOS_TRACE_LEVEL_INFO,
1450 "WMI_LINK_STATS_IFACE Data");
1451
1452 hddLog(VOS_TRACE_LEVEL_INFO,
1453 "LL_STATS_IFACE: "
1454 " Mode %u "
1455 " MAC %pM "
1456 " State %u "
1457 " Roaming %u "
1458 " capabilities 0x%x "
1459 " SSID %s "
1460 " BSSID %pM",
1461 pWifiIfaceStat->info.mode,
1462 pWifiIfaceStat->info.macAddr,
1463 pWifiIfaceStat->info.state,
1464 pWifiIfaceStat->info.roaming,
1465 pWifiIfaceStat->info.capabilities,
1466 pWifiIfaceStat->info.ssid,
1467 pWifiIfaceStat->info.bssid);
1468
1469 hddLog(VOS_TRACE_LEVEL_INFO,
1470 " AP country str: %c%c%c",
1471 pWifiIfaceStat->info.apCountryStr[0],
1472 pWifiIfaceStat->info.apCountryStr[1],
1473 pWifiIfaceStat->info.apCountryStr[2]);
1474
1475
1476 hddLog(VOS_TRACE_LEVEL_INFO,
1477 " Country Str Association: %c%c%c",
1478 pWifiIfaceStat->info.countryStr[0],
1479 pWifiIfaceStat->info.countryStr[1],
1480 pWifiIfaceStat->info.countryStr[2]);
1481
1482 hddLog(VOS_TRACE_LEVEL_INFO,
1483 " beaconRx %u "
1484 " mgmtRx %u "
1485 " mgmtActionRx %u "
1486 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301487 " rssiMgmt %d "
1488 " rssiData %d "
1489 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301490 pWifiIfaceStat->beaconRx,
1491 pWifiIfaceStat->mgmtRx,
1492 pWifiIfaceStat->mgmtActionRx,
1493 pWifiIfaceStat->mgmtActionTx,
1494 pWifiIfaceStat->rssiMgmt,
1495 pWifiIfaceStat->rssiData,
1496 pWifiIfaceStat->rssiAck );
1497
1498
1499 {
1500 int i;
1501 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1502 {
1503 hddLog(VOS_TRACE_LEVEL_INFO,
1504
1505 " %d) LL_STATS IFACE: "
1506 " ac: %u txMpdu: %u "
1507 " rxMpdu: %u txMcast: %u "
1508 " rxMcast: %u rxAmpdu: %u "
1509 " txAmpdu: %u mpduLost: %u "
1510 " retries: %u retriesShort: %u "
1511 " retriesLong: %u contentionTimeMin: %u "
1512 " contentionTimeMax: %u contentionTimeAvg: %u "
1513 " contentionNumSamples: %u",
1514 i,
1515 pWifiIfaceStat->AccessclassStats[i].ac,
1516 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1517 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1518 pWifiIfaceStat->AccessclassStats[i].txMcast,
1519 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1520 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1521 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1522 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1523 pWifiIfaceStat->AccessclassStats[i].retries,
1524 pWifiIfaceStat->
1525 AccessclassStats[i].retriesShort,
1526 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1527 pWifiIfaceStat->
1528 AccessclassStats[i].contentionTimeMin,
1529 pWifiIfaceStat->
1530 AccessclassStats[i].contentionTimeMax,
1531 pWifiIfaceStat->
1532 AccessclassStats[i].contentionTimeAvg,
1533 pWifiIfaceStat->
1534 AccessclassStats[i].contentionNumSamples);
1535
1536 }
1537 }
1538
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301539 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301540
1541 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301542}
1543
1544/*
1545 * hdd_link_layer_process_radio_stats () - This function is called after
1546 * receiving Link Layer Radio statistics from FW.This function converts
1547 * the firmware data to the NL data and sends the same to the kernel/upper
1548 * layers.
1549 */
1550static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1551 v_VOID_t *pData)
1552{
1553 int status, i;
1554 tpSirWifiRadioStat pWifiRadioStat;
1555 tpSirWifiChannelStats pWifiChannelStats;
1556 struct sk_buff *vendor_event;
1557 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1558 struct nlattr *chList;
1559
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301560 ENTER();
1561
Sunil Duttc69bccb2014-05-26 21:30:20 +05301562 status = wlan_hdd_validate_context(pHddCtx);
1563 if (0 != status)
1564 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301565 return;
1566 }
1567 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1568
1569 hddLog(VOS_TRACE_LEVEL_INFO,
1570 "LL_STATS_RADIO"
1571 " radio is %d onTime is %u "
1572 " txTime is %u rxTime is %u "
1573 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301574 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301575 " onTimePnoScan is %u onTimeHs20 is %u "
1576 " numChannels is %u",
1577 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1578 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1579 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301580 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301581 pWifiRadioStat->onTimeRoamScan,
1582 pWifiRadioStat->onTimePnoScan,
1583 pWifiRadioStat->onTimeHs20,
1584 pWifiRadioStat->numChannels);
1585 /*
1586 * Allocate a size of 4096 for the Radio stats comprising
1587 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1588 * (tSirWifiChannelStats).Each channel data is put with an
1589 * NL attribute.The size of 4096 is considered assuming that
1590 * number of channels shall not exceed beyond 60 with the
1591 * sizeof (tSirWifiChannelStats) being 24 bytes.
1592 */
1593
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301594 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1595 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301596 if (!vendor_event)
1597 {
1598 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301599 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301600 return;
1601 }
1602
1603 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301604 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1605 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_RADIO) ||
1606 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301607 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1608 pWifiRadioStat->radio) ||
1609 nla_put_u32(vendor_event,
1610 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1611 pWifiRadioStat->onTime) ||
1612 nla_put_u32(vendor_event,
1613 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1614 pWifiRadioStat->txTime) ||
1615 nla_put_u32(vendor_event,
1616 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1617 pWifiRadioStat->rxTime) ||
1618 nla_put_u32(vendor_event,
1619 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1620 pWifiRadioStat->onTimeScan) ||
1621 nla_put_u32(vendor_event,
1622 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1623 pWifiRadioStat->onTimeNbd) ||
1624 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301625 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1626 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301627 nla_put_u32(vendor_event,
1628 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1629 pWifiRadioStat->onTimeRoamScan) ||
1630 nla_put_u32(vendor_event,
1631 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1632 pWifiRadioStat->onTimePnoScan) ||
1633 nla_put_u32(vendor_event,
1634 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1635 pWifiRadioStat->onTimeHs20) ||
1636 nla_put_u32(vendor_event,
1637 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1638 pWifiRadioStat->numChannels))
1639 {
1640 hddLog(VOS_TRACE_LEVEL_ERROR,
1641 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1642 kfree_skb(vendor_event);
1643 return ;
1644 }
1645
1646 chList = nla_nest_start(vendor_event,
1647 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301648 if(!chList)
1649 {
1650 hddLog(VOS_TRACE_LEVEL_ERROR,
1651 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1652 __func__);
1653 kfree_skb(vendor_event);
1654 return;
1655 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301656 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1657 {
1658 struct nlattr *chInfo;
1659
1660 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1661 pWifiRadioStat->channels +
1662 (i * sizeof(tSirWifiChannelStats)));
1663
1664 hddLog(VOS_TRACE_LEVEL_INFO,
1665 " %d) Channel Info"
1666 " width is %u "
1667 " CenterFreq %u "
1668 " CenterFreq0 %u "
1669 " CenterFreq1 %u "
1670 " onTime %u "
1671 " ccaBusyTime %u",
1672 i,
1673 pWifiChannelStats->channel.width,
1674 pWifiChannelStats->channel.centerFreq,
1675 pWifiChannelStats->channel.centerFreq0,
1676 pWifiChannelStats->channel.centerFreq1,
1677 pWifiChannelStats->onTime,
1678 pWifiChannelStats->ccaBusyTime);
1679
1680
1681 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301682 if(!chInfo)
1683 {
1684 hddLog(VOS_TRACE_LEVEL_ERROR,
1685 "%s: failed to put chInfo",
1686 __func__);
1687 kfree_skb(vendor_event);
1688 return;
1689 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301690
1691 if (nla_put_u32(vendor_event,
1692 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1693 pWifiChannelStats->channel.width) ||
1694 nla_put_u32(vendor_event,
1695 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1696 pWifiChannelStats->channel.centerFreq) ||
1697 nla_put_u32(vendor_event,
1698 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1699 pWifiChannelStats->channel.centerFreq0) ||
1700 nla_put_u32(vendor_event,
1701 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1702 pWifiChannelStats->channel.centerFreq1) ||
1703 nla_put_u32(vendor_event,
1704 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1705 pWifiChannelStats->onTime) ||
1706 nla_put_u32(vendor_event,
1707 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1708 pWifiChannelStats->ccaBusyTime))
1709 {
1710 hddLog(VOS_TRACE_LEVEL_ERROR,
1711 FL("cfg80211_vendor_event_alloc failed") );
1712 kfree_skb(vendor_event);
1713 return ;
1714 }
1715 nla_nest_end(vendor_event, chInfo);
1716 }
1717 nla_nest_end(vendor_event, chList);
1718
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301719 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301720
1721 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301722 return;
1723}
1724
1725/*
1726 * hdd_link_layer_stats_ind_callback () - This function is called after
1727 * receiving Link Layer indications from FW.This callback converts the firmware
1728 * data to the NL data and send the same to the kernel/upper layers.
1729 */
1730static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1731 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301732 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301733{
Dino Mycled3d50022014-07-07 12:58:25 +05301734 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1735 hdd_adapter_t *pAdapter = NULL;
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301736 struct hdd_ll_stats_context *context;
Dino Mycled3d50022014-07-07 12:58:25 +05301737 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301738 int status;
1739
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301740 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301741
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301742 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301743 if (0 != status)
1744 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301745 return;
1746 }
1747
Dino Mycled3d50022014-07-07 12:58:25 +05301748 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1749 if (NULL == pAdapter)
1750 {
1751 hddLog(VOS_TRACE_LEVEL_ERROR,
1752 FL(" MAC address %pM does not exist with host"),
1753 macAddr);
1754 return;
1755 }
1756
Sunil Duttc69bccb2014-05-26 21:30:20 +05301757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301758 "%s: Interface: %s LLStats indType: %d", __func__,
1759 pAdapter->dev->name, indType);
1760
Sunil Duttc69bccb2014-05-26 21:30:20 +05301761 switch (indType)
1762 {
1763 case SIR_HAL_LL_STATS_RESULTS_RSP:
1764 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301765 hddLog(VOS_TRACE_LEVEL_INFO,
1766 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1767 hddLog(VOS_TRACE_LEVEL_INFO,
1768 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1769 linkLayerStatsResults->paramId);
1770 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301771 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1772 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301773 hddLog(VOS_TRACE_LEVEL_INFO,
1774 "LL_STATS RESULTS RESPONSE respId = %u",
1775 linkLayerStatsResults->respId);
1776 hddLog(VOS_TRACE_LEVEL_INFO,
1777 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1778 linkLayerStatsResults->moreResultToFollow);
1779 hddLog(VOS_TRACE_LEVEL_INFO,
1780 "LL_STATS RESULTS RESPONSE result = %p",
1781 linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301782 spin_lock(&hdd_context_lock);
1783 context = &pHddCtx->ll_stats_context;
1784 /* validate response received from target */
1785 if ((context->request_id != linkLayerStatsResults->respId) ||
1786 !(context->request_bitmap & linkLayerStatsResults->paramId))
1787 {
1788 spin_unlock(&hdd_context_lock);
1789 hddLog(LOGE,
1790 FL("Error : Request id %d response id %d request bitmap 0x%x"
1791 "response bitmap 0x%x"),
1792 context->request_id, linkLayerStatsResults->respId,
1793 context->request_bitmap, linkLayerStatsResults->paramId);
1794 return;
1795 }
1796 spin_unlock(&hdd_context_lock);
1797
Sunil Duttc69bccb2014-05-26 21:30:20 +05301798 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1799 {
1800 hdd_link_layer_process_radio_stats(pAdapter,
1801 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301802 spin_lock(&hdd_context_lock);
1803 context->request_bitmap &= ~(WMI_LINK_STATS_RADIO);
1804 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301805 }
1806 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1807 {
1808 hdd_link_layer_process_iface_stats(pAdapter,
1809 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301810 spin_lock(&hdd_context_lock);
1811 context->request_bitmap &= ~(WMI_LINK_STATS_IFACE);
1812 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301813 }
1814 else if ( linkLayerStatsResults->paramId &
1815 WMI_LINK_STATS_ALL_PEER )
1816 {
1817 hdd_link_layer_process_peer_stats(pAdapter,
1818 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301819 spin_lock(&hdd_context_lock);
1820 context->request_bitmap &= ~(WMI_LINK_STATS_ALL_PEER);
1821 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301822 } /* WMI_LINK_STATS_ALL_PEER */
1823 else
1824 {
1825 hddLog(VOS_TRACE_LEVEL_ERROR,
1826 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1827 }
1828
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301829 spin_lock(&hdd_context_lock);
1830 /* complete response event if all requests are completed */
1831 if (0 == context->request_bitmap)
1832 complete(&context->response_event);
1833 spin_unlock(&hdd_context_lock);
1834
Sunil Duttc69bccb2014-05-26 21:30:20 +05301835 break;
1836 }
1837 default:
1838 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1839 break;
1840 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301841
1842 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301843 return;
1844}
1845
1846const struct
1847nla_policy
1848qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1849{
1850 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1851 { .type = NLA_U32 },
1852 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1853 { .type = NLA_U32 },
1854};
1855
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301856static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1857 struct wireless_dev *wdev,
1858 const void *data,
1859 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301860{
1861 int status;
1862 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301863 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301864 struct net_device *dev = wdev->netdev;
1865 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1866 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1867
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301868 ENTER();
1869
Sunil Duttc69bccb2014-05-26 21:30:20 +05301870 status = wlan_hdd_validate_context(pHddCtx);
1871 if (0 != status)
1872 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301873 return -EINVAL;
1874 }
1875
1876 if (NULL == pAdapter)
1877 {
1878 hddLog(VOS_TRACE_LEVEL_ERROR,
1879 FL("HDD adapter is Null"));
1880 return -ENODEV;
1881 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301882 /* check the LLStats Capability */
1883 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1884 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1885 {
1886 hddLog(VOS_TRACE_LEVEL_ERROR,
1887 FL("Link Layer Statistics not supported by Firmware"));
1888 return -EINVAL;
1889 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301890
1891 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1892 (struct nlattr *)data,
1893 data_len, qca_wlan_vendor_ll_set_policy))
1894 {
1895 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1896 return -EINVAL;
1897 }
1898 if (!tb_vendor
1899 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1900 {
1901 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1902 return -EINVAL;
1903 }
1904 if (!tb_vendor[
1905 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1906 {
1907 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1908 return -EINVAL;
1909 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301910 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301911 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301912
Dino Mycledf0a5d92014-07-04 09:41:55 +05301913 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301914 nla_get_u32(
1915 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1916
Dino Mycledf0a5d92014-07-04 09:41:55 +05301917 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301918 nla_get_u32(
1919 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1920
Dino Mycled3d50022014-07-07 12:58:25 +05301921 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1922 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301923
1924
1925 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301926 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301927 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301928 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301929 hddLog(VOS_TRACE_LEVEL_INFO,
1930 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301931 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301932 hddLog(VOS_TRACE_LEVEL_INFO,
1933 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301934 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301935
1936 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1937 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301938 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301939 {
1940 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1941 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301942 return -EINVAL;
1943
1944 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301945
Sunil Duttc69bccb2014-05-26 21:30:20 +05301946 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301947 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301948 {
1949 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1950 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301951 return -EINVAL;
1952 }
1953
1954 pAdapter->isLinkLayerStatsSet = 1;
1955
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301956 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301957 return 0;
1958}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301959static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1960 struct wireless_dev *wdev,
1961 const void *data,
1962 int data_len)
1963{
1964 int ret = 0;
1965
1966 vos_ssr_protect(__func__);
1967 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1968 vos_ssr_unprotect(__func__);
1969
1970 return ret;
1971}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301972
1973const struct
1974nla_policy
1975qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1976{
1977 /* Unsigned 32bit value provided by the caller issuing the GET stats
1978 * command. When reporting
1979 * the stats results, the driver uses the same value to indicate
1980 * which GET request the results
1981 * correspond to.
1982 */
1983 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1984
1985 /* Unsigned 32bit value . bit mask to identify what statistics are
1986 requested for retrieval */
1987 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1988};
1989
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301990static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1991 struct wireless_dev *wdev,
1992 const void *data,
1993 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301994{
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301995 unsigned long rc;
1996 struct hdd_ll_stats_context *context;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301997 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1998 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301999 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302000 struct net_device *dev = wdev->netdev;
2001 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mukul Sharma10313ba2015-07-29 19:14:39 +05302002 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302003 int status;
2004
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302005 ENTER();
2006
Sunil Duttc69bccb2014-05-26 21:30:20 +05302007 status = wlan_hdd_validate_context(pHddCtx);
2008 if (0 != status)
2009 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302010 return -EINVAL ;
2011 }
2012
2013 if (NULL == pAdapter)
2014 {
2015 hddLog(VOS_TRACE_LEVEL_FATAL,
2016 "%s: HDD adapter is Null", __func__);
2017 return -ENODEV;
2018 }
Mukul Sharma10313ba2015-07-29 19:14:39 +05302019
2020 if (pHddStaCtx == NULL)
2021 {
2022 hddLog(VOS_TRACE_LEVEL_FATAL,
2023 "%s: HddStaCtx is Null", __func__);
2024 return -ENODEV;
2025 }
2026
Dino Mycledf0a5d92014-07-04 09:41:55 +05302027 /* check the LLStats Capability */
2028 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2029 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2030 {
2031 hddLog(VOS_TRACE_LEVEL_ERROR,
2032 FL("Link Layer Statistics not supported by Firmware"));
2033 return -EINVAL;
2034 }
2035
Sunil Duttc69bccb2014-05-26 21:30:20 +05302036
2037 if (!pAdapter->isLinkLayerStatsSet)
2038 {
2039 hddLog(VOS_TRACE_LEVEL_FATAL,
2040 "%s: isLinkLayerStatsSet : %d",
2041 __func__, pAdapter->isLinkLayerStatsSet);
2042 return -EINVAL;
2043 }
2044
Mukul Sharma10313ba2015-07-29 19:14:39 +05302045 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
2046 {
2047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2048 "%s: Roaming in progress, so unable to proceed this request", __func__);
2049 return -EBUSY;
2050 }
2051
Sunil Duttc69bccb2014-05-26 21:30:20 +05302052 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2053 (struct nlattr *)data,
2054 data_len, qca_wlan_vendor_ll_get_policy))
2055 {
2056 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2057 return -EINVAL;
2058 }
2059
2060 if (!tb_vendor
2061 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2062 {
2063 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2064 return -EINVAL;
2065 }
2066
2067 if (!tb_vendor
2068 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2069 {
2070 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
2071 return -EINVAL;
2072 }
2073
Sunil Duttc69bccb2014-05-26 21:30:20 +05302074
Dino Mycledf0a5d92014-07-04 09:41:55 +05302075 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302076 nla_get_u32( tb_vendor[
2077 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05302078 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302079 nla_get_u32( tb_vendor[
2080 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
2081
Dino Mycled3d50022014-07-07 12:58:25 +05302082 vos_mem_copy(linkLayerStatsGetReq.macAddr,
2083 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302084
2085 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302086 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302087 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302088 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302089 hddLog(VOS_TRACE_LEVEL_INFO,
2090 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302091 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302092
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302093 spin_lock(&hdd_context_lock);
2094 context = &pHddCtx->ll_stats_context;
2095 context->request_id = linkLayerStatsGetReq.reqId;
2096 context->request_bitmap = linkLayerStatsGetReq.paramIdMask;
2097 INIT_COMPLETION(context->response_event);
2098 spin_unlock(&hdd_context_lock);
2099
Sunil Duttc69bccb2014-05-26 21:30:20 +05302100 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302101 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302102 {
2103 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2104 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302105 return -EINVAL;
2106 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302107
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302108 rc = wait_for_completion_timeout(&context->response_event,
2109 msecs_to_jiffies(WLAN_WAIT_TIME_LL_STATS));
2110 if (!rc)
2111 {
2112 hddLog(LOGE,
2113 FL("Target response timed out request id %d request bitmap 0x%x"),
2114 context->request_id, context->request_bitmap);
2115 return -ETIMEDOUT;
2116 }
2117
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302118 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302119 return 0;
2120}
2121
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302122static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2123 struct wireless_dev *wdev,
2124 const void *data,
2125 int data_len)
2126{
2127 int ret = 0;
2128
2129 vos_ssr_protect(__func__);
2130 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
2131 vos_ssr_unprotect(__func__);
2132
2133 return ret;
2134}
2135
Sunil Duttc69bccb2014-05-26 21:30:20 +05302136const struct
2137nla_policy
2138qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
2139{
2140 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
2141 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
2142 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
2143 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
2144};
2145
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302146static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2147 struct wireless_dev *wdev,
2148 const void *data,
2149 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302150{
2151 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2152 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302153 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302154 struct net_device *dev = wdev->netdev;
2155 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2156 u32 statsClearReqMask;
2157 u8 stopReq;
2158 int status;
2159
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302160 ENTER();
2161
Sunil Duttc69bccb2014-05-26 21:30:20 +05302162 status = wlan_hdd_validate_context(pHddCtx);
2163 if (0 != status)
2164 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302165 return -EINVAL;
2166 }
2167
2168 if (NULL == pAdapter)
2169 {
2170 hddLog(VOS_TRACE_LEVEL_FATAL,
2171 "%s: HDD adapter is Null", __func__);
2172 return -ENODEV;
2173 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302174 /* check the LLStats Capability */
2175 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2176 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2177 {
2178 hddLog(VOS_TRACE_LEVEL_ERROR,
2179 FL("Enable LLStats Capability"));
2180 return -EINVAL;
2181 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302182
2183 if (!pAdapter->isLinkLayerStatsSet)
2184 {
2185 hddLog(VOS_TRACE_LEVEL_FATAL,
2186 "%s: isLinkLayerStatsSet : %d",
2187 __func__, pAdapter->isLinkLayerStatsSet);
2188 return -EINVAL;
2189 }
2190
2191 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2192 (struct nlattr *)data,
2193 data_len, qca_wlan_vendor_ll_clr_policy))
2194 {
2195 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2196 return -EINVAL;
2197 }
2198
2199 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2200
2201 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2202 {
2203 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2204 return -EINVAL;
2205
2206 }
2207
Sunil Duttc69bccb2014-05-26 21:30:20 +05302208
Dino Mycledf0a5d92014-07-04 09:41:55 +05302209 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302210 nla_get_u32(
2211 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2212
Dino Mycledf0a5d92014-07-04 09:41:55 +05302213 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302214 nla_get_u8(
2215 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2216
2217 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302218 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302219
Dino Mycled3d50022014-07-07 12:58:25 +05302220 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2221 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302222
2223 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302224 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302225 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302226 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302227 hddLog(VOS_TRACE_LEVEL_INFO,
2228 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302229 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302230 hddLog(VOS_TRACE_LEVEL_INFO,
2231 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302232 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302233
2234 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302235 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302236 {
2237 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302238 hdd_station_ctx_t *pHddStaCtx;
2239
2240 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2241 if (VOS_STATUS_SUCCESS !=
2242 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2243 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2244 {
2245 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2246 "WLANTL_ClearInterfaceStats Failed", __func__);
2247 return -EINVAL;
2248 }
2249 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2250 (statsClearReqMask & WIFI_STATS_IFACE)) {
2251 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2252 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2253 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2254 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2255 }
2256
Sunil Duttc69bccb2014-05-26 21:30:20 +05302257 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2258 2 * sizeof(u32) +
2259 NLMSG_HDRLEN);
2260
2261 if (temp_skbuff != NULL)
2262 {
2263
2264 if (nla_put_u32(temp_skbuff,
2265 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2266 statsClearReqMask) ||
2267 nla_put_u32(temp_skbuff,
2268 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2269 stopReq))
2270 {
2271 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2272 kfree_skb(temp_skbuff);
2273 return -EINVAL;
2274 }
2275 /* If the ask is to stop the stats collection as part of clear
2276 * (stopReq = 1) , ensure that no further requests of get
2277 * go to the firmware by having isLinkLayerStatsSet set to 0.
2278 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302279 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302280 * case the firmware is just asked to clear the statistics.
2281 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302282 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302283 pAdapter->isLinkLayerStatsSet = 0;
2284 return cfg80211_vendor_cmd_reply(temp_skbuff);
2285 }
2286 return -ENOMEM;
2287 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302288
2289 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302290 return -EINVAL;
2291}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302292static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2293 struct wireless_dev *wdev,
2294 const void *data,
2295 int data_len)
2296{
2297 int ret = 0;
2298
2299 vos_ssr_protect(__func__);
2300 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2301 vos_ssr_unprotect(__func__);
2302
2303 return ret;
2304
2305
2306}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302307#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2308
Dino Mycle6fb96c12014-06-10 11:52:40 +05302309#ifdef WLAN_FEATURE_EXTSCAN
2310static const struct nla_policy
2311wlan_hdd_extscan_config_policy
2312 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2313{
2314 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2315 { .type = NLA_U32 },
2316 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2317 { .type = NLA_U32 },
2318 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2319 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2320 { .type = NLA_U32 },
2321 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2322 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2323
2324 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2325 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2326 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2327 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2328 { .type = NLA_U8 },
2329 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2330 { .type = NLA_U32 },
2331 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2332 { .type = NLA_U32 },
2333 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2334 { .type = NLA_U32 },
2335 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] =
2336 { .type = NLA_U8 },
2337 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2338 { .type = NLA_U8 },
2339 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2340 { .type = NLA_U8 },
2341
2342 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2343 { .type = NLA_U32 },
2344 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2345 { .type = NLA_UNSPEC },
2346 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2347 { .type = NLA_S32 },
2348 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2349 { .type = NLA_S32 },
2350 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2351 { .type = NLA_U32 },
2352 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2353 { .type = NLA_U32 },
2354 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] =
2355 { .type = NLA_U32 },
2356 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]
2357 = { .type = NLA_U32 },
2358 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] =
2359 { .type = NLA_U32 },
2360 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type =
2361 NLA_U32 },
2362};
2363
2364static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg)
2365{
2366 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2367 struct sk_buff *skb = NULL;
2368 tpSirEXTScanCapabilitiesEvent pData =
2369 (tpSirEXTScanCapabilitiesEvent) pMsg;
2370
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302371 ENTER();
2372
2373 if (wlan_hdd_validate_context(pHddCtx))
2374 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302375 return;
2376 }
2377
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302378 if (!pMsg)
2379 {
2380 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2381 return;
2382 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302383 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302384#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2385 NULL,
2386#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302387 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2388 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
2389 GFP_KERNEL);
2390
2391 if (!skb) {
2392 hddLog(VOS_TRACE_LEVEL_ERROR,
2393 FL("cfg80211_vendor_event_alloc failed"));
2394 return;
2395 }
2396
2397 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2398 hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize);
2399 hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets);
2400 hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan);
2401 hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)",
2402 pData->maxRssiSampleSize);
2403 hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)",
2404 pData->maxScanReportingThreshold);
2405 hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs);
2406 hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)",
2407 pData->maxSignificantWifiChangeAPs);
2408 hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)",
2409 pData->maxBsidHistoryEntries);
2410
2411 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2412 pData->requestId) ||
2413 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) ||
2414 nla_put_u32(skb,
2415 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
2416 pData->scanCacheSize) ||
2417 nla_put_u32(skb,
2418 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
2419 pData->scanBuckets) ||
2420 nla_put_u32(skb,
2421 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
2422 pData->maxApPerScan) ||
2423 nla_put_u32(skb,
2424 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
2425 pData->maxRssiSampleSize) ||
2426 nla_put_u32(skb,
2427 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
2428 pData->maxScanReportingThreshold) ||
2429 nla_put_u32(skb,
2430 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS,
2431 pData->maxHotlistAPs) ||
2432 nla_put_u32(skb,
2433 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
2434 pData->maxSignificantWifiChangeAPs) ||
2435 nla_put_u32(skb,
2436 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
2437 pData->maxBsidHistoryEntries)) {
2438 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2439 goto nla_put_failure;
2440 }
2441
2442 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302443 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302444 return;
2445
2446nla_put_failure:
2447 kfree_skb(skb);
2448 return;
2449}
2450
2451
2452static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2453{
2454 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2455 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2456 struct sk_buff *skb = NULL;
2457 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
2458
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302459 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302460
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302461 if (wlan_hdd_validate_context(pHddCtx)){
2462 return;
2463 }
2464 if (!pMsg)
2465 {
2466 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302467 return;
2468 }
2469
2470 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302471#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2472 NULL,
2473#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302474 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2475 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
2476 GFP_KERNEL);
2477
2478 if (!skb) {
2479 hddLog(VOS_TRACE_LEVEL_ERROR,
2480 FL("cfg80211_vendor_event_alloc failed"));
2481 return;
2482 }
2483 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2484 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2485 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2486
2487 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2488 pData->requestId) ||
2489 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2490 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2491 goto nla_put_failure;
2492 }
2493
2494 /*
2495 * Store the Request ID for comparing with the requestID obtained
2496 * in other requests.HDD shall return a failure is the extscan_stop
2497 * request is issued with a different requestId as that of the
2498 * extscan_start request. Also, This requestId shall be used while
2499 * indicating the full scan results to the upper layers.
2500 * The requestId is stored with the assumption that the firmware
2501 * shall return the ext scan start request's requestId in ext scan
2502 * start response.
2503 */
2504 if (pData->status == 0)
2505 pMac->sme.extScanStartReqId = pData->requestId;
2506
2507
2508 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302509 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302510 return;
2511
2512nla_put_failure:
2513 kfree_skb(skb);
2514 return;
2515}
2516
2517
2518static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2519{
2520 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2521 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2522 struct sk_buff *skb = NULL;
2523
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302524 ENTER();
2525
2526 if (wlan_hdd_validate_context(pHddCtx)){
2527 return;
2528 }
2529 if (!pMsg)
2530 {
2531 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302532 return;
2533 }
2534
2535 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302536#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2537 NULL,
2538#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302539 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2540 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2541 GFP_KERNEL);
2542
2543 if (!skb) {
2544 hddLog(VOS_TRACE_LEVEL_ERROR,
2545 FL("cfg80211_vendor_event_alloc failed"));
2546 return;
2547 }
2548 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2549 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2550
2551 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2552 pData->requestId) ||
2553 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2554 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2555 goto nla_put_failure;
2556 }
2557
2558 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302559 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302560 return;
2561
2562nla_put_failure:
2563 kfree_skb(skb);
2564 return;
2565}
2566
2567
2568static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2569 void *pMsg)
2570{
2571 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2572 struct sk_buff *skb = NULL;
2573 tpSirEXTScanSetBssidHotListRspParams pData =
2574 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2575
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302576 ENTER();
2577
2578 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302579 return;
2580 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302581 if (!pMsg)
2582 {
2583 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2584 return;
2585 }
2586
Dino Mycle6fb96c12014-06-10 11:52:40 +05302587 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302588#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2589 NULL,
2590#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302591 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2592 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2593 GFP_KERNEL);
2594
2595 if (!skb) {
2596 hddLog(VOS_TRACE_LEVEL_ERROR,
2597 FL("cfg80211_vendor_event_alloc failed"));
2598 return;
2599 }
2600 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2601 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2602 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2603
2604 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2605 pData->requestId) ||
2606 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2607 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2608 goto nla_put_failure;
2609 }
2610
2611 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302612 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302613 return;
2614
2615nla_put_failure:
2616 kfree_skb(skb);
2617 return;
2618}
2619
2620static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2621 void *pMsg)
2622{
2623 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2624 struct sk_buff *skb = NULL;
2625 tpSirEXTScanResetBssidHotlistRspParams pData =
2626 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2627
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302628 ENTER();
2629
2630 if (wlan_hdd_validate_context(pHddCtx)) {
2631 return;
2632 }
2633 if (!pMsg)
2634 {
2635 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302636 return;
2637 }
2638
2639 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302640#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2641 NULL,
2642#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302643 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2644 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2645 GFP_KERNEL);
2646
2647 if (!skb) {
2648 hddLog(VOS_TRACE_LEVEL_ERROR,
2649 FL("cfg80211_vendor_event_alloc failed"));
2650 return;
2651 }
2652 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2653 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2654
2655 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2656 pData->requestId) ||
2657 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2658 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2659 goto nla_put_failure;
2660 }
2661
2662 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302663 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302664 return;
2665
2666nla_put_failure:
2667 kfree_skb(skb);
2668 return;
2669}
2670
2671
2672static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2673 void *pMsg)
2674{
2675 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2676 struct sk_buff *skb = NULL;
2677 tpSirEXTScanSetSignificantChangeRspParams pData =
2678 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2679
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302680 ENTER();
2681
2682 if (wlan_hdd_validate_context(pHddCtx)) {
2683 return;
2684 }
2685 if (!pMsg)
2686 {
2687 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302688 return;
2689 }
2690
2691 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302692#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2693 NULL,
2694#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302695 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2696 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2697 GFP_KERNEL);
2698
2699 if (!skb) {
2700 hddLog(VOS_TRACE_LEVEL_ERROR,
2701 FL("cfg80211_vendor_event_alloc failed"));
2702 return;
2703 }
2704 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2705 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2706 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2707
2708 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2709 pData->requestId) ||
2710 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2711 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2712 goto nla_put_failure;
2713 }
2714
2715 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302716 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302717 return;
2718
2719nla_put_failure:
2720 kfree_skb(skb);
2721 return;
2722}
2723
2724
2725static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2726 void *pMsg)
2727{
2728 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2729 struct sk_buff *skb = NULL;
2730 tpSirEXTScanResetSignificantChangeRspParams pData =
2731 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2732
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302733 ENTER();
2734
2735 if (wlan_hdd_validate_context(pHddCtx)) {
2736 return;
2737 }
2738 if (!pMsg)
2739 {
2740 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302741 return;
2742 }
2743
2744 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302745#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2746 NULL,
2747#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302748 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2749 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2750 GFP_KERNEL);
2751
2752 if (!skb) {
2753 hddLog(VOS_TRACE_LEVEL_ERROR,
2754 FL("cfg80211_vendor_event_alloc failed"));
2755 return;
2756 }
2757 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2758 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2759 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2760
2761 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2762 pData->requestId) ||
2763 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2764 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2765 goto nla_put_failure;
2766 }
2767
2768 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302769 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302770 return;
2771
2772nla_put_failure:
2773 kfree_skb(skb);
2774 return;
2775}
2776
2777static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2778 void *pMsg)
2779{
2780 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2781 struct sk_buff *skb = NULL;
2782 tANI_U32 i = 0, j, resultsPerEvent;
2783 tANI_S32 totalResults;
2784 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2785 tpSirWifiScanResult pSirWifiScanResult;
2786
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302787 ENTER();
2788
2789 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302790 return;
2791 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302792 if (!pMsg)
2793 {
2794 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2795 return;
2796 }
2797
Dino Mycle6fb96c12014-06-10 11:52:40 +05302798 totalResults = pData->numOfAps;
2799 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2800 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2801 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2802
2803 do{
2804 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2805 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2806 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2807
2808 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302809#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2810 NULL,
2811#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302812 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2813 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2814 GFP_KERNEL);
2815
2816 if (!skb) {
2817 hddLog(VOS_TRACE_LEVEL_ERROR,
2818 FL("cfg80211_vendor_event_alloc failed"));
2819 return;
2820 }
2821
2822 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2823
2824 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2825 pData->requestId) ||
2826 nla_put_u32(skb,
2827 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2828 resultsPerEvent)) {
2829 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2830 goto fail;
2831 }
2832 if (nla_put_u8(skb,
2833 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2834 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2835 {
2836 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2837 goto fail;
2838 }
2839
2840 if (resultsPerEvent) {
2841 struct nlattr *aps;
2842
2843 aps = nla_nest_start(skb,
2844 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2845 if (!aps)
2846 {
2847 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2848 goto fail;
2849 }
2850
2851 for (j = 0; j < resultsPerEvent; j++, i++) {
2852 struct nlattr *ap;
2853 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2854 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2855
2856 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2857 "Ssid (%s)"
2858 "Bssid: %pM "
2859 "Channel (%u)"
2860 "Rssi (%d)"
2861 "RTT (%u)"
2862 "RTT_SD (%u)",
2863 i,
2864 pSirWifiScanResult->ts,
2865 pSirWifiScanResult->ssid,
2866 pSirWifiScanResult->bssid,
2867 pSirWifiScanResult->channel,
2868 pSirWifiScanResult->rssi,
2869 pSirWifiScanResult->rtt,
2870 pSirWifiScanResult->rtt_sd);
2871
2872 ap = nla_nest_start(skb, j + 1);
2873 if (!ap)
2874 {
2875 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2876 goto fail;
2877 }
2878
2879 if (nla_put_u64(skb,
2880 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2881 pSirWifiScanResult->ts) )
2882 {
2883 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2884 goto fail;
2885 }
2886 if (nla_put(skb,
2887 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2888 sizeof(pSirWifiScanResult->ssid),
2889 pSirWifiScanResult->ssid) )
2890 {
2891 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2892 goto fail;
2893 }
2894 if (nla_put(skb,
2895 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2896 sizeof(pSirWifiScanResult->bssid),
2897 pSirWifiScanResult->bssid) )
2898 {
2899 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2900 goto fail;
2901 }
2902 if (nla_put_u32(skb,
2903 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2904 pSirWifiScanResult->channel) )
2905 {
2906 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2907 goto fail;
2908 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302909 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302910 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2911 pSirWifiScanResult->rssi) )
2912 {
2913 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2914 goto fail;
2915 }
2916 if (nla_put_u32(skb,
2917 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2918 pSirWifiScanResult->rtt) )
2919 {
2920 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2921 goto fail;
2922 }
2923 if (nla_put_u32(skb,
2924 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2925 pSirWifiScanResult->rtt_sd))
2926 {
2927 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2928 goto fail;
2929 }
2930
2931 nla_nest_end(skb, ap);
2932 }
2933 nla_nest_end(skb, aps);
2934
2935 }
2936 cfg80211_vendor_event(skb, GFP_KERNEL);
2937 } while (totalResults > 0);
2938
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302939 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302940 return;
2941fail:
2942 kfree_skb(skb);
2943 return;
2944}
2945
2946static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2947 void *pMsg)
2948{
2949 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2950 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2951 struct sk_buff *skb = NULL;
2952 tANI_U32 i;
2953
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302954 ENTER();
2955
2956 if (wlan_hdd_validate_context(pHddCtx)) {
2957 return;
2958 }
2959 if (!pMsg)
2960 {
2961 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302962 return;
2963 }
2964
2965 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302966#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2967 NULL,
2968#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302969 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2970 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
2971 GFP_KERNEL);
2972
2973 if (!skb) {
2974 hddLog(VOS_TRACE_LEVEL_ERROR,
2975 FL("cfg80211_vendor_event_alloc failed"));
2976 return;
2977 }
2978 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2979 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2980 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2981 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2982
2983 for (i = 0; i < pData->numOfAps; i++) {
2984 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2985 "Ssid (%s) "
2986 "Bssid (" MAC_ADDRESS_STR ") "
2987 "Channel (%u) "
2988 "Rssi (%d) "
2989 "RTT (%u) "
2990 "RTT_SD (%u) ",
2991 i,
2992 pData->ap[i].ts,
2993 pData->ap[i].ssid,
2994 MAC_ADDR_ARRAY(pData->ap[i].bssid),
2995 pData->ap[i].channel,
2996 pData->ap[i].rssi,
2997 pData->ap[i].rtt,
2998 pData->ap[i].rtt_sd);
2999 }
3000
3001 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3002 pData->requestId) ||
3003 nla_put_u32(skb,
3004 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3005 pData->numOfAps)) {
3006 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3007 goto fail;
3008 }
3009 if (pData->numOfAps) {
3010 struct nlattr *aps;
3011
3012 aps = nla_nest_start(skb,
3013 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3014 if (!aps)
3015 goto fail;
3016
3017 for (i = 0; i < pData->numOfAps; i++) {
3018 struct nlattr *ap;
3019
3020 ap = nla_nest_start(skb, i + 1);
3021 if (!ap)
3022 goto fail;
3023
3024 if (nla_put_u64(skb,
3025 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3026 pData->ap[i].ts) ||
3027 nla_put(skb,
3028 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3029 sizeof(pData->ap[i].ssid),
3030 pData->ap[i].ssid) ||
3031 nla_put(skb,
3032 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3033 sizeof(pData->ap[i].bssid),
3034 pData->ap[i].bssid) ||
3035 nla_put_u32(skb,
3036 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3037 pData->ap[i].channel) ||
3038 nla_put_s32(skb,
3039 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
3040 pData->ap[i].rssi) ||
3041 nla_put_u32(skb,
3042 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3043 pData->ap[i].rtt) ||
3044 nla_put_u32(skb,
3045 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3046 pData->ap[i].rtt_sd))
3047 goto fail;
3048
3049 nla_nest_end(skb, ap);
3050 }
3051 nla_nest_end(skb, aps);
3052
3053 if (nla_put_u8(skb,
3054 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3055 pData->moreData))
3056 goto fail;
3057 }
3058
3059 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303060 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303061 return;
3062
3063fail:
3064 kfree_skb(skb);
3065 return;
3066
3067}
3068static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
3069 void *pMsg)
3070{
3071 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3072 struct sk_buff *skb = NULL;
3073 tANI_U32 i, j;
3074 tpSirWifiSignificantChangeEvent pData =
3075 (tpSirWifiSignificantChangeEvent) pMsg;
3076
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303077 ENTER();
3078
3079 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303080 return;
3081 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303082 if (!pMsg)
3083 {
3084 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3085 return;
3086 }
3087
Dino Mycle6fb96c12014-06-10 11:52:40 +05303088 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303089#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3090 NULL,
3091#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303092 EXTSCAN_EVENT_BUF_SIZE,
3093 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
3094 GFP_KERNEL);
3095
3096 if (!skb) {
3097 hddLog(VOS_TRACE_LEVEL_ERROR,
3098 FL("cfg80211_vendor_event_alloc failed"));
3099 return;
3100 }
3101 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3102 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3103 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
3104 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
3105 pData->numSigRssiBss);
3106 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
3107
3108 for (i = 0; i < pData->numSigRssiBss; i++) {
3109 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
3110 " num RSSI %u ",
3111 i, pData->sigRssiResult[i].bssid,
3112 pData->sigRssiResult[i].channel,
3113 pData->sigRssiResult[i].numRssi);
3114
3115 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
3116
3117 hddLog(VOS_TRACE_LEVEL_INFO,
3118 " [%d]",
Dino Myclec8f3f332014-07-21 16:48:27 +05303119 pData->sigRssiResult[i].rssi[j]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303120
3121 }
3122 }
3123
3124
3125 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3126 pData->requestId) ||
3127 nla_put_u32(skb,
3128 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3129 pData->numSigRssiBss)) {
3130 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3131 goto fail;
3132 }
3133
3134 if (pData->numSigRssiBss) {
3135 struct nlattr *aps;
3136 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3137 if (!aps)
3138 goto fail;
3139 for (i = 0; i < pData->numSigRssiBss; i++) {
3140 struct nlattr *ap;
3141
3142 ap = nla_nest_start(skb, i);
3143 if (!ap)
3144 goto fail;
3145 if (nla_put(skb,
3146 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
3147 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
3148 nla_put_u32(skb,
3149 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
3150 pData->sigRssiResult[i].channel) ||
3151 nla_put_u32(skb,
3152 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
3153 pData->sigRssiResult[i].numRssi) ||
3154 nla_put(skb,
3155 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
3156 sizeof(s32) * pData->sigRssiResult[i].numRssi,
3157 pData->sigRssiResult[i].rssi))
3158 goto fail;
3159 nla_nest_end(skb, ap);
3160 }
3161 nla_nest_end(skb, aps);
3162 if (nla_put_u8(skb,
3163 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3164 pData->moreData))
3165 goto fail;
3166 }
3167 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303168 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303169 return;
3170fail:
3171 kfree_skb(skb);
3172 return;
3173}
3174
3175static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3176 void *pMsg)
3177{
3178 struct sk_buff *skb;
3179 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3180 tpSirWifiFullScanResultEvent pData =
3181 (tpSirWifiFullScanResultEvent) (pMsg);
3182
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303183 ENTER();
3184
3185 if (wlan_hdd_validate_context(pHddCtx)) {
3186 return;
3187 }
3188 if (!pMsg)
3189 {
3190 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303191 return;
3192 }
3193
3194 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303195#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3196 NULL,
3197#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303198 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3199 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3200 GFP_KERNEL);
3201
3202 if (!skb) {
3203 hddLog(VOS_TRACE_LEVEL_ERROR,
3204 FL("cfg80211_vendor_event_alloc failed"));
3205 return;
3206 }
3207
3208 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3209 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3210 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3211 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3212 "Ssid (%s)"
3213 "Bssid (" MAC_ADDRESS_STR ")"
3214 "Channel (%u)"
3215 "Rssi (%d)"
3216 "RTT (%u)"
3217 "RTT_SD (%u)"),
3218 pData->ap.ts,
3219 pData->ap.ssid,
3220 MAC_ADDR_ARRAY(pData->ap.bssid),
3221 pData->ap.channel,
3222 pData->ap.rssi,
3223 pData->ap.rtt,
3224 pData->ap.rtt_sd);
3225 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3226 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3227 pData->requestId) ||
3228 nla_put_u64(skb,
3229 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3230 pData->ap.ts) ||
3231 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3232 sizeof(pData->ap.ssid),
3233 pData->ap.ssid) ||
3234 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3235 WNI_CFG_BSSID_LEN,
3236 pData->ap.bssid) ||
3237 nla_put_u32(skb,
3238 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3239 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303240 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303241 pData->ap.rssi) ||
3242 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3243 pData->ap.rtt) ||
3244 nla_put_u32(skb,
3245 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3246 pData->ap.rtt_sd) ||
3247 nla_put_u16(skb,
3248 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3249 pData->ap.beaconPeriod) ||
3250 nla_put_u16(skb,
3251 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3252 pData->ap.capability) ||
3253 nla_put_u32(skb,
3254 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3255 pData->ieLength))
3256 {
3257 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3258 goto nla_put_failure;
3259 }
3260 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3261 pData->ieLength,
3262 pData->ie))
3263 {
3264 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3265 goto nla_put_failure;
3266 }
3267
3268 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303269 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303270 return;
3271
3272nla_put_failure:
3273 kfree_skb(skb);
3274 return;
3275}
3276
3277static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3278 void *pMsg)
3279{
3280 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3281 struct sk_buff *skb = NULL;
3282 tpSirEXTScanResultsAvailableIndParams pData =
3283 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3284
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303285 ENTER();
3286
3287 if (wlan_hdd_validate_context(pHddCtx)){
3288 return;
3289 }
3290 if (!pMsg)
3291 {
3292 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303293 return;
3294 }
3295
3296 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303297#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3298 NULL,
3299#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303300 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3301 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3302 GFP_KERNEL);
3303
3304 if (!skb) {
3305 hddLog(VOS_TRACE_LEVEL_ERROR,
3306 FL("cfg80211_vendor_event_alloc failed"));
3307 return;
3308 }
3309
3310 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3311 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3312 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3313 pData->numResultsAvailable);
3314 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3315 pData->requestId) ||
3316 nla_put_u32(skb,
3317 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3318 pData->numResultsAvailable)) {
3319 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3320 goto nla_put_failure;
3321 }
3322
3323 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303324 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303325 return;
3326
3327nla_put_failure:
3328 kfree_skb(skb);
3329 return;
3330}
3331
3332static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3333{
3334 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3335 struct sk_buff *skb = NULL;
3336 tpSirEXTScanProgressIndParams pData =
3337 (tpSirEXTScanProgressIndParams) pMsg;
3338
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303339 ENTER();
3340
3341 if (wlan_hdd_validate_context(pHddCtx)){
3342 return;
3343 }
3344 if (!pMsg)
3345 {
3346 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303347 return;
3348 }
3349
3350 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303351#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3352 NULL,
3353#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303354 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3355 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3356 GFP_KERNEL);
3357
3358 if (!skb) {
3359 hddLog(VOS_TRACE_LEVEL_ERROR,
3360 FL("cfg80211_vendor_event_alloc failed"));
3361 return;
3362 }
3363 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3364 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3365 pData->extScanEventType);
3366 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3367 pData->status);
3368
3369 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3370 pData->extScanEventType) ||
3371 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303372 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3373 pData->requestId) ||
3374 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303375 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3376 pData->status)) {
3377 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3378 goto nla_put_failure;
3379 }
3380
3381 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303382 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303383 return;
3384
3385nla_put_failure:
3386 kfree_skb(skb);
3387 return;
3388}
3389
3390void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3391 void *pMsg)
3392{
3393 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3394
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303395 ENTER();
3396
Dino Mycle6fb96c12014-06-10 11:52:40 +05303397 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303398 return;
3399 }
3400
3401 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3402
3403
3404 switch(evType) {
3405 case SIR_HAL_EXTSCAN_START_RSP:
3406 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3407 break;
3408
3409 case SIR_HAL_EXTSCAN_STOP_RSP:
3410 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3411 break;
3412 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3413 /* There is no need to send this response to upper layer
3414 Just log the message */
3415 hddLog(VOS_TRACE_LEVEL_INFO,
3416 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3417 break;
3418 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3419 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3420 break;
3421
3422 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3423 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3424 break;
3425
3426 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
3427 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
3428 break;
3429
3430 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
3431 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
3432 break;
3433 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
3434 wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg);
3435 break;
3436 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3437 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3438 break;
3439 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3440 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3441 break;
3442 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3443 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3444 break;
3445 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3446 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3447 break;
3448 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
3449 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
3450 break;
3451 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3452 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3453 break;
3454 default:
3455 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3456 break;
3457 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303458 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303459}
3460
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303461static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3462 struct wireless_dev *wdev,
3463 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303464{
Dino Myclee8843b32014-07-04 14:21:45 +05303465 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303466 struct net_device *dev = wdev->netdev;
3467 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3468 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3469 struct nlattr
3470 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3471 eHalStatus status;
3472
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303473 ENTER();
3474
Dino Mycle6fb96c12014-06-10 11:52:40 +05303475 status = wlan_hdd_validate_context(pHddCtx);
3476 if (0 != status)
3477 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303478 return -EINVAL;
3479 }
Dino Myclee8843b32014-07-04 14:21:45 +05303480 /* check the EXTScan Capability */
3481 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3482 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3483 {
3484 hddLog(VOS_TRACE_LEVEL_ERROR,
3485 FL("EXTScan not enabled/supported by Firmware"));
3486 return -EINVAL;
3487 }
3488
Dino Mycle6fb96c12014-06-10 11:52:40 +05303489 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3490 data, dataLen,
3491 wlan_hdd_extscan_config_policy)) {
3492 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3493 return -EINVAL;
3494 }
3495
3496 /* Parse and fetch request Id */
3497 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3498 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3499 return -EINVAL;
3500 }
3501
Dino Mycle6fb96c12014-06-10 11:52:40 +05303502
Dino Myclee8843b32014-07-04 14:21:45 +05303503 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303504 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303505 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303506
Dino Myclee8843b32014-07-04 14:21:45 +05303507 reqMsg.sessionId = pAdapter->sessionId;
3508 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303509
Dino Myclee8843b32014-07-04 14:21:45 +05303510 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303511 if (!HAL_STATUS_SUCCESS(status)) {
3512 hddLog(VOS_TRACE_LEVEL_ERROR,
3513 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303514 return -EINVAL;
3515 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303516 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303517 return 0;
3518}
3519
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303520static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3521 struct wireless_dev *wdev,
3522 const void *data, int dataLen)
3523{
3524 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303525
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303526 vos_ssr_protect(__func__);
3527 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3528 vos_ssr_unprotect(__func__);
3529
3530 return ret;
3531}
3532
3533static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3534 struct wireless_dev *wdev,
3535 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303536{
Dino Myclee8843b32014-07-04 14:21:45 +05303537 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303538 struct net_device *dev = wdev->netdev;
3539 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3540 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3541 struct nlattr
3542 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3543 eHalStatus status;
3544
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303545 ENTER();
3546
Dino Mycle6fb96c12014-06-10 11:52:40 +05303547 status = wlan_hdd_validate_context(pHddCtx);
3548 if (0 != status)
3549 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303550 return -EINVAL;
3551 }
Dino Myclee8843b32014-07-04 14:21:45 +05303552 /* check the EXTScan Capability */
3553 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3554 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3555 {
3556 hddLog(VOS_TRACE_LEVEL_ERROR,
3557 FL("EXTScan not enabled/supported by Firmware"));
3558 return -EINVAL;
3559 }
3560
Dino Mycle6fb96c12014-06-10 11:52:40 +05303561 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3562 data, dataLen,
3563 wlan_hdd_extscan_config_policy)) {
3564 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3565 return -EINVAL;
3566 }
3567 /* Parse and fetch request Id */
3568 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3569 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3570 return -EINVAL;
3571 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303572
Dino Myclee8843b32014-07-04 14:21:45 +05303573 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303574 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3575
Dino Myclee8843b32014-07-04 14:21:45 +05303576 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303577
Dino Myclee8843b32014-07-04 14:21:45 +05303578 reqMsg.sessionId = pAdapter->sessionId;
3579 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303580
3581 /* Parse and fetch flush parameter */
3582 if (!tb
3583 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3584 {
3585 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3586 goto failed;
3587 }
Dino Myclee8843b32014-07-04 14:21:45 +05303588 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303589 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3590
Dino Myclee8843b32014-07-04 14:21:45 +05303591 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303592
Dino Myclee8843b32014-07-04 14:21:45 +05303593 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303594 if (!HAL_STATUS_SUCCESS(status)) {
3595 hddLog(VOS_TRACE_LEVEL_ERROR,
3596 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303597 return -EINVAL;
3598 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303599 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303600 return 0;
3601
3602failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303603 return -EINVAL;
3604}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303605static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3606 struct wireless_dev *wdev,
3607 const void *data, int dataLen)
3608{
3609 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303610
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303611 vos_ssr_protect(__func__);
3612 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3613 vos_ssr_unprotect(__func__);
3614
3615 return ret;
3616}
3617
3618static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303619 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303620 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303621{
3622 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3623 struct net_device *dev = wdev->netdev;
3624 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3625 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3626 struct nlattr
3627 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3628 struct nlattr
3629 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3630 struct nlattr *apTh;
3631 eHalStatus status;
3632 tANI_U8 i = 0;
3633 int rem;
3634
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303635 ENTER();
3636
Dino Mycle6fb96c12014-06-10 11:52:40 +05303637 status = wlan_hdd_validate_context(pHddCtx);
3638 if (0 != status)
3639 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303640 return -EINVAL;
3641 }
Dino Myclee8843b32014-07-04 14:21:45 +05303642 /* check the EXTScan Capability */
3643 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3644 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3645 {
3646 hddLog(VOS_TRACE_LEVEL_ERROR,
3647 FL("EXTScan not enabled/supported by Firmware"));
3648 return -EINVAL;
3649 }
3650
Dino Mycle6fb96c12014-06-10 11:52:40 +05303651 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3652 data, dataLen,
3653 wlan_hdd_extscan_config_policy)) {
3654 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3655 return -EINVAL;
3656 }
3657
3658 /* Parse and fetch request Id */
3659 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3660 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3661 return -EINVAL;
3662 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303663 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3664 vos_mem_malloc(sizeof(*pReqMsg));
3665 if (!pReqMsg) {
3666 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3667 return -ENOMEM;
3668 }
3669
Dino Myclee8843b32014-07-04 14:21:45 +05303670
Dino Mycle6fb96c12014-06-10 11:52:40 +05303671 pReqMsg->requestId = nla_get_u32(
3672 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3673 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3674
3675 /* Parse and fetch number of APs */
3676 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3677 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3678 goto fail;
3679 }
3680
3681 pReqMsg->sessionId = pAdapter->sessionId;
3682 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3683
3684 pReqMsg->numAp = nla_get_u32(
3685 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3686 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3687
3688 nla_for_each_nested(apTh,
3689 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3690 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3691 nla_data(apTh), nla_len(apTh),
3692 NULL)) {
3693 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3694 goto fail;
3695 }
3696
3697 /* Parse and fetch MAC address */
3698 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3699 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3700 goto fail;
3701 }
3702 memcpy(pReqMsg->ap[i].bssid, nla_data(
3703 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3704 sizeof(tSirMacAddr));
3705 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3706
3707 /* Parse and fetch low RSSI */
3708 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3709 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3710 goto fail;
3711 }
3712 pReqMsg->ap[i].low = nla_get_s32(
3713 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3714 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3715
3716 /* Parse and fetch high RSSI */
3717 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3718 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3719 goto fail;
3720 }
3721 pReqMsg->ap[i].high = nla_get_s32(
3722 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3723 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3724 pReqMsg->ap[i].high);
3725
3726 /* Parse and fetch channel */
3727 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3728 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3729 goto fail;
3730 }
3731 pReqMsg->ap[i].channel = nla_get_u32(
3732 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3733 hddLog(VOS_TRACE_LEVEL_INFO,
3734 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3735 i++;
3736 }
3737 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3738 if (!HAL_STATUS_SUCCESS(status)) {
3739 hddLog(VOS_TRACE_LEVEL_ERROR,
3740 FL("sme_SetBssHotlist failed(err=%d)"), status);
3741 vos_mem_free(pReqMsg);
3742 return -EINVAL;
3743 }
3744
Dino Myclee8843b32014-07-04 14:21:45 +05303745 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303746 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303747 return 0;
3748
3749fail:
3750 vos_mem_free(pReqMsg);
3751 return -EINVAL;
3752}
3753
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303754static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3755 struct wireless_dev *wdev,
3756 const void *data, int dataLen)
3757{
3758 int ret = 0;
3759
3760 vos_ssr_protect(__func__);
3761 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3762 dataLen);
3763 vos_ssr_unprotect(__func__);
3764
3765 return ret;
3766}
3767
3768static int __wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303769 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303770 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303771{
3772 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3773 struct net_device *dev = wdev->netdev;
3774 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3775 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3776 struct nlattr
3777 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3778 struct nlattr
3779 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3780 struct nlattr *apTh;
3781 eHalStatus status;
3782 int i = 0;
3783 int rem;
3784
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303785 ENTER();
3786
Dino Mycle6fb96c12014-06-10 11:52:40 +05303787 status = wlan_hdd_validate_context(pHddCtx);
3788 if (0 != status)
3789 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303790 return -EINVAL;
3791 }
Dino Myclee8843b32014-07-04 14:21:45 +05303792 /* check the EXTScan Capability */
3793 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3794 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3795 {
3796 hddLog(VOS_TRACE_LEVEL_ERROR,
3797 FL("EXTScan not enabled/supported by Firmware"));
3798 return -EINVAL;
3799 }
3800
Dino Mycle6fb96c12014-06-10 11:52:40 +05303801 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3802 data, dataLen,
3803 wlan_hdd_extscan_config_policy)) {
3804 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3805 return -EINVAL;
3806 }
3807
3808 /* Parse and fetch request Id */
3809 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3810 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3811 return -EINVAL;
3812 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303813 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303814 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303815 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303816 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3817 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303818 }
3819
Dino Myclee8843b32014-07-04 14:21:45 +05303820
3821
Dino Mycle6fb96c12014-06-10 11:52:40 +05303822 pReqMsg->requestId = nla_get_u32(
3823 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3824 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3825
3826 /* Parse and fetch RSSI sample size */
3827 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3828 {
3829 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3830 goto fail;
3831 }
3832 pReqMsg->rssiSampleSize = nla_get_u32(
3833 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3834 hddLog(VOS_TRACE_LEVEL_INFO,
3835 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3836
3837 /* Parse and fetch lost AP sample size */
3838 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3839 {
3840 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3841 goto fail;
3842 }
3843 pReqMsg->lostApSampleSize = nla_get_u32(
3844 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3845 hddLog(VOS_TRACE_LEVEL_INFO,
3846 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3847 /* Parse and fetch minimum Breaching */
3848 if (!tb
3849 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3850 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3851 goto fail;
3852 }
3853 pReqMsg->minBreaching = nla_get_u32(
3854 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3855 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3856
3857 /* Parse and fetch number of APs */
3858 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3859 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3860 goto fail;
3861 }
3862 pReqMsg->numAp = nla_get_u32(
3863 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3864 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3865
3866 pReqMsg->sessionId = pAdapter->sessionId;
3867 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3868
3869 nla_for_each_nested(apTh,
3870 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3871 if(nla_parse(tb2,
3872 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3873 nla_data(apTh), nla_len(apTh),
3874 NULL)) {
3875 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3876 goto fail;
3877 }
3878
3879 /* Parse and fetch MAC address */
3880 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3881 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3882 goto fail;
3883 }
3884 memcpy(pReqMsg->ap[i].bssid, nla_data(
3885 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3886 sizeof(tSirMacAddr));
3887
3888 /* Parse and fetch low RSSI */
3889 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3890 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3891 goto fail;
3892 }
3893 pReqMsg->ap[i].low = nla_get_s32(
3894 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3895 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3896
3897 /* Parse and fetch high RSSI */
3898 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3899 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3900 goto fail;
3901 }
3902 pReqMsg->ap[i].high = nla_get_s32(
3903 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3904 hddLog(VOS_TRACE_LEVEL_INFO,
3905 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
3906
3907 /* Parse and fetch channel */
3908 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3909 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3910 goto fail;
3911 }
3912 pReqMsg->ap[i].channel = nla_get_u32(
3913 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3914 hddLog(VOS_TRACE_LEVEL_INFO,
3915 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3916 i++;
3917 }
3918
3919 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
3920 if (!HAL_STATUS_SUCCESS(status)) {
3921 hddLog(VOS_TRACE_LEVEL_ERROR,
3922 FL("sme_SetSignificantChange failed(err=%d)"), status);
3923 vos_mem_free(pReqMsg);
3924 return -EINVAL;
3925 }
Dino Myclee8843b32014-07-04 14:21:45 +05303926 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303927 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303928 return 0;
3929
3930fail:
3931 vos_mem_free(pReqMsg);
3932 return -EINVAL;
3933}
3934
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303935static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
3936 struct wireless_dev *wdev,
3937 const void *data, int dataLen)
3938{
3939 int ret = 0;
3940
3941 vos_ssr_protect(__func__);
3942 ret = __wlan_hdd_cfg80211_extscan_set_significant_change(wiphy, wdev, data,
3943 dataLen);
3944 vos_ssr_unprotect(__func__);
3945
3946 return ret;
3947}
3948
3949static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303950 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303951 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303952{
3953 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3954 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3955 tANI_U8 numChannels = 0;
3956 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05303957 tANI_U32 requestId, maxChannels;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303958 tWifiBand wifiBand;
3959 eHalStatus status;
3960 struct sk_buff *replySkb;
3961 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303962 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303963
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303964 ENTER();
3965
Dino Mycle6fb96c12014-06-10 11:52:40 +05303966 status = wlan_hdd_validate_context(pHddCtx);
3967 if (0 != status)
3968 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303969 return -EINVAL;
3970 }
Dino Myclee8843b32014-07-04 14:21:45 +05303971
Dino Mycle6fb96c12014-06-10 11:52:40 +05303972 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3973 data, dataLen,
3974 wlan_hdd_extscan_config_policy)) {
3975 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3976 return -EINVAL;
3977 }
3978
3979 /* Parse and fetch request Id */
3980 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3981 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3982 return -EINVAL;
3983 }
3984 requestId = nla_get_u32(
3985 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3986 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3987
3988 /* Parse and fetch wifi band */
3989 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3990 {
3991 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3992 return -EINVAL;
3993 }
3994 wifiBand = nla_get_u32(
3995 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3996 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3997
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05303998 /* Parse and fetch max channels */
3999 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS])
4000 {
4001 hddLog(LOGE, FL("attr max channels failed"));
4002 return -EINVAL;
4003 }
4004 maxChannels = nla_get_u32(
4005 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_MAX_CHANNELS]);
4006 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max channels %d"), maxChannels);
4007
Dino Mycle6fb96c12014-06-10 11:52:40 +05304008 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
4009 wifiBand, ChannelList,
4010 &numChannels);
4011 if (eHAL_STATUS_SUCCESS != status) {
4012 hddLog(VOS_TRACE_LEVEL_ERROR,
4013 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
4014 return -EINVAL;
4015 }
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304016
4017 numChannels = VOS_MIN(numChannels, maxChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304018 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
Padma, Santhosh Kumar387aa9c2015-06-19 15:39:37 +05304019
Dino Mycle6fb96c12014-06-10 11:52:40 +05304020 for (i = 0; i < numChannels; i++)
4021 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
4022
4023 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
4024 sizeof(u32) * numChannels +
4025 NLMSG_HDRLEN);
4026
4027 if (!replySkb) {
4028 hddLog(VOS_TRACE_LEVEL_ERROR,
4029 FL("valid channels: buffer alloc fail"));
4030 return -EINVAL;
4031 }
4032 if (nla_put_u32(replySkb,
4033 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
4034 numChannels) ||
4035 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
4036 sizeof(u32) * numChannels, ChannelList)) {
4037
4038 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4039 kfree_skb(replySkb);
4040 return -EINVAL;
4041 }
4042
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304043 ret = cfg80211_vendor_cmd_reply(replySkb);
4044
4045 EXIT();
4046 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304047}
4048
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304049static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
4050 struct wireless_dev *wdev,
4051 const void *data, int dataLen)
4052{
4053 int ret = 0;
4054
4055 vos_ssr_protect(__func__);
4056 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
4057 dataLen);
4058 vos_ssr_unprotect(__func__);
4059
4060 return ret;
4061}
4062
4063static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304064 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304065 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304066{
Dino Myclee8843b32014-07-04 14:21:45 +05304067 tpSirEXTScanStartReqParams pReqMsg = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304068 struct net_device *dev = wdev->netdev;
4069 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4070 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4071 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4072 struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4073 struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4074 struct nlattr *buckets;
4075 struct nlattr *channels;
4076 int rem1;
4077 int rem2;
4078 eHalStatus status;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304079 tANI_U32 j = 0, index = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304080
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304081 ENTER();
4082
Dino Mycle6fb96c12014-06-10 11:52:40 +05304083 status = wlan_hdd_validate_context(pHddCtx);
4084 if (0 != status)
4085 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304086 return -EINVAL;
4087 }
Dino Myclee8843b32014-07-04 14:21:45 +05304088 /* check the EXTScan Capability */
4089 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4090 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4091 {
4092 hddLog(VOS_TRACE_LEVEL_ERROR,
4093 FL("EXTScan not enabled/supported by Firmware"));
4094 return -EINVAL;
4095 }
4096
Dino Mycle6fb96c12014-06-10 11:52:40 +05304097 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4098 data, dataLen,
4099 wlan_hdd_extscan_config_policy)) {
4100 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4101 return -EINVAL;
4102 }
4103
4104 /* Parse and fetch request Id */
4105 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4106 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4107 return -EINVAL;
4108 }
4109
Dino Myclee8843b32014-07-04 14:21:45 +05304110 pReqMsg = (tpSirEXTScanStartReqParams)
4111 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304112 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304113 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4114 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304115 }
4116
4117 pReqMsg->requestId = nla_get_u32(
4118 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4119 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4120
4121 pReqMsg->sessionId = pAdapter->sessionId;
4122 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4123
4124 /* Parse and fetch base period */
4125 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) {
4126 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4127 goto fail;
4128 }
4129 pReqMsg->basePeriod = nla_get_u32(
4130 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]);
4131 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4132 pReqMsg->basePeriod);
4133
4134 /* Parse and fetch max AP per scan */
4135 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) {
4136 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4137 goto fail;
4138 }
4139 pReqMsg->maxAPperScan = nla_get_u32(
4140 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]);
4141 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4142 pReqMsg->maxAPperScan);
4143
4144 /* Parse and fetch report threshold */
4145 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) {
4146 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4147 goto fail;
4148 }
4149 pReqMsg->reportThreshold = nla_get_u8(
4150 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]);
4151 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
4152 pReqMsg->reportThreshold);
4153
4154 /* Parse and fetch number of buckets */
4155 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) {
4156 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4157 goto fail;
4158 }
4159 pReqMsg->numBuckets = nla_get_u8(
4160 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]);
4161 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4162 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4163 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4164 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4165 }
4166 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4167 pReqMsg->numBuckets);
4168 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4169 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4170 goto fail;
4171 }
4172
4173 nla_for_each_nested(buckets,
4174 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4175 if(nla_parse(bucket,
4176 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4177 nla_data(buckets), nla_len(buckets), NULL)) { //policy
4178 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4179 goto fail;
4180 }
4181
4182 /* Parse and fetch bucket spec */
4183 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4184 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed"));
4185 goto fail;
4186 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304187
4188 pReqMsg->buckets[index].bucket = nla_get_u8(
4189 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4190
4191 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"),
4192 pReqMsg->buckets[index].bucket);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304193
4194 /* Parse and fetch wifi band */
4195 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4196 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4197 goto fail;
4198 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304199 pReqMsg->buckets[index].band = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304200 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4201 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304202 pReqMsg->buckets[index].band);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304203
4204 /* Parse and fetch period */
4205 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4206 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed"));
4207 goto fail;
4208 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304209 pReqMsg->buckets[index].period = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304210 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4211 hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304212 pReqMsg->buckets[index].period);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304213
4214 /* Parse and fetch report events */
4215 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4216 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed"));
4217 goto fail;
4218 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304219 pReqMsg->buckets[index].reportEvents = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304220 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4221 hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304222 pReqMsg->buckets[index].reportEvents);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304223
4224 /* Parse and fetch number of channels */
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304225 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS])
4226 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304227 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed"));
4228 goto fail;
4229 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304230 pReqMsg->buckets[index].numChannels = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304231 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4232 hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304233 pReqMsg->buckets[index].numChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304234
4235 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4236 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed"));
4237 goto fail;
4238 }
4239
4240 j = 0;
4241 nla_for_each_nested(channels,
4242 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4243 if(nla_parse(channel,
4244 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4245 nla_data(channels), nla_len(channels),
4246 NULL)) { //wlan_hdd_extscan_config_policy here
4247 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4248 goto fail;
4249 }
4250
4251 /* Parse and fetch channel */
4252 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4253 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4254 goto fail;
4255 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304256 pReqMsg->buckets[index].channels[j].channel = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304257 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4258 hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304259 pReqMsg->buckets[index].channels[j].channel);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304260
4261 /* Parse and fetch dwell time */
4262 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4263 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed"));
4264 goto fail;
4265 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304266 pReqMsg->buckets[index].channels[j].dwellTimeMs = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304267 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4268 hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304269 pReqMsg->buckets[index].channels[j].dwellTimeMs);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304270
4271 /* Parse and fetch channel spec passive */
4272 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4273 hddLog(VOS_TRACE_LEVEL_ERROR,
4274 FL("attr channel spec passive failed"));
4275 goto fail;
4276 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304277 pReqMsg->buckets[index].channels[j].passive = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304278 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4279 hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304280 pReqMsg->buckets[index].channels[j].passive);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304281 j++;
4282 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304283 index++;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304284 }
4285 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4286 if (!HAL_STATUS_SUCCESS(status)) {
4287 hddLog(VOS_TRACE_LEVEL_ERROR,
4288 FL("sme_EXTScanStart failed(err=%d)"), status);
4289 vos_mem_free(pReqMsg);
4290 return -EINVAL;
4291 }
4292
Dino Myclee8843b32014-07-04 14:21:45 +05304293 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304294 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304295 return 0;
4296
4297fail:
4298 vos_mem_free(pReqMsg);
4299 return -EINVAL;
4300}
4301
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304302static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4303 struct wireless_dev *wdev,
4304 const void *data, int dataLen)
4305{
4306 int ret = 0;
4307
4308 vos_ssr_protect(__func__);
4309 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4310 vos_ssr_unprotect(__func__);
4311
4312 return ret;
4313}
4314
4315static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304316 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304317 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304318{
Dino Myclee8843b32014-07-04 14:21:45 +05304319 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304320 struct net_device *dev = wdev->netdev;
4321 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4322 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4323 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4324 eHalStatus status;
4325
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304326 ENTER();
4327
Dino Mycle6fb96c12014-06-10 11:52:40 +05304328 status = wlan_hdd_validate_context(pHddCtx);
4329 if (0 != status)
4330 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304331 return -EINVAL;
4332 }
Dino Myclee8843b32014-07-04 14:21:45 +05304333 /* check the EXTScan Capability */
4334 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4335 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4336 {
4337 hddLog(VOS_TRACE_LEVEL_ERROR,
4338 FL("EXTScan not enabled/supported by Firmware"));
4339 return -EINVAL;
4340 }
4341
Dino Mycle6fb96c12014-06-10 11:52:40 +05304342 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4343 data, dataLen,
4344 wlan_hdd_extscan_config_policy)) {
4345 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4346 return -EINVAL;
4347 }
4348
4349 /* Parse and fetch request Id */
4350 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4351 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4352 return -EINVAL;
4353 }
4354
Dino Myclee8843b32014-07-04 14:21:45 +05304355 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304356 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304357 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304358
Dino Myclee8843b32014-07-04 14:21:45 +05304359 reqMsg.sessionId = pAdapter->sessionId;
4360 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304361
Dino Myclee8843b32014-07-04 14:21:45 +05304362 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304363 if (!HAL_STATUS_SUCCESS(status)) {
4364 hddLog(VOS_TRACE_LEVEL_ERROR,
4365 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304366 return -EINVAL;
4367 }
4368
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304369 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304370 return 0;
4371}
4372
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304373static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4374 struct wireless_dev *wdev,
4375 const void *data, int dataLen)
4376{
4377 int ret = 0;
4378
4379 vos_ssr_protect(__func__);
4380 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4381 vos_ssr_unprotect(__func__);
4382
4383 return ret;
4384}
4385
4386static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304387 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304388 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304389{
Dino Myclee8843b32014-07-04 14:21:45 +05304390 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304391 struct net_device *dev = wdev->netdev;
4392 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4393 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4394 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4395 eHalStatus status;
4396
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304397 ENTER();
4398
Dino Mycle6fb96c12014-06-10 11:52:40 +05304399 status = wlan_hdd_validate_context(pHddCtx);
4400 if (0 != status)
4401 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304402 return -EINVAL;
4403 }
Dino Myclee8843b32014-07-04 14:21:45 +05304404 /* check the EXTScan Capability */
4405 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4406 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4407 {
4408 hddLog(VOS_TRACE_LEVEL_ERROR,
4409 FL("EXTScan not enabled/supported by Firmware"));
4410 return -EINVAL;
4411 }
4412
Dino Mycle6fb96c12014-06-10 11:52:40 +05304413 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4414 data, dataLen,
4415 wlan_hdd_extscan_config_policy)) {
4416 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4417 return -EINVAL;
4418 }
4419
4420 /* Parse and fetch request Id */
4421 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4422 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4423 return -EINVAL;
4424 }
4425
Dino Myclee8843b32014-07-04 14:21:45 +05304426 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304427 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304428 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304429
Dino Myclee8843b32014-07-04 14:21:45 +05304430 reqMsg.sessionId = pAdapter->sessionId;
4431 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304432
Dino Myclee8843b32014-07-04 14:21:45 +05304433 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304434 if (!HAL_STATUS_SUCCESS(status)) {
4435 hddLog(VOS_TRACE_LEVEL_ERROR,
4436 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304437 return -EINVAL;
4438 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304439 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304440 return 0;
4441}
4442
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304443static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4444 struct wireless_dev *wdev,
4445 const void *data, int dataLen)
4446{
4447 int ret = 0;
4448
4449 vos_ssr_protect(__func__);
4450 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4451 vos_ssr_unprotect(__func__);
4452
4453 return ret;
4454}
4455
4456static int __wlan_hdd_cfg80211_extscan_reset_significant_change(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304457 struct wiphy *wiphy,
4458 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304459 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304460{
Dino Myclee8843b32014-07-04 14:21:45 +05304461 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304462 struct net_device *dev = wdev->netdev;
4463 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4464 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4465 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4466 eHalStatus status;
4467
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304468 ENTER();
4469
Dino Mycle6fb96c12014-06-10 11:52:40 +05304470 status = wlan_hdd_validate_context(pHddCtx);
4471 if (0 != status)
4472 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304473 return -EINVAL;
4474 }
Dino Myclee8843b32014-07-04 14:21:45 +05304475 /* check the EXTScan Capability */
4476 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4477 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4478 {
4479 hddLog(VOS_TRACE_LEVEL_ERROR,
4480 FL("EXTScan not enabled/supported by Firmware"));
4481 return -EINVAL;
4482 }
4483
Dino Mycle6fb96c12014-06-10 11:52:40 +05304484 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4485 data, dataLen,
4486 wlan_hdd_extscan_config_policy)) {
4487 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4488 return -EINVAL;
4489 }
4490
4491 /* Parse and fetch request Id */
4492 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4493 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4494 return -EINVAL;
4495 }
4496
Dino Mycle6fb96c12014-06-10 11:52:40 +05304497
Dino Myclee8843b32014-07-04 14:21:45 +05304498 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304499 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304500 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304501
Dino Myclee8843b32014-07-04 14:21:45 +05304502 reqMsg.sessionId = pAdapter->sessionId;
4503 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304504
Dino Myclee8843b32014-07-04 14:21:45 +05304505 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304506 if (!HAL_STATUS_SUCCESS(status)) {
4507 hddLog(VOS_TRACE_LEVEL_ERROR,
4508 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304509 return -EINVAL;
4510 }
4511
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304512 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304513 return 0;
4514}
4515
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304516static int wlan_hdd_cfg80211_extscan_reset_significant_change(
4517 struct wiphy *wiphy,
4518 struct wireless_dev *wdev,
4519 const void *data, int dataLen)
4520{
4521 int ret = 0;
4522
4523 vos_ssr_protect(__func__);
4524 ret = __wlan_hdd_cfg80211_extscan_reset_significant_change(wiphy,
4525 wdev, data,
4526 dataLen);
4527 vos_ssr_unprotect(__func__);
4528
4529 return ret;
4530}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304531#endif /* WLAN_FEATURE_EXTSCAN */
4532
Atul Mittal115287b2014-07-08 13:26:33 +05304533/*EXT TDLS*/
4534static const struct nla_policy
4535wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4536{
4537 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4538 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4539 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4540 {.type = NLA_S32 },
4541 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4542 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4543
4544};
4545
4546static const struct nla_policy
4547wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4548{
4549 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4550
4551};
4552
4553static const struct nla_policy
4554wlan_hdd_tdls_config_state_change_policy[
4555 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4556{
4557 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4558 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4559 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304560 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4561 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4562 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304563
4564};
4565
4566static const struct nla_policy
4567wlan_hdd_tdls_config_get_status_policy[
4568 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4569{
4570 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4571 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4572 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304573 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4574 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4575 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304576
4577};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304578
4579static const struct nla_policy
4580wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4581{
4582 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4583};
4584
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304585static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304586 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304587 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304588 int data_len)
4589{
4590
4591 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4592 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4593
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304594 ENTER();
4595
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304596 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304597 return -EINVAL;
4598 }
4599 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05304600 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304601 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304602 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304603 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05304604 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304605 return -ENOTSUPP;
4606 }
4607
4608 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4609 data, data_len, wlan_hdd_mac_config)) {
4610 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4611 return -EINVAL;
4612 }
4613
4614 /* Parse and fetch mac address */
4615 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4616 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4617 return -EINVAL;
4618 }
4619
4620 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4621 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4622 VOS_MAC_ADDR_LAST_3_BYTES);
4623
Siddharth Bhal76972212014-10-15 16:22:51 +05304624 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4625
4626 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304627 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4628 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304629 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4630 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4631 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4632 {
4633 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4634 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4635 VOS_MAC_ADDRESS_LEN);
4636 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304637 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304638
Siddharth Bhal76972212014-10-15 16:22:51 +05304639 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
4640 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304641 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4642 }
4643
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304644 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304645 return 0;
4646}
4647
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304648static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4649 struct wireless_dev *wdev,
4650 const void *data,
4651 int data_len)
4652{
4653 int ret = 0;
4654
4655 vos_ssr_protect(__func__);
4656 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
4657 vos_ssr_unprotect(__func__);
4658
4659 return ret;
4660}
4661
4662static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304663 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304664 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304665 int data_len)
4666{
4667 u8 peer[6] = {0};
4668 struct net_device *dev = wdev->netdev;
4669 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4670 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4671 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4672 eHalStatus ret;
4673 tANI_S32 state;
4674 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304675 tANI_S32 global_operating_class = 0;
4676 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304677 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304678 int retVal;
4679
4680 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304681
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304682 if (!pAdapter) {
4683 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4684 return -EINVAL;
4685 }
4686
Atul Mittal115287b2014-07-08 13:26:33 +05304687 ret = wlan_hdd_validate_context(pHddCtx);
4688 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304689 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304690 return -EINVAL;
4691 }
4692 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304693 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304694 return -ENOTSUPP;
4695 }
4696 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4697 data, data_len,
4698 wlan_hdd_tdls_config_get_status_policy)) {
4699 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4700 return -EINVAL;
4701 }
4702
4703 /* Parse and fetch mac address */
4704 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4705 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4706 return -EINVAL;
4707 }
4708
4709 memcpy(peer, nla_data(
4710 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4711 sizeof(peer));
4712 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4713
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05304714 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05304715
Atul Mittal115287b2014-07-08 13:26:33 +05304716 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304717 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304718 NLMSG_HDRLEN);
4719
4720 if (!skb) {
4721 hddLog(VOS_TRACE_LEVEL_ERROR,
4722 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4723 return -EINVAL;
4724 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304725 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 +05304726 reason,
4727 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304728 global_operating_class,
4729 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304730 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304731 if (nla_put_s32(skb,
4732 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4733 state) ||
4734 nla_put_s32(skb,
4735 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4736 reason) ||
4737 nla_put_s32(skb,
4738 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4739 global_operating_class) ||
4740 nla_put_s32(skb,
4741 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4742 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304743
4744 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4745 goto nla_put_failure;
4746 }
4747
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304748 retVal = cfg80211_vendor_cmd_reply(skb);
4749 EXIT();
4750 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05304751
4752nla_put_failure:
4753 kfree_skb(skb);
4754 return -EINVAL;
4755}
4756
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304757static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4758 struct wireless_dev *wdev,
4759 const void *data,
4760 int data_len)
4761{
4762 int ret = 0;
4763
4764 vos_ssr_protect(__func__);
4765 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
4766 vos_ssr_unprotect(__func__);
4767
4768 return ret;
4769}
4770
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05304771static int wlan_hdd_cfg80211_exttdls_callback(
4772#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
4773 const tANI_U8* mac,
4774#else
4775 tANI_U8* mac,
4776#endif
Atul Mittal115287b2014-07-08 13:26:33 +05304777 tANI_S32 state,
4778 tANI_S32 reason,
4779 void *ctx)
4780{
4781 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05304782 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304783 tANI_S32 global_operating_class = 0;
4784 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304785 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05304786
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304787 ENTER();
4788
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304789 if (!pAdapter) {
4790 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4791 return -EINVAL;
4792 }
4793
4794 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05304795 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304796 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304797 return -EINVAL;
4798 }
4799
4800 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304801 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304802 return -ENOTSUPP;
4803 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05304804 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
4805#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
4806 NULL,
4807#endif
Atul Mittal115287b2014-07-08 13:26:33 +05304808 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4809 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4810 GFP_KERNEL);
4811
4812 if (!skb) {
4813 hddLog(VOS_TRACE_LEVEL_ERROR,
4814 FL("cfg80211_vendor_event_alloc failed"));
4815 return -EINVAL;
4816 }
4817 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304818 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4819 reason,
4820 state,
4821 global_operating_class,
4822 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304823 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4824 MAC_ADDR_ARRAY(mac));
4825
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304826 if (nla_put(skb,
4827 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4828 VOS_MAC_ADDR_SIZE, mac) ||
4829 nla_put_s32(skb,
4830 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4831 state) ||
4832 nla_put_s32(skb,
4833 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4834 reason) ||
4835 nla_put_s32(skb,
4836 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4837 channel) ||
4838 nla_put_s32(skb,
4839 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4840 global_operating_class)
4841 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304842 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4843 goto nla_put_failure;
4844 }
4845
4846 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304847 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05304848 return (0);
4849
4850nla_put_failure:
4851 kfree_skb(skb);
4852 return -EINVAL;
4853}
4854
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304855static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304856 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304857 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304858 int data_len)
4859{
4860 u8 peer[6] = {0};
4861 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304862 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4863 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4864 eHalStatus status;
4865 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304866 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304867 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304868
4869 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304870
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304871 if (!dev) {
4872 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4873 return -EINVAL;
4874 }
4875
4876 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4877 if (!pAdapter) {
4878 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4879 return -EINVAL;
4880 }
4881
Atul Mittal115287b2014-07-08 13:26:33 +05304882 status = wlan_hdd_validate_context(pHddCtx);
4883 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304884 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304885 return -EINVAL;
4886 }
4887 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304888 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304889 return -ENOTSUPP;
4890 }
4891 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4892 data, data_len,
4893 wlan_hdd_tdls_config_enable_policy)) {
4894 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4895 return -EINVAL;
4896 }
4897
4898 /* Parse and fetch mac address */
4899 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4900 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4901 return -EINVAL;
4902 }
4903
4904 memcpy(peer, nla_data(
4905 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4906 sizeof(peer));
4907 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4908
4909 /* Parse and fetch channel */
4910 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4911 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4912 return -EINVAL;
4913 }
4914 pReqMsg.channel = nla_get_s32(
4915 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4916 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4917
4918 /* Parse and fetch global operating class */
4919 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4920 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4921 return -EINVAL;
4922 }
4923 pReqMsg.global_operating_class = nla_get_s32(
4924 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4925 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4926 pReqMsg.global_operating_class);
4927
4928 /* Parse and fetch latency ms */
4929 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4930 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4931 return -EINVAL;
4932 }
4933 pReqMsg.max_latency_ms = nla_get_s32(
4934 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4935 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4936 pReqMsg.max_latency_ms);
4937
4938 /* Parse and fetch required bandwidth kbps */
4939 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4940 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4941 return -EINVAL;
4942 }
4943
4944 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4945 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4946 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4947 pReqMsg.min_bandwidth_kbps);
4948
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304949 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05304950 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05304951 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304952 wlan_hdd_cfg80211_exttdls_callback);
4953
4954 EXIT();
4955 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304956}
4957
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304958static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4959 struct wireless_dev *wdev,
4960 const void *data,
4961 int data_len)
4962{
4963 int ret = 0;
4964
4965 vos_ssr_protect(__func__);
4966 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
4967 vos_ssr_unprotect(__func__);
4968
4969 return ret;
4970}
4971
4972static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304973 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304974 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304975 int data_len)
4976{
4977 u8 peer[6] = {0};
4978 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304979 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4980 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4981 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304982 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304983 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304984
4985 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304986
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304987 if (!dev) {
4988 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4989 return -EINVAL;
4990 }
4991
4992 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4993 if (!pAdapter) {
4994 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
4995 return -EINVAL;
4996 }
4997
Atul Mittal115287b2014-07-08 13:26:33 +05304998 status = wlan_hdd_validate_context(pHddCtx);
4999 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305000 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05305001 return -EINVAL;
5002 }
5003 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05305004 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05305005 return -ENOTSUPP;
5006 }
5007 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
5008 data, data_len,
5009 wlan_hdd_tdls_config_disable_policy)) {
5010 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5011 return -EINVAL;
5012 }
5013 /* Parse and fetch mac address */
5014 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
5015 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5016 return -EINVAL;
5017 }
5018
5019 memcpy(peer, nla_data(
5020 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
5021 sizeof(peer));
5022 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5023
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305024 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
5025
5026 EXIT();
5027 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305028}
5029
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305030static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
5031 struct wireless_dev *wdev,
5032 const void *data,
5033 int data_len)
5034{
5035 int ret = 0;
5036
5037 vos_ssr_protect(__func__);
5038 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
5039 vos_ssr_unprotect(__func__);
5040
5041 return ret;
5042}
5043
Dasari Srinivas7875a302014-09-26 17:50:57 +05305044static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305045__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05305046 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305047 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05305048{
5049 struct net_device *dev = wdev->netdev;
5050 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5051 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5052 struct sk_buff *skb = NULL;
5053 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305054 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305055
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305056 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305057
5058 ret = wlan_hdd_validate_context(pHddCtx);
5059 if (0 != ret)
5060 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305061 return ret;
5062 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305063 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
5064 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
5065 fset |= WIFI_FEATURE_INFRA;
5066 }
5067
5068 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
5069 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
5070 fset |= WIFI_FEATURE_INFRA_5G;
5071 }
5072
5073#ifdef WLAN_FEATURE_P2P
5074 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
5075 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
5076 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
5077 fset |= WIFI_FEATURE_P2P;
5078 }
5079#endif
5080
5081 /* Soft-AP is supported currently by default */
5082 fset |= WIFI_FEATURE_SOFT_AP;
5083
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05305084 /* HOTSPOT is a supplicant feature, enable it by default */
5085 fset |= WIFI_FEATURE_HOTSPOT;
5086
Dasari Srinivas7875a302014-09-26 17:50:57 +05305087#ifdef WLAN_FEATURE_EXTSCAN
5088 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
5089 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
5090 hddLog(LOG1, FL("EXTScan is supported by firmware"));
5091 fset |= WIFI_FEATURE_EXTSCAN;
5092 }
5093#endif
5094
Dasari Srinivas7875a302014-09-26 17:50:57 +05305095 if (sme_IsFeatureSupportedByFW(NAN)) {
5096 hddLog(LOG1, FL("NAN is supported by firmware"));
5097 fset |= WIFI_FEATURE_NAN;
5098 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305099
5100 /* D2D RTT is not supported currently by default */
5101 if (sme_IsFeatureSupportedByFW(RTT)) {
5102 hddLog(LOG1, FL("RTT is supported by firmware"));
5103 fset |= WIFI_FEATURE_D2AP_RTT;
5104 }
5105
5106#ifdef FEATURE_WLAN_BATCH_SCAN
5107 if (fset & WIFI_FEATURE_EXTSCAN) {
5108 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5109 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5110 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5111 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5112 fset |= WIFI_FEATURE_BATCH_SCAN;
5113 }
5114#endif
5115
5116#ifdef FEATURE_WLAN_SCAN_PNO
5117 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5118 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5119 hddLog(LOG1, FL("PNO is supported by firmware"));
5120 fset |= WIFI_FEATURE_PNO;
5121 }
5122#endif
5123
5124 /* STA+STA is supported currently by default */
5125 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5126
5127#ifdef FEATURE_WLAN_TDLS
5128 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5129 sme_IsFeatureSupportedByFW(TDLS)) {
5130 hddLog(LOG1, FL("TDLS is supported by firmware"));
5131 fset |= WIFI_FEATURE_TDLS;
5132 }
5133
5134 /* TDLS_OFFCHANNEL is not supported currently by default */
5135#endif
5136
5137#ifdef WLAN_AP_STA_CONCURRENCY
5138 /* AP+STA concurrency is supported currently by default */
5139 fset |= WIFI_FEATURE_AP_STA;
5140#endif
5141
Mukul Sharma5add0532015-08-17 15:57:47 +05305142#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5143 fset |= WIFI_FEATURE_LINK_LAYER_STATS;
5144 hddLog(LOG1, FL("Link layer stats is supported by driver"));
5145#endif
5146
Dasari Srinivas7875a302014-09-26 17:50:57 +05305147 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5148 NLMSG_HDRLEN);
5149
5150 if (!skb) {
5151 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5152 return -EINVAL;
5153 }
5154 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5155
5156 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5157 hddLog(LOGE, FL("nla put fail"));
5158 goto nla_put_failure;
5159 }
5160
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305161 ret = cfg80211_vendor_cmd_reply(skb);
5162 EXIT();
5163 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305164
5165nla_put_failure:
5166 kfree_skb(skb);
5167 return -EINVAL;
5168}
5169
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305170static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305171wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5172 struct wireless_dev *wdev,
5173 const void *data, int data_len)
5174{
5175 int ret = 0;
5176
5177 vos_ssr_protect(__func__);
5178 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5179 vos_ssr_unprotect(__func__);
5180
5181 return ret;
5182}
5183
5184static int
5185__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305186 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305187 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305188{
5189 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5190 uint8_t i, feature_sets, max_feature_sets;
5191 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5192 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305193 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5194 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305195
5196 ENTER();
5197
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305198 ret = wlan_hdd_validate_context(pHddCtx);
5199 if (0 != ret)
5200 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305201 return ret;
5202 }
5203
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305204 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5205 data, data_len, NULL)) {
5206 hddLog(LOGE, FL("Invalid ATTR"));
5207 return -EINVAL;
5208 }
5209
5210 /* Parse and fetch max feature set */
5211 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5212 hddLog(LOGE, FL("Attr max feature set size failed"));
5213 return -EINVAL;
5214 }
5215 max_feature_sets = nla_get_u32(
5216 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5217 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5218
5219 /* Fill feature combination matrix */
5220 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305221 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5222 WIFI_FEATURE_P2P;
5223
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305224 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5225 WIFI_FEATURE_SOFT_AP;
5226
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305227 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5228 WIFI_FEATURE_SOFT_AP;
5229
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305230 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5231 WIFI_FEATURE_SOFT_AP |
5232 WIFI_FEATURE_P2P;
5233
5234 /* Add more feature combinations here */
5235
5236 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5237 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5238 hddLog(LOG1, "Feature set matrix");
5239 for (i = 0; i < feature_sets; i++)
5240 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5241
5242 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5243 sizeof(u32) * feature_sets +
5244 NLMSG_HDRLEN);
5245
5246 if (reply_skb) {
5247 if (nla_put_u32(reply_skb,
5248 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5249 feature_sets) ||
5250 nla_put(reply_skb,
5251 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5252 sizeof(u32) * feature_sets, feature_set_matrix)) {
5253 hddLog(LOGE, FL("nla put fail"));
5254 kfree_skb(reply_skb);
5255 return -EINVAL;
5256 }
5257
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305258 ret = cfg80211_vendor_cmd_reply(reply_skb);
5259 EXIT();
5260 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305261 }
5262 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5263 return -ENOMEM;
5264
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305265}
5266
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305267static int
5268wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5269 struct wireless_dev *wdev,
5270 const void *data, int data_len)
5271{
5272 int ret = 0;
5273
5274 vos_ssr_protect(__func__);
5275 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5276 data_len);
5277 vos_ssr_unprotect(__func__);
5278
5279 return ret;
5280}
5281
Agarwal Ashish738843c2014-09-25 12:27:56 +05305282static const struct nla_policy
5283wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5284 +1] =
5285{
5286 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5287};
5288
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305289static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305290 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305291 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305292 int data_len)
5293{
5294 struct net_device *dev = wdev->netdev;
5295 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5296 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5297 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5298 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5299 eHalStatus status;
5300 u32 dfsFlag = 0;
5301
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305302 ENTER();
5303
Agarwal Ashish738843c2014-09-25 12:27:56 +05305304 status = wlan_hdd_validate_context(pHddCtx);
5305 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305306 return -EINVAL;
5307 }
5308 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5309 data, data_len,
5310 wlan_hdd_set_no_dfs_flag_config_policy)) {
5311 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5312 return -EINVAL;
5313 }
5314
5315 /* Parse and fetch required bandwidth kbps */
5316 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5317 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5318 return -EINVAL;
5319 }
5320
5321 dfsFlag = nla_get_u32(
5322 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5323 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
5324 dfsFlag);
5325
5326 pHddCtx->disable_dfs_flag = dfsFlag;
5327
5328 sme_disable_dfs_channel(hHal, dfsFlag);
5329 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305330
5331 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05305332 return 0;
5333}
Atul Mittal115287b2014-07-08 13:26:33 +05305334
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305335static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
5336 struct wireless_dev *wdev,
5337 const void *data,
5338 int data_len)
5339{
5340 int ret = 0;
5341
5342 vos_ssr_protect(__func__);
5343 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
5344 vos_ssr_unprotect(__func__);
5345
5346 return ret;
5347
5348}
5349
Mukul Sharma2a271632014-10-13 14:59:01 +05305350const struct
5351nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
5352{
5353 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
5354 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
5355};
5356
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305357static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05305358 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05305359{
5360
5361 u8 bssid[6] = {0};
5362 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5363 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5364 eHalStatus status = eHAL_STATUS_SUCCESS;
5365 v_U32_t isFwrRoamEnabled = FALSE;
5366 int ret;
5367
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305368 ENTER();
5369
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305370 ret = wlan_hdd_validate_context(pHddCtx);
5371 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305372 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05305373 }
5374
5375 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
5376 data, data_len,
5377 qca_wlan_vendor_attr);
5378 if (ret){
5379 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5380 return -EINVAL;
5381 }
5382
5383 /* Parse and fetch Enable flag */
5384 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
5385 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
5386 return -EINVAL;
5387 }
5388
5389 isFwrRoamEnabled = nla_get_u32(
5390 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
5391
5392 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
5393
5394 /* Parse and fetch bssid */
5395 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
5396 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
5397 return -EINVAL;
5398 }
5399
5400 memcpy(bssid, nla_data(
5401 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
5402 sizeof(bssid));
5403 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
5404
5405 //Update roaming
5406 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305407 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05305408 return status;
5409}
5410
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305411static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
5412 struct wireless_dev *wdev, const void *data, int data_len)
5413{
5414 int ret = 0;
5415
5416 vos_ssr_protect(__func__);
5417 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
5418 vos_ssr_unprotect(__func__);
5419
5420 return ret;
5421}
5422
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305423/**
5424 * __wlan_hdd_cfg80211_setband() - set band
5425 * @wiphy: Pointer to wireless phy
5426 * @wdev: Pointer to wireless device
5427 * @data: Pointer to data
5428 * @data_len: Data length
5429 *
5430 * Return: 0 on success, negative errno on failure
5431 */
5432static int
5433__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5434 struct wireless_dev *wdev,
5435 const void *data,
5436 int data_len)
5437{
5438 struct net_device *dev = wdev->netdev;
5439 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5440 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5441 int ret;
5442 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
5443 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
5444
5445 ENTER();
5446
5447 ret = wlan_hdd_validate_context(hdd_ctx);
5448 if (0 != ret) {
5449 hddLog(LOGE, FL("HDD context is not valid"));
5450 return ret;
5451 }
5452
5453 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
5454 policy)) {
5455 hddLog(LOGE, FL("Invalid ATTR"));
5456 return -EINVAL;
5457 }
5458
5459 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
5460 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
5461 return -EINVAL;
5462 }
5463
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05305464 hdd_ctx->isSetBandByNL = TRUE;
5465 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305466 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05305467 hdd_ctx->isSetBandByNL = FALSE;
5468
5469 EXIT();
5470 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305471}
5472
5473/**
5474 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
5475 * @wiphy: wiphy structure pointer
5476 * @wdev: Wireless device structure pointer
5477 * @data: Pointer to the data received
5478 * @data_len: Length of @data
5479 *
5480 * Return: 0 on success; errno on failure
5481 */
5482static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5483 struct wireless_dev *wdev,
5484 const void *data,
5485 int data_len)
5486{
5487 int ret = 0;
5488
5489 vos_ssr_protect(__func__);
5490 ret = __wlan_hdd_cfg80211_setband(wiphy,
5491 wdev, data, data_len);
5492 vos_ssr_unprotect(__func__);
5493
5494 return ret;
5495}
5496
Sunil Duttc69bccb2014-05-26 21:30:20 +05305497const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
5498{
Mukul Sharma2a271632014-10-13 14:59:01 +05305499 {
5500 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5501 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
5502 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5503 WIPHY_VENDOR_CMD_NEED_NETDEV |
5504 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305505 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05305506 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305507
5508 {
5509 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5510 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
5511 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5512 WIPHY_VENDOR_CMD_NEED_NETDEV |
5513 WIPHY_VENDOR_CMD_NEED_RUNNING,
5514 .doit = wlan_hdd_cfg80211_nan_request
5515 },
5516
Sunil Duttc69bccb2014-05-26 21:30:20 +05305517#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5518 {
5519 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5520 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
5521 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5522 WIPHY_VENDOR_CMD_NEED_NETDEV |
5523 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305524 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05305525 },
5526
5527 {
5528 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5529 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
5530 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5531 WIPHY_VENDOR_CMD_NEED_NETDEV |
5532 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305533 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05305534 },
5535
5536 {
5537 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5538 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
5539 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5540 WIPHY_VENDOR_CMD_NEED_NETDEV |
5541 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305542 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05305543 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305544#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305545#ifdef WLAN_FEATURE_EXTSCAN
5546 {
5547 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5548 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
5549 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5550 WIPHY_VENDOR_CMD_NEED_NETDEV |
5551 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305552 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05305553 },
5554 {
5555 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5556 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
5557 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5558 WIPHY_VENDOR_CMD_NEED_NETDEV |
5559 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305560 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05305561 },
5562 {
5563 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5564 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
5565 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5566 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305567 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05305568 },
5569 {
5570 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5571 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
5572 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5573 WIPHY_VENDOR_CMD_NEED_NETDEV |
5574 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305575 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05305576 },
5577 {
5578 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5579 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
5580 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5581 WIPHY_VENDOR_CMD_NEED_NETDEV |
5582 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305583 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05305584 },
5585 {
5586 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5587 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
5588 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5589 WIPHY_VENDOR_CMD_NEED_NETDEV |
5590 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305591 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305592 },
5593 {
5594 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5595 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
5596 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5597 WIPHY_VENDOR_CMD_NEED_NETDEV |
5598 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305599 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305600 },
5601 {
5602 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5603 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
5604 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5605 WIPHY_VENDOR_CMD_NEED_NETDEV |
5606 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305607 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305608 },
5609 {
5610 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5611 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
5612 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5613 WIPHY_VENDOR_CMD_NEED_NETDEV |
5614 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305615 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305616 },
5617#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305618/*EXT TDLS*/
5619 {
5620 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5621 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
5622 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5623 WIPHY_VENDOR_CMD_NEED_NETDEV |
5624 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305625 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05305626 },
5627 {
5628 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5629 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
5630 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5631 WIPHY_VENDOR_CMD_NEED_NETDEV |
5632 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305633 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05305634 },
5635 {
5636 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5637 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
5638 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5639 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305640 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05305641 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05305642 {
5643 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5644 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
5645 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5646 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305647 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05305648 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05305649 {
5650 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5651 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
5652 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5653 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305654 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05305655 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305656 {
5657 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5658 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
5659 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5660 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305661 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305662 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305663 {
5664 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5665 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
5666 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5667 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305668 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305669 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305670 {
5671 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5672 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
5673 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5674 WIPHY_VENDOR_CMD_NEED_NETDEV |
5675 WIPHY_VENDOR_CMD_NEED_RUNNING,
5676 .doit = wlan_hdd_cfg80211_setband
5677 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05305678};
5679
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005680/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05305681static const
5682struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005683{
5684#ifdef FEATURE_WLAN_CH_AVOID
5685 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05305686 .vendor_id = QCA_NL80211_VENDOR_ID,
5687 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005688 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305689#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
5690#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5691 {
5692 /* Index = 1*/
5693 .vendor_id = QCA_NL80211_VENDOR_ID,
5694 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
5695 },
5696 {
5697 /* Index = 2*/
5698 .vendor_id = QCA_NL80211_VENDOR_ID,
5699 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
5700 },
5701 {
5702 /* Index = 3*/
5703 .vendor_id = QCA_NL80211_VENDOR_ID,
5704 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
5705 },
5706 {
5707 /* Index = 4*/
5708 .vendor_id = QCA_NL80211_VENDOR_ID,
5709 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
5710 },
5711 {
5712 /* Index = 5*/
5713 .vendor_id = QCA_NL80211_VENDOR_ID,
5714 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
5715 },
5716 {
5717 /* Index = 6*/
5718 .vendor_id = QCA_NL80211_VENDOR_ID,
5719 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
5720 },
5721#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305722#ifdef WLAN_FEATURE_EXTSCAN
5723 {
5724 .vendor_id = QCA_NL80211_VENDOR_ID,
5725 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
5726 },
5727 {
5728 .vendor_id = QCA_NL80211_VENDOR_ID,
5729 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
5730 },
5731 {
5732 .vendor_id = QCA_NL80211_VENDOR_ID,
5733 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
5734 },
5735 {
5736 .vendor_id = QCA_NL80211_VENDOR_ID,
5737 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
5738 },
5739 {
5740 .vendor_id = QCA_NL80211_VENDOR_ID,
5741 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
5742 },
5743 {
5744 .vendor_id = QCA_NL80211_VENDOR_ID,
5745 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
5746 },
5747 {
5748 .vendor_id = QCA_NL80211_VENDOR_ID,
5749 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
5750 },
5751 {
5752 .vendor_id = QCA_NL80211_VENDOR_ID,
5753 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
5754 },
5755 {
5756 .vendor_id = QCA_NL80211_VENDOR_ID,
5757 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
5758 },
5759 {
5760 .vendor_id = QCA_NL80211_VENDOR_ID,
5761 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
5762 },
5763 {
5764 .vendor_id = QCA_NL80211_VENDOR_ID,
5765 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
5766 },
5767 {
5768 .vendor_id = QCA_NL80211_VENDOR_ID,
5769 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
5770 },
5771 {
5772 .vendor_id = QCA_NL80211_VENDOR_ID,
5773 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
5774 },
5775#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305776/*EXT TDLS*/
5777 {
5778 .vendor_id = QCA_NL80211_VENDOR_ID,
5779 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
5780 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305781
5782 {
5783 .vendor_id = QCA_NL80211_VENDOR_ID,
5784 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
5785 },
5786
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005787};
5788
Jeff Johnson295189b2012-06-20 16:38:30 -07005789/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305790 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305791 * This function is called by hdd_wlan_startup()
5792 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305793 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07005794 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305795struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07005796{
5797 struct wiphy *wiphy;
5798 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305799 /*
5800 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07005801 */
5802 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
5803
5804 if (!wiphy)
5805 {
5806 /* Print error and jump into err label and free the memory */
5807 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
5808 return NULL;
5809 }
5810
Sunil Duttc69bccb2014-05-26 21:30:20 +05305811
Jeff Johnson295189b2012-06-20 16:38:30 -07005812 return wiphy;
5813}
5814
5815/*
5816 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305817 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 * private ioctl to change the band value
5819 */
5820int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
5821{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305822 int i, j;
5823 eNVChannelEnabledType channelEnabledState;
5824
Jeff Johnsone7245742012-09-05 17:12:55 -07005825 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305826
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305827 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005828 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305829
5830 if (NULL == wiphy->bands[i])
5831 {
5832 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5833 __func__, i);
5834 continue;
5835 }
5836
5837 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5838 {
5839 struct ieee80211_supported_band *band = wiphy->bands[i];
5840
5841 channelEnabledState = vos_nv_getChannelEnabledState(
5842 band->channels[j].hw_value);
5843
5844 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
5845 {
Abhishek Singh678227a2014-11-04 10:52:38 +05305846 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305847 continue;
5848 }
5849 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
5850 {
5851 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5852 continue;
5853 }
5854
5855 if (NV_CHANNEL_DISABLE == channelEnabledState ||
5856 NV_CHANNEL_INVALID == channelEnabledState)
5857 {
5858 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5859 }
5860 else if (NV_CHANNEL_DFS == channelEnabledState)
5861 {
5862 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5863 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
5864 }
5865 else
5866 {
5867 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
5868 |IEEE80211_CHAN_RADAR);
5869 }
5870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005871 }
5872 return 0;
5873}
5874/*
5875 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305876 * This function is called by hdd_wlan_startup()
5877 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07005878 * This function is used to initialize and register wiphy structure.
5879 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305880int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005881 struct wiphy *wiphy,
5882 hdd_config_t *pCfg
5883 )
5884{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305885 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305886 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5887
Jeff Johnsone7245742012-09-05 17:12:55 -07005888 ENTER();
5889
Jeff Johnson295189b2012-06-20 16:38:30 -07005890 /* Now bind the underlying wlan device with wiphy */
5891 set_wiphy_dev(wiphy, dev);
5892
5893 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005894
Kiet Lam6c583332013-10-14 05:37:09 +05305895#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07005896 /* the flag for the other case would be initialzed in
5897 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07005898 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05305899#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005900
Amar Singhalfddc28c2013-09-05 13:03:40 -07005901 /* This will disable updating of NL channels from passive to
5902 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305903#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
5904 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
5905#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07005906 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305907#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07005908
Amar Singhala49cbc52013-10-08 18:37:44 -07005909
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005910#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07005911 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
5912 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
5913 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07005914 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305915#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
5916 wiphy->regulatory_flags = REGULATORY_COUNTRY_IE_IGNORE;
5917#else
5918 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
5919#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005920#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005921
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005922#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005923 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08005924#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005925 || pCfg->isFastRoamIniFeatureEnabled
5926#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005927#ifdef FEATURE_WLAN_ESE
5928 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005929#endif
5930 )
5931 {
5932 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
5933 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08005934#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005935#ifdef FEATURE_WLAN_TDLS
5936 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
5937 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
5938#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305939#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05305940 if (pCfg->configPNOScanSupport)
5941 {
5942 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
5943 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
5944 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
5945 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
5946 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305947#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005948
Abhishek Singh10d85972015-04-17 10:27:23 +05305949#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5950 wiphy->features |= NL80211_FEATURE_HT_IBSS;
5951#endif
5952
Amar Singhalfddc28c2013-09-05 13:03:40 -07005953#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005954 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
5955 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07005956 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005957 driver need to determine what to do with both
5958 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07005959
5960 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07005961#else
5962 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005963#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005964
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305965 wiphy->max_scan_ssids = MAX_SCAN_SSID;
5966
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05305967 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07005968
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305969 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
5970
Jeff Johnson295189b2012-06-20 16:38:30 -07005971 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05305972 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
5973 | BIT(NL80211_IFTYPE_ADHOC)
5974 | BIT(NL80211_IFTYPE_P2P_CLIENT)
5975 | BIT(NL80211_IFTYPE_P2P_GO)
5976 | BIT(NL80211_IFTYPE_AP);
5977
5978 if (VOS_MONITOR_MODE == hdd_get_conparam())
5979 {
5980 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
5981 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005982
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305983 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005984 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305985#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5986 if( pCfg->enableMCC )
5987 {
5988 /* Currently, supports up to two channels */
5989 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005990
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305991 if( !pCfg->allowMCCGODiffBI )
5992 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005993
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305994 }
5995 wiphy->iface_combinations = &wlan_hdd_iface_combination;
5996 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005997#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305998 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005999
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 /* Before registering we need to update the ht capabilitied based
6001 * on ini values*/
6002 if( !pCfg->ShortGI20MhzEnable )
6003 {
6004 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
6005 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
6006 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
6007 }
6008
6009 if( !pCfg->ShortGI40MhzEnable )
6010 {
6011 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
6012 }
6013
6014 if( !pCfg->nChannelBondingMode5GHz )
6015 {
6016 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
6017 }
6018
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306019 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05306020 if (true == hdd_is_5g_supported(pHddCtx))
6021 {
6022 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
6023 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306024
6025 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
6026 {
6027
6028 if (NULL == wiphy->bands[i])
6029 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05306030 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306031 __func__, i);
6032 continue;
6033 }
6034
6035 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
6036 {
6037 struct ieee80211_supported_band *band = wiphy->bands[i];
6038
6039 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
6040 {
6041 // Enable social channels for P2P
6042 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
6043 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
6044 else
6045 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
6046 continue;
6047 }
6048 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
6049 {
6050 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
6051 continue;
6052 }
6053 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 }
6055 /*Initialise the supported cipher suite details*/
6056 wiphy->cipher_suites = hdd_cipher_suites;
6057 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
6058
6059 /*signal strength in mBm (100*dBm) */
6060 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
6061
6062#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05306063 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07006064#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006065
Sunil Duttc69bccb2014-05-26 21:30:20 +05306066 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
6067 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08006068 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
6069 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
6070
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306071 EXIT();
6072 return 0;
6073}
6074
6075/* In this function we are registering wiphy. */
6076int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
6077{
6078 ENTER();
6079 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006080 if (0 > wiphy_register(wiphy))
6081 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306082 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
6084 return -EIO;
6085 }
6086
6087 EXIT();
6088 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306089}
Jeff Johnson295189b2012-06-20 16:38:30 -07006090
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306091/* In this function we are updating channel list when,
6092 regulatory domain is FCC and country code is US.
6093 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
6094 As per FCC smart phone is not a indoor device.
6095 GO should not opeate on indoor channels */
6096void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
6097{
6098 int j;
6099 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6100 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
6101 //Default counrtycode from NV at the time of wiphy initialization.
6102 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
6103 &defaultCountryCode[0]))
6104 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006105 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306106 }
6107 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
6108 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306109 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
6110 {
6111 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
6112 return;
6113 }
6114 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
6115 {
6116 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
6117 // Mark UNII -1 band channel as passive
6118 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
6119 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
6120 }
6121 }
6122}
6123
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05306124/* This function registers for all frame which supplicant is interested in */
6125void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07006126{
Jeff Johnson295189b2012-06-20 16:38:30 -07006127 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6128 /* Register for all P2P action, public action etc frames */
6129 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
6130
Jeff Johnsone7245742012-09-05 17:12:55 -07006131 ENTER();
6132
Jeff Johnson295189b2012-06-20 16:38:30 -07006133 /* Right now we are registering these frame when driver is getting
6134 initialized. Once we will move to 2.6.37 kernel, in which we have
6135 frame register ops, we will move this code as a part of that */
6136 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306137 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006138 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6139
6140 /* GAS Initial Response */
6141 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6142 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306143
Jeff Johnson295189b2012-06-20 16:38:30 -07006144 /* GAS Comeback Request */
6145 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6146 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6147
6148 /* GAS Comeback Response */
6149 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6150 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6151
6152 /* P2P Public Action */
6153 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306154 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 P2P_PUBLIC_ACTION_FRAME_SIZE );
6156
6157 /* P2P Action */
6158 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6159 (v_U8_t*)P2P_ACTION_FRAME,
6160 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07006161
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05306162 /* WNM BSS Transition Request frame */
6163 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6164 (v_U8_t*)WNM_BSS_ACTION_FRAME,
6165 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006166
6167 /* WNM-Notification */
6168 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6169 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6170 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006171}
6172
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05306173void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07006174{
Jeff Johnson295189b2012-06-20 16:38:30 -07006175 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6176 /* Register for all P2P action, public action etc frames */
6177 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
6178
Jeff Johnsone7245742012-09-05 17:12:55 -07006179 ENTER();
6180
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 /* Right now we are registering these frame when driver is getting
6182 initialized. Once we will move to 2.6.37 kernel, in which we have
6183 frame register ops, we will move this code as a part of that */
6184 /* GAS Initial Request */
6185
6186 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6187 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6188
6189 /* GAS Initial Response */
6190 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6191 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306192
Jeff Johnson295189b2012-06-20 16:38:30 -07006193 /* GAS Comeback Request */
6194 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6195 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6196
6197 /* GAS Comeback Response */
6198 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6199 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6200
6201 /* P2P Public Action */
6202 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306203 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 P2P_PUBLIC_ACTION_FRAME_SIZE );
6205
6206 /* P2P Action */
6207 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6208 (v_U8_t*)P2P_ACTION_FRAME,
6209 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006210 /* WNM-Notification */
6211 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6212 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6213 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006214}
6215
6216#ifdef FEATURE_WLAN_WAPI
6217void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05306218 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006219{
6220 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6221 tCsrRoamSetKey setKey;
6222 v_BOOL_t isConnected = TRUE;
6223 int status = 0;
6224 v_U32_t roamId= 0xFF;
6225 tANI_U8 *pKeyPtr = NULL;
6226 int n = 0;
6227
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306228 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
6229 __func__, hdd_device_modetoString(pAdapter->device_mode),
6230 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006231
Gopichand Nakkalae7480202013-02-11 15:24:22 +05306232 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 setKey.keyId = key_index; // Store Key ID
6234 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
6235 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
6236 setKey.paeRole = 0 ; // the PAE role
6237 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
6238 {
6239 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
6240 }
6241 else
6242 {
6243 isConnected = hdd_connIsConnected(pHddStaCtx);
6244 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
6245 }
6246 setKey.keyLength = key_Len;
6247 pKeyPtr = setKey.Key;
6248 memcpy( pKeyPtr, key, key_Len);
6249
Arif Hussain6d2a3322013-11-17 19:50:10 -08006250 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006251 __func__, key_Len);
6252 for (n = 0 ; n < key_Len; n++)
6253 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
6254 __func__,n,setKey.Key[n]);
6255
6256 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6257 if ( isConnected )
6258 {
6259 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
6260 pAdapter->sessionId, &setKey, &roamId );
6261 }
6262 if ( status != 0 )
6263 {
6264 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6265 "[%4d] sme_RoamSetKey returned ERROR status= %d",
6266 __LINE__, status );
6267 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6268 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05306269 /* Need to clear any trace of key value in the memory.
6270 * Thus zero out the memory even though it is local
6271 * variable.
6272 */
6273 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006274}
6275#endif /* FEATURE_WLAN_WAPI*/
6276
6277#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306278int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 beacon_data_t **ppBeacon,
6280 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006281#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306282int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006283 beacon_data_t **ppBeacon,
6284 struct cfg80211_beacon_data *params,
6285 int dtim_period)
6286#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306287{
Jeff Johnson295189b2012-06-20 16:38:30 -07006288 int size;
6289 beacon_data_t *beacon = NULL;
6290 beacon_data_t *old = NULL;
6291 int head_len,tail_len;
6292
Jeff Johnsone7245742012-09-05 17:12:55 -07006293 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306295 {
6296 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6297 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006298 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306299 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006300
6301 old = pAdapter->sessionCtx.ap.beacon;
6302
6303 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306304 {
6305 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6306 FL("session(%d) old and new heads points to NULL"),
6307 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006308 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306309 }
6310
6311 if (params->tail && !params->tail_len)
6312 {
6313 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6314 FL("tail_len is zero but tail is not NULL"));
6315 return -EINVAL;
6316 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006317
Jeff Johnson295189b2012-06-20 16:38:30 -07006318#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
6319 /* Kernel 3.0 is not updating dtim_period for set beacon */
6320 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306321 {
6322 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6323 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006324 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306325 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006326#endif
6327
6328 if(params->head)
6329 head_len = params->head_len;
6330 else
6331 head_len = old->head_len;
6332
6333 if(params->tail || !old)
6334 tail_len = params->tail_len;
6335 else
6336 tail_len = old->tail_len;
6337
6338 size = sizeof(beacon_data_t) + head_len + tail_len;
6339
6340 beacon = kzalloc(size, GFP_KERNEL);
6341
6342 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306343 {
6344 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6345 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006346 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306347 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006348
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006349#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006350 if(params->dtim_period || !old )
6351 beacon->dtim_period = params->dtim_period;
6352 else
6353 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006354#else
6355 if(dtim_period || !old )
6356 beacon->dtim_period = dtim_period;
6357 else
6358 beacon->dtim_period = old->dtim_period;
6359#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306360
Jeff Johnson295189b2012-06-20 16:38:30 -07006361 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
6362 beacon->tail = beacon->head + head_len;
6363 beacon->head_len = head_len;
6364 beacon->tail_len = tail_len;
6365
6366 if(params->head) {
6367 memcpy (beacon->head,params->head,beacon->head_len);
6368 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306369 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07006370 if(old)
6371 memcpy (beacon->head,old->head,beacon->head_len);
6372 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306373
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 if(params->tail) {
6375 memcpy (beacon->tail,params->tail,beacon->tail_len);
6376 }
6377 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306378 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07006379 memcpy (beacon->tail,old->tail,beacon->tail_len);
6380 }
6381
6382 *ppBeacon = beacon;
6383
6384 kfree(old);
6385
6386 return 0;
6387
6388}
Jeff Johnson295189b2012-06-20 16:38:30 -07006389
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05306390v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
6391#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
6392 const v_U8_t *pIes,
6393#else
6394 v_U8_t *pIes,
6395#endif
6396 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006397{
6398 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05306399 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07006400 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306401
Jeff Johnson295189b2012-06-20 16:38:30 -07006402 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306403 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006404 elem_id = ptr[0];
6405 elem_len = ptr[1];
6406 left -= 2;
6407 if(elem_len > left)
6408 {
6409 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006410 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 eid,elem_len,left);
6412 return NULL;
6413 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306414 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006415 {
6416 return ptr;
6417 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306418
Jeff Johnson295189b2012-06-20 16:38:30 -07006419 left -= elem_len;
6420 ptr += (elem_len + 2);
6421 }
6422 return NULL;
6423}
6424
Jeff Johnson295189b2012-06-20 16:38:30 -07006425/* Check if rate is 11g rate or not */
6426static int wlan_hdd_rate_is_11g(u8 rate)
6427{
Sanjay Devnani28322e22013-06-21 16:13:40 -07006428 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006429 u8 i;
6430 for (i = 0; i < 8; i++)
6431 {
6432 if(rate == gRateArray[i])
6433 return TRUE;
6434 }
6435 return FALSE;
6436}
6437
6438/* Check for 11g rate and set proper 11g only mode */
6439static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
6440 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
6441{
6442 u8 i, num_rates = pIe[0];
6443
6444 pIe += 1;
6445 for ( i = 0; i < num_rates; i++)
6446 {
6447 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
6448 {
6449 /* If rate set have 11g rate than change the mode to 11G */
6450 *pSapHw_mode = eSAP_DOT11_MODE_11g;
6451 if (pIe[i] & BASIC_RATE_MASK)
6452 {
6453 /* If we have 11g rate as basic rate, it means mode
6454 is 11g only mode.
6455 */
6456 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
6457 *pCheckRatesfor11g = FALSE;
6458 }
6459 }
6460 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
6461 {
6462 *require_ht = TRUE;
6463 }
6464 }
6465 return;
6466}
6467
6468static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
6469{
6470 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6471 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6472 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6473 u8 checkRatesfor11g = TRUE;
6474 u8 require_ht = FALSE;
6475 u8 *pIe=NULL;
6476
6477 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
6478
6479 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
6480 pBeacon->head_len, WLAN_EID_SUPP_RATES);
6481 if (pIe != NULL)
6482 {
6483 pIe += 1;
6484 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6485 &pConfig->SapHw_mode);
6486 }
6487
6488 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6489 WLAN_EID_EXT_SUPP_RATES);
6490 if (pIe != NULL)
6491 {
6492
6493 pIe += 1;
6494 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6495 &pConfig->SapHw_mode);
6496 }
6497
6498 if( pConfig->channel > 14 )
6499 {
6500 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
6501 }
6502
6503 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6504 WLAN_EID_HT_CAPABILITY);
6505
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306506 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006507 {
6508 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
6509 if(require_ht)
6510 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
6511 }
6512}
6513
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306514static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
6515 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
6516{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006517 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306518 v_U8_t *pIe = NULL;
6519 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6520
6521 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
6522 pBeacon->tail, pBeacon->tail_len);
6523
6524 if (pIe)
6525 {
6526 ielen = pIe[1] + 2;
6527 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6528 {
6529 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
6530 }
6531 else
6532 {
6533 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
6534 return -EINVAL;
6535 }
6536 *total_ielen += ielen;
6537 }
6538 return 0;
6539}
6540
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006541static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
6542 v_U8_t *genie, v_U8_t *total_ielen)
6543{
6544 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6545 int left = pBeacon->tail_len;
6546 v_U8_t *ptr = pBeacon->tail;
6547 v_U8_t elem_id, elem_len;
6548 v_U16_t ielen = 0;
6549
6550 if ( NULL == ptr || 0 == left )
6551 return;
6552
6553 while (left >= 2)
6554 {
6555 elem_id = ptr[0];
6556 elem_len = ptr[1];
6557 left -= 2;
6558 if (elem_len > left)
6559 {
6560 hddLog( VOS_TRACE_LEVEL_ERROR,
6561 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
6562 elem_id, elem_len, left);
6563 return;
6564 }
6565 if (IE_EID_VENDOR == elem_id)
6566 {
6567 /* skipping the VSIE's which we don't want to include or
6568 * it will be included by existing code
6569 */
6570 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
6571#ifdef WLAN_FEATURE_WFD
6572 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
6573#endif
6574 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6575 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6576 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
6577 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6578 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
6579 {
6580 ielen = ptr[1] + 2;
6581 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6582 {
6583 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
6584 *total_ielen += ielen;
6585 }
6586 else
6587 {
6588 hddLog( VOS_TRACE_LEVEL_ERROR,
6589 "IE Length is too big "
6590 "IEs eid=%d elem_len=%d total_ie_lent=%d",
6591 elem_id, elem_len, *total_ielen);
6592 }
6593 }
6594 }
6595
6596 left -= elem_len;
6597 ptr += (elem_len + 2);
6598 }
6599 return;
6600}
6601
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006602#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006603static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6604 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006605#else
6606static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6607 struct cfg80211_beacon_data *params)
6608#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006609{
6610 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306611 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006612 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07006613 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006614
6615 genie = vos_mem_malloc(MAX_GENIE_LEN);
6616
6617 if(genie == NULL) {
6618
6619 return -ENOMEM;
6620 }
6621
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306622 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6623 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306625 hddLog(LOGE,
6626 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306627 ret = -EINVAL;
6628 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 }
6630
6631#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306632 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6633 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
6634 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306635 hddLog(LOGE,
6636 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306637 ret = -EINVAL;
6638 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 }
6640#endif
6641
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306642 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6643 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006644 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306645 hddLog(LOGE,
6646 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306647 ret = -EINVAL;
6648 goto done;
6649 }
6650
6651 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
6652 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006653 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006655
6656 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6657 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
6658 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6659 {
6660 hddLog(LOGE,
6661 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006662 ret = -EINVAL;
6663 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006664 }
6665
6666 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6667 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6668 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6669 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6670 ==eHAL_STATUS_FAILURE)
6671 {
6672 hddLog(LOGE,
6673 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006674 ret = -EINVAL;
6675 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 }
6677
6678 // Added for ProResp IE
6679 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
6680 {
6681 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
6682 u8 probe_rsp_ie_len[3] = {0};
6683 u8 counter = 0;
6684 /* Check Probe Resp Length if it is greater then 255 then Store
6685 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
6686 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
6687 Store More then 255 bytes into One Variable.
6688 */
6689 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6690 {
6691 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6692 {
6693 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6694 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6695 }
6696 else
6697 {
6698 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6699 rem_probe_resp_ie_len = 0;
6700 }
6701 }
6702
6703 rem_probe_resp_ie_len = 0;
6704
6705 if (probe_rsp_ie_len[0] > 0)
6706 {
6707 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6708 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6709 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6710 probe_rsp_ie_len[0], NULL,
6711 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6712 {
6713 hddLog(LOGE,
6714 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006715 ret = -EINVAL;
6716 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006717 }
6718 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6719 }
6720
6721 if (probe_rsp_ie_len[1] > 0)
6722 {
6723 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6724 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6725 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6726 probe_rsp_ie_len[1], NULL,
6727 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6728 {
6729 hddLog(LOGE,
6730 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006731 ret = -EINVAL;
6732 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006733 }
6734 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6735 }
6736
6737 if (probe_rsp_ie_len[2] > 0)
6738 {
6739 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6740 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6741 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6742 probe_rsp_ie_len[2], NULL,
6743 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6744 {
6745 hddLog(LOGE,
6746 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006747 ret = -EINVAL;
6748 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006749 }
6750 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6751 }
6752
6753 if (probe_rsp_ie_len[1] == 0 )
6754 {
6755 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6756 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
6757 eANI_BOOLEAN_FALSE) )
6758 {
6759 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006760 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006761 }
6762 }
6763
6764 if (probe_rsp_ie_len[2] == 0 )
6765 {
6766 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6767 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
6768 eANI_BOOLEAN_FALSE) )
6769 {
6770 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006771 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 }
6773 }
6774
6775 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6776 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6777 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6778 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6779 == eHAL_STATUS_FAILURE)
6780 {
6781 hddLog(LOGE,
6782 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006783 ret = -EINVAL;
6784 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006785 }
6786 }
6787 else
6788 {
6789 // Reset WNI_CFG_PROBE_RSP Flags
6790 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
6791
6792 hddLog(VOS_TRACE_LEVEL_INFO,
6793 "%s: No Probe Response IE received in set beacon",
6794 __func__);
6795 }
6796
6797 // Added for AssocResp IE
6798 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
6799 {
6800 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6801 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
6802 params->assocresp_ies_len, NULL,
6803 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6804 {
6805 hddLog(LOGE,
6806 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006807 ret = -EINVAL;
6808 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006809 }
6810
6811 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6812 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
6813 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6814 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6815 == eHAL_STATUS_FAILURE)
6816 {
6817 hddLog(LOGE,
6818 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006819 ret = -EINVAL;
6820 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006821 }
6822 }
6823 else
6824 {
6825 hddLog(VOS_TRACE_LEVEL_INFO,
6826 "%s: No Assoc Response IE received in set beacon",
6827 __func__);
6828
6829 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6830 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6831 eANI_BOOLEAN_FALSE) )
6832 {
6833 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006834 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006835 }
6836 }
6837
Jeff Johnsone7245742012-09-05 17:12:55 -07006838done:
Jeff Johnson295189b2012-06-20 16:38:30 -07006839 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306840 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006841}
Jeff Johnson295189b2012-06-20 16:38:30 -07006842
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306843/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006844 * FUNCTION: wlan_hdd_validate_operation_channel
6845 * called by wlan_hdd_cfg80211_start_bss() and
6846 * wlan_hdd_cfg80211_set_channel()
6847 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306848 * channel list.
6849 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07006850VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006851{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306852
Jeff Johnson295189b2012-06-20 16:38:30 -07006853 v_U32_t num_ch = 0;
6854 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6855 u32 indx = 0;
6856 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306857 v_U8_t fValidChannel = FALSE, count = 0;
6858 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306859
Jeff Johnson295189b2012-06-20 16:38:30 -07006860 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6861
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306862 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306864 /* Validate the channel */
6865 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006866 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306867 if ( channel == rfChannels[count].channelNum )
6868 {
6869 fValidChannel = TRUE;
6870 break;
6871 }
6872 }
6873 if (fValidChannel != TRUE)
6874 {
6875 hddLog(VOS_TRACE_LEVEL_ERROR,
6876 "%s: Invalid Channel [%d]", __func__, channel);
6877 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006878 }
6879 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306880 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006881 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306882 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6883 valid_ch, &num_ch))
6884 {
6885 hddLog(VOS_TRACE_LEVEL_ERROR,
6886 "%s: failed to get valid channel list", __func__);
6887 return VOS_STATUS_E_FAILURE;
6888 }
6889 for (indx = 0; indx < num_ch; indx++)
6890 {
6891 if (channel == valid_ch[indx])
6892 {
6893 break;
6894 }
6895 }
6896
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306897 if (indx >= num_ch)
6898 {
6899 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6900 {
6901 eCsrBand band;
6902 unsigned int freq;
6903
6904 sme_GetFreqBand(hHal, &band);
6905
6906 if (eCSR_BAND_5G == band)
6907 {
6908#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
6909 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
6910 {
6911 freq = ieee80211_channel_to_frequency(channel,
6912 IEEE80211_BAND_2GHZ);
6913 }
6914 else
6915 {
6916 freq = ieee80211_channel_to_frequency(channel,
6917 IEEE80211_BAND_5GHZ);
6918 }
6919#else
6920 freq = ieee80211_channel_to_frequency(channel);
6921#endif
6922 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
6923 return VOS_STATUS_SUCCESS;
6924 }
6925 }
6926
6927 hddLog(VOS_TRACE_LEVEL_ERROR,
6928 "%s: Invalid Channel [%d]", __func__, channel);
6929 return VOS_STATUS_E_FAILURE;
6930 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006931 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306932
Jeff Johnson295189b2012-06-20 16:38:30 -07006933 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306934
Jeff Johnson295189b2012-06-20 16:38:30 -07006935}
6936
Viral Modi3a32cc52013-02-08 11:14:52 -08006937/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306938 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08006939 * This function is used to set the channel number
6940 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306941static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08006942 struct ieee80211_channel *chan,
6943 enum nl80211_channel_type channel_type
6944 )
6945{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306946 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08006947 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07006948 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08006949 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306950 hdd_context_t *pHddCtx;
6951 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006952
6953 ENTER();
6954
6955 if( NULL == dev )
6956 {
6957 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006958 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006959 return -ENODEV;
6960 }
6961 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306962
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306963 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6964 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
6965 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08006966 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306967 "%s: device_mode = %s (%d) freq = %d", __func__,
6968 hdd_device_modetoString(pAdapter->device_mode),
6969 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306970
6971 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6972 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306973 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08006974 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306975 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006976 }
6977
6978 /*
6979 * Do freq to chan conversion
6980 * TODO: for 11a
6981 */
6982
6983 channel = ieee80211_frequency_to_channel(freq);
6984
6985 /* Check freq range */
6986 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
6987 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
6988 {
6989 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006990 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08006991 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
6992 WNI_CFG_CURRENT_CHANNEL_STAMAX);
6993 return -EINVAL;
6994 }
6995
6996 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6997
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05306998 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
6999 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08007000 {
7001 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
7002 {
7003 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007004 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08007005 return -EINVAL;
7006 }
7007 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
7008 "%s: set channel to [%d] for device mode =%d",
7009 __func__, channel,pAdapter->device_mode);
7010 }
7011 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08007012 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08007013 )
7014 {
7015 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7016 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
7017 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7018
7019 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
7020 {
7021 /* Link is up then return cant set channel*/
7022 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007023 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08007024 return -EINVAL;
7025 }
7026
7027 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
7028 pHddStaCtx->conn_info.operationChannel = channel;
7029 pRoamProfile->ChannelInfo.ChannelList =
7030 &pHddStaCtx->conn_info.operationChannel;
7031 }
7032 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08007033 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08007034 )
7035 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307036 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
7037 {
7038 if(VOS_STATUS_SUCCESS !=
7039 wlan_hdd_validate_operation_channel(pAdapter,channel))
7040 {
7041 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007042 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307043 return -EINVAL;
7044 }
7045 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
7046 }
7047 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08007048 {
7049 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
7050
7051 /* If auto channel selection is configured as enable/ 1 then ignore
7052 channel set by supplicant
7053 */
7054 if ( cfg_param->apAutoChannelSelection )
7055 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307056 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
7057 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08007058 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307059 "%s: set channel to auto channel (0) for device mode =%s (%d)",
7060 __func__, hdd_device_modetoString(pAdapter->device_mode),
7061 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08007062 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307063 else
7064 {
7065 if(VOS_STATUS_SUCCESS !=
7066 wlan_hdd_validate_operation_channel(pAdapter,channel))
7067 {
7068 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007069 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307070 return -EINVAL;
7071 }
7072 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
7073 }
Viral Modi3a32cc52013-02-08 11:14:52 -08007074 }
7075 }
7076 else
7077 {
7078 hddLog(VOS_TRACE_LEVEL_FATAL,
7079 "%s: Invalid device mode failed to set valid channel", __func__);
7080 return -EINVAL;
7081 }
7082 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307083 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08007084}
7085
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05307086static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
7087 struct net_device *dev,
7088 struct ieee80211_channel *chan,
7089 enum nl80211_channel_type channel_type
7090 )
7091{
7092 int ret;
7093
7094 vos_ssr_protect(__func__);
7095 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
7096 vos_ssr_unprotect(__func__);
7097
7098 return ret;
7099}
7100
Jeff Johnson295189b2012-06-20 16:38:30 -07007101#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7102static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
7103 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007104#else
7105static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
7106 struct cfg80211_beacon_data *params,
7107 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307108 enum nl80211_hidden_ssid hidden_ssid,
7109 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007110#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007111{
7112 tsap_Config_t *pConfig;
7113 beacon_data_t *pBeacon = NULL;
7114 struct ieee80211_mgmt *pMgmt_frame;
7115 v_U8_t *pIe=NULL;
7116 v_U16_t capab_info;
7117 eCsrAuthType RSNAuthType;
7118 eCsrEncryptionType RSNEncryptType;
7119 eCsrEncryptionType mcRSNEncryptType;
7120 int status = VOS_STATUS_SUCCESS;
7121 tpWLAN_SAPEventCB pSapEventCallback;
7122 hdd_hostapd_state_t *pHostapdState;
7123 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
7124 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307125 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007126 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307127 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07007128 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08007129 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05307130 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07007131 v_BOOL_t MFPCapable = VOS_FALSE;
7132 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307133 v_BOOL_t sapEnable11AC =
7134 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07007135 ENTER();
7136
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307137 iniConfig = pHddCtx->cfg_ini;
7138
Jeff Johnson295189b2012-06-20 16:38:30 -07007139 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
7140
7141 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
7142
7143 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
7144
7145 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
7146
7147 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
7148
7149 //channel is already set in the set_channel Call back
7150 //pConfig->channel = pCommitConfig->channel;
7151
7152 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307153 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07007154 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
7155
7156 pConfig->dtim_period = pBeacon->dtim_period;
7157
Arif Hussain6d2a3322013-11-17 19:50:10 -08007158 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07007159 pConfig->dtim_period);
7160
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08007161 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07007162 {
7163 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007164 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05307165 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
7166 {
7167 tANI_BOOLEAN restartNeeded;
7168 pConfig->ieee80211d = 1;
7169 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
7170 sme_setRegInfo(hHal, pConfig->countryCode);
7171 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
7172 }
7173 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07007174 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07007175 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007176 pConfig->ieee80211d = 1;
7177 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
7178 sme_setRegInfo(hHal, pConfig->countryCode);
7179 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07007180 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007181 else
7182 {
7183 pConfig->ieee80211d = 0;
7184 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307185 /*
7186 * If auto channel is configured i.e. channel is 0,
7187 * so skip channel validation.
7188 */
7189 if( AUTO_CHANNEL_SELECT != pConfig->channel )
7190 {
7191 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
7192 {
7193 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007194 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307195 return -EINVAL;
7196 }
7197 }
7198 else
7199 {
7200 if(1 != pHddCtx->is_dynamic_channel_range_set)
7201 {
7202 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
7203 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
7204 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
7205 }
7206 pHddCtx->is_dynamic_channel_range_set = 0;
7207 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007209 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007210 {
7211 pConfig->ieee80211d = 0;
7212 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307213
7214#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7215 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7216 pConfig->authType = eSAP_OPEN_SYSTEM;
7217 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7218 pConfig->authType = eSAP_SHARED_KEY;
7219 else
7220 pConfig->authType = eSAP_AUTO_SWITCH;
7221#else
7222 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7223 pConfig->authType = eSAP_OPEN_SYSTEM;
7224 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7225 pConfig->authType = eSAP_SHARED_KEY;
7226 else
7227 pConfig->authType = eSAP_AUTO_SWITCH;
7228#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007229
7230 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307231
7232 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07007233 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
7234
7235 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
7236
7237 /*Set wps station to configured*/
7238 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
7239
7240 if(pIe)
7241 {
7242 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
7243 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007244 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07007245 return -EINVAL;
7246 }
7247 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
7248 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007249 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07007250 /* Check 15 bit of WPS IE as it contain information for wps state
7251 * WPS state
7252 */
7253 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
7254 {
7255 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
7256 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
7257 {
7258 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
7259 }
7260 }
7261 }
7262 else
7263 {
7264 pConfig->wps_state = SAP_WPS_DISABLED;
7265 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307266 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07007267
c_hpothufe599e92014-06-16 11:38:55 +05307268 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7269 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7270 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
7271 eCSR_ENCRYPT_TYPE_NONE;
7272
Jeff Johnson295189b2012-06-20 16:38:30 -07007273 pConfig->RSNWPAReqIELength = 0;
7274 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307275 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007276 WLAN_EID_RSN);
7277 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307278 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007279 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7280 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7281 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307282 /* The actual processing may eventually be more extensive than
7283 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07007284 * by the app.
7285 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307286 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007287 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7288 &RSNEncryptType,
7289 &mcRSNEncryptType,
7290 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007291 &MFPCapable,
7292 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007293 pConfig->pRSNWPAReqIE[1]+2,
7294 pConfig->pRSNWPAReqIE );
7295
7296 if( VOS_STATUS_SUCCESS == status )
7297 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307298 /* Now copy over all the security attributes you have
7299 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007300 * */
7301 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7302 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7303 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7304 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307305 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007306 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007307 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7308 }
7309 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307310
Jeff Johnson295189b2012-06-20 16:38:30 -07007311 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7312 pBeacon->tail, pBeacon->tail_len);
7313
7314 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
7315 {
7316 if (pConfig->pRSNWPAReqIE)
7317 {
7318 /*Mixed mode WPA/WPA2*/
7319 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
7320 pConfig->RSNWPAReqIELength += pIe[1] + 2;
7321 }
7322 else
7323 {
7324 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7325 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7326 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307327 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007328 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7329 &RSNEncryptType,
7330 &mcRSNEncryptType,
7331 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007332 &MFPCapable,
7333 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007334 pConfig->pRSNWPAReqIE[1]+2,
7335 pConfig->pRSNWPAReqIE );
7336
7337 if( VOS_STATUS_SUCCESS == status )
7338 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307339 /* Now copy over all the security attributes you have
7340 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007341 * */
7342 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7343 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7344 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7345 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307346 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007347 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007348 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7349 }
7350 }
7351 }
7352
Jeff Johnson4416a782013-03-25 14:17:50 -07007353 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
7354 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
7355 return -EINVAL;
7356 }
7357
Jeff Johnson295189b2012-06-20 16:38:30 -07007358 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
7359
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007360#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007361 if (params->ssid != NULL)
7362 {
7363 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
7364 pConfig->SSIDinfo.ssid.length = params->ssid_len;
7365 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7366 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7367 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007368#else
7369 if (ssid != NULL)
7370 {
7371 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
7372 pConfig->SSIDinfo.ssid.length = ssid_len;
7373 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7374 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7375 }
7376#endif
7377
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307378 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07007379 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307380
Jeff Johnson295189b2012-06-20 16:38:30 -07007381 /* default value */
7382 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
7383 pConfig->num_accept_mac = 0;
7384 pConfig->num_deny_mac = 0;
7385
7386 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7387 pBeacon->tail, pBeacon->tail_len);
7388
7389 /* pIe for black list is following form:
7390 type : 1 byte
7391 length : 1 byte
7392 OUI : 4 bytes
7393 acl type : 1 byte
7394 no of mac addr in black list: 1 byte
7395 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307396 */
7397 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007398 {
7399 pConfig->SapMacaddr_acl = pIe[6];
7400 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007401 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007402 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307403 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
7404 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007405 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7406 for (i = 0; i < pConfig->num_deny_mac; i++)
7407 {
7408 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7409 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307410 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007411 }
7412 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7413 pBeacon->tail, pBeacon->tail_len);
7414
7415 /* pIe for white list is following form:
7416 type : 1 byte
7417 length : 1 byte
7418 OUI : 4 bytes
7419 acl type : 1 byte
7420 no of mac addr in white list: 1 byte
7421 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307422 */
7423 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007424 {
7425 pConfig->SapMacaddr_acl = pIe[6];
7426 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007427 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007428 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307429 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
7430 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007431 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7432 for (i = 0; i < pConfig->num_accept_mac; i++)
7433 {
7434 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7435 acl_entry++;
7436 }
7437 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307438
Jeff Johnson295189b2012-06-20 16:38:30 -07007439 wlan_hdd_set_sapHwmode(pHostapdAdapter);
7440
Jeff Johnsone7245742012-09-05 17:12:55 -07007441#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007442 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307443 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
7444 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05307445 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
7446 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007447 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
7448 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307449 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
7450 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07007451 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307452 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007453 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307454 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007455
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307456 /* If ACS disable and selected channel <= 14
7457 * OR
7458 * ACS enabled and ACS operating band is choosen as 2.4
7459 * AND
7460 * VHT in 2.4G Disabled
7461 * THEN
7462 * Fallback to 11N mode
7463 */
7464 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
7465 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05307466 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307467 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007468 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307469 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
7470 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007471 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
7472 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007473 }
7474#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307475
Jeff Johnson295189b2012-06-20 16:38:30 -07007476 // ht_capab is not what the name conveys,this is used for protection bitmap
7477 pConfig->ht_capab =
7478 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
7479
7480 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
7481 {
7482 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
7483 return -EINVAL;
7484 }
7485
7486 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307487 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07007488 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
7489 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307490 pConfig->obssProtEnabled =
7491 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07007492
Chet Lanctot8cecea22014-02-11 19:09:36 -08007493#ifdef WLAN_FEATURE_11W
7494 pConfig->mfpCapable = MFPCapable;
7495 pConfig->mfpRequired = MFPRequired;
7496 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
7497 pConfig->mfpCapable, pConfig->mfpRequired);
7498#endif
7499
Arif Hussain6d2a3322013-11-17 19:50:10 -08007500 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007502 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
7503 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
7504 (int)pConfig->channel);
7505 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
7506 pConfig->SapHw_mode, pConfig->privacy,
7507 pConfig->authType);
7508 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
7509 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
7510 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
7511 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07007512
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307513 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007514 {
7515 //Bss already started. just return.
7516 //TODO Probably it should update some beacon params.
7517 hddLog( LOGE, "Bss Already started...Ignore the request");
7518 EXIT();
7519 return 0;
7520 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307521
Agarwal Ashish51325b52014-06-16 16:50:49 +05307522 if (vos_max_concurrent_connections_reached()) {
7523 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7524 return -EINVAL;
7525 }
7526
Jeff Johnson295189b2012-06-20 16:38:30 -07007527 pConfig->persona = pHostapdAdapter->device_mode;
7528
Peng Xu2446a892014-09-05 17:21:18 +05307529 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
7530 if ( NULL != psmeConfig)
7531 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307532 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05307533 sme_GetConfigParam(hHal, psmeConfig);
7534 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307535#ifdef WLAN_FEATURE_AP_HT40_24G
7536 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
7537 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
7538 && pHddCtx->cfg_ini->apHT40_24GEnabled)
7539 {
7540 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
7541 sme_UpdateConfig (hHal, psmeConfig);
7542 }
7543#endif
Peng Xu2446a892014-09-05 17:21:18 +05307544 vos_mem_free(psmeConfig);
7545 }
Peng Xuafc34e32014-09-25 13:23:55 +05307546 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05307547
Jeff Johnson295189b2012-06-20 16:38:30 -07007548 pSapEventCallback = hdd_hostapd_SAPEventCB;
7549 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
7550 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
7551 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007552 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007553 return -EINVAL;
7554 }
7555
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307556 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07007557 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
7558
7559 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307560
Jeff Johnson295189b2012-06-20 16:38:30 -07007561 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307562 {
7563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007564 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07007565 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007566 VOS_ASSERT(0);
7567 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307568
Jeff Johnson295189b2012-06-20 16:38:30 -07007569 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05307570 /* Initialize WMM configuation */
7571 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307572 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007573
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007574#ifdef WLAN_FEATURE_P2P_DEBUG
7575 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
7576 {
7577 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
7578 {
7579 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7580 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007581 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007582 }
7583 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
7584 {
7585 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7586 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007587 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007588 }
7589 }
7590#endif
7591
Jeff Johnson295189b2012-06-20 16:38:30 -07007592 pHostapdState->bCommit = TRUE;
7593 EXIT();
7594
7595 return 0;
7596}
7597
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007598#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307599static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307600 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007601 struct beacon_parameters *params)
7602{
7603 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307604 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307605 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007606
7607 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307608
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307609 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7610 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
7611 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307612 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
7613 hdd_device_modetoString(pAdapter->device_mode),
7614 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007615
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307616 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7617 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307618 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007619 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307620 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007621 }
7622
Agarwal Ashish51325b52014-06-16 16:50:49 +05307623 if (vos_max_concurrent_connections_reached()) {
7624 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7625 return -EINVAL;
7626 }
7627
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307628 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007629 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 )
7631 {
7632 beacon_data_t *old,*new;
7633
7634 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307635
Jeff Johnson295189b2012-06-20 16:38:30 -07007636 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307637 {
7638 hddLog(VOS_TRACE_LEVEL_WARN,
7639 FL("already beacon info added to session(%d)"),
7640 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007641 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307642 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007643
7644 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7645
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307646 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 {
7648 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007649 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007650 return -EINVAL;
7651 }
7652
7653 pAdapter->sessionCtx.ap.beacon = new;
7654
7655 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7656 }
7657
7658 EXIT();
7659 return status;
7660}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307661
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307662static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
7663 struct net_device *dev,
7664 struct beacon_parameters *params)
7665{
7666 int ret;
7667
7668 vos_ssr_protect(__func__);
7669 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
7670 vos_ssr_unprotect(__func__);
7671
7672 return ret;
7673}
7674
7675static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007676 struct net_device *dev,
7677 struct beacon_parameters *params)
7678{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307679 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307680 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7681 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307682 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007683
7684 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307685
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307686 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7687 TRACE_CODE_HDD_CFG80211_SET_BEACON,
7688 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
7689 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7690 __func__, hdd_device_modetoString(pAdapter->device_mode),
7691 pAdapter->device_mode);
7692
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307693 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7694 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307695 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007696 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307697 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007698 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307699
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307700 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007701 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307702 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007703 {
7704 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307705
Jeff Johnson295189b2012-06-20 16:38:30 -07007706 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307707
Jeff Johnson295189b2012-06-20 16:38:30 -07007708 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307709 {
7710 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7711 FL("session(%d) old and new heads points to NULL"),
7712 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007713 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007715
7716 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7717
7718 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307719 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007720 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007721 return -EINVAL;
7722 }
7723
7724 pAdapter->sessionCtx.ap.beacon = new;
7725
7726 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7727 }
7728
7729 EXIT();
7730 return status;
7731}
7732
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307733static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
7734 struct net_device *dev,
7735 struct beacon_parameters *params)
7736{
7737 int ret;
7738
7739 vos_ssr_protect(__func__);
7740 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
7741 vos_ssr_unprotect(__func__);
7742
7743 return ret;
7744}
7745
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007746#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7747
7748#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307749static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007750 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007751#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307752static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007753 struct net_device *dev)
7754#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007755{
7756 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07007757 hdd_context_t *pHddCtx = NULL;
7758 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307759 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307760 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007761
7762 ENTER();
7763
7764 if (NULL == pAdapter)
7765 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307766 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007767 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007768 return -ENODEV;
7769 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007770
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307771 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7772 TRACE_CODE_HDD_CFG80211_STOP_AP,
7773 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307774 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7775 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307776 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007777 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307778 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07007779 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007780
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007781 pScanInfo = &pHddCtx->scan_info;
7782
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307783 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7784 __func__, hdd_device_modetoString(pAdapter->device_mode),
7785 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007786
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307787 ret = wlan_hdd_scan_abort(pAdapter);
7788
Girish Gowli4bf7a632014-06-12 13:42:11 +05307789 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07007790 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307791 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7792 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307793
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307794 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07007795 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7797 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08007798
Jeff Johnsone7245742012-09-05 17:12:55 -07007799 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307800 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07007801 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307802 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07007803 }
7804
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05307805 /* Delete all associated STAs before stopping AP/P2P GO */
7806 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05307807 hdd_hostapd_stop(dev);
7808
Jeff Johnson295189b2012-06-20 16:38:30 -07007809 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007810 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007811 )
7812 {
7813 beacon_data_t *old;
7814
7815 old = pAdapter->sessionCtx.ap.beacon;
7816
7817 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307818 {
7819 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7820 FL("session(%d) beacon data points to NULL"),
7821 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007822 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307823 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007824
Jeff Johnson295189b2012-06-20 16:38:30 -07007825 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007826
7827 mutex_lock(&pHddCtx->sap_lock);
7828 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7829 {
Jeff Johnson4416a782013-03-25 14:17:50 -07007830 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007831 {
7832 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7833
7834 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
7835
7836 if (!VOS_IS_STATUS_SUCCESS(status))
7837 {
7838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007839 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007840 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307841 }
7842 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007843 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307844 /* BSS stopped, clear the active sessions for this device mode */
7845 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007846 }
7847 mutex_unlock(&pHddCtx->sap_lock);
7848
7849 if(status != VOS_STATUS_SUCCESS)
7850 {
7851 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007852 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007853 return -EINVAL;
7854 }
7855
Jeff Johnson4416a782013-03-25 14:17:50 -07007856 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007857 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
7858 ==eHAL_STATUS_FAILURE)
7859 {
7860 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007861 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007862 }
7863
Jeff Johnson4416a782013-03-25 14:17:50 -07007864 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007865 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7866 eANI_BOOLEAN_FALSE) )
7867 {
7868 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007869 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007870 }
7871
7872 // Reset WNI_CFG_PROBE_RSP Flags
7873 wlan_hdd_reset_prob_rspies(pAdapter);
7874
7875 pAdapter->sessionCtx.ap.beacon = NULL;
7876 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007877#ifdef WLAN_FEATURE_P2P_DEBUG
7878 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
7879 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
7880 {
7881 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
7882 "GO got removed");
7883 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
7884 }
7885#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007886 }
7887 EXIT();
7888 return status;
7889}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007890
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307891#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7892static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
7893 struct net_device *dev)
7894{
7895 int ret;
7896
7897 vos_ssr_protect(__func__);
7898 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
7899 vos_ssr_unprotect(__func__);
7900
7901 return ret;
7902}
7903#else
7904static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
7905 struct net_device *dev)
7906{
7907 int ret;
7908
7909 vos_ssr_protect(__func__);
7910 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
7911 vos_ssr_unprotect(__func__);
7912
7913 return ret;
7914}
7915#endif
7916
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007917#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
7918
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307919static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307920 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007921 struct cfg80211_ap_settings *params)
7922{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307923 hdd_adapter_t *pAdapter;
7924 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307925 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007926
7927 ENTER();
7928
Girish Gowlib143d7a2015-02-18 19:39:55 +05307929 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007930 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307931 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05307932 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307933 return -ENODEV;
7934 }
7935
7936 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7937 if (NULL == pAdapter)
7938 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307939 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307940 "%s: HDD adapter is Null", __func__);
7941 return -ENODEV;
7942 }
7943
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307944 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7945 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
7946 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307947 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
7948 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307949 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307950 "%s: HDD adapter magic is invalid", __func__);
7951 return -ENODEV;
7952 }
7953
7954 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307955 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307956 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307957 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307958 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307959 }
7960
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307961 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
7962 __func__, hdd_device_modetoString(pAdapter->device_mode),
7963 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307964
7965 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007966 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007967 )
7968 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307969 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007970
7971 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307972
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007973 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307974 {
7975 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7976 FL("already beacon info added to session(%d)"),
7977 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007978 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307979 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007980
Girish Gowlib143d7a2015-02-18 19:39:55 +05307981#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7982 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7983 &new,
7984 &params->beacon);
7985#else
7986 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7987 &new,
7988 &params->beacon,
7989 params->dtim_period);
7990#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007991
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307992 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007993 {
7994 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307995 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007996 return -EINVAL;
7997 }
7998 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08007999#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07008000 wlan_hdd_cfg80211_set_channel(wiphy, dev,
8001#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
8002 params->channel, params->channel_type);
8003#else
8004 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
8005#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08008006#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008007 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05308008 params->ssid_len, params->hidden_ssid,
8009 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008010 }
8011
8012 EXIT();
8013 return status;
8014}
8015
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308016static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
8017 struct net_device *dev,
8018 struct cfg80211_ap_settings *params)
8019{
8020 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008021
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308022 vos_ssr_protect(__func__);
8023 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
8024 vos_ssr_unprotect(__func__);
8025
8026 return ret;
8027}
8028
8029static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008030 struct net_device *dev,
8031 struct cfg80211_beacon_data *params)
8032{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308033 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308034 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308035 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008036
8037 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308038
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308039 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8040 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
8041 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08008042 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008043 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308044
8045 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8046 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308047 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07008048 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308049 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07008050 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008051
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308052 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008053 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308054 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008055 {
8056 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308057
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008058 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308059
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008060 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308061 {
8062 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8063 FL("session(%d) beacon data points to NULL"),
8064 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008065 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308066 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008067
8068 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
8069
8070 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308071 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008072 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008073 return -EINVAL;
8074 }
8075
8076 pAdapter->sessionCtx.ap.beacon = new;
8077
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05308078 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
8079 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008080 }
8081
8082 EXIT();
8083 return status;
8084}
8085
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308086static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
8087 struct net_device *dev,
8088 struct cfg80211_beacon_data *params)
8089{
8090 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008091
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308092 vos_ssr_protect(__func__);
8093 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
8094 vos_ssr_unprotect(__func__);
8095
8096 return ret;
8097}
8098
8099#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008100
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308101static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008102 struct net_device *dev,
8103 struct bss_parameters *params)
8104{
8105 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308106 hdd_context_t *pHddCtx;
8107 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008108
8109 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308110
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308111 if (NULL == pAdapter)
8112 {
8113 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8114 "%s: HDD adapter is Null", __func__);
8115 return -ENODEV;
8116 }
8117 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308118 ret = wlan_hdd_validate_context(pHddCtx);
8119 if (0 != ret)
8120 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308121 return ret;
8122 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308123 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8124 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
8125 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308126 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8127 __func__, hdd_device_modetoString(pAdapter->device_mode),
8128 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008129
8130 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008131 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308132 )
Jeff Johnson295189b2012-06-20 16:38:30 -07008133 {
8134 /* ap_isolate == -1 means that in change bss, upper layer doesn't
8135 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308136 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07008137 {
8138 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008140 }
8141
8142 EXIT();
8143 return 0;
8144}
8145
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308146static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
8147 struct net_device *dev,
8148 struct bss_parameters *params)
8149{
8150 int ret;
8151
8152 vos_ssr_protect(__func__);
8153 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
8154 vos_ssr_unprotect(__func__);
8155
8156 return ret;
8157}
Kiet Lam10841362013-11-01 11:36:50 +05308158/* FUNCTION: wlan_hdd_change_country_code_cd
8159* to wait for contry code completion
8160*/
8161void* wlan_hdd_change_country_code_cb(void *pAdapter)
8162{
8163 hdd_adapter_t *call_back_pAdapter = pAdapter;
8164 complete(&call_back_pAdapter->change_country_code);
8165 return NULL;
8166}
8167
Jeff Johnson295189b2012-06-20 16:38:30 -07008168/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308169 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07008170 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
8171 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308172int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008173 struct net_device *ndev,
8174 enum nl80211_iftype type,
8175 u32 *flags,
8176 struct vif_params *params
8177 )
8178{
8179 struct wireless_dev *wdev;
8180 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008181 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07008182 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008183 tCsrRoamProfile *pRoamProfile = NULL;
8184 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308185 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008186 eMib_dot11DesiredBssType connectedBssType;
8187 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308188 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008189
8190 ENTER();
8191
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308192 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008193 {
8194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8195 "%s: Adapter context is null", __func__);
8196 return VOS_STATUS_E_FAILURE;
8197 }
8198
8199 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8200 if (!pHddCtx)
8201 {
8202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8203 "%s: HDD context is null", __func__);
8204 return VOS_STATUS_E_FAILURE;
8205 }
8206
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308207 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8208 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
8209 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308210 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308211 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07008212 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308213 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008214 }
8215
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308216 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8217 __func__, hdd_device_modetoString(pAdapter->device_mode),
8218 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008219
Agarwal Ashish51325b52014-06-16 16:50:49 +05308220 if (vos_max_concurrent_connections_reached()) {
8221 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
8222 return -EINVAL;
8223 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308224 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07008225 wdev = ndev->ieee80211_ptr;
8226
8227#ifdef WLAN_BTAMP_FEATURE
8228 if((NL80211_IFTYPE_P2P_CLIENT == type)||
8229 (NL80211_IFTYPE_ADHOC == type)||
8230 (NL80211_IFTYPE_AP == type)||
8231 (NL80211_IFTYPE_P2P_GO == type))
8232 {
8233 pHddCtx->isAmpAllowed = VOS_FALSE;
8234 // stop AMP traffic
8235 status = WLANBAP_StopAmp();
8236 if(VOS_STATUS_SUCCESS != status )
8237 {
8238 pHddCtx->isAmpAllowed = VOS_TRUE;
8239 hddLog(VOS_TRACE_LEVEL_FATAL,
8240 "%s: Failed to stop AMP", __func__);
8241 return -EINVAL;
8242 }
8243 }
8244#endif //WLAN_BTAMP_FEATURE
8245 /* Reset the current device mode bit mask*/
8246 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
8247
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05308248 if ((pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) &&
8249 ((type == NL80211_IFTYPE_P2P_CLIENT) ||
8250 (type == NL80211_IFTYPE_P2P_GO)))
8251 {
8252 /* Notify Mode change in case of concurrency.
8253 * Below function invokes TDLS teardown Functionality Since TDLS is
8254 * not Supported in case of concurrency i.e Once P2P session
8255 * is detected disable offchannel and teardown TDLS links
8256 */
8257 hddLog(LOG1,
8258 FL("Device mode = %d Interface type = %d"),
8259 pAdapter->device_mode, type);
8260 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
8261 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05308262
Jeff Johnson295189b2012-06-20 16:38:30 -07008263 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008264 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07008265 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07008266 )
8267 {
8268 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008269 if (!pWextState)
8270 {
8271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8272 "%s: pWextState is null", __func__);
8273 return VOS_STATUS_E_FAILURE;
8274 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008275 pRoamProfile = &pWextState->roamProfile;
8276 LastBSSType = pRoamProfile->BSSType;
8277
8278 switch (type)
8279 {
8280 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008281 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008282 hddLog(VOS_TRACE_LEVEL_INFO,
8283 "%s: setting interface Type to INFRASTRUCTURE", __func__);
8284 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07008285#ifdef WLAN_FEATURE_11AC
8286 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
8287 {
8288 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
8289 }
8290#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308291 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07008292 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008293 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008294 //Check for sub-string p2p to confirm its a p2p interface
8295 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308296 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +05308297#ifdef FEATURE_WLAN_TDLS
8298 mutex_lock(&pHddCtx->tdls_lock);
8299 wlan_hdd_tdls_exit(pAdapter, TRUE);
8300 mutex_unlock(&pHddCtx->tdls_lock);
8301#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008302 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8303 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8304 }
8305 else
8306 {
8307 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008308 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008309 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008310 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05308311
Jeff Johnson295189b2012-06-20 16:38:30 -07008312 case NL80211_IFTYPE_ADHOC:
8313 hddLog(VOS_TRACE_LEVEL_INFO,
8314 "%s: setting interface Type to ADHOC", __func__);
8315 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
8316 pRoamProfile->phyMode =
8317 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07008318 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008319 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +05308320 hdd_set_ibss_ops( pAdapter );
8321 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +05308322
8323 status = hdd_sta_id_hash_attach(pAdapter);
8324 if (VOS_STATUS_SUCCESS != status) {
8325 hddLog(VOS_TRACE_LEVEL_ERROR,
8326 FL("Failed to initialize hash for IBSS"));
8327 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008328 break;
8329
8330 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008331 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008332 {
8333 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8334 "%s: setting interface Type to %s", __func__,
8335 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
8336
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008337 //Cancel any remain on channel for GO mode
8338 if (NL80211_IFTYPE_P2P_GO == type)
8339 {
8340 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
8341 }
Mohit Khanna0f232092012-09-11 14:46:08 -07008342 if (NL80211_IFTYPE_AP == type)
8343 {
8344 /* As Loading WLAN Driver one interface being created for p2p device
8345 * address. This will take one HW STA and the max number of clients
8346 * that can connect to softAP will be reduced by one. so while changing
8347 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
8348 * interface as it is not required in SoftAP mode.
8349 */
8350
8351 // Get P2P Adapter
8352 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
8353
8354 if (pP2pAdapter)
8355 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05308356 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +05308357 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07008358 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
8359 }
8360 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05308361 //Disable IMPS & BMPS for SAP/GO
8362 if(VOS_STATUS_E_FAILURE ==
8363 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
8364 {
8365 //Fail to Exit BMPS
8366 VOS_ASSERT(0);
8367 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05308368
8369 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
8370
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308371#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07008372
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308373 /* A Mutex Lock is introduced while changing the mode to
8374 * protect the concurrent access for the Adapters by TDLS
8375 * module.
8376 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308377 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308378#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008379 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +05308380 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008381 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07008382 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8383 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308384#ifdef FEATURE_WLAN_TDLS
8385 mutex_unlock(&pHddCtx->tdls_lock);
8386#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008387 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
8388 (pConfig->apRandomBssidEnabled))
8389 {
8390 /* To meet Android requirements create a randomized
8391 MAC address of the form 02:1A:11:Fx:xx:xx */
8392 get_random_bytes(&ndev->dev_addr[3], 3);
8393 ndev->dev_addr[0] = 0x02;
8394 ndev->dev_addr[1] = 0x1A;
8395 ndev->dev_addr[2] = 0x11;
8396 ndev->dev_addr[3] |= 0xF0;
8397 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
8398 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08008399 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
8400 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008401 }
8402
Jeff Johnson295189b2012-06-20 16:38:30 -07008403 hdd_set_ap_ops( pAdapter->dev );
8404
Kiet Lam10841362013-11-01 11:36:50 +05308405 /* This is for only SAP mode where users can
8406 * control country through ini.
8407 * P2P GO follows station country code
8408 * acquired during the STA scanning. */
8409 if((NL80211_IFTYPE_AP == type) &&
8410 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
8411 {
8412 int status = 0;
8413 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
8414 "%s: setting country code from INI ", __func__);
8415 init_completion(&pAdapter->change_country_code);
8416 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
8417 (void *)(tSmeChangeCountryCallback)
8418 wlan_hdd_change_country_code_cb,
8419 pConfig->apCntryCode, pAdapter,
8420 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05308421 eSIR_FALSE,
8422 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05308423 if (eHAL_STATUS_SUCCESS == status)
8424 {
8425 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308426 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05308427 &pAdapter->change_country_code,
8428 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308429 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05308430 {
8431 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308432 FL("SME Timed out while setting country code %ld"),
8433 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08008434
8435 if (pHddCtx->isLogpInProgress)
8436 {
8437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8438 "%s: LOGP in Progress. Ignore!!!", __func__);
8439 return -EAGAIN;
8440 }
Kiet Lam10841362013-11-01 11:36:50 +05308441 }
8442 }
8443 else
8444 {
8445 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008446 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05308447 return -EINVAL;
8448 }
8449 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008450 status = hdd_init_ap_mode(pAdapter);
8451 if(status != VOS_STATUS_SUCCESS)
8452 {
8453 hddLog(VOS_TRACE_LEVEL_FATAL,
8454 "%s: Error initializing the ap mode", __func__);
8455 return -EINVAL;
8456 }
8457 hdd_set_conparam(1);
8458
Nirav Shah7e3c8132015-06-22 23:51:42 +05308459 status = hdd_sta_id_hash_attach(pAdapter);
8460 if (VOS_STATUS_SUCCESS != status)
8461 {
8462 hddLog(VOS_TRACE_LEVEL_ERROR,
8463 FL("Failed to initialize hash for AP"));
8464 return -EINVAL;
8465 }
8466
Jeff Johnson295189b2012-06-20 16:38:30 -07008467 /*interface type changed update in wiphy structure*/
8468 if(wdev)
8469 {
8470 wdev->iftype = type;
8471 pHddCtx->change_iface = type;
8472 }
8473 else
8474 {
8475 hddLog(VOS_TRACE_LEVEL_ERROR,
8476 "%s: ERROR !!!! Wireless dev is NULL", __func__);
8477 return -EINVAL;
8478 }
8479 goto done;
8480 }
8481
8482 default:
8483 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8484 __func__);
8485 return -EOPNOTSUPP;
8486 }
8487 }
8488 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008489 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07008490 )
8491 {
8492 switch(type)
8493 {
8494 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008495 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008496 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05308497
8498 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308499#ifdef FEATURE_WLAN_TDLS
8500
8501 /* A Mutex Lock is introduced while changing the mode to
8502 * protect the concurrent access for the Adapters by TDLS
8503 * module.
8504 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308505 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308506#endif
c_hpothu002231a2015-02-05 14:58:51 +05308507 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008508 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008509 //Check for sub-string p2p to confirm its a p2p interface
8510 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008511 {
8512 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8513 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8514 }
8515 else
8516 {
8517 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008518 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008519 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008520 hdd_set_conparam(0);
8521 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008522 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
8523 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308524#ifdef FEATURE_WLAN_TDLS
8525 mutex_unlock(&pHddCtx->tdls_lock);
8526#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05308527 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008528 if( VOS_STATUS_SUCCESS != status )
8529 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07008530 /* In case of JB, for P2P-GO, only change interface will be called,
8531 * This is the right place to enable back bmps_imps()
8532 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308533 if (pHddCtx->hdd_wlan_suspended)
8534 {
8535 hdd_set_pwrparams(pHddCtx);
8536 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008537 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008538 goto done;
8539 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008540 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008541 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008542 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8543 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008544 goto done;
8545 default:
8546 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8547 __func__);
8548 return -EOPNOTSUPP;
8549
8550 }
8551
8552 }
8553 else
8554 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308555 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
8556 __func__, hdd_device_modetoString(pAdapter->device_mode),
8557 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008558 return -EOPNOTSUPP;
8559 }
8560
8561
8562 if(pRoamProfile)
8563 {
8564 if ( LastBSSType != pRoamProfile->BSSType )
8565 {
8566 /*interface type changed update in wiphy structure*/
8567 wdev->iftype = type;
8568
8569 /*the BSS mode changed, We need to issue disconnect
8570 if connected or in IBSS disconnect state*/
8571 if ( hdd_connGetConnectedBssType(
8572 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
8573 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
8574 {
8575 /*need to issue a disconnect to CSR.*/
8576 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8577 if( eHAL_STATUS_SUCCESS ==
8578 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8579 pAdapter->sessionId,
8580 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
8581 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308582 ret = wait_for_completion_interruptible_timeout(
8583 &pAdapter->disconnect_comp_var,
8584 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8585 if (ret <= 0)
8586 {
8587 hddLog(VOS_TRACE_LEVEL_ERROR,
8588 FL("wait on disconnect_comp_var failed %ld"), ret);
8589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008590 }
8591 }
8592 }
8593 }
8594
8595done:
8596 /*set bitmask based on updated value*/
8597 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07008598
8599 /* Only STA mode support TM now
8600 * all other mode, TM feature should be disabled */
8601 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
8602 (~VOS_STA & pHddCtx->concurrency_mode) )
8603 {
8604 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
8605 }
8606
Jeff Johnson295189b2012-06-20 16:38:30 -07008607#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308608 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05308609 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07008610 {
8611 //we are ok to do AMP
8612 pHddCtx->isAmpAllowed = VOS_TRUE;
8613 }
8614#endif //WLAN_BTAMP_FEATURE
8615 EXIT();
8616 return 0;
8617}
8618
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308619/*
8620 * FUNCTION: wlan_hdd_cfg80211_change_iface
8621 * wrapper function to protect the actual implementation from SSR.
8622 */
8623int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
8624 struct net_device *ndev,
8625 enum nl80211_iftype type,
8626 u32 *flags,
8627 struct vif_params *params
8628 )
8629{
8630 int ret;
8631
8632 vos_ssr_protect(__func__);
8633 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
8634 vos_ssr_unprotect(__func__);
8635
8636 return ret;
8637}
8638
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008639#ifdef FEATURE_WLAN_TDLS
8640static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308641 struct net_device *dev,
8642#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
8643 const u8 *mac,
8644#else
8645 u8 *mac,
8646#endif
8647 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008648{
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008649 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008650 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308651 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308652 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308653 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308654 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008655
8656 ENTER();
8657
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308658 if (!dev) {
8659 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
8660 return -EINVAL;
8661 }
8662
8663 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8664 if (!pAdapter) {
8665 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
8666 return -EINVAL;
8667 }
8668
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308669 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008670 {
8671 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8672 "Invalid arguments");
8673 return -EINVAL;
8674 }
Hoonki Lee27511902013-03-14 18:19:06 -07008675
8676 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
8677 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
8678 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308679 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -07008680 "%s: TDLS mode is disabled OR not enabled in FW."
8681 MAC_ADDRESS_STR " Request declined.",
8682 __func__, MAC_ADDR_ARRAY(mac));
8683 return -ENOTSUPP;
8684 }
8685
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008686 if (pHddCtx->isLogpInProgress)
8687 {
8688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8689 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05308690 wlan_hdd_tdls_set_link_status(pAdapter,
8691 mac,
8692 eTDLS_LINK_IDLE,
8693 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008694 return -EBUSY;
8695 }
8696
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308697 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05308698 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008699
8700 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308701 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008702 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
8703 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308704 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008705 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008706 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308707 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008708
8709 /* in add station, we accept existing valid staId if there is */
8710 if ((0 == update) &&
8711 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
8712 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008713 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308714 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008715 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008716 " link_status %d. staId %d. add station ignored.",
8717 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
8718 return 0;
8719 }
8720 /* in change station, we accept only when staId is valid */
8721 if ((1 == update) &&
8722 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
8723 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
8724 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308725 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008726 "%s: " MAC_ADDRESS_STR
8727 " link status %d. staId %d. change station %s.",
8728 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
8729 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
8730 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008731 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008732
8733 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05308734 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008735 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008736 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8737 "%s: " MAC_ADDRESS_STR
8738 " TDLS setup is ongoing. Request declined.",
8739 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07008740 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008741 }
8742
8743 /* first to check if we reached to maximum supported TDLS peer.
8744 TODO: for now, return -EPERM looks working fine,
8745 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308746 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
8747 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008748 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008749 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8750 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308751 " TDLS Max peer already connected. Request declined."
8752 " Num of peers (%d), Max allowed (%d).",
8753 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
8754 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008755 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008756 }
8757 else
8758 {
8759 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308760 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008761 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008762 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008763 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8764 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
8765 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008766 return -EPERM;
8767 }
8768 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008769 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05308770 wlan_hdd_tdls_set_link_status(pAdapter,
8771 mac,
8772 eTDLS_LINK_CONNECTING,
8773 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008774
Jeff Johnsond75fe012013-04-06 10:53:06 -07008775 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308776 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008777 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008779 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008780 if(StaParams->htcap_present)
8781 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008783 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008785 "ht_capa->extended_capabilities: %0x",
8786 StaParams->HTCap.extendedHtCapInfo);
8787 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308788 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008789 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008791 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008792 if(StaParams->vhtcap_present)
8793 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008795 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
8796 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
8797 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
8798 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008799 {
8800 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008801 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008802 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008804 "[%d]: %x ", i, StaParams->supported_rates[i]);
8805 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07008806 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308807 else if ((1 == update) && (NULL == StaParams))
8808 {
8809 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8810 "%s : update is true, but staParams is NULL. Error!", __func__);
8811 return -EPERM;
8812 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008813
8814 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
8815
8816 if (!update)
8817 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308818 /*Before adding sta make sure that device exited from BMPS*/
8819 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8820 {
8821 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8822 "%s: Adding tdls peer sta. Disable BMPS", __func__);
8823 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8824 if (status != VOS_STATUS_SUCCESS) {
8825 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
8826 }
8827 }
8828
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308829 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008830 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308831 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308832 hddLog(VOS_TRACE_LEVEL_ERROR,
8833 FL("Failed to add TDLS peer STA. Enable Bmps"));
8834 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308835 return -EPERM;
8836 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008837 }
8838 else
8839 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308840 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008841 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308842 if (ret != eHAL_STATUS_SUCCESS) {
8843 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
8844 return -EPERM;
8845 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008846 }
8847
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308848 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008849 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
8850
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308851 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008852 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308854 "%s: timeout waiting for tdls add station indication %ld",
8855 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008856 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008857 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308858
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008859 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
8860 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008862 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008863 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008864 }
8865
8866 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008867
8868error:
Atul Mittal115287b2014-07-08 13:26:33 +05308869 wlan_hdd_tdls_set_link_status(pAdapter,
8870 mac,
8871 eTDLS_LINK_IDLE,
8872 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008873 return -EPERM;
8874
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008875}
8876#endif
8877
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308878static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308880#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
8881 const u8 *mac,
8882#else
Jeff Johnson295189b2012-06-20 16:38:30 -07008883 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308884#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008885 struct station_parameters *params)
8886{
8887 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308888 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308889 hdd_context_t *pHddCtx;
8890 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008891 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308892 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008893#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008894 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008895 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308896 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008897#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008898
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308899 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308900
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308901 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308902 if ((NULL == pAdapter))
8903 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308905 "invalid adapter ");
8906 return -EINVAL;
8907 }
8908
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308909 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8910 TRACE_CODE_HDD_CHANGE_STATION,
8911 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05308912 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308913
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308914 ret = wlan_hdd_validate_context(pHddCtx);
8915 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +05308916 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308917 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308918 }
8919
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308920 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8921
8922 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008923 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8925 "invalid HDD station context");
8926 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008928 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
8929
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008930 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
8931 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07008932 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008933 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07008934 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308935 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008936 WLANTL_STA_AUTHENTICATED);
8937
Gopichand Nakkala29149562013-05-10 21:43:41 +05308938 if (status != VOS_STATUS_SUCCESS)
8939 {
8940 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8941 "%s: Not able to change TL state to AUTHENTICATED", __func__);
8942 return -EINVAL;
8943 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008944 }
8945 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07008946 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
8947 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308948#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008949 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
8950 StaParams.capability = params->capability;
8951 StaParams.uapsd_queues = params->uapsd_queues;
8952 StaParams.max_sp = params->max_sp;
8953
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308954 /* Convert (first channel , number of channels) tuple to
8955 * the total list of channels. This goes with the assumption
8956 * that if the first channel is < 14, then the next channels
8957 * are an incremental of 1 else an incremental of 4 till the number
8958 * of channels.
8959 */
8960 if (0 != params->supported_channels_len) {
8961 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
8962 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
8963 {
8964 int wifi_chan_index;
8965 StaParams.supported_channels[j] = params->supported_channels[i];
8966 wifi_chan_index =
8967 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
8968 no_of_channels = params->supported_channels[i+1];
8969 for(k=1; k <= no_of_channels; k++)
8970 {
8971 StaParams.supported_channels[j+1] =
8972 StaParams.supported_channels[j] + wifi_chan_index;
8973 j+=1;
8974 }
8975 }
8976 StaParams.supported_channels_len = j;
8977 }
8978 vos_mem_copy(StaParams.supported_oper_classes,
8979 params->supported_oper_classes,
8980 params->supported_oper_classes_len);
8981 StaParams.supported_oper_classes_len =
8982 params->supported_oper_classes_len;
8983
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008984 if (0 != params->ext_capab_len)
8985 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
8986 sizeof(StaParams.extn_capability));
8987
8988 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008989 {
8990 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008991 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008992 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008993
8994 StaParams.supported_rates_len = params->supported_rates_len;
8995
8996 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
8997 * The supported_rates array , for all the structures propogating till Add Sta
8998 * to the firmware has to be modified , if the supplicant (ieee80211) is
8999 * modified to send more rates.
9000 */
9001
9002 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
9003 */
9004 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
9005 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
9006
9007 if (0 != StaParams.supported_rates_len) {
9008 int i = 0;
9009 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
9010 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009011 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009012 "Supported Rates with Length %d", StaParams.supported_rates_len);
9013 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07009014 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009015 "[%d]: %0x", i, StaParams.supported_rates[i]);
9016 }
9017
9018 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07009019 {
9020 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009021 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07009022 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009023
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009024 if (0 != params->ext_capab_len ) {
9025 /*Define A Macro : TODO Sunil*/
9026 if ((1<<4) & StaParams.extn_capability[3]) {
9027 isBufSta = 1;
9028 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05309029 /* TDLS Channel Switching Support */
9030 if ((1<<6) & StaParams.extn_capability[3]) {
9031 isOffChannelSupported = 1;
9032 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009033 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05309034 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
9035 &StaParams, isBufSta,
9036 isOffChannelSupported);
9037
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309038 if (VOS_STATUS_SUCCESS != status) {
9039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9040 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
9041 return -EINVAL;
9042 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009043 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
9044
9045 if (VOS_STATUS_SUCCESS != status) {
9046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9047 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
9048 return -EINVAL;
9049 }
9050 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07009051#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05309052 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009053 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009054 return status;
9055}
9056
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309057#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
9058static int wlan_hdd_change_station(struct wiphy *wiphy,
9059 struct net_device *dev,
9060 const u8 *mac,
9061 struct station_parameters *params)
9062#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309063static int wlan_hdd_change_station(struct wiphy *wiphy,
9064 struct net_device *dev,
9065 u8 *mac,
9066 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309067#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309068{
9069 int ret;
9070
9071 vos_ssr_protect(__func__);
9072 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
9073 vos_ssr_unprotect(__func__);
9074
9075 return ret;
9076}
9077
Jeff Johnson295189b2012-06-20 16:38:30 -07009078/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309079 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009080 * This function is used to initialize the key information
9081 */
9082#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309083static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009084 struct net_device *ndev,
9085 u8 key_index, bool pairwise,
9086 const u8 *mac_addr,
9087 struct key_params *params
9088 )
9089#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309090static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009091 struct net_device *ndev,
9092 u8 key_index, const u8 *mac_addr,
9093 struct key_params *params
9094 )
9095#endif
9096{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009097 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07009098 tCsrRoamSetKey setKey;
9099 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309100 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009101 v_U32_t roamId= 0xFF;
9102 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009103 hdd_hostapd_state_t *pHostapdState;
9104 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009105 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309106 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009107
9108 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309109
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309110 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9111 TRACE_CODE_HDD_CFG80211_ADD_KEY,
9112 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309113 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9114 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309115 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009116 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309117 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009118 }
9119
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309120 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9121 __func__, hdd_device_modetoString(pAdapter->device_mode),
9122 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009123
9124 if (CSR_MAX_NUM_KEY <= key_index)
9125 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009126 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009127 key_index);
9128
9129 return -EINVAL;
9130 }
9131
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009132 if (CSR_MAX_KEY_LEN < params->key_len)
9133 {
9134 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
9135 params->key_len);
9136
9137 return -EINVAL;
9138 }
9139
9140 hddLog(VOS_TRACE_LEVEL_INFO,
9141 "%s: called with key index = %d & key length %d",
9142 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07009143
9144 /*extract key idx, key len and key*/
9145 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9146 setKey.keyId = key_index;
9147 setKey.keyLength = params->key_len;
9148 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
9149
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009150 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07009151 {
9152 case WLAN_CIPHER_SUITE_WEP40:
9153 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
9154 break;
9155
9156 case WLAN_CIPHER_SUITE_WEP104:
9157 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
9158 break;
9159
9160 case WLAN_CIPHER_SUITE_TKIP:
9161 {
9162 u8 *pKey = &setKey.Key[0];
9163 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
9164
9165 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
9166
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009167 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07009168
9169 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009170 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07009171 |--------------|----------|----------|
9172 <---16bytes---><--8bytes--><--8bytes-->
9173
9174 */
9175 /*Sme expects the 32 bytes key to be in the below order
9176
9177 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009178 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07009179 |--------------|----------|----------|
9180 <---16bytes---><--8bytes--><--8bytes-->
9181 */
9182 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009183 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07009184
9185 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009186 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009187
9188 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009189 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009190
9191
9192 break;
9193 }
9194
9195 case WLAN_CIPHER_SUITE_CCMP:
9196 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
9197 break;
9198
9199#ifdef FEATURE_WLAN_WAPI
9200 case WLAN_CIPHER_SUITE_SMS4:
9201 {
9202 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9203 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
9204 params->key, params->key_len);
9205 return 0;
9206 }
9207#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009208
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009209#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009210 case WLAN_CIPHER_SUITE_KRK:
9211 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
9212 break;
9213#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009214
9215#ifdef WLAN_FEATURE_11W
9216 case WLAN_CIPHER_SUITE_AES_CMAC:
9217 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07009218 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07009219#endif
9220
Jeff Johnson295189b2012-06-20 16:38:30 -07009221 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009222 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07009223 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309224 status = -EOPNOTSUPP;
9225 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009226 }
9227
9228 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
9229 __func__, setKey.encType);
9230
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009231 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07009232#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9233 (!pairwise)
9234#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009235 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07009236#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009237 )
9238 {
9239 /* set group key*/
9240 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9241 "%s- %d: setting Broadcast key",
9242 __func__, __LINE__);
9243 setKey.keyDirection = eSIR_RX_ONLY;
9244 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9245 }
9246 else
9247 {
9248 /* set pairwise key*/
9249 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9250 "%s- %d: setting pairwise key",
9251 __func__, __LINE__);
9252 setKey.keyDirection = eSIR_TX_RX;
9253 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9254 }
9255 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
9256 {
9257 setKey.keyDirection = eSIR_TX_RX;
9258 /*Set the group key*/
9259 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9260 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009261
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009262 if ( 0 != status )
9263 {
9264 hddLog(VOS_TRACE_LEVEL_ERROR,
9265 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309266 status = -EINVAL;
9267 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009268 }
9269 /*Save the keys here and call sme_RoamSetKey for setting
9270 the PTK after peer joins the IBSS network*/
9271 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
9272 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309273 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009274 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05309275 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
9276 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
9277 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009278 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009279 if( pHostapdState->bssState == BSS_START )
9280 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009281 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9282 vos_status = wlan_hdd_check_ula_done(pAdapter);
9283
9284 if ( vos_status != VOS_STATUS_SUCCESS )
9285 {
9286 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9287 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9288 __LINE__, vos_status );
9289
9290 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9291
9292 status = -EINVAL;
9293 goto end;
9294 }
9295
Jeff Johnson295189b2012-06-20 16:38:30 -07009296 status = WLANSAP_SetKeySta( pVosContext, &setKey);
9297
9298 if ( status != eHAL_STATUS_SUCCESS )
9299 {
9300 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9301 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9302 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309303 status = -EINVAL;
9304 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009305 }
9306 }
9307
9308 /* Saving WEP keys */
9309 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
9310 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
9311 {
9312 //Save the wep key in ap context. Issue setkey after the BSS is started.
9313 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9314 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
9315 }
9316 else
9317 {
9318 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009319 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009320 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
9321 }
9322 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009323 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9324 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009325 {
9326 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9327 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9328
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309329#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9330 if (!pairwise)
9331#else
9332 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9333#endif
9334 {
9335 /* set group key*/
9336 if (pHddStaCtx->roam_info.deferKeyComplete)
9337 {
9338 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9339 "%s- %d: Perform Set key Complete",
9340 __func__, __LINE__);
9341 hdd_PerformRoamSetKeyComplete(pAdapter);
9342 }
9343 }
9344
Jeff Johnson295189b2012-06-20 16:38:30 -07009345 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
9346
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08009347 pWextState->roamProfile.Keys.defaultIndex = key_index;
9348
9349
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009350 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009351 params->key, params->key_len);
9352
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309353
Jeff Johnson295189b2012-06-20 16:38:30 -07009354 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9355
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309356 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009357 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309358 __func__, setKey.peerMac[0], setKey.peerMac[1],
9359 setKey.peerMac[2], setKey.peerMac[3],
9360 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009361 setKey.keyDirection);
9362
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009363 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +05309364
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009365 if ( vos_status != VOS_STATUS_SUCCESS )
9366 {
9367 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009368 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9369 __LINE__, vos_status );
9370
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009371 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009372
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009373 status = -EINVAL;
9374 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009375
9376 }
9377
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009378#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309379 /* The supplicant may attempt to set the PTK once pre-authentication
9380 is done. Save the key in the UMAC and include it in the ADD BSS
9381 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009382 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309383 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009384 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309385 hddLog(VOS_TRACE_LEVEL_INFO_MED,
9386 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309387 status = 0;
9388 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309389 }
9390 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
9391 {
9392 hddLog(VOS_TRACE_LEVEL_ERROR,
9393 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309394 status = -EINVAL;
9395 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009396 }
9397#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07009398
9399 /* issue set key request to SME*/
9400 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9401 pAdapter->sessionId, &setKey, &roamId );
9402
9403 if ( 0 != status )
9404 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309405 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009406 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
9407 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309408 status = -EINVAL;
9409 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009410 }
9411
9412
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309413 /* in case of IBSS as there was no information available about WEP keys during
9414 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07009415 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309416 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
9417 !( ( IW_AUTH_KEY_MGMT_802_1X
9418 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07009419 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
9420 )
9421 &&
9422 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
9423 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
9424 )
9425 )
9426 {
9427 setKey.keyDirection = eSIR_RX_ONLY;
9428 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9429
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309430 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009431 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309432 __func__, setKey.peerMac[0], setKey.peerMac[1],
9433 setKey.peerMac[2], setKey.peerMac[3],
9434 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009435 setKey.keyDirection);
9436
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309437 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009438 pAdapter->sessionId, &setKey, &roamId );
9439
9440 if ( 0 != status )
9441 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309442 hddLog(VOS_TRACE_LEVEL_ERROR,
9443 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009444 __func__, status);
9445 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309446 status = -EINVAL;
9447 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009448 }
9449 }
9450 }
9451
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309452end:
9453 /* Need to clear any trace of key value in the memory.
9454 * Thus zero out the memory even though it is local
9455 * variable.
9456 */
9457 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309458 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309459 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009460}
9461
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309462#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9463static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9464 struct net_device *ndev,
9465 u8 key_index, bool pairwise,
9466 const u8 *mac_addr,
9467 struct key_params *params
9468 )
9469#else
9470static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9471 struct net_device *ndev,
9472 u8 key_index, const u8 *mac_addr,
9473 struct key_params *params
9474 )
9475#endif
9476{
9477 int ret;
9478 vos_ssr_protect(__func__);
9479#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9480 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
9481 mac_addr, params);
9482#else
9483 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
9484 params);
9485#endif
9486 vos_ssr_unprotect(__func__);
9487
9488 return ret;
9489}
9490
Jeff Johnson295189b2012-06-20 16:38:30 -07009491/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309492 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009493 * This function is used to get the key information
9494 */
9495#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309496static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309497 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009498 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309499 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009500 const u8 *mac_addr, void *cookie,
9501 void (*callback)(void *cookie, struct key_params*)
9502 )
9503#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309504static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309505 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009506 struct net_device *ndev,
9507 u8 key_index, const u8 *mac_addr, void *cookie,
9508 void (*callback)(void *cookie, struct key_params*)
9509 )
9510#endif
9511{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309512 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309513 hdd_wext_state_t *pWextState = NULL;
9514 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009515 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309516 hdd_context_t *pHddCtx;
9517 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009518
9519 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309520
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309521 if (NULL == pAdapter)
9522 {
9523 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9524 "%s: HDD adapter is Null", __func__);
9525 return -ENODEV;
9526 }
9527
9528 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9529 ret = wlan_hdd_validate_context(pHddCtx);
9530 if (0 != ret)
9531 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309532 return ret;
9533 }
9534
9535 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9536 pRoamProfile = &(pWextState->roamProfile);
9537
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309538 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9539 __func__, hdd_device_modetoString(pAdapter->device_mode),
9540 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309541
Jeff Johnson295189b2012-06-20 16:38:30 -07009542 memset(&params, 0, sizeof(params));
9543
9544 if (CSR_MAX_NUM_KEY <= key_index)
9545 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309546 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07009547 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009549
9550 switch(pRoamProfile->EncryptionType.encryptionType[0])
9551 {
9552 case eCSR_ENCRYPT_TYPE_NONE:
9553 params.cipher = IW_AUTH_CIPHER_NONE;
9554 break;
9555
9556 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
9557 case eCSR_ENCRYPT_TYPE_WEP40:
9558 params.cipher = WLAN_CIPHER_SUITE_WEP40;
9559 break;
9560
9561 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
9562 case eCSR_ENCRYPT_TYPE_WEP104:
9563 params.cipher = WLAN_CIPHER_SUITE_WEP104;
9564 break;
9565
9566 case eCSR_ENCRYPT_TYPE_TKIP:
9567 params.cipher = WLAN_CIPHER_SUITE_TKIP;
9568 break;
9569
9570 case eCSR_ENCRYPT_TYPE_AES:
9571 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
9572 break;
9573
9574 default:
9575 params.cipher = IW_AUTH_CIPHER_NONE;
9576 break;
9577 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309578
c_hpothuaaf19692014-05-17 17:01:48 +05309579 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9580 TRACE_CODE_HDD_CFG80211_GET_KEY,
9581 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309582
Jeff Johnson295189b2012-06-20 16:38:30 -07009583 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
9584 params.seq_len = 0;
9585 params.seq = NULL;
9586 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
9587 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309588 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009589 return 0;
9590}
9591
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309592#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9593static int wlan_hdd_cfg80211_get_key(
9594 struct wiphy *wiphy,
9595 struct net_device *ndev,
9596 u8 key_index, bool pairwise,
9597 const u8 *mac_addr, void *cookie,
9598 void (*callback)(void *cookie, struct key_params*)
9599 )
9600#else
9601static int wlan_hdd_cfg80211_get_key(
9602 struct wiphy *wiphy,
9603 struct net_device *ndev,
9604 u8 key_index, const u8 *mac_addr, void *cookie,
9605 void (*callback)(void *cookie, struct key_params*)
9606 )
9607#endif
9608{
9609 int ret;
9610
9611 vos_ssr_protect(__func__);
9612#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9613 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
9614 mac_addr, cookie, callback);
9615#else
9616 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
9617 callback);
9618#endif
9619 vos_ssr_unprotect(__func__);
9620
9621 return ret;
9622}
9623
Jeff Johnson295189b2012-06-20 16:38:30 -07009624/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309625 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009626 * This function is used to delete the key information
9627 */
9628#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309629static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009630 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309631 u8 key_index,
9632 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009633 const u8 *mac_addr
9634 )
9635#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309636static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009637 struct net_device *ndev,
9638 u8 key_index,
9639 const u8 *mac_addr
9640 )
9641#endif
9642{
9643 int status = 0;
9644
9645 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309646 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009647 //it is observed that this is invalidating peer
9648 //key index whenever re-key is done. This is affecting data link.
9649 //It should be ok to ignore del_key.
9650#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309651 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
9652 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009653 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
9654 tCsrRoamSetKey setKey;
9655 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309656
Jeff Johnson295189b2012-06-20 16:38:30 -07009657 ENTER();
9658
9659 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
9660 __func__,pAdapter->device_mode);
9661
9662 if (CSR_MAX_NUM_KEY <= key_index)
9663 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309664 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009665 key_index);
9666
9667 return -EINVAL;
9668 }
9669
9670 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9671 setKey.keyId = key_index;
9672
9673 if (mac_addr)
9674 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9675 else
9676 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
9677
9678 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
9679
9680 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009681 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309682 )
9683 {
9684
9685 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07009686 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9687 if( pHostapdState->bssState == BSS_START)
9688 {
9689 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309690
Jeff Johnson295189b2012-06-20 16:38:30 -07009691 if ( status != eHAL_STATUS_SUCCESS )
9692 {
9693 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9694 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9695 __LINE__, status );
9696 }
9697 }
9698 }
9699 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309700 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07009701 )
9702 {
9703 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9704
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309705 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9706
9707 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009708 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309709 __func__, setKey.peerMac[0], setKey.peerMac[1],
9710 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07009711 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309712 if(pAdapter->sessionCtx.station.conn_info.connState ==
9713 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07009714 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309715 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009716 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309717
Jeff Johnson295189b2012-06-20 16:38:30 -07009718 if ( 0 != status )
9719 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309720 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009721 "%s: sme_RoamSetKey failure, returned %d",
9722 __func__, status);
9723 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9724 return -EINVAL;
9725 }
9726 }
9727 }
9728#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07009729 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009730 return status;
9731}
9732
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309733#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9734static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9735 struct net_device *ndev,
9736 u8 key_index,
9737 bool pairwise,
9738 const u8 *mac_addr
9739 )
9740#else
9741static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9742 struct net_device *ndev,
9743 u8 key_index,
9744 const u8 *mac_addr
9745 )
9746#endif
9747{
9748 int ret;
9749
9750 vos_ssr_protect(__func__);
9751#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9752 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
9753 mac_addr);
9754#else
9755 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
9756#endif
9757 vos_ssr_unprotect(__func__);
9758
9759 return ret;
9760}
9761
Jeff Johnson295189b2012-06-20 16:38:30 -07009762/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309763 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009764 * This function is used to set the default tx key index
9765 */
9766#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309767static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009768 struct net_device *ndev,
9769 u8 key_index,
9770 bool unicast, bool multicast)
9771#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309772static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009773 struct net_device *ndev,
9774 u8 key_index)
9775#endif
9776{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309777 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309778 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05309779 hdd_wext_state_t *pWextState;
9780 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309781 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009782
9783 ENTER();
9784
Gopichand Nakkala29149562013-05-10 21:43:41 +05309785 if ((NULL == pAdapter))
9786 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05309788 "invalid adapter");
9789 return -EINVAL;
9790 }
9791
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309792 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9793 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
9794 pAdapter->sessionId, key_index));
9795
Gopichand Nakkala29149562013-05-10 21:43:41 +05309796 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9797 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9798
9799 if ((NULL == pWextState) || (NULL == pHddStaCtx))
9800 {
9801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9802 "invalid Wext state or HDD context");
9803 return -EINVAL;
9804 }
9805
Arif Hussain6d2a3322013-11-17 19:50:10 -08009806 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009807 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309808
Jeff Johnson295189b2012-06-20 16:38:30 -07009809 if (CSR_MAX_NUM_KEY <= key_index)
9810 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309811 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009812 key_index);
9813
9814 return -EINVAL;
9815 }
9816
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309817 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9818 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309819 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009820 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309821 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009822 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309823
Jeff Johnson295189b2012-06-20 16:38:30 -07009824 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07009825 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309826 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009827 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05309828 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08009829 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309830 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08009831 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009832 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309833 {
9834 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07009835 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309836
Jeff Johnson295189b2012-06-20 16:38:30 -07009837 tCsrRoamSetKey setKey;
9838 v_U32_t roamId= 0xFF;
9839 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309840
9841 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009842 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309843
Jeff Johnson295189b2012-06-20 16:38:30 -07009844 Keys->defaultIndex = (u8)key_index;
9845 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9846 setKey.keyId = key_index;
9847 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309848
9849 vos_mem_copy(&setKey.Key[0],
9850 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009851 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309852
Gopichand Nakkala29149562013-05-10 21:43:41 +05309853 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309854
9855 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07009856 &pHddStaCtx->conn_info.bssId[0],
9857 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309858
Gopichand Nakkala29149562013-05-10 21:43:41 +05309859 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
9860 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
9861 eCSR_ENCRYPT_TYPE_WEP104)
9862 {
9863 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
9864 even though ap is configured for WEP-40 encryption. In this canse the key length
9865 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
9866 type(104) and switching encryption type to 40*/
9867 pWextState->roamProfile.EncryptionType.encryptionType[0] =
9868 eCSR_ENCRYPT_TYPE_WEP40;
9869 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
9870 eCSR_ENCRYPT_TYPE_WEP40;
9871 }
9872
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309873 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07009874 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309875
Jeff Johnson295189b2012-06-20 16:38:30 -07009876 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309877 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009878 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309879
Jeff Johnson295189b2012-06-20 16:38:30 -07009880 if ( 0 != status )
9881 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309882 hddLog(VOS_TRACE_LEVEL_ERROR,
9883 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009884 status);
9885 return -EINVAL;
9886 }
9887 }
9888 }
9889
9890 /* In SoftAp mode setting key direction for default mode */
9891 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
9892 {
9893 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
9894 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
9895 (eCSR_ENCRYPT_TYPE_AES !=
9896 pWextState->roamProfile.EncryptionType.encryptionType[0])
9897 )
9898 {
9899 /* Saving key direction for default key index to TX default */
9900 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9901 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
9902 }
9903 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309904 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009905 return status;
9906}
9907
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309908#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9909static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9910 struct net_device *ndev,
9911 u8 key_index,
9912 bool unicast, bool multicast)
9913#else
9914static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9915 struct net_device *ndev,
9916 u8 key_index)
9917#endif
9918{
9919 int ret;
9920 vos_ssr_protect(__func__);
9921#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9922 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
9923 multicast);
9924#else
9925 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
9926#endif
9927 vos_ssr_unprotect(__func__);
9928
9929 return ret;
9930}
9931
Jeff Johnson295189b2012-06-20 16:38:30 -07009932/*
9933 * FUNCTION: wlan_hdd_cfg80211_inform_bss
9934 * This function is used to inform the BSS details to nl80211 interface.
9935 */
9936static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
9937 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
9938{
9939 struct net_device *dev = pAdapter->dev;
9940 struct wireless_dev *wdev = dev->ieee80211_ptr;
9941 struct wiphy *wiphy = wdev->wiphy;
9942 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
9943 int chan_no;
9944 int ie_length;
9945 const char *ie;
9946 unsigned int freq;
9947 struct ieee80211_channel *chan;
9948 int rssi = 0;
9949 struct cfg80211_bss *bss = NULL;
9950
Jeff Johnson295189b2012-06-20 16:38:30 -07009951 if( NULL == pBssDesc )
9952 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009953 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009954 return bss;
9955 }
9956
9957 chan_no = pBssDesc->channelId;
9958 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
9959 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
9960
9961 if( NULL == ie )
9962 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009963 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009964 return bss;
9965 }
9966
9967#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
9968 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
9969 {
9970 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9971 }
9972 else
9973 {
9974 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9975 }
9976#else
9977 freq = ieee80211_channel_to_frequency(chan_no);
9978#endif
9979
9980 chan = __ieee80211_get_channel(wiphy, freq);
9981
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05309982 if (!chan) {
9983 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
9984 return NULL;
9985 }
9986
Abhishek Singhaee43942014-06-16 18:55:47 +05309987 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07009988
Anand N Sunkad9f80b742015-07-30 20:05:51 +05309989 return cfg80211_inform_bss(wiphy, chan,
9990#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
9991 CFG80211_BSS_FTYPE_UNKNOWN,
9992#endif
9993 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309994 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07009995 pBssDesc->capabilityInfo,
9996 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05309997 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07009998}
9999
10000
10001
10002/*
10003 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
10004 * This function is used to inform the BSS details to nl80211 interface.
10005 */
10006struct cfg80211_bss*
10007wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
10008 tSirBssDescription *bss_desc
10009 )
10010{
10011 /*
10012 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
10013 already exists in bss data base of cfg80211 for that particular BSS ID.
10014 Using cfg80211_inform_bss_frame to update the bss entry instead of
10015 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
10016 now there is no possibility to get the mgmt(probe response) frame from PE,
10017 converting bss_desc to ieee80211_mgmt(probe response) and passing to
10018 cfg80211_inform_bss_frame.
10019 */
10020 struct net_device *dev = pAdapter->dev;
10021 struct wireless_dev *wdev = dev->ieee80211_ptr;
10022 struct wiphy *wiphy = wdev->wiphy;
10023 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080010024#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
10025 qcom_ie_age *qie_age = NULL;
10026 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
10027#else
Jeff Johnson295189b2012-06-20 16:38:30 -070010028 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080010029#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010030 const char *ie =
10031 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
10032 unsigned int freq;
10033 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053010034 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010035 struct cfg80211_bss *bss_status = NULL;
10036 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
10037 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070010038 hdd_context_t *pHddCtx;
10039 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070010040#ifdef WLAN_OPEN_SOURCE
10041 struct timespec ts;
10042#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010043
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010044
Wilson Yangf80a0542013-10-07 13:02:37 -070010045 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10046 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070010047 if (0 != status)
10048 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070010049 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070010050 }
10051
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053010052 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070010053 if (!mgmt)
10054 {
10055 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10056 "%s: memory allocation failed ", __func__);
10057 return NULL;
10058 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070010059
Jeff Johnson295189b2012-06-20 16:38:30 -070010060 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070010061
10062#ifdef WLAN_OPEN_SOURCE
10063 /* Android does not want the timestamp from the frame.
10064 Instead it wants a monotonic increasing value */
10065 get_monotonic_boottime(&ts);
10066 mgmt->u.probe_resp.timestamp =
10067 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
10068#else
10069 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070010070 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
10071 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070010072
10073#endif
10074
Jeff Johnson295189b2012-06-20 16:38:30 -070010075 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
10076 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080010077
10078#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
10079 /* GPS Requirement: need age ie per entry. Using vendor specific. */
10080 /* Assuming this is the last IE, copy at the end */
10081 ie_length -=sizeof(qcom_ie_age);
10082 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
10083 qie_age->element_id = QCOM_VENDOR_IE_ID;
10084 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
10085 qie_age->oui_1 = QCOM_OUI1;
10086 qie_age->oui_2 = QCOM_OUI2;
10087 qie_age->oui_3 = QCOM_OUI3;
10088 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
10089 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
10090#endif
10091
Jeff Johnson295189b2012-06-20 16:38:30 -070010092 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053010093 if (bss_desc->fProbeRsp)
10094 {
10095 mgmt->frame_control |=
10096 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
10097 }
10098 else
10099 {
10100 mgmt->frame_control |=
10101 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
10102 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010103
10104#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010105 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070010106 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
10107 {
10108 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
10109 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010110 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070010111 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
10112
10113 {
10114 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
10115 }
10116 else
10117 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010118 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
10119 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070010120 kfree(mgmt);
10121 return NULL;
10122 }
10123#else
10124 freq = ieee80211_channel_to_frequency(chan_no);
10125#endif
10126 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080010127 /*when the band is changed on the fly using the GUI, three things are done
10128 * 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)
10129 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
10130 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
10131 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
10132 * and discards the channels correponding to previous band and calls back with zero bss results.
10133 * 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
10134 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
10135 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
10136 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
10137 * So drop the bss and continue to next bss.
10138 */
10139 if(chan == NULL)
10140 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010141 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -070010142 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080010143 return NULL;
10144 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053010145 /*To keep the rssi icon of the connected AP in the scan window
10146 *and the rssi icon of the wireless networks in sync
10147 * */
10148 if (( eConnectionState_Associated ==
10149 pAdapter->sessionCtx.station.conn_info.connState ) &&
10150 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
10151 pAdapter->sessionCtx.station.conn_info.bssId,
10152 WNI_CFG_BSSID_LEN)) &&
10153 (pHddCtx->hdd_wlan_suspended == FALSE))
10154 {
10155 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
10156 rssi = (pAdapter->rssi * 100);
10157 }
10158 else
10159 {
10160 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
10161 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010162
Nirav Shah20ac06f2013-12-12 18:14:06 +053010163 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053010164 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
10165 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053010166
Jeff Johnson295189b2012-06-20 16:38:30 -070010167 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
10168 frame_len, rssi, GFP_KERNEL);
10169 kfree(mgmt);
10170 return bss_status;
10171}
10172
10173/*
10174 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
10175 * This function is used to update the BSS data base of CFG8011
10176 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010177struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070010178 tCsrRoamInfo *pRoamInfo
10179 )
10180{
10181 tCsrRoamConnectedProfile roamProfile;
10182 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10183 struct cfg80211_bss *bss = NULL;
10184
10185 ENTER();
10186
10187 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
10188 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
10189
10190 if (NULL != roamProfile.pBssDesc)
10191 {
Girish Gowlif4b68022014-08-28 23:18:57 +053010192 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10193 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010194
10195 if (NULL == bss)
10196 {
10197 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
10198 __func__);
10199 }
10200
10201 sme_RoamFreeConnectProfile(hHal, &roamProfile);
10202 }
10203 else
10204 {
10205 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
10206 __func__);
10207 }
10208 return bss;
10209}
10210
10211/*
10212 * FUNCTION: wlan_hdd_cfg80211_update_bss
10213 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010214static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
10215 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070010216 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010217{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010218 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010219 tCsrScanResultInfo *pScanResult;
10220 eHalStatus status = 0;
10221 tScanResultHandle pResult;
10222 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070010223 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010224 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070010225 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010226
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010227 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10228 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
10229 NO_SESSION, pAdapter->sessionId));
10230
Wilson Yangf80a0542013-10-07 13:02:37 -070010231 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10232
10233 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -070010234 {
Wilson Yangf80a0542013-10-07 13:02:37 -070010235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10236 "%s:LOGP in Progress. Ignore!!!",__func__);
10237 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010238 }
10239
Wilson Yangf80a0542013-10-07 13:02:37 -070010240
10241 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +053010242 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -070010243 {
10244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10245 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
10246 return VOS_STATUS_E_PERM;
10247 }
10248
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010249 if (pAdapter->request != NULL)
10250 {
10251 if ((pAdapter->request->n_ssids == 1)
10252 && (pAdapter->request->ssids != NULL)
10253 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
10254 is_p2p_scan = true;
10255 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010256 /*
10257 * start getting scan results and populate cgf80211 BSS database
10258 */
10259 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
10260
10261 /* no scan results */
10262 if (NULL == pResult)
10263 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010264 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
10265 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053010266 wlan_hdd_get_frame_logs(pAdapter,
10267 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070010268 return status;
10269 }
10270
10271 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
10272
10273 while (pScanResult)
10274 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010275 /*
10276 * cfg80211_inform_bss() is not updating ie field of bss entry, if
10277 * entry already exists in bss data base of cfg80211 for that
10278 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
10279 * bss entry instead of cfg80211_inform_bss, But this call expects
10280 * mgmt packet as input. As of now there is no possibility to get
10281 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070010282 * ieee80211_mgmt(probe response) and passing to c
10283 * fg80211_inform_bss_frame.
10284 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010285 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
10286 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
10287 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010288 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10289 continue; //Skip the non p2p bss entries
10290 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010291 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10292 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010293
Jeff Johnson295189b2012-06-20 16:38:30 -070010294
10295 if (NULL == bss_status)
10296 {
10297 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010298 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010299 }
10300 else
10301 {
Yue Maf49ba872013-08-19 12:04:25 -070010302 cfg80211_put_bss(
10303#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10304 wiphy,
10305#endif
10306 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010307 }
10308
10309 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10310 }
10311
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010312 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010313 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010314 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010315}
10316
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010317void
10318hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
10319{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010320 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080010321 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010322} /****** end hddPrintMacAddr() ******/
10323
10324void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010325hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010326{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010327 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010328 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010329 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
10330 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
10331 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010332} /****** end hddPrintPmkId() ******/
10333
10334//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
10335//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
10336
10337//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
10338//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
10339
10340#define dump_bssid(bssid) \
10341 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010342 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
10343 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010344 }
10345
10346#define dump_pmkid(pMac, pmkid) \
10347 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010348 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
10349 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010350 }
10351
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070010352#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010353/*
10354 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
10355 * This function is used to notify the supplicant of a new PMKSA candidate.
10356 */
10357int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010358 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010359 int index, bool preauth )
10360{
Jeff Johnsone7245742012-09-05 17:12:55 -070010361#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010362 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010363 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010364
10365 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070010366 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010367
10368 if( NULL == pRoamInfo )
10369 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010370 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010371 return -EINVAL;
10372 }
10373
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010374 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
10375 {
10376 dump_bssid(pRoamInfo->bssid);
10377 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010378 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010379 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010380#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010381 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010382}
10383#endif //FEATURE_WLAN_LFR
10384
Yue Maef608272013-04-08 23:09:17 -070010385#ifdef FEATURE_WLAN_LFR_METRICS
10386/*
10387 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
10388 * 802.11r/LFR metrics reporting function to report preauth initiation
10389 *
10390 */
10391#define MAX_LFR_METRICS_EVENT_LENGTH 100
10392VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
10393 tCsrRoamInfo *pRoamInfo)
10394{
10395 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10396 union iwreq_data wrqu;
10397
10398 ENTER();
10399
10400 if (NULL == pAdapter)
10401 {
10402 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10403 return VOS_STATUS_E_FAILURE;
10404 }
10405
10406 /* create the event */
10407 memset(&wrqu, 0, sizeof(wrqu));
10408 memset(metrics_notification, 0, sizeof(metrics_notification));
10409
10410 wrqu.data.pointer = metrics_notification;
10411 wrqu.data.length = scnprintf(metrics_notification,
10412 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
10413 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10414
10415 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10416
10417 EXIT();
10418
10419 return VOS_STATUS_SUCCESS;
10420}
10421
10422/*
10423 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
10424 * 802.11r/LFR metrics reporting function to report preauth completion
10425 * or failure
10426 */
10427VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
10428 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
10429{
10430 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10431 union iwreq_data wrqu;
10432
10433 ENTER();
10434
10435 if (NULL == pAdapter)
10436 {
10437 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10438 return VOS_STATUS_E_FAILURE;
10439 }
10440
10441 /* create the event */
10442 memset(&wrqu, 0, sizeof(wrqu));
10443 memset(metrics_notification, 0, sizeof(metrics_notification));
10444
10445 scnprintf(metrics_notification, sizeof(metrics_notification),
10446 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
10447 MAC_ADDR_ARRAY(pRoamInfo->bssid));
10448
10449 if (1 == preauth_status)
10450 strncat(metrics_notification, " TRUE", 5);
10451 else
10452 strncat(metrics_notification, " FALSE", 6);
10453
10454 wrqu.data.pointer = metrics_notification;
10455 wrqu.data.length = strlen(metrics_notification);
10456
10457 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10458
10459 EXIT();
10460
10461 return VOS_STATUS_SUCCESS;
10462}
10463
10464/*
10465 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
10466 * 802.11r/LFR metrics reporting function to report handover initiation
10467 *
10468 */
10469VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
10470 tCsrRoamInfo *pRoamInfo)
10471{
10472 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10473 union iwreq_data wrqu;
10474
10475 ENTER();
10476
10477 if (NULL == pAdapter)
10478 {
10479 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10480 return VOS_STATUS_E_FAILURE;
10481 }
10482
10483 /* create the event */
10484 memset(&wrqu, 0, sizeof(wrqu));
10485 memset(metrics_notification, 0, sizeof(metrics_notification));
10486
10487 wrqu.data.pointer = metrics_notification;
10488 wrqu.data.length = scnprintf(metrics_notification,
10489 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
10490 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10491
10492 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10493
10494 EXIT();
10495
10496 return VOS_STATUS_SUCCESS;
10497}
10498#endif
10499
Jeff Johnson295189b2012-06-20 16:38:30 -070010500/*
10501 * FUNCTION: hdd_cfg80211_scan_done_callback
10502 * scanning callback function, called after finishing scan
10503 *
10504 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010505static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070010506 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
10507{
10508 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010509 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070010510 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010511 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010512 struct cfg80211_scan_request *req = NULL;
10513 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010514 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010515 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010516 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010517 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010518
10519 ENTER();
10520
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010521 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053010522 if (NULL == pHddCtx) {
10523 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010524 goto allow_suspend;
10525 }
10526
10527 pScanInfo = &pHddCtx->scan_info;
10528
Jeff Johnson295189b2012-06-20 16:38:30 -070010529 hddLog(VOS_TRACE_LEVEL_INFO,
10530 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080010531 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010532 __func__, halHandle, pContext, (int) scanId, (int) status);
10533
Kiet Lamac06e2c2013-10-23 16:25:07 +053010534 pScanInfo->mScanPendingCounter = 0;
10535
Jeff Johnson295189b2012-06-20 16:38:30 -070010536 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010537 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070010538 &pScanInfo->scan_req_completion_event,
10539 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010540 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070010541 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010542 hddLog(VOS_TRACE_LEVEL_ERROR,
10543 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070010544 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010545 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010546 }
10547
Yue Maef608272013-04-08 23:09:17 -070010548 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010549 {
10550 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010551 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010552 }
10553
10554 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010555 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070010556 {
10557 hddLog(VOS_TRACE_LEVEL_INFO,
10558 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010559 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070010560 (int) scanId);
10561 }
10562
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010563 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010564 pAdapter);
10565
10566 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010567 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010568
10569
10570 /* If any client wait scan result through WEXT
10571 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010572 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070010573 {
10574 /* The other scan request waiting for current scan finish
10575 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010576 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010577 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010578 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070010579 }
10580 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010581 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010582 {
10583 struct net_device *dev = pAdapter->dev;
10584 union iwreq_data wrqu;
10585 int we_event;
10586 char *msg;
10587
10588 memset(&wrqu, '\0', sizeof(wrqu));
10589 we_event = SIOCGIWSCAN;
10590 msg = NULL;
10591 wireless_send_event(dev, we_event, &wrqu, msg);
10592 }
10593 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010594 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010595
10596 /* Get the Scan Req */
10597 req = pAdapter->request;
10598
10599 if (!req)
10600 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010601 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010602 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010603 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010604 }
10605
Jeff Johnson295189b2012-06-20 16:38:30 -070010606 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070010607 /* Scan is no longer pending */
10608 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010609
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010610 /* last_scan_timestamp is used to decide if new scan
10611 * is needed or not on station interface. If last station
10612 * scan time and new station scan time is less then
10613 * last_scan_timestamp ; driver will return cached scan.
10614 */
10615 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
10616 {
10617 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
10618
10619 if ( req->n_channels )
10620 {
10621 for (i = 0; i < req->n_channels ; i++ )
10622 {
10623 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
10624 }
10625 /* store no of channel scanned */
10626 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
10627 }
10628
10629 }
10630
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070010631 /*
10632 * cfg80211_scan_done informing NL80211 about completion
10633 * of scanning
10634 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010635 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
10636 {
10637 aborted = true;
10638 }
10639 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080010640 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070010641
Siddharth Bhal76972212014-10-15 16:22:51 +053010642 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
10643 /* Generate new random mac addr for next scan */
10644 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
10645 hdd_processSpoofMacAddrRequest(pHddCtx);
10646 }
10647
Jeff Johnsone7245742012-09-05 17:12:55 -070010648allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010649 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010650 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070010651
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010652 /* Acquire wakelock to handle the case where APP's tries to suspend
10653 * immediatly after the driver gets connect request(i.e after scan)
10654 * from supplicant, this result in app's is suspending and not able
10655 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010656 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010657
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010658#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010659 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010660#endif
10661
Jeff Johnson295189b2012-06-20 16:38:30 -070010662 EXIT();
10663 return 0;
10664}
10665
10666/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053010667 * FUNCTION: hdd_isConnectionInProgress
10668 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010669 *
10670 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010671v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010672{
10673 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10674 hdd_station_ctx_t *pHddStaCtx = NULL;
10675 hdd_adapter_t *pAdapter = NULL;
10676 VOS_STATUS status = 0;
10677 v_U8_t staId = 0;
10678 v_U8_t *staMac = NULL;
10679
c_hpothu9b781ba2013-12-30 20:57:45 +053010680 if (TRUE == pHddCtx->btCoexModeSet)
10681 {
10682 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053010683 FL("BTCoex Mode operation in progress"));
10684 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053010685 }
10686
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010687 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10688
10689 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10690 {
10691 pAdapter = pAdapterNode->pAdapter;
10692
10693 if( pAdapter )
10694 {
10695 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010696 "%s: Adapter with device mode %s (%d) exists",
10697 __func__, hdd_device_modetoString(pAdapter->device_mode),
10698 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010699 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053010700 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10701 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
10702 (eConnectionState_Connecting ==
10703 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
10704 {
10705 hddLog(VOS_TRACE_LEVEL_ERROR,
10706 "%s: %p(%d) Connection is in progress", __func__,
10707 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10708 return VOS_TRUE;
10709 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010710 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053010711 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010712 {
10713 hddLog(VOS_TRACE_LEVEL_ERROR,
10714 "%s: %p(%d) Reassociation is in progress", __func__,
10715 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10716 return VOS_TRUE;
10717 }
10718 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010719 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10720 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010721 {
10722 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10723 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010724 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010725 {
10726 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
10727 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010728 "%s: client " MAC_ADDRESS_STR
10729 " is in the middle of WPS/EAPOL exchange.", __func__,
10730 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010731 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010732 }
10733 }
10734 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
10735 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
10736 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010737 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10738 ptSapContext pSapCtx = NULL;
10739 pSapCtx = VOS_GET_SAP_CB(pVosContext);
10740 if(pSapCtx == NULL){
10741 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10742 FL("psapCtx is NULL"));
10743 return VOS_FALSE;
10744 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010745 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
10746 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010747 if ((pSapCtx->aStaInfo[staId].isUsed) &&
10748 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010749 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010750 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010751
10752 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010753 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
10754 "middle of WPS/EAPOL exchange.", __func__,
10755 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010756 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010757 }
10758 }
10759 }
10760 }
10761 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10762 pAdapterNode = pNext;
10763 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053010764 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010765}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010766
10767/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010768 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070010769 * this scan respond to scan trigger and update cfg80211 scan database
10770 * later, scan dump command can be used to recieve scan results
10771 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010772int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010773#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10774 struct net_device *dev,
10775#endif
10776 struct cfg80211_scan_request *request)
10777{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010778 hdd_adapter_t *pAdapter = NULL;
10779 hdd_context_t *pHddCtx = NULL;
10780 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010781 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010782 tCsrScanRequest scanRequest;
10783 tANI_U8 *channelList = NULL, i;
10784 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010785 int status;
10786 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010787 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010788 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053010789 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010790 bool is_p2p_scan = false;
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010791 v_S7_t rssi=0;
10792 hdd_station_ctx_t *pHddStaCtx=NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010793
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010794#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
10795 struct net_device *dev = NULL;
10796 if (NULL == request)
10797 {
10798 hddLog(VOS_TRACE_LEVEL_ERROR,
10799 "%s: scan req param null", __func__);
10800 return -EINVAL;
10801 }
10802 dev = request->wdev->netdev;
10803#endif
10804
10805 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
10806 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
10807 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10808
Jeff Johnson295189b2012-06-20 16:38:30 -070010809 ENTER();
10810
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010811 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10812 __func__, hdd_device_modetoString(pAdapter->device_mode),
10813 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010814
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010815 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010816 if (0 != status)
10817 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010818 return status;
10819 }
10820
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010821 if (NULL == pwextBuf)
10822 {
10823 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
10824 __func__);
10825 return -EIO;
10826 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010827 cfg_param = pHddCtx->cfg_ini;
10828 pScanInfo = &pHddCtx->scan_info;
10829
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010830 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10831 if ( (pHddStaCtx != NULL) && (TRUE == hdd_connIsConnected(pHddStaCtx)))
10832 {
10833 wlan_hdd_get_roam_rssi(pAdapter, &rssi);
10834 hddLog(VOS_TRACE_LEVEL_INFO, FL("rssi: %d"), rssi);
10835 }
10836
Jeff Johnson295189b2012-06-20 16:38:30 -070010837#ifdef WLAN_BTAMP_FEATURE
10838 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010839 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070010840 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010841 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010842 "%s: No scanning when AMP is on", __func__);
10843 return -EOPNOTSUPP;
10844 }
10845#endif
10846 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010847 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010848 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010849 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010850 "%s: Not scanning on device_mode = %s (%d)",
10851 __func__, hdd_device_modetoString(pAdapter->device_mode),
10852 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010853 return -EOPNOTSUPP;
10854 }
10855
10856 if (TRUE == pScanInfo->mScanPending)
10857 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010858 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
10859 {
10860 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
10861 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010862 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010863 }
10864
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053010865 // Don't allow scan if PNO scan is going on.
10866 if (pHddCtx->isPnoEnable)
10867 {
10868 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10869 FL("pno scan in progress"));
10870 return -EBUSY;
10871 }
10872
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010873 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070010874 //Channel and action frame is pending
10875 //Otherwise Cancel Remain On Channel and allow Scan
10876 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010877 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070010878 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010879 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010880 return -EBUSY;
10881 }
10882
Jeff Johnson295189b2012-06-20 16:38:30 -070010883 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
10884 {
10885 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080010886 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010887 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010888 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010889 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
10890 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010891 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010892 "%s: MAX TM Level Scan not allowed", __func__);
10893 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010894 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010895 }
10896 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
10897
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010898 /* Check if scan is allowed at this point of time.
10899 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010900 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010901 {
10902 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
10903 return -EBUSY;
10904 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010905
Jeff Johnson295189b2012-06-20 16:38:30 -070010906 vos_mem_zero( &scanRequest, sizeof(scanRequest));
10907
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010908 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
10909 * Becasue of this, driver is assuming that this is not wildcard scan and so
10910 * is not aging out the scan results.
10911 */
10912 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070010913 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010914 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010915 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010916
10917 if ((request->ssids) && (0 < request->n_ssids))
10918 {
10919 tCsrSSIDInfo *SsidInfo;
10920 int j;
10921 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
10922 /* Allocate num_ssid tCsrSSIDInfo structure */
10923 SsidInfo = scanRequest.SSIDs.SSIDList =
10924 ( tCsrSSIDInfo *)vos_mem_malloc(
10925 request->n_ssids*sizeof(tCsrSSIDInfo));
10926
10927 if(NULL == scanRequest.SSIDs.SSIDList)
10928 {
10929 hddLog(VOS_TRACE_LEVEL_ERROR,
10930 "%s: memory alloc failed SSIDInfo buffer", __func__);
10931 return -ENOMEM;
10932 }
10933
10934 /* copy all the ssid's and their length */
10935 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
10936 {
10937 /* get the ssid length */
10938 SsidInfo->SSID.length = request->ssids[j].ssid_len;
10939 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
10940 SsidInfo->SSID.length);
10941 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
10942 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
10943 j, SsidInfo->SSID.ssId);
10944 }
10945 /* set the scan type to active */
10946 scanRequest.scanType = eSIR_ACTIVE_SCAN;
10947 }
10948 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070010949 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010950 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10951 TRACE_CODE_HDD_CFG80211_SCAN,
10952 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070010953 /* set the scan type to active */
10954 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010955 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010956 else
10957 {
10958 /*Set the scan type to default type, in this case it is ACTIVE*/
10959 scanRequest.scanType = pScanInfo->scan_mode;
10960 }
10961 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
10962 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070010963
10964 /* set BSSType to default type */
10965 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
10966
10967 /*TODO: scan the requested channels only*/
10968
10969 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010970 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070010971 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010972 hddLog(VOS_TRACE_LEVEL_WARN,
10973 "No of Scan Channels exceeded limit: %d", request->n_channels);
10974 request->n_channels = MAX_CHANNEL;
10975 }
10976
10977 hddLog(VOS_TRACE_LEVEL_INFO,
10978 "No of Scan Channels: %d", request->n_channels);
10979
10980
10981 if( request->n_channels )
10982 {
10983 char chList [(request->n_channels*5)+1];
10984 int len;
10985 channelList = vos_mem_malloc( request->n_channels );
10986 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053010987 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010988 hddLog(VOS_TRACE_LEVEL_ERROR,
10989 "%s: memory alloc failed channelList", __func__);
10990 status = -ENOMEM;
10991 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053010992 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010993
10994 for( i = 0, len = 0; i < request->n_channels ; i++ )
10995 {
10996 channelList[i] = request->channels[i]->hw_value;
10997 len += snprintf(chList+len, 5, "%d ", channelList[i]);
10998 }
10999
Nirav Shah20ac06f2013-12-12 18:14:06 +053011000 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011001 "Channel-List: %s ", chList);
11002 }
c_hpothu53512302014-04-15 18:49:53 +053011003
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011004 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
11005 scanRequest.ChannelInfo.ChannelList = channelList;
11006
11007 /* set requestType to full scan */
11008 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
11009
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011010 /* if there is back to back scan happening in driver with in
11011 * nDeferScanTimeInterval interval driver should defer new scan request
11012 * and should provide last cached scan results instead of new channel list.
11013 * This rule is not applicable if scan is p2p scan.
11014 * This condition will work only in case when last request no of channels
11015 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053011016 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053011017 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011018 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011019
Sushant Kaushik86592172015-04-27 16:35:03 +053011020 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
11021 /* if wps ie is NULL , then only defer scan */
11022 if ( pWpsIe == NULL &&
11023 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053011024 {
11025 if ( pScanInfo->last_scan_timestamp !=0 &&
11026 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
11027 {
11028 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
11029 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
11030 vos_mem_compare(pScanInfo->last_scan_channelList,
11031 channelList, pScanInfo->last_scan_numChannels))
11032 {
11033 hddLog(VOS_TRACE_LEVEL_WARN,
11034 " New and old station scan time differ is less then %u",
11035 pHddCtx->cfg_ini->nDeferScanTimeInterval);
11036
11037 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011038 pAdapter);
11039
Agarwal Ashish57e84372014-12-05 18:26:53 +053011040 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053011041 "Return old cached scan as all channels and no of channels are same");
11042
Agarwal Ashish57e84372014-12-05 18:26:53 +053011043 if (0 > ret)
11044 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011045
Agarwal Ashish57e84372014-12-05 18:26:53 +053011046 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053011047
11048 status = eHAL_STATUS_SUCCESS;
11049 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053011050 }
11051 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011052 }
11053
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011054 /* Flush the scan results(only p2p beacons) for STA scan and P2P
11055 * search (Flush on both full scan and social scan but not on single
11056 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
11057 */
11058
11059 /* Supplicant does single channel scan after 8-way handshake
11060 * and in that case driver shoudnt flush scan results. If
11061 * driver flushes the scan results here and unfortunately if
11062 * the AP doesnt respond to our probe req then association
11063 * fails which is not desired
11064 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053011065 if ((request->n_ssids == 1)
11066 && (request->ssids != NULL)
11067 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
11068 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011069
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053011070 if( is_p2p_scan ||
11071 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011072 {
11073 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
11074 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
11075 pAdapter->sessionId );
11076 }
11077
11078 if( request->ie_len )
11079 {
11080 /* save this for future association (join requires this) */
11081 /*TODO: Array needs to be converted to dynamic allocation,
11082 * as multiple ie.s can be sent in cfg80211_scan_request structure
11083 * CR 597966
11084 */
11085 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
11086 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
11087 pScanInfo->scanAddIE.length = request->ie_len;
11088
11089 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11090 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
11091 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070011092 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011093 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070011094 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011095 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
11096 memcpy( pwextBuf->roamProfile.addIEScan,
11097 request->ie, request->ie_len);
11098 }
11099 else
11100 {
11101 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
11102 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070011103 }
11104
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011105 }
11106 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
11107 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
11108
11109 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
11110 request->ie_len);
11111 if (pP2pIe != NULL)
11112 {
11113#ifdef WLAN_FEATURE_P2P_DEBUG
11114 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
11115 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
11116 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053011117 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011118 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
11119 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
11120 "Go nego completed to Connection is started");
11121 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
11122 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053011123 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011124 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
11125 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070011126 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011127 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
11128 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
11129 "Disconnected state to Connection is started");
11130 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
11131 "for 4way Handshake");
11132 }
11133#endif
11134
11135 /* no_cck will be set during p2p find to disable 11b rates */
11136 if(TRUE == request->no_cck)
11137 {
11138 hddLog(VOS_TRACE_LEVEL_INFO,
11139 "%s: This is a P2P Search", __func__);
11140 scanRequest.p2pSearch = 1;
11141
11142 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053011143 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011144 /* set requestType to P2P Discovery */
11145 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
11146 }
11147
11148 /*
11149 Skip Dfs Channel in case of P2P Search
11150 if it is set in ini file
11151 */
11152 if(cfg_param->skipDfsChnlInP2pSearch)
11153 {
11154 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053011155 }
11156 else
11157 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011158 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053011159 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011160
Agarwal Ashish4f616132013-12-30 23:32:50 +053011161 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011162 }
11163 }
11164
11165 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
11166
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053011167#ifdef FEATURE_WLAN_TDLS
11168 /* if tdls disagree scan right now, return immediately.
11169 tdls will schedule the scan when scan is allowed. (return SUCCESS)
11170 or will reject the scan if any TDLS is in progress. (return -EBUSY)
11171 */
11172 status = wlan_hdd_tdls_scan_callback (pAdapter,
11173 wiphy,
11174#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11175 dev,
11176#endif
11177 request);
11178 if(status <= 0)
11179 {
11180 if(!status)
11181 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
11182 "scan rejected %d", __func__, status);
11183 else
11184 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
11185 __func__, status);
11186
11187 return status;
11188 }
11189#endif
11190
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070011191 /* acquire the wakelock to avoid the apps suspend during the scan. To
11192 * address the following issues.
11193 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
11194 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
11195 * for long time, this result in apps running at full power for long time.
11196 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
11197 * be stuck in full power because of resume BMPS
11198 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011199 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070011200
Nirav Shah20ac06f2013-12-12 18:14:06 +053011201 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
11202 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011203 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
11204 scanRequest.requestType, scanRequest.scanType,
11205 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053011206 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
11207
Siddharth Bhal76972212014-10-15 16:22:51 +053011208 if (pHddCtx->spoofMacAddr.isEnabled)
11209 {
11210 hddLog(VOS_TRACE_LEVEL_INFO,
11211 "%s: MAC Spoofing enabled for current scan", __func__);
11212 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
11213 * to fill TxBds for probe request during current scan
11214 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011215 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053011216 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011217
11218 if(status != VOS_STATUS_SUCCESS)
11219 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011220 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011221 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053011222#ifdef FEATURE_WLAN_TDLS
11223 wlan_hdd_tdls_scan_done_callback(pAdapter);
11224#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011225 goto free_mem;
11226 }
Siddharth Bhal76972212014-10-15 16:22:51 +053011227 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053011228 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070011229 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011230 pAdapter->sessionId, &scanRequest, &scanId,
11231 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070011232
Jeff Johnson295189b2012-06-20 16:38:30 -070011233 if (eHAL_STATUS_SUCCESS != status)
11234 {
11235 hddLog(VOS_TRACE_LEVEL_ERROR,
11236 "%s: sme_ScanRequest returned error %d", __func__, status);
11237 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011238 if(eHAL_STATUS_RESOURCES == status)
11239 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053011240 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
11241 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011242 status = -EBUSY;
11243 } else {
11244 status = -EIO;
11245 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011246 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053011247
11248#ifdef FEATURE_WLAN_TDLS
11249 wlan_hdd_tdls_scan_done_callback(pAdapter);
11250#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011251 goto free_mem;
11252 }
11253
11254 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053011255 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011256 pAdapter->request = request;
11257 pScanInfo->scanId = scanId;
11258
11259 complete(&pScanInfo->scan_req_completion_event);
11260
11261free_mem:
11262 if( scanRequest.SSIDs.SSIDList )
11263 {
11264 vos_mem_free(scanRequest.SSIDs.SSIDList);
11265 }
11266
11267 if( channelList )
11268 vos_mem_free( channelList );
11269
11270 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011271 return status;
11272}
11273
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011274int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
11275#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11276 struct net_device *dev,
11277#endif
11278 struct cfg80211_scan_request *request)
11279{
11280 int ret;
11281
11282 vos_ssr_protect(__func__);
11283 ret = __wlan_hdd_cfg80211_scan(wiphy,
11284#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11285 dev,
11286#endif
11287 request);
11288 vos_ssr_unprotect(__func__);
11289
11290 return ret;
11291}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011292
11293void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
11294{
11295 v_U8_t iniDot11Mode =
11296 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
11297 eHddDot11Mode hddDot11Mode = iniDot11Mode;
11298
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011299 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
11300 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011301 switch ( iniDot11Mode )
11302 {
11303 case eHDD_DOT11_MODE_AUTO:
11304 case eHDD_DOT11_MODE_11ac:
11305 case eHDD_DOT11_MODE_11ac_ONLY:
11306#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053011307 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
11308 sme_IsFeatureSupportedByFW(DOT11AC) )
11309 hddDot11Mode = eHDD_DOT11_MODE_11ac;
11310 else
11311 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011312#else
11313 hddDot11Mode = eHDD_DOT11_MODE_11n;
11314#endif
11315 break;
11316 case eHDD_DOT11_MODE_11n:
11317 case eHDD_DOT11_MODE_11n_ONLY:
11318 hddDot11Mode = eHDD_DOT11_MODE_11n;
11319 break;
11320 default:
11321 hddDot11Mode = iniDot11Mode;
11322 break;
11323 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011324#ifdef WLAN_FEATURE_AP_HT40_24G
11325 if (operationChannel > SIR_11B_CHANNEL_END)
11326#endif
11327 {
11328 /* This call decides required channel bonding mode */
11329 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011330 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
11331 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011332 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011333}
11334
Jeff Johnson295189b2012-06-20 16:38:30 -070011335/*
11336 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011337 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011338 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011339int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011340 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070011341{
11342 int status = 0;
11343 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080011344 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011345 v_U32_t roamId;
11346 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070011347 eCsrAuthType RSNAuthType;
11348
11349 ENTER();
11350
11351 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080011352 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11353
11354 status = wlan_hdd_validate_context(pHddCtx);
11355 if (status)
11356 {
Yue Mae36e3552014-03-05 17:06:20 -080011357 return status;
11358 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011359
Jeff Johnson295189b2012-06-20 16:38:30 -070011360 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
11361 {
11362 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
11363 return -EINVAL;
11364 }
11365
11366 pRoamProfile = &pWextState->roamProfile;
11367
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011368 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070011369 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011370 hdd_station_ctx_t *pHddStaCtx;
11371 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011372
Siddharth Bhalda0d1622015-04-24 15:47:49 +053011373 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
11374
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011375 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070011376 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
11377 {
11378 /*QoS not enabled in cfg file*/
11379 pRoamProfile->uapsd_mask = 0;
11380 }
11381 else
11382 {
11383 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011384 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070011385 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
11386 }
11387
11388 pRoamProfile->SSIDs.numOfSSIDs = 1;
11389 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
11390 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011391 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070011392 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
11393 ssid, ssid_len);
11394
11395 if (bssid)
11396 {
11397 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
11398 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
11399 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011400 /* Save BSSID in seperate variable as well, as RoamProfile
11401 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070011402 case of join failure we should send valid BSSID to supplicant
11403 */
11404 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
11405 WNI_CFG_BSSID_LEN);
11406 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070011407 else
11408 {
11409 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
11410 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011411
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011412 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
11413 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011414 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
11415 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011416 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011417 /*set gen ie*/
11418 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
11419 /*set auth*/
11420 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
11421 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011422#ifdef FEATURE_WLAN_WAPI
11423 if (pAdapter->wapi_info.nWapiMode)
11424 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011425 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011426 switch (pAdapter->wapi_info.wapiAuthMode)
11427 {
11428 case WAPI_AUTH_MODE_PSK:
11429 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011430 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011431 pAdapter->wapi_info.wapiAuthMode);
11432 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
11433 break;
11434 }
11435 case WAPI_AUTH_MODE_CERT:
11436 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011437 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011438 pAdapter->wapi_info.wapiAuthMode);
11439 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
11440 break;
11441 }
11442 } // End of switch
11443 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
11444 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
11445 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011446 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011447 pRoamProfile->AuthType.numEntries = 1;
11448 pRoamProfile->EncryptionType.numEntries = 1;
11449 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11450 pRoamProfile->mcEncryptionType.numEntries = 1;
11451 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11452 }
11453 }
11454#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011455#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011456 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011457 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11458 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
11459 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011460 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
11461 sizeof (tSirGtkOffloadParams));
11462 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011463 }
11464#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011465 pRoamProfile->csrPersona = pAdapter->device_mode;
11466
Jeff Johnson32d95a32012-09-10 13:15:23 -070011467 if( operatingChannel )
11468 {
11469 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
11470 pRoamProfile->ChannelInfo.numOfChannels = 1;
11471 }
Chet Lanctot186b5732013-03-18 10:26:30 -070011472 else
11473 {
11474 pRoamProfile->ChannelInfo.ChannelList = NULL;
11475 pRoamProfile->ChannelInfo.numOfChannels = 0;
11476 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011477 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
11478 {
11479 hdd_select_cbmode(pAdapter,operatingChannel);
11480 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011481
Agarwal Ashish40f9b872015-09-01 16:17:35 +053011482 /*
11483 * Change conn_state to connecting before sme_RoamConnect(),
11484 * because sme_RoamConnect() has a direct path to call
11485 * hdd_smeRoamCallback(), which will change the conn_state
11486 * If direct path, conn_state will be accordingly changed
11487 * to NotConnected or Associated by either
11488 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
11489 * in sme_RoamCallback()
11490 * if sme_RomConnect is to be queued,
11491 * Connecting state will remain until it is completed.
11492 * If connection state is not changed,
11493 * connection state will remain in eConnectionState_NotConnected state.
11494 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
11495 * if conn state is eConnectionState_NotConnected.
11496 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
11497 * informed of connect result indication which is an issue.
11498 */
11499
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011500 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11501 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053011502 {
11503 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish40f9b872015-09-01 16:17:35 +053011504 FL("Set HDD connState to eConnectionState_Connecting"));
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011505 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
11506 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053011507 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011508 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011509 pAdapter->sessionId, pRoamProfile, &roamId);
11510
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011511 if ((eHAL_STATUS_SUCCESS != status) &&
11512 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11513 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011514
11515 {
Agarwal Ashish40f9b872015-09-01 16:17:35 +053011516 hddLog(VOS_TRACE_LEVEL_ERROR,
11517 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
11518 pAdapter->sessionId, status);
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011519 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011520 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011521 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011522 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011523
11524 pRoamProfile->ChannelInfo.ChannelList = NULL;
11525 pRoamProfile->ChannelInfo.numOfChannels = 0;
11526
Jeff Johnson295189b2012-06-20 16:38:30 -070011527 }
11528 else
11529 {
11530 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
11531 return -EINVAL;
11532 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080011533 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011534 return status;
11535}
11536
11537/*
11538 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
11539 * This function is used to set the authentication type (OPEN/SHARED).
11540 *
11541 */
11542static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
11543 enum nl80211_auth_type auth_type)
11544{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011545 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011546 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11547
11548 ENTER();
11549
11550 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011551 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070011552 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011553 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011554 hddLog(VOS_TRACE_LEVEL_INFO,
11555 "%s: set authentication type to AUTOSWITCH", __func__);
11556 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
11557 break;
11558
11559 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011560#ifdef WLAN_FEATURE_VOWIFI_11R
11561 case NL80211_AUTHTYPE_FT:
11562#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011563 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011564 "%s: set authentication type to OPEN", __func__);
11565 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11566 break;
11567
11568 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011569 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011570 "%s: set authentication type to SHARED", __func__);
11571 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
11572 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011573#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011574 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011575 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011576 "%s: set authentication type to CCKM WPA", __func__);
11577 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
11578 break;
11579#endif
11580
11581
11582 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011583 hddLog(VOS_TRACE_LEVEL_ERROR,
11584 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011585 auth_type);
11586 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
11587 return -EINVAL;
11588 }
11589
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011590 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011591 pHddStaCtx->conn_info.authType;
11592 return 0;
11593}
11594
11595/*
11596 * FUNCTION: wlan_hdd_set_akm_suite
11597 * This function is used to set the key mgmt type(PSK/8021x).
11598 *
11599 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011600static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011601 u32 key_mgmt
11602 )
11603{
11604 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11605 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053011606 /* Should be in ieee802_11_defs.h */
11607#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
11608#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070011609 /*set key mgmt type*/
11610 switch(key_mgmt)
11611 {
11612 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053011613 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011614#ifdef WLAN_FEATURE_VOWIFI_11R
11615 case WLAN_AKM_SUITE_FT_PSK:
11616#endif
11617 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070011618 __func__);
11619 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
11620 break;
11621
11622 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053011623 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011624#ifdef WLAN_FEATURE_VOWIFI_11R
11625 case WLAN_AKM_SUITE_FT_8021X:
11626#endif
11627 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011628 __func__);
11629 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11630 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011631#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011632#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
11633#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
11634 case WLAN_AKM_SUITE_CCKM:
11635 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
11636 __func__);
11637 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
11638 break;
11639#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070011640#ifndef WLAN_AKM_SUITE_OSEN
11641#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
11642 case WLAN_AKM_SUITE_OSEN:
11643 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
11644 __func__);
11645 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11646 break;
11647#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011648
11649 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011650 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011651 __func__, key_mgmt);
11652 return -EINVAL;
11653
11654 }
11655 return 0;
11656}
11657
11658/*
11659 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011660 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070011661 * (NONE/WEP40/WEP104/TKIP/CCMP).
11662 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011663static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
11664 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070011665 bool ucast
11666 )
11667{
11668 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011669 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011670 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11671
11672 ENTER();
11673
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011674 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011675 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053011676 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070011677 __func__, cipher);
11678 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11679 }
11680 else
11681 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011682
Jeff Johnson295189b2012-06-20 16:38:30 -070011683 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011684 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011685 {
11686 case IW_AUTH_CIPHER_NONE:
11687 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11688 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011689
Jeff Johnson295189b2012-06-20 16:38:30 -070011690 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011691 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070011692 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011693
Jeff Johnson295189b2012-06-20 16:38:30 -070011694 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011695 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070011696 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011697
Jeff Johnson295189b2012-06-20 16:38:30 -070011698 case WLAN_CIPHER_SUITE_TKIP:
11699 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
11700 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011701
Jeff Johnson295189b2012-06-20 16:38:30 -070011702 case WLAN_CIPHER_SUITE_CCMP:
11703 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11704 break;
11705#ifdef FEATURE_WLAN_WAPI
11706 case WLAN_CIPHER_SUITE_SMS4:
11707 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
11708 break;
11709#endif
11710
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011711#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011712 case WLAN_CIPHER_SUITE_KRK:
11713 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
11714 break;
11715#endif
11716 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011717 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011718 __func__, cipher);
11719 return -EOPNOTSUPP;
11720 }
11721 }
11722
11723 if (ucast)
11724 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011725 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011726 __func__, encryptionType);
11727 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11728 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011729 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011730 encryptionType;
11731 }
11732 else
11733 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011734 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011735 __func__, encryptionType);
11736 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
11737 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
11738 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
11739 }
11740
11741 return 0;
11742}
11743
11744
11745/*
11746 * FUNCTION: wlan_hdd_cfg80211_set_ie
11747 * This function is used to parse WPA/RSN IE's.
11748 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011749int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011750#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11751 const u8 *ie,
11752#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011753 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011754#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011755 size_t ie_len
11756 )
11757{
11758 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011759#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11760 const u8 *genie = ie;
11761#else
Jeff Johnson295189b2012-06-20 16:38:30 -070011762 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011763#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011764 v_U16_t remLen = ie_len;
11765#ifdef FEATURE_WLAN_WAPI
11766 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
11767 u16 *tmp;
11768 v_U16_t akmsuiteCount;
11769 int *akmlist;
11770#endif
11771 ENTER();
11772
11773 /* clear previous assocAddIE */
11774 pWextState->assocAddIE.length = 0;
11775 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011776 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011777
11778 while (remLen >= 2)
11779 {
11780 v_U16_t eLen = 0;
11781 v_U8_t elementId;
11782 elementId = *genie++;
11783 eLen = *genie++;
11784 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011785
Arif Hussain6d2a3322013-11-17 19:50:10 -080011786 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070011787 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011788
11789 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070011790 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011791 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011792 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 -070011793 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011794 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011795 "%s: Invalid WPA IE", __func__);
11796 return -EINVAL;
11797 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011798 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070011799 {
11800 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011801 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011802 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011803
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011804 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011805 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011806 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
11807 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011808 VOS_ASSERT(0);
11809 return -ENOMEM;
11810 }
11811 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11812 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11813 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011814
Jeff Johnson295189b2012-06-20 16:38:30 -070011815 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
11816 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11817 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11818 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011819 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
11820 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011821 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
11822 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11823 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
11824 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
11825 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
11826 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011827 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053011828 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070011829 {
11830 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011831 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011832 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011833
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011834 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011835 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011836 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11837 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011838 VOS_ASSERT(0);
11839 return -ENOMEM;
11840 }
11841 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11842 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11843 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011844
Jeff Johnson295189b2012-06-20 16:38:30 -070011845 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11846 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11847 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011848#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011849 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
11850 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011851 /*Consider WFD IE, only for P2P Client */
11852 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
11853 {
11854 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011855 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011856 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011857
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011858 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011859 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011860 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11861 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011862 VOS_ASSERT(0);
11863 return -ENOMEM;
11864 }
11865 // WFD IE is saved to Additional IE ; it should be accumulated to handle
11866 // WPS IE + P2P IE + WFD IE
11867 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11868 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011869
Jeff Johnson295189b2012-06-20 16:38:30 -070011870 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11871 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11872 }
11873#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011874 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011875 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011876 HS20_OUI_TYPE_SIZE)) )
11877 {
11878 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011879 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011880 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011881
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011882 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011883 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011884 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11885 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011886 VOS_ASSERT(0);
11887 return -ENOMEM;
11888 }
11889 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11890 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011891
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011892 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11893 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11894 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011895 /* Appending OSEN Information Element in Assiciation Request */
11896 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
11897 OSEN_OUI_TYPE_SIZE)) )
11898 {
11899 v_U16_t curAddIELen = pWextState->assocAddIE.length;
11900 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
11901 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011902
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011903 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011904 {
11905 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11906 "Need bigger buffer space");
11907 VOS_ASSERT(0);
11908 return -ENOMEM;
11909 }
11910 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11911 pWextState->assocAddIE.length += eLen + 2;
11912
11913 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
11914 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11915 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11916 }
11917
Abhishek Singh4322e622015-06-10 15:42:54 +053011918 /* Update only for WPA IE */
11919 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
11920 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011921
11922 /* populating as ADDIE in beacon frames */
11923 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011924 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011925 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
11926 {
11927 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11928 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
11929 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11930 {
11931 hddLog(LOGE,
11932 "Coldn't pass "
11933 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
11934 }
11935 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
11936 else
11937 hddLog(LOGE,
11938 "Could not pass on "
11939 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
11940
11941 /* IBSS mode doesn't contain params->proberesp_ies still
11942 beaconIE's need to be populated in probe response frames */
11943 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
11944 {
11945 u16 rem_probe_resp_ie_len = eLen + 2;
11946 u8 probe_rsp_ie_len[3] = {0};
11947 u8 counter = 0;
11948
11949 /* Check Probe Resp Length if it is greater then 255 then
11950 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
11951 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
11952 not able Store More then 255 bytes into One Variable */
11953
11954 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
11955 {
11956 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
11957 {
11958 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
11959 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
11960 }
11961 else
11962 {
11963 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
11964 rem_probe_resp_ie_len = 0;
11965 }
11966 }
11967
11968 rem_probe_resp_ie_len = 0;
11969
11970 if (probe_rsp_ie_len[0] > 0)
11971 {
11972 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11973 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
11974 (tANI_U8*)(genie - 2),
11975 probe_rsp_ie_len[0], NULL,
11976 eANI_BOOLEAN_FALSE)
11977 == eHAL_STATUS_FAILURE)
11978 {
11979 hddLog(LOGE,
11980 "Could not pass"
11981 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
11982 }
11983 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
11984 }
11985
11986 if (probe_rsp_ie_len[1] > 0)
11987 {
11988 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11989 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
11990 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11991 probe_rsp_ie_len[1], NULL,
11992 eANI_BOOLEAN_FALSE)
11993 == eHAL_STATUS_FAILURE)
11994 {
11995 hddLog(LOGE,
11996 "Could not pass"
11997 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
11998 }
11999 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
12000 }
12001
12002 if (probe_rsp_ie_len[2] > 0)
12003 {
12004 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
12005 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
12006 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
12007 probe_rsp_ie_len[2], NULL,
12008 eANI_BOOLEAN_FALSE)
12009 == eHAL_STATUS_FAILURE)
12010 {
12011 hddLog(LOGE,
12012 "Could not pass"
12013 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
12014 }
12015 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
12016 }
12017
12018 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
12019 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
12020 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
12021 {
12022 hddLog(LOGE,
12023 "Could not pass"
12024 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
12025 }
12026 }
12027 else
12028 {
12029 // Reset WNI_CFG_PROBE_RSP Flags
12030 wlan_hdd_reset_prob_rspies(pAdapter);
12031
12032 hddLog(VOS_TRACE_LEVEL_INFO,
12033 "%s: No Probe Response IE received in set beacon",
12034 __func__);
12035 }
12036 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070012037 break;
12038 case DOT11F_EID_RSN:
12039 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
12040 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
12041 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
12042 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
12043 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
12044 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053012045
12046 /* Appending Extended Capabilities with Interworking bit set
12047 * in Assoc Req.
12048 *
12049 * In assoc req this EXT Cap will only be taken into account if
12050 * interworkingService bit is set to 1. Currently
12051 * driver is only interested in interworkingService capability
12052 * from supplicant. If in future any other EXT Cap info is
12053 * required from supplicat, it needs to be handled while
12054 * sending Assoc Req in LIM.
12055 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012056 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012057 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012058 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012059 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012060 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012061
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053012062 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012063 {
Jeff Johnson902c9832012-12-10 14:28:09 -080012064 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
12065 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012066 VOS_ASSERT(0);
12067 return -ENOMEM;
12068 }
12069 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
12070 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012071
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012072 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
12073 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
12074 break;
12075 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012076#ifdef FEATURE_WLAN_WAPI
12077 case WLAN_EID_WAPI:
12078 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070012079 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070012080 pAdapter->wapi_info.nWapiMode);
12081 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012082 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070012083 akmsuiteCount = WPA_GET_LE16(tmp);
12084 tmp = tmp + 1;
12085 akmlist = (int *)(tmp);
12086 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
12087 {
12088 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
12089 }
12090 else
12091 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012092 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070012093 VOS_ASSERT(0);
12094 return -EINVAL;
12095 }
12096
12097 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
12098 {
12099 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012100 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012101 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012102 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012103 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012104 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012105 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012106 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012107 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
12108 }
12109 break;
12110#endif
12111 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012112 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012113 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012114 /* when Unknown IE is received we should break and continue
12115 * to the next IE in the buffer instead we were returning
12116 * so changing this to break */
12117 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012118 }
12119 genie += eLen;
12120 remLen -= eLen;
12121 }
12122 EXIT();
12123 return 0;
12124}
12125
12126/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053012127 * FUNCTION: hdd_isWPAIEPresent
12128 * Parse the received IE to find the WPA IE
12129 *
12130 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012131static bool hdd_isWPAIEPresent(
12132#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
12133 const u8 *ie,
12134#else
12135 u8 *ie,
12136#endif
12137 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053012138{
12139 v_U8_t eLen = 0;
12140 v_U16_t remLen = ie_len;
12141 v_U8_t elementId = 0;
12142
12143 while (remLen >= 2)
12144 {
12145 elementId = *ie++;
12146 eLen = *ie++;
12147 remLen -= 2;
12148 if (eLen > remLen)
12149 {
12150 hddLog(VOS_TRACE_LEVEL_ERROR,
12151 "%s: IE length is wrong %d", __func__, eLen);
12152 return FALSE;
12153 }
12154 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
12155 {
12156 /* OUI - 0x00 0X50 0XF2
12157 WPA Information Element - 0x01
12158 WPA version - 0x01*/
12159 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
12160 return TRUE;
12161 }
12162 ie += eLen;
12163 remLen -= eLen;
12164 }
12165 return FALSE;
12166}
12167
12168/*
Jeff Johnson295189b2012-06-20 16:38:30 -070012169 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012170 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012171 * parameters during connect operation.
12172 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012173int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012174 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012175 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012176{
12177 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012178 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012179 ENTER();
12180
12181 /*set wpa version*/
12182 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
12183
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012184 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070012185 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053012186 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070012187 {
12188 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12189 }
12190 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
12191 {
12192 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12193 }
12194 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012195
12196 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012197 pWextState->wpaVersion);
12198
12199 /*set authentication type*/
12200 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
12201
12202 if (0 > status)
12203 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012204 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012205 "%s: failed to set authentication type ", __func__);
12206 return status;
12207 }
12208
12209 /*set key mgmt type*/
12210 if (req->crypto.n_akm_suites)
12211 {
12212 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
12213 if (0 > status)
12214 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012215 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070012216 __func__);
12217 return status;
12218 }
12219 }
12220
12221 /*set pairwise cipher type*/
12222 if (req->crypto.n_ciphers_pairwise)
12223 {
12224 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
12225 req->crypto.ciphers_pairwise[0], true);
12226 if (0 > status)
12227 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012228 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012229 "%s: failed to set unicast cipher type", __func__);
12230 return status;
12231 }
12232 }
12233 else
12234 {
12235 /*Reset previous cipher suite to none*/
12236 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
12237 if (0 > status)
12238 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012239 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012240 "%s: failed to set unicast cipher type", __func__);
12241 return status;
12242 }
12243 }
12244
12245 /*set group cipher type*/
12246 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
12247 false);
12248
12249 if (0 > status)
12250 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012251 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070012252 __func__);
12253 return status;
12254 }
12255
Chet Lanctot186b5732013-03-18 10:26:30 -070012256#ifdef WLAN_FEATURE_11W
12257 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
12258#endif
12259
Jeff Johnson295189b2012-06-20 16:38:30 -070012260 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
12261 if (req->ie_len)
12262 {
12263 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
12264 if ( 0 > status)
12265 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012266 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012267 __func__);
12268 return status;
12269 }
12270 }
12271
12272 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012273 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012274 {
12275 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
12276 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
12277 )
12278 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012279 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070012280 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
12281 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012282 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012283 __func__);
12284 return -EOPNOTSUPP;
12285 }
12286 else
12287 {
12288 u8 key_len = req->key_len;
12289 u8 key_idx = req->key_idx;
12290
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012291 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012292 && (CSR_MAX_NUM_KEY > key_idx)
12293 )
12294 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012295 hddLog(VOS_TRACE_LEVEL_INFO,
12296 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012297 __func__, key_idx, key_len);
12298 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012299 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012300 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012301 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070012302 (u8)key_len;
12303 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
12304 }
12305 }
12306 }
12307 }
12308
12309 return status;
12310}
12311
12312/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012313 * FUNCTION: wlan_hdd_try_disconnect
12314 * This function is used to disconnect from previous
12315 * connection
12316 */
12317static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
12318{
12319 long ret = 0;
12320 hdd_station_ctx_t *pHddStaCtx;
12321 eMib_dot11DesiredBssType connectedBssType;
12322
12323 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12324
12325 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
12326
12327 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
12328 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
12329 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
12330 {
12331 /* Issue disconnect to CSR */
12332 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12333 if( eHAL_STATUS_SUCCESS ==
12334 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12335 pAdapter->sessionId,
12336 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
12337 {
12338 ret = wait_for_completion_interruptible_timeout(
12339 &pAdapter->disconnect_comp_var,
12340 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12341 if (0 >= ret)
12342 {
12343 hddLog(LOGE, FL("Failed to receive disconnect event"));
12344 return -EALREADY;
12345 }
12346 }
12347 }
12348 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
12349 {
12350 ret = wait_for_completion_interruptible_timeout(
12351 &pAdapter->disconnect_comp_var,
12352 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12353 if (0 >= ret)
12354 {
12355 hddLog(LOGE, FL("Failed to receive disconnect event"));
12356 return -EALREADY;
12357 }
12358 }
12359
12360 return 0;
12361}
12362
12363/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053012364 * FUNCTION: __wlan_hdd_cfg80211_connect
12365 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070012366 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012367static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012368 struct net_device *ndev,
12369 struct cfg80211_connect_params *req
12370 )
12371{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012372 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012373 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012374 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053012375 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012376
12377 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012378
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012379 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12380 TRACE_CODE_HDD_CFG80211_CONNECT,
12381 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012382 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012383 "%s: device_mode = %s (%d)", __func__,
12384 hdd_device_modetoString(pAdapter->device_mode),
12385 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012386
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012387 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012388 if (!pHddCtx)
12389 {
12390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12391 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053012392 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012393 }
12394
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012395 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012396 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012397 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012398 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012399 }
12400
Agarwal Ashish51325b52014-06-16 16:50:49 +053012401 if (vos_max_concurrent_connections_reached()) {
12402 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12403 return -ECONNREFUSED;
12404 }
12405
Jeff Johnson295189b2012-06-20 16:38:30 -070012406#ifdef WLAN_BTAMP_FEATURE
12407 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012408 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070012409 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012410 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012411 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080012412 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012413 }
12414#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012415
12416 //If Device Mode is Station Concurrent Sessions Exit BMps
12417 //P2P Mode will be taken care in Open/close adapter
12418 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012419 (vos_concurrent_open_sessions_running())) {
12420 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
12421 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012422 }
12423
12424 /*Try disconnecting if already in connected state*/
12425 status = wlan_hdd_try_disconnect(pAdapter);
12426 if ( 0 > status)
12427 {
12428 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12429 " connection"));
12430 return -EALREADY;
12431 }
12432
Jeff Johnson295189b2012-06-20 16:38:30 -070012433 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012434 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070012435
12436 if ( 0 > status)
12437 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012438 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070012439 __func__);
12440 return status;
12441 }
Mohit Khanna765234a2012-09-11 15:08:35 -070012442 if ( req->channel )
12443 {
12444 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
12445 req->ssid_len, req->bssid,
12446 req->channel->hw_value);
12447 }
12448 else
12449 {
12450 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012451 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070012452 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012453
Sushant Kaushikd7083982015-03-18 14:33:24 +053012454 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012455 {
12456 //ReEnable BMPS if disabled
12457 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
12458 (NULL != pHddCtx))
12459 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012460 if (pHddCtx->hdd_wlan_suspended)
12461 {
12462 hdd_set_pwrparams(pHddCtx);
12463 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012464 //ReEnable Bmps and Imps back
12465 hdd_enable_bmps_imps(pHddCtx);
12466 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053012467 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012468 return status;
12469 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012470 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012471 EXIT();
12472 return status;
12473}
12474
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012475static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
12476 struct net_device *ndev,
12477 struct cfg80211_connect_params *req)
12478{
12479 int ret;
12480 vos_ssr_protect(__func__);
12481 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
12482 vos_ssr_unprotect(__func__);
12483
12484 return ret;
12485}
Jeff Johnson295189b2012-06-20 16:38:30 -070012486
12487/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012488 * FUNCTION: wlan_hdd_disconnect
12489 * This function is used to issue a disconnect request to SME
12490 */
12491int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
12492{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012493 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012494 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012495 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012496 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012497
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012498 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012499
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012500 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012501 if (0 != status)
12502 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012503 return status;
12504 }
12505
Sushant Kaushikb4834d22015-07-15 15:29:05 +053012506 if (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)
12507 {
12508 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
12509 pAdapter->sessionId);
12510 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012511 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012512
Agarwal Ashish47d18112014-08-04 19:55:07 +053012513 /* Need to apply spin lock before decreasing active sessions
12514 * as there can be chance for double decrement if context switch
12515 * Calls hdd_DisConnectHandler.
12516 */
12517
12518 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012519 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
12520 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012521 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
12522 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053012523 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
12524 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012525
Abhishek Singhf4669da2014-05-26 15:07:49 +053012526 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053012527 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
12528
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012529 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012530
Mihir Shete182a0b22014-08-18 16:08:48 +053012531 /*
12532 * stop tx queues before deleting STA/BSS context from the firmware.
12533 * tx has to be disabled because the firmware can get busy dropping
12534 * the tx frames after BSS/STA has been deleted and will not send
12535 * back a response resulting in WDI timeout
12536 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053012537 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053012538 netif_tx_disable(pAdapter->dev);
12539 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012540
Mihir Shete182a0b22014-08-18 16:08:48 +053012541 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012542 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12543 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012544 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
12545 {
12546 hddLog(VOS_TRACE_LEVEL_INFO,
12547 FL("status = %d, already disconnected"),
12548 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012549
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012550 }
12551 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012552 {
12553 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012554 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012555 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012556 result = -EINVAL;
12557 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012558 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012559 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012560 &pAdapter->disconnect_comp_var,
12561 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012562 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012563 {
12564 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012565 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012566 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012567 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012568 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012569 {
12570 hddLog(VOS_TRACE_LEVEL_ERROR,
12571 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012572 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012573 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012574disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012575 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12576 FL("Set HDD connState to eConnectionState_NotConnected"));
12577 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
12578
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012579 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012580 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012581}
12582
12583
12584/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012585 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070012586 * This function is used to issue a disconnect request to SME
12587 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012588static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012589 struct net_device *dev,
12590 u16 reason
12591 )
12592{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012593 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012594 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012595 tCsrRoamProfile *pRoamProfile;
12596 hdd_station_ctx_t *pHddStaCtx;
12597 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012598#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012599 tANI_U8 staIdx;
12600#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012601
Jeff Johnson295189b2012-06-20 16:38:30 -070012602 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012603
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012604 if (!pAdapter) {
12605 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
12606 return -EINVAL;
12607 }
12608
12609 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12610 if (!pHddStaCtx) {
12611 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
12612 return -EINVAL;
12613 }
12614
12615 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12616 status = wlan_hdd_validate_context(pHddCtx);
12617 if (0 != status)
12618 {
12619 return status;
12620 }
12621
12622 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
12623
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012624 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12625 TRACE_CODE_HDD_CFG80211_DISCONNECT,
12626 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012627 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
12628 __func__, hdd_device_modetoString(pAdapter->device_mode),
12629 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012630
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012631 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
12632 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070012633
Jeff Johnson295189b2012-06-20 16:38:30 -070012634 if (NULL != pRoamProfile)
12635 {
12636 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012637 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
12638 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070012639 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012640 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070012641 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012642 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012643 switch(reason)
12644 {
12645 case WLAN_REASON_MIC_FAILURE:
12646 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
12647 break;
12648
12649 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
12650 case WLAN_REASON_DISASSOC_AP_BUSY:
12651 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
12652 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
12653 break;
12654
12655 case WLAN_REASON_PREV_AUTH_NOT_VALID:
12656 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053012657 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070012658 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
12659 break;
12660
Jeff Johnson295189b2012-06-20 16:38:30 -070012661 default:
12662 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
12663 break;
12664 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012665 pScanInfo = &pHddCtx->scan_info;
12666 if (pScanInfo->mScanPending)
12667 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012668 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012669 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053012670 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012671 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012672 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053012673 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012674#ifdef FEATURE_WLAN_TDLS
12675 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012676 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012677 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012678 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
12679 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012680 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012681 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012682 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012684 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012685 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012686 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012687 status = sme_DeleteTdlsPeerSta(
12688 WLAN_HDD_GET_HAL_CTX(pAdapter),
12689 pAdapter->sessionId,
12690 mac);
12691 if (status != eHAL_STATUS_SUCCESS) {
12692 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
12693 return -EPERM;
12694 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012695 }
12696 }
12697#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012698 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012699 status = wlan_hdd_disconnect(pAdapter, reasonCode);
12700 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070012701 {
12702 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012703 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012704 __func__, (int)status );
12705 return -EINVAL;
12706 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012707 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012708 else
12709 {
12710 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
12711 "called while in %d state", __func__,
12712 pHddStaCtx->conn_info.connState);
12713 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012714 }
12715 else
12716 {
12717 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
12718 }
12719
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012720 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012721 return status;
12722}
12723
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012724static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
12725 struct net_device *dev,
12726 u16 reason
12727 )
12728{
12729 int ret;
12730 vos_ssr_protect(__func__);
12731 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
12732 vos_ssr_unprotect(__func__);
12733
12734 return ret;
12735}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012736
Jeff Johnson295189b2012-06-20 16:38:30 -070012737/*
12738 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012739 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012740 * settings in IBSS mode.
12741 */
12742static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012743 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012744 struct cfg80211_ibss_params *params
12745 )
12746{
12747 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012748 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012749 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
12750 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012751
Jeff Johnson295189b2012-06-20 16:38:30 -070012752 ENTER();
12753
12754 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070012755 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070012756
12757 if (params->ie_len && ( NULL != params->ie) )
12758 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012759 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12760 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012761 {
12762 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12763 encryptionType = eCSR_ENCRYPT_TYPE_AES;
12764 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012765 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012766 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012767 tDot11fIEWPA dot11WPAIE;
12768 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012769 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012770
Wilson Yang00256342013-10-10 23:13:38 -070012771 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012772 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12773 params->ie_len, DOT11F_EID_WPA);
12774 if ( NULL != ie )
12775 {
12776 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12777 // Unpack the WPA IE
12778 //Skip past the EID byte and length byte - and four byte WiFi OUI
12779 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
12780 &ie[2+4],
12781 ie[1] - 4,
12782 &dot11WPAIE);
12783 /*Extract the multicast cipher, the encType for unicast
12784 cipher for wpa-none is none*/
12785 encryptionType =
12786 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
12787 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012788 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012789
Jeff Johnson295189b2012-06-20 16:38:30 -070012790 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
12791
12792 if (0 > status)
12793 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012794 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012795 __func__);
12796 return status;
12797 }
12798 }
12799
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012800 pWextState->roamProfile.AuthType.authType[0] =
12801 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012802 eCSR_AUTH_TYPE_OPEN_SYSTEM;
12803
12804 if (params->privacy)
12805 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012806 /* Security enabled IBSS, At this time there is no information available
12807 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070012808 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012809 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070012810 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012811 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070012812 *enable privacy bit in beacons */
12813
12814 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
12815 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012816 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
12817 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012818 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
12819 pWextState->roamProfile.EncryptionType.numEntries = 1;
12820 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012821 return status;
12822}
12823
12824/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012825 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012826 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012827 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012828static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012829 struct net_device *dev,
12830 struct cfg80211_ibss_params *params
12831 )
12832{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012833 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012834 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12835 tCsrRoamProfile *pRoamProfile;
12836 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012837 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12838 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012839 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070012840
12841 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012842
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012843 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12844 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
12845 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012846 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012847 "%s: device_mode = %s (%d)", __func__,
12848 hdd_device_modetoString(pAdapter->device_mode),
12849 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012850
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012851 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012852 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012853 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012854 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012855 }
12856
12857 if (NULL == pWextState)
12858 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012859 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012860 __func__);
12861 return -EIO;
12862 }
12863
Agarwal Ashish51325b52014-06-16 16:50:49 +053012864 if (vos_max_concurrent_connections_reached()) {
12865 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12866 return -ECONNREFUSED;
12867 }
12868
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012869 /*Try disconnecting if already in connected state*/
12870 status = wlan_hdd_try_disconnect(pAdapter);
12871 if ( 0 > status)
12872 {
12873 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12874 " IBSS connection"));
12875 return -EALREADY;
12876 }
12877
Jeff Johnson295189b2012-06-20 16:38:30 -070012878 pRoamProfile = &pWextState->roamProfile;
12879
12880 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
12881 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012882 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012883 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012884 return -EINVAL;
12885 }
12886
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012887 /* BSSID is provided by upper layers hence no need to AUTO generate */
12888 if (NULL != params->bssid) {
12889 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12890 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
12891 hddLog (VOS_TRACE_LEVEL_ERROR,
12892 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12893 return -EIO;
12894 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012895 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012896 }
krunal sonie9002db2013-11-25 14:24:17 -080012897 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
12898 {
12899 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12900 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
12901 {
12902 hddLog (VOS_TRACE_LEVEL_ERROR,
12903 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12904 return -EIO;
12905 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012906
12907 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080012908 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012909 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080012910 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012911
Jeff Johnson295189b2012-06-20 16:38:30 -070012912 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070012913 if (NULL !=
12914#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12915 params->chandef.chan)
12916#else
12917 params->channel)
12918#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012919 {
12920 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012921 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12922 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
12923 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12924 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012925
12926 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012927 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070012928 ieee80211_frequency_to_channel(
12929#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12930 params->chandef.chan->center_freq);
12931#else
12932 params->channel->center_freq);
12933#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012934
12935 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
12936 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070012937 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012938 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
12939 __func__);
12940 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070012941 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012942
12943 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012944 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012945 if (channelNum == validChan[indx])
12946 {
12947 break;
12948 }
12949 }
12950 if (indx >= numChans)
12951 {
12952 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012953 __func__, channelNum);
12954 return -EINVAL;
12955 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012956 /* Set the Operational Channel */
12957 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
12958 channelNum);
12959 pRoamProfile->ChannelInfo.numOfChannels = 1;
12960 pHddStaCtx->conn_info.operationChannel = channelNum;
12961 pRoamProfile->ChannelInfo.ChannelList =
12962 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070012963 }
12964
12965 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012966 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070012967 if (status < 0)
12968 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012969 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070012970 __func__);
12971 return status;
12972 }
12973
12974 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012975 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012976 params->ssid_len, params->bssid,
12977 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070012978
12979 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012980 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012981
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012982 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012983 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012984}
12985
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012986static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
12987 struct net_device *dev,
12988 struct cfg80211_ibss_params *params
12989 )
12990{
12991 int ret = 0;
12992
12993 vos_ssr_protect(__func__);
12994 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
12995 vos_ssr_unprotect(__func__);
12996
12997 return ret;
12998}
12999
Jeff Johnson295189b2012-06-20 16:38:30 -070013000/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013001 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013002 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070013003 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013004static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013005 struct net_device *dev
13006 )
13007{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013008 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013009 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13010 tCsrRoamProfile *pRoamProfile;
13011 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013012 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013013
13014 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013015
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013016 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13017 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
13018 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013019 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013020 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013021 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013022 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013023 }
13024
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013025 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
13026 hdd_device_modetoString(pAdapter->device_mode),
13027 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070013028 if (NULL == pWextState)
13029 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013030 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070013031 __func__);
13032 return -EIO;
13033 }
13034
13035 pRoamProfile = &pWextState->roamProfile;
13036
13037 /* Issue disconnect only if interface type is set to IBSS */
13038 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
13039 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013040 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070013041 __func__);
13042 return -EINVAL;
13043 }
13044
13045 /* Issue Disconnect request */
13046 INIT_COMPLETION(pAdapter->disconnect_comp_var);
13047 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
13048 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
13049
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013050 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013051 return 0;
13052}
13053
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013054static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
13055 struct net_device *dev
13056 )
13057{
13058 int ret = 0;
13059
13060 vos_ssr_protect(__func__);
13061 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
13062 vos_ssr_unprotect(__func__);
13063
13064 return ret;
13065}
13066
Jeff Johnson295189b2012-06-20 16:38:30 -070013067/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013068 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070013069 * This function is used to set the phy parameters
13070 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
13071 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013072static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013073 u32 changed)
13074{
13075 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
13076 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013077 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013078
13079 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013080
13081 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013082 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
13083 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013084
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013085 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013086 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013087 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013088 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013089 }
13090
Jeff Johnson295189b2012-06-20 16:38:30 -070013091 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
13092 {
13093 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
13094 WNI_CFG_RTS_THRESHOLD_STAMAX :
13095 wiphy->rts_threshold;
13096
13097 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013098 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070013099 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013100 hddLog(VOS_TRACE_LEVEL_ERROR,
13101 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013102 __func__, rts_threshold);
13103 return -EINVAL;
13104 }
13105
13106 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
13107 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013108 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013109 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013110 hddLog(VOS_TRACE_LEVEL_ERROR,
13111 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013112 __func__, rts_threshold);
13113 return -EIO;
13114 }
13115
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013116 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013117 rts_threshold);
13118 }
13119
13120 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
13121 {
13122 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
13123 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
13124 wiphy->frag_threshold;
13125
13126 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013127 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013128 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013129 hddLog(VOS_TRACE_LEVEL_ERROR,
13130 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013131 frag_threshold);
13132 return -EINVAL;
13133 }
13134
13135 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
13136 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013137 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013138 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013139 hddLog(VOS_TRACE_LEVEL_ERROR,
13140 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013141 __func__, frag_threshold);
13142 return -EIO;
13143 }
13144
13145 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
13146 frag_threshold);
13147 }
13148
13149 if ((changed & WIPHY_PARAM_RETRY_SHORT)
13150 || (changed & WIPHY_PARAM_RETRY_LONG))
13151 {
13152 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
13153 wiphy->retry_short :
13154 wiphy->retry_long;
13155
13156 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
13157 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
13158 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013159 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013160 __func__, retry_value);
13161 return -EINVAL;
13162 }
13163
13164 if (changed & WIPHY_PARAM_RETRY_SHORT)
13165 {
13166 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
13167 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013168 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013169 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013170 hddLog(VOS_TRACE_LEVEL_ERROR,
13171 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013172 __func__, retry_value);
13173 return -EIO;
13174 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013175 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013176 __func__, retry_value);
13177 }
13178 else if (changed & WIPHY_PARAM_RETRY_SHORT)
13179 {
13180 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
13181 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013182 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013183 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013184 hddLog(VOS_TRACE_LEVEL_ERROR,
13185 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013186 __func__, retry_value);
13187 return -EIO;
13188 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013189 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013190 __func__, retry_value);
13191 }
13192 }
13193
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013194 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013195 return 0;
13196}
13197
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013198static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
13199 u32 changed)
13200{
13201 int ret;
13202
13203 vos_ssr_protect(__func__);
13204 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
13205 vos_ssr_unprotect(__func__);
13206
13207 return ret;
13208}
13209
Jeff Johnson295189b2012-06-20 16:38:30 -070013210/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013211 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013212 * This function is used to set the txpower
13213 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013214static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013215#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13216 struct wireless_dev *wdev,
13217#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013218#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013219 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013220#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013221 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013222#endif
13223 int dbm)
13224{
13225 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013226 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013227 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
13228 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013229 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013230
13231 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013232
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013233 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13234 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
13235 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013236 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013237 if (0 != status)
13238 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013239 return status;
13240 }
13241
13242 hHal = pHddCtx->hHal;
13243
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013244 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
13245 dbm, ccmCfgSetCallback,
13246 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013247 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013248 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013249 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
13250 return -EIO;
13251 }
13252
13253 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
13254 dbm);
13255
13256 switch(type)
13257 {
13258 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
13259 /* Fall through */
13260 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
13261 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
13262 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013263 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
13264 __func__);
13265 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070013266 }
13267 break;
13268 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013269 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070013270 __func__);
13271 return -EOPNOTSUPP;
13272 break;
13273 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013274 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
13275 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070013276 return -EIO;
13277 }
13278
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013279 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013280 return 0;
13281}
13282
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013283static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
13284#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13285 struct wireless_dev *wdev,
13286#endif
13287#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13288 enum tx_power_setting type,
13289#else
13290 enum nl80211_tx_power_setting type,
13291#endif
13292 int dbm)
13293{
13294 int ret;
13295 vos_ssr_protect(__func__);
13296 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
13297#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13298 wdev,
13299#endif
13300#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13301 type,
13302#else
13303 type,
13304#endif
13305 dbm);
13306 vos_ssr_unprotect(__func__);
13307
13308 return ret;
13309}
13310
Jeff Johnson295189b2012-06-20 16:38:30 -070013311/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013312 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013313 * This function is used to read the txpower
13314 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013315static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013316#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13317 struct wireless_dev *wdev,
13318#endif
13319 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070013320{
13321
13322 hdd_adapter_t *pAdapter;
13323 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013324 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013325
Jeff Johnsone7245742012-09-05 17:12:55 -070013326 ENTER();
13327
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013328 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013329 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013330 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013331 *dbm = 0;
13332 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013333 }
13334
Jeff Johnson295189b2012-06-20 16:38:30 -070013335 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
13336 if (NULL == pAdapter)
13337 {
13338 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
13339 return -ENOENT;
13340 }
13341
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053013342 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13343 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
13344 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070013345 wlan_hdd_get_classAstats(pAdapter);
13346 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
13347
Jeff Johnsone7245742012-09-05 17:12:55 -070013348 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013349 return 0;
13350}
13351
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013352static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
13353#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13354 struct wireless_dev *wdev,
13355#endif
13356 int *dbm)
13357{
13358 int ret;
13359
13360 vos_ssr_protect(__func__);
13361 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
13362#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13363 wdev,
13364#endif
13365 dbm);
13366 vos_ssr_unprotect(__func__);
13367
13368 return ret;
13369}
13370
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013371static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013372#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13373 const u8* mac,
13374#else
13375 u8* mac,
13376#endif
13377 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070013378{
13379 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13380 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13381 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053013382 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013383
13384 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
13385 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070013386
13387 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
13388 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
13389 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
13390 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
13391 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
13392 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
13393 tANI_U16 maxRate = 0;
13394 tANI_U16 myRate;
13395 tANI_U16 currentRate = 0;
13396 tANI_U8 maxSpeedMCS = 0;
13397 tANI_U8 maxMCSIdx = 0;
13398 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053013399 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013400 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013401 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013402
Leo Chang6f8870f2013-03-26 18:11:36 -070013403#ifdef WLAN_FEATURE_11AC
13404 tANI_U32 vht_mcs_map;
13405 eDataRate11ACMaxMcs vhtMaxMcs;
13406#endif /* WLAN_FEATURE_11AC */
13407
Jeff Johnsone7245742012-09-05 17:12:55 -070013408 ENTER();
13409
Jeff Johnson295189b2012-06-20 16:38:30 -070013410 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
13411 (0 == ssidlen))
13412 {
13413 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
13414 " Invalid ssidlen, %d", __func__, ssidlen);
13415 /*To keep GUI happy*/
13416 return 0;
13417 }
13418
Mukul Sharma811205f2014-07-09 21:07:30 +053013419 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
13420 {
13421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13422 "%s: Roaming in progress, so unable to proceed this request", __func__);
13423 return 0;
13424 }
13425
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013426 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013427 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013428 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013429 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013430 }
13431
Hanumantha Reddy Pothuladce66742015-08-25 18:08:44 +053013432 wlan_hdd_get_station_stats(pAdapter);
13433 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013434
Kiet Lam3b17fc82013-09-27 05:24:08 +053013435 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
13436 sinfo->filled |= STATION_INFO_SIGNAL;
13437
c_hpothu09f19542014-05-30 21:53:31 +053013438 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053013439 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
13440 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053013441 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053013442 {
13443 rate_flags = pAdapter->maxRateFlags;
13444 }
c_hpothu44ff4e02014-05-08 00:13:57 +053013445
Jeff Johnson295189b2012-06-20 16:38:30 -070013446 //convert to the UI units of 100kbps
13447 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
13448
13449#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070013450 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 -070013451 sinfo->signal,
13452 pCfg->reportMaxLinkSpeed,
13453 myRate,
13454 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013455 (int) pCfg->linkSpeedRssiMid,
13456 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070013457 (int) rate_flags,
13458 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013459#endif //LINKSPEED_DEBUG_ENABLED
13460
13461 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
13462 {
13463 // we do not want to necessarily report the current speed
13464 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
13465 {
13466 // report the max possible speed
13467 rssidx = 0;
13468 }
13469 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
13470 {
13471 // report the max possible speed with RSSI scaling
13472 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
13473 {
13474 // report the max possible speed
13475 rssidx = 0;
13476 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013477 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070013478 {
13479 // report middle speed
13480 rssidx = 1;
13481 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013482 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
13483 {
13484 // report middle speed
13485 rssidx = 2;
13486 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013487 else
13488 {
13489 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013490 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070013491 }
13492 }
13493 else
13494 {
13495 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
13496 hddLog(VOS_TRACE_LEVEL_ERROR,
13497 "%s: Invalid value for reportMaxLinkSpeed: %u",
13498 __func__, pCfg->reportMaxLinkSpeed);
13499 rssidx = 0;
13500 }
13501
13502 maxRate = 0;
13503
13504 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013505 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
13506 OperationalRates, &ORLeng))
13507 {
13508 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13509 /*To keep GUI happy*/
13510 return 0;
13511 }
13512
Jeff Johnson295189b2012-06-20 16:38:30 -070013513 for (i = 0; i < ORLeng; i++)
13514 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013515 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013516 {
13517 /* Validate Rate Set */
13518 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
13519 {
13520 currentRate = supported_data_rate[j].supported_rate[rssidx];
13521 break;
13522 }
13523 }
13524 /* Update MAX rate */
13525 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13526 }
13527
13528 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013529 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
13530 ExtendedRates, &ERLeng))
13531 {
13532 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13533 /*To keep GUI happy*/
13534 return 0;
13535 }
13536
Jeff Johnson295189b2012-06-20 16:38:30 -070013537 for (i = 0; i < ERLeng; i++)
13538 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013539 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013540 {
13541 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
13542 {
13543 currentRate = supported_data_rate[j].supported_rate[rssidx];
13544 break;
13545 }
13546 }
13547 /* Update MAX rate */
13548 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13549 }
c_hpothu79aab322014-07-14 21:11:01 +053013550
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013551 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053013552 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013553 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053013554 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070013555 {
c_hpothu79aab322014-07-14 21:11:01 +053013556 if (rate_flags & eHAL_TX_RATE_VHT80)
13557 mode = 2;
13558 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
13559 mode = 1;
13560 else
13561 mode = 0;
13562
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013563 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
13564 MCSRates, &MCSLeng))
13565 {
13566 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13567 /*To keep GUI happy*/
13568 return 0;
13569 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013570 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070013571#ifdef WLAN_FEATURE_11AC
13572 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013573 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070013574 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013575 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013576 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070013577 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070013578 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013579 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013580 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013581 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070013582 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013583 maxMCSIdx = 7;
13584 }
13585 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
13586 {
13587 maxMCSIdx = 8;
13588 }
13589 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
13590 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013591 //VHT20 is supporting 0~8
13592 if (rate_flags & eHAL_TX_RATE_VHT20)
13593 maxMCSIdx = 8;
13594 else
13595 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070013596 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013597
c_hpothu79aab322014-07-14 21:11:01 +053013598 if (0 != rssidx)/*check for scaled */
13599 {
13600 //get middle rate MCS index if rssi=1/2
13601 for (i=0; i <= maxMCSIdx; i++)
13602 {
13603 if (sinfo->signal <= rssiMcsTbl[mode][i])
13604 {
13605 maxMCSIdx = i;
13606 break;
13607 }
13608 }
13609 }
13610
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013611 if (rate_flags & eHAL_TX_RATE_VHT80)
13612 {
13613 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
13614 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
13615 }
13616 else if (rate_flags & eHAL_TX_RATE_VHT40)
13617 {
13618 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
13619 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
13620 }
13621 else if (rate_flags & eHAL_TX_RATE_VHT20)
13622 {
13623 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
13624 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
13625 }
13626
Leo Chang6f8870f2013-03-26 18:11:36 -070013627 maxSpeedMCS = 1;
13628 if (currentRate > maxRate)
13629 {
13630 maxRate = currentRate;
13631 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013632
Leo Chang6f8870f2013-03-26 18:11:36 -070013633 }
13634 else
13635#endif /* WLAN_FEATURE_11AC */
13636 {
13637 if (rate_flags & eHAL_TX_RATE_HT40)
13638 {
13639 rateFlag |= 1;
13640 }
13641 if (rate_flags & eHAL_TX_RATE_SGI)
13642 {
13643 rateFlag |= 2;
13644 }
13645
Girish Gowli01abcee2014-07-31 20:18:55 +053013646 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053013647 if (rssidx == 1 || rssidx == 2)
13648 {
13649 //get middle rate MCS index if rssi=1/2
13650 for (i=0; i <= 7; i++)
13651 {
13652 if (sinfo->signal <= rssiMcsTbl[mode][i])
13653 {
13654 temp = i+1;
13655 break;
13656 }
13657 }
13658 }
c_hpothu79aab322014-07-14 21:11:01 +053013659
13660 for (i = 0; i < MCSLeng; i++)
13661 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013662 for (j = 0; j < temp; j++)
13663 {
13664 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
13665 {
13666 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013667 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013668 break;
13669 }
13670 }
13671 if ((j < temp) && (currentRate > maxRate))
13672 {
13673 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070013674 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013675 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013676 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013677 }
13678 }
13679
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013680 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
13681 {
13682 maxRate = myRate;
13683 maxSpeedMCS = 1;
13684 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13685 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013686 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053013687 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070013688 {
13689 maxRate = myRate;
13690 if (rate_flags & eHAL_TX_RATE_LEGACY)
13691 {
13692 maxSpeedMCS = 0;
13693 }
13694 else
13695 {
13696 maxSpeedMCS = 1;
13697 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13698 }
13699 }
13700
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013701 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070013702 {
13703 sinfo->txrate.legacy = maxRate;
13704#ifdef LINKSPEED_DEBUG_ENABLED
13705 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
13706#endif //LINKSPEED_DEBUG_ENABLED
13707 }
13708 else
13709 {
13710 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070013711#ifdef WLAN_FEATURE_11AC
13712 sinfo->txrate.nss = 1;
13713 if (rate_flags & eHAL_TX_RATE_VHT80)
13714 {
13715 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013716 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070013717 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013718 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070013719 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013720 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13721 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13722 }
13723 else if (rate_flags & eHAL_TX_RATE_VHT20)
13724 {
13725 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13726 }
13727#endif /* WLAN_FEATURE_11AC */
13728 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
13729 {
13730 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13731 if (rate_flags & eHAL_TX_RATE_HT40)
13732 {
13733 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13734 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013735 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013736 if (rate_flags & eHAL_TX_RATE_SGI)
13737 {
13738 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13739 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013740
Jeff Johnson295189b2012-06-20 16:38:30 -070013741#ifdef LINKSPEED_DEBUG_ENABLED
13742 pr_info("Reporting MCS rate %d flags %x\n",
13743 sinfo->txrate.mcs,
13744 sinfo->txrate.flags );
13745#endif //LINKSPEED_DEBUG_ENABLED
13746 }
13747 }
13748 else
13749 {
13750 // report current rate instead of max rate
13751
13752 if (rate_flags & eHAL_TX_RATE_LEGACY)
13753 {
13754 //provide to the UI in units of 100kbps
13755 sinfo->txrate.legacy = myRate;
13756#ifdef LINKSPEED_DEBUG_ENABLED
13757 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
13758#endif //LINKSPEED_DEBUG_ENABLED
13759 }
13760 else
13761 {
13762 //must be MCS
13763 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013764#ifdef WLAN_FEATURE_11AC
13765 sinfo->txrate.nss = 1;
13766 if (rate_flags & eHAL_TX_RATE_VHT80)
13767 {
13768 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13769 }
13770 else
13771#endif /* WLAN_FEATURE_11AC */
13772 {
13773 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13774 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013775 if (rate_flags & eHAL_TX_RATE_SGI)
13776 {
13777 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13778 }
13779 if (rate_flags & eHAL_TX_RATE_HT40)
13780 {
13781 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13782 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013783#ifdef WLAN_FEATURE_11AC
13784 else if (rate_flags & eHAL_TX_RATE_VHT80)
13785 {
13786 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
13787 }
13788#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070013789#ifdef LINKSPEED_DEBUG_ENABLED
13790 pr_info("Reporting actual MCS rate %d flags %x\n",
13791 sinfo->txrate.mcs,
13792 sinfo->txrate.flags );
13793#endif //LINKSPEED_DEBUG_ENABLED
13794 }
13795 }
13796 sinfo->filled |= STATION_INFO_TX_BITRATE;
13797
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013798 sinfo->tx_packets =
13799 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
13800 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
13801 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
13802 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
13803
13804 sinfo->tx_retries =
13805 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
13806 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
13807 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
13808 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
13809
13810 sinfo->tx_failed =
13811 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
13812 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
13813 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
13814 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
13815
13816 sinfo->filled |=
13817 STATION_INFO_TX_PACKETS |
13818 STATION_INFO_TX_RETRIES |
13819 STATION_INFO_TX_FAILED;
13820
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013821 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13822 TRACE_CODE_HDD_CFG80211_GET_STA,
13823 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013824 EXIT();
13825 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013826}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013827#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
13828static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13829 const u8* mac, struct station_info *sinfo)
13830#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013831static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13832 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013833#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013834{
13835 int ret;
13836
13837 vos_ssr_protect(__func__);
13838 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
13839 vos_ssr_unprotect(__func__);
13840
13841 return ret;
13842}
13843
13844static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070013845 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070013846{
13847 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013848 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013849 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013850 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013851
Jeff Johnsone7245742012-09-05 17:12:55 -070013852 ENTER();
13853
Jeff Johnson295189b2012-06-20 16:38:30 -070013854 if (NULL == pAdapter)
13855 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013856 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013857 return -ENODEV;
13858 }
13859
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013860 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13861 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
13862 pAdapter->sessionId, timeout));
13863
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013864 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013865 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013866 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013867 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013868 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013869 }
13870
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013871 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
13872 (TRUE == pHddCtx->hdd_wlan_suspended) &&
13873 (pHddCtx->cfg_ini->fhostArpOffload) &&
13874 (eConnectionState_Associated ==
13875 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13876 {
Amar Singhald53568e2013-09-26 11:03:45 -070013877
13878 hddLog(VOS_TRACE_LEVEL_INFO,
13879 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053013880 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013881 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13882 {
13883 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013884 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013885 __func__, vos_status);
13886 }
13887 }
13888
Jeff Johnson295189b2012-06-20 16:38:30 -070013889 /**The get power cmd from the supplicant gets updated by the nl only
13890 *on successful execution of the function call
13891 *we are oppositely mapped w.r.t mode in the driver
13892 **/
13893 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
13894
13895 if (VOS_STATUS_E_FAILURE == vos_status)
13896 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013897 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13898 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013899 return -EINVAL;
13900 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013901 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013902 return 0;
13903}
13904
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013905static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
13906 struct net_device *dev, bool mode, int timeout)
13907{
13908 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013909
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013910 vos_ssr_protect(__func__);
13911 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
13912 vos_ssr_unprotect(__func__);
13913
13914 return ret;
13915}
Jeff Johnson295189b2012-06-20 16:38:30 -070013916#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013917static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
13918 struct net_device *netdev,
13919 u8 key_index)
13920{
13921 ENTER();
13922 return 0;
13923}
13924
Jeff Johnson295189b2012-06-20 16:38:30 -070013925static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013926 struct net_device *netdev,
13927 u8 key_index)
13928{
13929 int ret;
13930 vos_ssr_protect(__func__);
13931 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
13932 vos_ssr_unprotect(__func__);
13933 return ret;
13934}
13935#endif //LINUX_VERSION_CODE
13936
13937#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13938static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13939 struct net_device *dev,
13940 struct ieee80211_txq_params *params)
13941{
13942 ENTER();
13943 return 0;
13944}
13945#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13946static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13947 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013948{
Jeff Johnsone7245742012-09-05 17:12:55 -070013949 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070013950 return 0;
13951}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013952#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070013953
13954#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13955static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013956 struct net_device *dev,
13957 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013958{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013959 int ret;
13960
13961 vos_ssr_protect(__func__);
13962 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
13963 vos_ssr_unprotect(__func__);
13964 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013965}
13966#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13967static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
13968 struct ieee80211_txq_params *params)
13969{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013970 int ret;
13971
13972 vos_ssr_protect(__func__);
13973 ret = __wlan_hdd_set_txq_params(wiphy, params);
13974 vos_ssr_unprotect(__func__);
13975 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013976}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013977#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013978
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013979static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013980 struct net_device *dev,
13981 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070013982{
13983 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013984 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013985 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013986 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013987 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013988 v_CONTEXT_t pVosContext = NULL;
13989 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013990
Jeff Johnsone7245742012-09-05 17:12:55 -070013991 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013992
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013993 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070013994 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013995 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013996 return -EINVAL;
13997 }
13998
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013999 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14000 TRACE_CODE_HDD_CFG80211_DEL_STA,
14001 pAdapter->sessionId, pAdapter->device_mode));
14002
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014003 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14004 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014005 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014006 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014007 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014008 }
14009
Jeff Johnson295189b2012-06-20 16:38:30 -070014010 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070014011 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070014012 )
14013 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014014 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
14015 pSapCtx = VOS_GET_SAP_CB(pVosContext);
14016 if(pSapCtx == NULL){
14017 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14018 FL("psapCtx is NULL"));
14019 return -ENOENT;
14020 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014021 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070014022 {
14023 v_U16_t i;
14024 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
14025 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014026 if ((pSapCtx->aStaInfo[i].isUsed) &&
14027 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070014028 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014029 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014030 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014031 ETHER_ADDR_LEN);
14032
Jeff Johnson295189b2012-06-20 16:38:30 -070014033 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080014034 "%s: Delete STA with MAC::"
14035 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014036 __func__,
14037 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
14038 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070014039 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014040 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014041 }
14042 }
14043 }
14044 else
14045 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014046
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014047 vos_status = hdd_softap_GetStaId(pAdapter,
14048 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014049 if (!VOS_IS_STATUS_SUCCESS(vos_status))
14050 {
14051 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080014052 "%s: Skip this DEL STA as this is not used::"
14053 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014054 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014055 return -ENOENT;
14056 }
14057
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014058 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014059 {
14060 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080014061 "%s: Skip this DEL STA as deauth is in progress::"
14062 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014063 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014064 return -ENOENT;
14065 }
14066
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014067 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014068
Jeff Johnson295189b2012-06-20 16:38:30 -070014069 hddLog(VOS_TRACE_LEVEL_INFO,
14070 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080014071 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014072 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014073 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014074
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014075 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014076 if (!VOS_IS_STATUS_SUCCESS(vos_status))
14077 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014078 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014079 hddLog(VOS_TRACE_LEVEL_INFO,
14080 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080014081 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014082 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014083 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014084 return -ENOENT;
14085 }
14086
Jeff Johnson295189b2012-06-20 16:38:30 -070014087 }
14088 }
14089
14090 EXIT();
14091
14092 return 0;
14093}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014094
14095#ifdef CFG80211_DEL_STA_V2
14096static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14097 struct net_device *dev,
14098 struct station_del_parameters *param)
14099#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014100#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
14101static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14102 struct net_device *dev, const u8 *mac)
14103#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014104static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14105 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014106#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014107#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014108{
14109 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014110 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070014111
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014112 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014113
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014114#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014115 if (NULL == param) {
14116 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014117 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014118 return -EINVAL;
14119 }
14120
14121 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
14122 param->subtype, &delStaParams);
14123
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014124#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053014125 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014126 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014127#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014128 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
14129
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014130 vos_ssr_unprotect(__func__);
14131
14132 return ret;
14133}
14134
14135static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014136 struct net_device *dev,
14137#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14138 const u8 *mac,
14139#else
14140 u8 *mac,
14141#endif
14142 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014143{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014144 hdd_adapter_t *pAdapter;
14145 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014146 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014147#ifdef FEATURE_WLAN_TDLS
14148 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014149
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014150 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014151
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014152 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14153 if (NULL == pAdapter)
14154 {
14155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14156 "%s: Adapter is NULL",__func__);
14157 return -EINVAL;
14158 }
14159 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14160 status = wlan_hdd_validate_context(pHddCtx);
14161 if (0 != status)
14162 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014163 return status;
14164 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014165
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014166 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14167 TRACE_CODE_HDD_CFG80211_ADD_STA,
14168 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014169 mask = params->sta_flags_mask;
14170
14171 set = params->sta_flags_set;
14172
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014173 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014174 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
14175 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014176
14177 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
14178 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080014179 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014180 }
14181 }
14182#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014183 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014184 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014185}
14186
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014187#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
14188static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
14189 struct net_device *dev, const u8 *mac,
14190 struct station_parameters *params)
14191#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014192static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
14193 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014194#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014195{
14196 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014197
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014198 vos_ssr_protect(__func__);
14199 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
14200 vos_ssr_unprotect(__func__);
14201
14202 return ret;
14203}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014204#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070014205
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014206static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070014207 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014208{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014209 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14210 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014211 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014212 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014213 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014214 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070014215
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014216 ENTER();
14217
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014218 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014219 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014220 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014221 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014222 return -EINVAL;
14223 }
14224
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014225 if (!pmksa) {
14226 hddLog(LOGE, FL("pmksa is NULL"));
14227 return -EINVAL;
14228 }
14229
14230 if (!pmksa->bssid || !pmksa->pmkid) {
14231 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
14232 pmksa->bssid, pmksa->pmkid);
14233 return -EINVAL;
14234 }
14235
14236 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
14237 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14238
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014239 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14240 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014241 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014242 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014243 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014244 }
14245
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014246 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014247 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14248
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014249 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
14250 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014251
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014252 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014253 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014254 &pmk_id, 1, FALSE);
14255
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014256 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14257 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
14258 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014259
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014260 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014261 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014262}
14263
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014264static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
14265 struct cfg80211_pmksa *pmksa)
14266{
14267 int ret;
14268
14269 vos_ssr_protect(__func__);
14270 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
14271 vos_ssr_unprotect(__func__);
14272
14273 return ret;
14274}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014275
Wilson Yang6507c4e2013-10-01 20:11:19 -070014276
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014277static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070014278 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014279{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014280 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14281 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014282 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014283 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014284
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014285 ENTER();
14286
Wilson Yang6507c4e2013-10-01 20:11:19 -070014287 /* Validate pAdapter */
14288 if (NULL == pAdapter)
14289 {
14290 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
14291 return -EINVAL;
14292 }
14293
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014294 if (!pmksa) {
14295 hddLog(LOGE, FL("pmksa is NULL"));
14296 return -EINVAL;
14297 }
14298
14299 if (!pmksa->bssid) {
14300 hddLog(LOGE, FL("pmksa->bssid is NULL"));
14301 return -EINVAL;
14302 }
14303
Kiet Lam98c46a12014-10-31 15:34:57 -070014304 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
14305 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14306
Wilson Yang6507c4e2013-10-01 20:11:19 -070014307 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14308 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014309 if (0 != status)
14310 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014311 return status;
14312 }
14313
14314 /*Retrieve halHandle*/
14315 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14316
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014317 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14318 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
14319 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014320 /* Delete the PMKID CSR cache */
14321 if (eHAL_STATUS_SUCCESS !=
14322 sme_RoamDelPMKIDfromCache(halHandle,
14323 pAdapter->sessionId, pmksa->bssid, FALSE)) {
14324 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
14325 MAC_ADDR_ARRAY(pmksa->bssid));
14326 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014327 }
14328
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014329 EXIT();
14330 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014331}
14332
Wilson Yang6507c4e2013-10-01 20:11:19 -070014333
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014334static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
14335 struct cfg80211_pmksa *pmksa)
14336{
14337 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014338
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014339 vos_ssr_protect(__func__);
14340 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
14341 vos_ssr_unprotect(__func__);
14342
14343 return ret;
14344
14345}
14346
14347static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014348{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014349 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14350 tHalHandle halHandle;
14351 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014352 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014353
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014354 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070014355
14356 /* Validate pAdapter */
14357 if (NULL == pAdapter)
14358 {
14359 hddLog(VOS_TRACE_LEVEL_ERROR,
14360 "%s: Invalid Adapter" ,__func__);
14361 return -EINVAL;
14362 }
14363
14364 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14365 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014366 if (0 != status)
14367 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014368 return status;
14369 }
14370
14371 /*Retrieve halHandle*/
14372 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14373
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014374 /* Flush the PMKID cache in CSR */
14375 if (eHAL_STATUS_SUCCESS !=
14376 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
14377 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
14378 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014379 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014380 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080014381 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014382}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014383
14384static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
14385{
14386 int ret;
14387
14388 vos_ssr_protect(__func__);
14389 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
14390 vos_ssr_unprotect(__func__);
14391
14392 return ret;
14393}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014394#endif
14395
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014396#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014397static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14398 struct net_device *dev,
14399 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014400{
14401 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14402 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014403 hdd_context_t *pHddCtx;
14404 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014405
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014406 ENTER();
14407
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014408 if (NULL == pAdapter)
14409 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014410 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014411 return -ENODEV;
14412 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014413 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14414 ret = wlan_hdd_validate_context(pHddCtx);
14415 if (0 != ret)
14416 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014417 return ret;
14418 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014419 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014420 if (NULL == pHddStaCtx)
14421 {
14422 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
14423 return -EINVAL;
14424 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014425
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014426 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14427 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
14428 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014429 // Added for debug on reception of Re-assoc Req.
14430 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
14431 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014432 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014433 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080014434 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014435 }
14436
14437#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080014438 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014439 ftie->ie_len);
14440#endif
14441
14442 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014443 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14444 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014445 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014446
14447 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014448 return 0;
14449}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014450
14451static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14452 struct net_device *dev,
14453 struct cfg80211_update_ft_ies_params *ftie)
14454{
14455 int ret;
14456
14457 vos_ssr_protect(__func__);
14458 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
14459 vos_ssr_unprotect(__func__);
14460
14461 return ret;
14462}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014463#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014464
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014465#ifdef FEATURE_WLAN_SCAN_PNO
14466
14467void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
14468 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
14469{
14470 int ret;
14471 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
14472 hdd_context_t *pHddCtx;
14473
Nirav Shah80830bf2013-12-31 16:35:12 +053014474 ENTER();
14475
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014476 if (NULL == pAdapter)
14477 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014478 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014479 "%s: HDD adapter is Null", __func__);
14480 return ;
14481 }
14482
14483 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14484 if (NULL == pHddCtx)
14485 {
14486 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14487 "%s: HDD context is Null!!!", __func__);
14488 return ;
14489 }
14490
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014491 spin_lock(&pHddCtx->schedScan_lock);
14492 if (TRUE == pHddCtx->isWiphySuspended)
14493 {
14494 pHddCtx->isSchedScanUpdatePending = TRUE;
14495 spin_unlock(&pHddCtx->schedScan_lock);
14496 hddLog(VOS_TRACE_LEVEL_INFO,
14497 "%s: Update cfg80211 scan database after it resume", __func__);
14498 return ;
14499 }
14500 spin_unlock(&pHddCtx->schedScan_lock);
14501
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014502 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
14503
14504 if (0 > ret)
14505 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
14506
14507 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14509 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014510}
14511
14512/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014513 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014514 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014515 */
14516static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
14517{
14518 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
14519 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014520 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014521 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14522 int status = 0;
14523 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
14524
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014525 /* The current firmware design does not allow PNO during any
14526 * active sessions. Hence, determine the active sessions
14527 * and return a failure.
14528 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014529 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
14530 {
14531 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014532 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014533
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014534 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
14535 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
14536 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
14537 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
14538 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053014539 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014540 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014541 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014542 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014543 }
14544 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14545 pAdapterNode = pNext;
14546 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014547 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014548}
14549
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014550void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
14551{
14552 hdd_adapter_t *pAdapter = callbackContext;
14553 hdd_context_t *pHddCtx;
14554
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014555 ENTER();
14556
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014557 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
14558 {
14559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14560 FL("Invalid adapter or adapter has invalid magic"));
14561 return;
14562 }
14563
14564 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14565 if (0 != wlan_hdd_validate_context(pHddCtx))
14566 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014567 return;
14568 }
14569
c_hpothub53c45d2014-08-18 16:53:14 +053014570 if (VOS_STATUS_SUCCESS != status)
14571 {
14572 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014573 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053014574 pHddCtx->isPnoEnable = FALSE;
14575 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014576
14577 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
14578 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014579 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014580}
14581
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014582/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014583 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
14584 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014585 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014586static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014587 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14588{
14589 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014590 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014591 hdd_context_t *pHddCtx;
14592 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014593 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053014594 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
14595 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014596 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14597 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014598 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014599 hdd_config_t *pConfig = NULL;
14600 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014601
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014602 ENTER();
14603
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014604 if (NULL == pAdapter)
14605 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014607 "%s: HDD adapter is Null", __func__);
14608 return -ENODEV;
14609 }
14610
14611 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014612 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014613
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014614 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014615 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014616 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014617 }
14618
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014619 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014620 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14621 if (NULL == hHal)
14622 {
14623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14624 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014625 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014626 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014627 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14628 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
14629 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053014630 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014631 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053014632 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014633 {
14634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14635 "%s: aborting the existing scan is unsuccessfull", __func__);
14636 return -EBUSY;
14637 }
14638
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014639 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014640 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014641 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014642 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014643 return -EBUSY;
14644 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014645
c_hpothu37f21312014-04-09 21:49:54 +053014646 if (TRUE == pHddCtx->isPnoEnable)
14647 {
14648 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14649 FL("already PNO is enabled"));
14650 return -EBUSY;
14651 }
c_hpothu225aa7c2014-10-22 17:45:13 +053014652
14653 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
14654 {
14655 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14656 "%s: abort ROC failed ", __func__);
14657 return -EBUSY;
14658 }
14659
c_hpothu37f21312014-04-09 21:49:54 +053014660 pHddCtx->isPnoEnable = TRUE;
14661
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014662 pnoRequest.enable = 1; /*Enable PNO */
14663 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014664
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014665 if (( !pnoRequest.ucNetworksCount ) ||
14666 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014667 {
14668 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014669 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014670 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014671 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014672 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014673 goto error;
14674 }
14675
14676 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
14677 {
14678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014679 "%s: Incorrect number of channels %d",
14680 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014681 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014682 goto error;
14683 }
14684
14685 /* Framework provides one set of channels(all)
14686 * common for all saved profile */
14687 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14688 channels_allowed, &num_channels_allowed))
14689 {
14690 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14691 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014692 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014693 goto error;
14694 }
14695 /* Checking each channel against allowed channel list */
14696 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053014697 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014698 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014699 char chList [(request->n_channels*5)+1];
14700 int len;
14701 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014702 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014703 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014704 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014705 if (request->channels[i]->hw_value == channels_allowed[indx])
14706 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014707 if ((!pConfig->enableDFSPnoChnlScan) &&
14708 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
14709 {
14710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14711 "%s : Dropping DFS channel : %d",
14712 __func__,channels_allowed[indx]);
14713 num_ignore_dfs_ch++;
14714 break;
14715 }
14716
Nirav Shah80830bf2013-12-31 16:35:12 +053014717 valid_ch[num_ch++] = request->channels[i]->hw_value;
14718 len += snprintf(chList+len, 5, "%d ",
14719 request->channels[i]->hw_value);
14720 break ;
14721 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014722 }
14723 }
Nirav Shah80830bf2013-12-31 16:35:12 +053014724 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014725
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014726 /*If all channels are DFS and dropped, then ignore the PNO request*/
14727 if (num_ignore_dfs_ch == request->n_channels)
14728 {
14729 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14730 "%s : All requested channels are DFS channels", __func__);
14731 ret = -EINVAL;
14732 goto error;
14733 }
14734 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014735
14736 pnoRequest.aNetworks =
14737 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14738 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014739 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014740 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14741 FL("failed to allocate memory aNetworks %u"),
14742 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14743 goto error;
14744 }
14745 vos_mem_zero(pnoRequest.aNetworks,
14746 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14747
14748 /* Filling per profile params */
14749 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
14750 {
14751 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014752 request->match_sets[i].ssid.ssid_len;
14753
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014754 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
14755 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014756 {
14757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014758 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014759 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014760 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014761 goto error;
14762 }
14763
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014764 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014765 request->match_sets[i].ssid.ssid,
14766 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14768 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014769 i, pnoRequest.aNetworks[i].ssId.ssId);
14770 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
14771 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
14772 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014773
14774 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014775 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
14776 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014777
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014778 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014779 }
14780
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014781 for (i = 0; i < request->n_ssids; i++)
14782 {
14783 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014784 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014785 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014786 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014787 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014788 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014789 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014790 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014791 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014792 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014793 break;
14794 }
14795 j++;
14796 }
14797 }
14798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14799 "Number of hidden networks being Configured = %d",
14800 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080014802 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014803
14804 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14805 if (pnoRequest.p24GProbeTemplate == NULL)
14806 {
14807 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14808 FL("failed to allocate memory p24GProbeTemplate %u"),
14809 SIR_PNO_MAX_PB_REQ_SIZE);
14810 goto error;
14811 }
14812
14813 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14814 if (pnoRequest.p5GProbeTemplate == NULL)
14815 {
14816 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14817 FL("failed to allocate memory p5GProbeTemplate %u"),
14818 SIR_PNO_MAX_PB_REQ_SIZE);
14819 goto error;
14820 }
14821
14822 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14823 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14824
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053014825 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
14826 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014827 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014828 pnoRequest.us24GProbeTemplateLen = request->ie_len;
14829 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
14830 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014831
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014832 pnoRequest.us5GProbeTemplateLen = request->ie_len;
14833 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
14834 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014835 }
14836
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014837 /* Driver gets only one time interval which is hardcoded in
14838 * supplicant for 10000ms. Taking power consumption into account 6 timers
14839 * will be used, Timervalue is increased exponentially i.e 10,20,40,
14840 * 80,160,320 secs. And number of scan cycle for each timer
14841 * is configurable through INI param gPNOScanTimerRepeatValue.
14842 * If it is set to 0 only one timer will be used and PNO scan cycle
14843 * will be repeated after each interval specified by supplicant
14844 * till PNO is disabled.
14845 */
14846 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014847 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014848 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014849 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014850 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
14851
14852 tempInterval = (request->interval)/1000;
14853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14854 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
14855 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014856 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014857 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014858 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014859 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014860 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014861 tempInterval *= 2;
14862 }
14863 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014864 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014865
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014866 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014867
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014868 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014869 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
14870 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014871 pAdapter->pno_req_status = 0;
14872
Nirav Shah80830bf2013-12-31 16:35:12 +053014873 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14874 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014875 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
14876 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053014877
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014878 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014879 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014880 hdd_cfg80211_sched_scan_done_callback, pAdapter);
14881 if (eHAL_STATUS_SUCCESS != status)
14882 {
14883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014884 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014885 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014886 goto error;
14887 }
14888
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014889 ret = wait_for_completion_timeout(
14890 &pAdapter->pno_comp_var,
14891 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
14892 if (0 >= ret)
14893 {
14894 // Did not receive the response for PNO enable in time.
14895 // Assuming the PNO enable was success.
14896 // Returning error from here, because we timeout, results
14897 // in side effect of Wifi (Wifi Setting) not to work.
14898 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14899 FL("Timed out waiting for PNO to be Enabled"));
14900 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014901 }
14902
14903 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053014904 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014905
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014906error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014907 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14908 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053014909 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014910 if (pnoRequest.aNetworks)
14911 vos_mem_free(pnoRequest.aNetworks);
14912 if (pnoRequest.p24GProbeTemplate)
14913 vos_mem_free(pnoRequest.p24GProbeTemplate);
14914 if (pnoRequest.p5GProbeTemplate)
14915 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014916
14917 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014918 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014919}
14920
14921/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014922 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
14923 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014924 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014925static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
14926 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14927{
14928 int ret;
14929
14930 vos_ssr_protect(__func__);
14931 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
14932 vos_ssr_unprotect(__func__);
14933
14934 return ret;
14935}
14936
14937/*
14938 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
14939 * Function to disable PNO
14940 */
14941static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014942 struct net_device *dev)
14943{
14944 eHalStatus status = eHAL_STATUS_FAILURE;
14945 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14946 hdd_context_t *pHddCtx;
14947 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014948 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014949 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014950
14951 ENTER();
14952
14953 if (NULL == pAdapter)
14954 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014956 "%s: HDD adapter is Null", __func__);
14957 return -ENODEV;
14958 }
14959
14960 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014961
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014962 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014963 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014964 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014965 "%s: HDD context is Null", __func__);
14966 return -ENODEV;
14967 }
14968
14969 /* The return 0 is intentional when isLogpInProgress and
14970 * isLoadUnloadInProgress. We did observe a crash due to a return of
14971 * failure in sched_scan_stop , especially for a case where the unload
14972 * of the happens at the same time. The function __cfg80211_stop_sched_scan
14973 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
14974 * success. If it returns a failure , then its next invocation due to the
14975 * clean up of the second interface will have the dev pointer corresponding
14976 * to the first one leading to a crash.
14977 */
14978 if (pHddCtx->isLogpInProgress)
14979 {
14980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14981 "%s: LOGP in Progress. Ignore!!!", __func__);
14982 return ret;
14983 }
14984
Mihir Shete18156292014-03-11 15:38:30 +053014985 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014986 {
14987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14988 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14989 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014990 }
14991
14992 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14993 if (NULL == hHal)
14994 {
14995 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14996 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014997 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014998 }
14999
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015000 pnoRequest.enable = 0; /* Disable PNO */
15001 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015002
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053015003 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15004 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
15005 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053015006 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015007 pAdapter->sessionId,
15008 NULL, pAdapter);
15009 if (eHAL_STATUS_SUCCESS != status)
15010 {
15011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15012 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053015013 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053015014 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015015 }
c_hpothu37f21312014-04-09 21:49:54 +053015016 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015017
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053015018error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053015019 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053015020 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015021
15022 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053015023 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015024}
15025
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053015026/*
15027 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
15028 * NL interface to disable PNO
15029 */
15030static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
15031 struct net_device *dev)
15032{
15033 int ret;
15034
15035 vos_ssr_protect(__func__);
15036 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
15037 vos_ssr_unprotect(__func__);
15038
15039 return ret;
15040}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015041#endif /*FEATURE_WLAN_SCAN_PNO*/
15042
15043
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015044#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015045#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015046static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15047 struct net_device *dev,
15048 u8 *peer, u8 action_code,
15049 u8 dialog_token,
15050 u16 status_code, u32 peer_capability,
15051 const u8 *buf, size_t len)
15052#else /* TDLS_MGMT_VERSION2 */
15053#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
15054static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15055 struct net_device *dev,
15056 const u8 *peer, u8 action_code,
15057 u8 dialog_token, u16 status_code,
15058 u32 peer_capability, bool initiator,
15059 const u8 *buf, size_t len)
15060#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
15061static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15062 struct net_device *dev,
15063 const u8 *peer, u8 action_code,
15064 u8 dialog_token, u16 status_code,
15065 u32 peer_capability, const u8 *buf,
15066 size_t len)
15067#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
15068static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15069 struct net_device *dev,
15070 u8 *peer, u8 action_code,
15071 u8 dialog_token,
15072 u16 status_code, u32 peer_capability,
15073 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015074#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015075static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15076 struct net_device *dev,
15077 u8 *peer, u8 action_code,
15078 u8 dialog_token,
15079 u16 status_code, const u8 *buf,
15080 size_t len)
15081#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015082#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015083{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015084 hdd_adapter_t *pAdapter;
15085 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015086 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070015087 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080015088 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070015089 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015090 int ret;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015091#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015092 u32 peer_capability = 0;
15093#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015094 tANI_U16 numCurrTdlsPeers;
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015095 hdd_station_ctx_t *pHddStaCtx = NULL;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015096
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015097 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15098 if (NULL == pAdapter)
15099 {
15100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15101 "%s: Adapter is NULL",__func__);
15102 return -EINVAL;
15103 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015104 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15105 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
15106 pAdapter->sessionId, action_code));
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015107
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015108 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015109 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015110 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015111 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015112 "Invalid arguments");
15113 return -EINVAL;
15114 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015115
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015116 if (pHddCtx->isLogpInProgress)
15117 {
15118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15119 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053015120 wlan_hdd_tdls_set_link_status(pAdapter,
15121 peer,
15122 eTDLS_LINK_IDLE,
15123 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015124 return -EBUSY;
15125 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015126
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015127 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
15128 {
15129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15130 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
15131 return -EAGAIN;
15132 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015133
Hoonki Lee27511902013-03-14 18:19:06 -070015134 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015135 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015136 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070015137 "%s: TDLS mode is disabled OR not enabled in FW."
15138 MAC_ADDRESS_STR " action %d declined.",
15139 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015140 return -ENOTSUPP;
15141 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015142
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015143 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15144
15145 if( NULL == pHddStaCtx )
15146 {
15147 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15148 "%s: HDD station context NULL ",__func__);
15149 return -EINVAL;
15150 }
15151
15152 /* STA should be connected and authenticated
15153 * before sending any TDLS frames
15154 */
15155 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
15156 (FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
15157 {
15158 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15159 "STA is not connected or unauthenticated. "
15160 "connState %u, uIsAuthenticated %u",
15161 pHddStaCtx->conn_info.connState,
15162 pHddStaCtx->conn_info.uIsAuthenticated);
15163 return -EAGAIN;
15164 }
15165
Hoonki Lee27511902013-03-14 18:19:06 -070015166 /* other than teardown frame, other mgmt frames are not sent if disabled */
15167 if (SIR_MAC_TDLS_TEARDOWN != action_code)
15168 {
15169 /* if tdls_mode is disabled to respond to peer's request */
15170 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
15171 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015172 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070015173 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015174 " TDLS mode is disabled. action %d declined.",
15175 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070015176
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015177 return -ENOTSUPP;
Hoonki Lee27511902013-03-14 18:19:06 -070015178 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053015179
15180 if (vos_max_concurrent_connections_reached())
15181 {
15182 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15183 return -EINVAL;
15184 }
Hoonki Lee27511902013-03-14 18:19:06 -070015185 }
15186
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015187 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
15188 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053015189 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015190 {
15191 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015192 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015193 " TDLS setup is ongoing. action %d declined.",
15194 __func__, MAC_ADDR_ARRAY(peer), action_code);
15195 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015196 }
15197 }
15198
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015199 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
15200 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080015201 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015202 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15203 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080015204 {
15205 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
15206 we return error code at 'add_station()'. Hence we have this
15207 check again in addtion to add_station().
15208 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015209 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080015210 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015211 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15212 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015213 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
15214 __func__, MAC_ADDR_ARRAY(peer), action_code,
15215 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053015216 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080015217 }
15218 else
15219 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015220 /* maximum reached. tweak to send error code to peer and return
15221 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080015222 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015223 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15224 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015225 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
15226 __func__, MAC_ADDR_ARRAY(peer), status_code,
15227 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070015228 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015229 /* fall through to send setup resp with failure status
15230 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080015231 }
15232 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015233 else
15234 {
15235 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053015236 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015237 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015238 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015239 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015240 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
15241 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015242 return -EPERM;
15243 }
15244 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015245 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015246
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015247 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053015248 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015249 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
15250 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015251
Hoonki Leea34dd892013-02-05 22:56:02 -080015252 /*Except teardown responder will not be used so just make 0*/
15253 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015254 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080015255 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015256
15257 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015258 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015259
15260 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
15261 responder = pTdlsPeer->is_responder;
15262 else
Hoonki Leea34dd892013-02-05 22:56:02 -080015263 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015264 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053015265 "%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 -070015266 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
15267 dialog_token, status_code, len);
15268 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080015269 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015270 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015271
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015272 /* For explicit trigger of DIS_REQ come out of BMPS for
15273 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070015274 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015275 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
15276 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070015277 {
15278 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
15279 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015280 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015281 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015282 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
15283 if (status != VOS_STATUS_SUCCESS) {
15284 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
15285 }
Hoonki Lee14621352013-04-16 17:51:19 -070015286 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015287 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015288 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015289 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
15290 }
15291 }
Hoonki Lee14621352013-04-16 17:51:19 -070015292 }
15293
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015294 /* make sure doesn't call send_mgmt() while it is pending */
15295 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
15296 {
15297 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015298 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015299 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015300 ret = -EBUSY;
15301 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015302 }
15303
15304 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015305 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
15306
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015307 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter),
15308 pAdapter->sessionId, peer, action_code, dialog_token,
15309 status_code, peer_capability, (tANI_U8 *)buf, len,
15310 responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015311
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015312 if (VOS_STATUS_SUCCESS != status)
15313 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015314 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15315 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015316 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015317 ret = -EINVAL;
15318 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015319 }
15320
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015321 if ((SIR_MAC_TDLS_DIS_REQ == action_code) ||
15322 (SIR_MAC_TDLS_DIS_RSP == action_code))
15323 {
15324 /* for DIS_REQ/DIS_RSP, supplicant don't consider the return status.
15325 * So we no need to wait for tdls_mgmt_comp for sending ack status.
15326 */
15327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15328 "%s: tx done for frm %u", __func__, action_code);
15329 return 0;
15330 }
15331
15332 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15333 "%s: Wait for tdls_mgmt_comp. Timeout %u ms", __func__,
15334 WAIT_TIME_TDLS_MGMT);
15335
Hoonki Leed37cbb32013-04-20 00:31:14 -070015336 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
15337 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
15338
15339 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015340 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070015341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070015342 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070015343 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015344 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080015345
15346 if (pHddCtx->isLogpInProgress)
15347 {
15348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15349 "%s: LOGP in Progress. Ignore!!!", __func__);
15350 return -EAGAIN;
15351 }
15352
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015353 ret = -EINVAL;
15354 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015355 }
Ganesh Kondabattini8d0d35b2015-08-20 15:39:09 +053015356 else
15357 {
15358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15359 "%s: Mgmt Tx Completion status %ld TxCompletion %u",
15360 __func__, rc, pAdapter->mgmtTxCompletionStatus);
15361 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015362
Gopichand Nakkala05922802013-03-14 12:23:19 -070015363 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070015364 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015365 ret = max_sta_failed;
15366 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070015367 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015368
Hoonki Leea34dd892013-02-05 22:56:02 -080015369 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
15370 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015371 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015372 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15373 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015374 }
15375 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
15376 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015377 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015378 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15379 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015380 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015381
15382 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015383
15384tx_failed:
15385 /* add_station will be called before sending TDLS_SETUP_REQ and
15386 * TDLS_SETUP_RSP and as part of add_station driver will enable
15387 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
15388 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
15389 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
15390 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
15391 */
15392
15393 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
15394 (SIR_MAC_TDLS_SETUP_RSP == action_code))
15395 wlan_hdd_tdls_check_bmps(pAdapter);
15396 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015397}
15398
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015399#if TDLS_MGMT_VERSION2
15400static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15401 u8 *peer, u8 action_code, u8 dialog_token,
15402 u16 status_code, u32 peer_capability,
15403 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015404#else /* TDLS_MGMT_VERSION2 */
15405#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
15406static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15407 struct net_device *dev,
15408 const u8 *peer, u8 action_code,
15409 u8 dialog_token, u16 status_code,
15410 u32 peer_capability, bool initiator,
15411 const u8 *buf, size_t len)
15412#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
15413static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15414 struct net_device *dev,
15415 const u8 *peer, u8 action_code,
15416 u8 dialog_token, u16 status_code,
15417 u32 peer_capability, const u8 *buf,
15418 size_t len)
15419#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
15420static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15421 struct net_device *dev,
15422 u8 *peer, u8 action_code,
15423 u8 dialog_token,
15424 u16 status_code, u32 peer_capability,
15425 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015426#else
15427static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15428 u8 *peer, u8 action_code, u8 dialog_token,
15429 u16 status_code, const u8 *buf, size_t len)
15430#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015431#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015432{
15433 int ret;
15434
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015435 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015436#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015437 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15438 dialog_token, status_code,
15439 peer_capability, buf, len);
15440#else /* TDLS_MGMT_VERSION2 */
15441#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
15442 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15443 dialog_token, status_code,
15444 peer_capability, initiator,
15445 buf, len);
15446#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
15447 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15448 dialog_token, status_code,
15449 peer_capability, buf, len);
15450#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
15451 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15452 dialog_token, status_code,
15453 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015454#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015455 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15456 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015457#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015458#endif
15459 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015460
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015461 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015462}
Atul Mittal115287b2014-07-08 13:26:33 +053015463
15464int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015465#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15466 const u8 *peer,
15467#else
Atul Mittal115287b2014-07-08 13:26:33 +053015468 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015469#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015470 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053015471 cfg80211_exttdls_callback callback)
15472{
15473
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015474 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053015475 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015476 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053015477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15478 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
15479 __func__, MAC_ADDR_ARRAY(peer));
15480
15481 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15482 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15483
15484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015485 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15486 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15487 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015488 return -ENOTSUPP;
15489 }
15490
15491 /* To cater the requirement of establishing the TDLS link
15492 * irrespective of the data traffic , get an entry of TDLS peer.
15493 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015494 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015495 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
15496 if (pTdlsPeer == NULL) {
15497 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15498 "%s: peer " MAC_ADDRESS_STR " not existing",
15499 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015500 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015501 return -EINVAL;
15502 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015503 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015504
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015505 /* check FW TDLS Off Channel capability */
15506 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015507 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015508 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015509 {
15510 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
15511 pTdlsPeer->peerParams.global_operating_class =
15512 tdls_peer_params->global_operating_class;
15513 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
15514 pTdlsPeer->peerParams.min_bandwidth_kbps =
15515 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015516 /* check configured channel is valid, non dfs and
15517 * not current operating channel */
15518 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
15519 tdls_peer_params->channel)) &&
15520 (pHddStaCtx) &&
15521 (tdls_peer_params->channel !=
15522 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015523 {
15524 pTdlsPeer->isOffChannelConfigured = TRUE;
15525 }
15526 else
15527 {
15528 pTdlsPeer->isOffChannelConfigured = FALSE;
15529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15530 "%s: Configured Tdls Off Channel is not valid", __func__);
15531
15532 }
15533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015534 "%s: tdls_off_channel %d isOffChannelConfigured %d "
15535 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015536 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015537 pTdlsPeer->isOffChannelConfigured,
15538 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015539 }
15540 else
15541 {
15542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015543 "%s: TDLS off channel FW capability %d, "
15544 "host capab %d or Invalid TDLS Peer Params", __func__,
15545 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
15546 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015547 }
15548
Atul Mittal115287b2014-07-08 13:26:33 +053015549 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
15550
15551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15552 " %s TDLS Add Force Peer Failed",
15553 __func__);
15554 return -EINVAL;
15555 }
15556 /*EXT TDLS*/
15557
15558 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
15559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15560 " %s TDLS set callback Failed",
15561 __func__);
15562 return -EINVAL;
15563 }
15564
15565 return(0);
15566
15567}
15568
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015569int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
15570#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15571 const u8 *peer
15572#else
15573 u8 *peer
15574#endif
15575)
Atul Mittal115287b2014-07-08 13:26:33 +053015576{
15577
15578 hddTdlsPeer_t *pTdlsPeer;
15579 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15581 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
15582 __func__, MAC_ADDR_ARRAY(peer));
15583
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015584 if (0 != wlan_hdd_validate_context(pHddCtx)) {
15585 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
15586 return -EINVAL;
15587 }
15588
Atul Mittal115287b2014-07-08 13:26:33 +053015589 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15590 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15591
15592 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015593 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15594 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15595 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015596 return -ENOTSUPP;
15597 }
15598
15599
15600 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15601
15602 if ( NULL == pTdlsPeer ) {
15603 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015604 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053015605 __func__, MAC_ADDR_ARRAY(peer));
15606 return -EINVAL;
15607 }
15608 else {
15609 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
15610 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015611 /* if channel switch is configured, reset
15612 the channel for this peer */
15613 if (TRUE == pTdlsPeer->isOffChannelConfigured)
15614 {
15615 pTdlsPeer->peerParams.channel = 0;
15616 pTdlsPeer->isOffChannelConfigured = FALSE;
15617 }
Atul Mittal115287b2014-07-08 13:26:33 +053015618 }
15619
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015620 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
15621 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053015622 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015623 }
Atul Mittal115287b2014-07-08 13:26:33 +053015624
15625 /*EXT TDLS*/
15626
15627 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
15628
15629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15630 " %s TDLS set callback Failed",
15631 __func__);
15632 return -EINVAL;
15633 }
15634 return(0);
15635
15636}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015637static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015638#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15639 const u8 *peer,
15640#else
15641 u8 *peer,
15642#endif
15643 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015644{
15645 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15646 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015647 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015648 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015649
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015650 ENTER();
15651
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015652 if (!pAdapter) {
15653 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15654 return -EINVAL;
15655 }
15656
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015657 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15658 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
15659 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015660 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015661 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015662 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070015663 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015664 return -EINVAL;
15665 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015666
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015667 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015668 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015669 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015670 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015671 }
15672
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015673
15674 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015675 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015676 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015677 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015678 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
15679 "Cannot process TDLS commands",
15680 pHddCtx->cfg_ini->fEnableTDLSSupport,
15681 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015682 return -ENOTSUPP;
15683 }
15684
15685 switch (oper) {
15686 case NL80211_TDLS_ENABLE_LINK:
15687 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015688 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015689 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015690 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053015691 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015692 tANI_U16 numCurrTdlsPeers = 0;
15693 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015694 tANI_U8 suppChannelLen = 0;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015695
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015696 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15697 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
15698 __func__, MAC_ADDR_ARRAY(peer));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015699 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015700 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015701 if ( NULL == pTdlsPeer ) {
15702 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15703 " (oper %d) not exsting. ignored",
15704 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15705 return -EINVAL;
15706 }
15707
15708 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15709 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15710 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15711 "NL80211_TDLS_ENABLE_LINK");
15712
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070015713 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
15714 {
15715 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
15716 MAC_ADDRESS_STR " failed",
15717 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
15718 return -EINVAL;
15719 }
15720
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015721 /* before starting tdls connection, set tdls
15722 * off channel established status to default value */
15723 pTdlsPeer->isOffChannelEstablished = FALSE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015724 /* TDLS Off Channel, Disable tdls channel switch,
15725 when there are more than one tdls link */
15726 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053015727 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015728 {
15729 /* get connected peer and send disable tdls off chan */
15730 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015731 if ((connPeer) &&
15732 (connPeer->isOffChannelSupported == TRUE) &&
15733 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015734 {
15735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15736 "%s: More then one peer connected, Disable "
15737 "TDLS channel switch", __func__);
15738
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015739 connPeer->isOffChannelEstablished = FALSE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015740 ret = sme_SendTdlsChanSwitchReq(
15741 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015742 pAdapter->sessionId,
15743 connPeer->peerMac,
15744 connPeer->peerParams.channel,
15745 TDLS_OFF_CHANNEL_BW_OFFSET,
15746 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015747 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015748 hddLog(VOS_TRACE_LEVEL_ERROR,
15749 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015750 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015751 }
15752 else
15753 {
15754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15755 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015756 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015757 "isOffChannelConfigured %d",
15758 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015759 (connPeer ? (connPeer->isOffChannelSupported)
15760 : -1),
15761 (connPeer ? (connPeer->isOffChannelConfigured)
15762 : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015763 }
15764 }
15765
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015766 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015767 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015768 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053015769
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015770 if (0 != wlan_hdd_tdls_get_link_establish_params(
15771 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015772 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015773 return -EINVAL;
15774 }
15775 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015776
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015777 ret = sme_SendTdlsLinkEstablishParams(
15778 WLAN_HDD_GET_HAL_CTX(pAdapter),
15779 pAdapter->sessionId, peer,
15780 &tdlsLinkEstablishParams);
15781 if (ret != VOS_STATUS_SUCCESS) {
15782 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
15783 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015784 /* Send TDLS peer UAPSD capabilities to the firmware and
15785 * register with the TL on after the response for this operation
15786 * is received .
15787 */
15788 ret = wait_for_completion_interruptible_timeout(
15789 &pAdapter->tdls_link_establish_req_comp,
15790 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
15791 if (ret <= 0)
15792 {
15793 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015794 FL("Link Establish Request Failed Status %ld"),
15795 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015796 return -EINVAL;
15797 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015798 }
Atul Mittal115287b2014-07-08 13:26:33 +053015799 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15800 eTDLS_LINK_CONNECTED,
15801 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015802 staDesc.ucSTAId = pTdlsPeer->staId;
15803 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015804 ret = WLANTL_UpdateTdlsSTAClient(
15805 pHddCtx->pvosContext,
15806 &staDesc);
15807 if (ret != VOS_STATUS_SUCCESS) {
15808 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
15809 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053015810
Gopichand Nakkala471708b2013-06-04 20:03:01 +053015811 /* Mark TDLS client Authenticated .*/
15812 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
15813 pTdlsPeer->staId,
15814 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015815 if (VOS_STATUS_SUCCESS == status)
15816 {
Hoonki Lee14621352013-04-16 17:51:19 -070015817 if (pTdlsPeer->is_responder == 0)
15818 {
15819 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
15820
15821 wlan_hdd_tdls_timer_restart(pAdapter,
15822 &pTdlsPeer->initiatorWaitTimeoutTimer,
15823 WAIT_TIME_TDLS_INITIATOR);
15824 /* suspend initiator TX until it receives direct packet from the
15825 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015826 ret = WLANTL_SuspendDataTx(
15827 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15828 &staId, NULL);
15829 if (ret != VOS_STATUS_SUCCESS) {
15830 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
15831 }
Hoonki Lee14621352013-04-16 17:51:19 -070015832 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015833
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015834 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015835 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015836 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015837 suppChannelLen =
15838 tdlsLinkEstablishParams.supportedChannelsLen;
15839
15840 if ((suppChannelLen > 0) &&
15841 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
15842 {
15843 tANI_U8 suppPeerChannel = 0;
15844 int i = 0;
15845 for (i = 0U; i < suppChannelLen; i++)
15846 {
15847 suppPeerChannel =
15848 tdlsLinkEstablishParams.supportedChannels[i];
15849
15850 pTdlsPeer->isOffChannelSupported = FALSE;
15851 if (suppPeerChannel ==
15852 pTdlsPeer->peerParams.channel)
15853 {
15854 pTdlsPeer->isOffChannelSupported = TRUE;
15855 break;
15856 }
15857 }
15858 }
15859 else
15860 {
15861 pTdlsPeer->isOffChannelSupported = FALSE;
15862 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015863 }
15864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15865 "%s: TDLS channel switch request for channel "
15866 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015867 "%d isOffChannelSupported %d", __func__,
15868 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015869 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015870 suppChannelLen,
15871 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015872
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015873 /* TDLS Off Channel, Enable tdls channel switch,
15874 when their is only one tdls link and it supports */
15875 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15876 if ((numCurrTdlsPeers == 1) &&
15877 (TRUE == pTdlsPeer->isOffChannelSupported) &&
15878 (TRUE == pTdlsPeer->isOffChannelConfigured))
15879 {
15880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15881 "%s: Send TDLS channel switch request for channel %d",
15882 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015883
15884 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015885 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
15886 pAdapter->sessionId,
15887 pTdlsPeer->peerMac,
15888 pTdlsPeer->peerParams.channel,
15889 TDLS_OFF_CHANNEL_BW_OFFSET,
15890 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015891 if (ret != VOS_STATUS_SUCCESS) {
15892 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
15893 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015894 }
15895 else
15896 {
15897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15898 "%s: TDLS channel switch request not sent"
15899 " numCurrTdlsPeers %d "
15900 "isOffChannelSupported %d "
15901 "isOffChannelConfigured %d",
15902 __func__, numCurrTdlsPeers,
15903 pTdlsPeer->isOffChannelSupported,
15904 pTdlsPeer->isOffChannelConfigured);
15905 }
15906
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015907 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015908 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015909
15910 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015911 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
15912 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015913 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015914 int ac;
15915 uint8 ucAc[4] = { WLANTL_AC_VO,
15916 WLANTL_AC_VI,
15917 WLANTL_AC_BK,
15918 WLANTL_AC_BE };
15919 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
15920 for(ac=0; ac < 4; ac++)
15921 {
15922 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15923 pTdlsPeer->staId, ucAc[ac],
15924 tlTid[ac], tlTid[ac], 0, 0,
15925 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015926 if (status != VOS_STATUS_SUCCESS) {
15927 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
15928 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015929 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015930 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015931 }
15932
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015933 }
15934 break;
15935 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080015936 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015937 tANI_U16 numCurrTdlsPeers = 0;
15938 hddTdlsPeer_t *connPeer = NULL;
15939
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15941 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
15942 __func__, MAC_ADDR_ARRAY(peer));
15943
Sunil Dutt41de4e22013-11-14 18:09:02 +053015944 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15945
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015946
Sunil Dutt41de4e22013-11-14 18:09:02 +053015947 if ( NULL == pTdlsPeer ) {
15948 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15949 " (oper %d) not exsting. ignored",
15950 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15951 return -EINVAL;
15952 }
15953
15954 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15955 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15956 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15957 "NL80211_TDLS_DISABLE_LINK");
15958
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015959 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080015960 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015961 long status;
15962
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015963 /* set tdls off channel status to false for this peer */
15964 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053015965 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15966 eTDLS_LINK_TEARING,
15967 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
15968 eTDLS_LINK_UNSPECIFIED:
15969 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015970 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
15971
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015972 status = sme_DeleteTdlsPeerSta(
15973 WLAN_HDD_GET_HAL_CTX(pAdapter),
15974 pAdapter->sessionId, peer );
15975 if (status != VOS_STATUS_SUCCESS) {
15976 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15977 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015978
15979 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
15980 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053015981 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053015982 eTDLS_LINK_IDLE,
15983 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015984 if (status <= 0)
15985 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15987 "%s: Del station failed status %ld",
15988 __func__, status);
15989 return -EPERM;
15990 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015991
15992 /* TDLS Off Channel, Enable tdls channel switch,
15993 when their is only one tdls link and it supports */
15994 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15995 if (numCurrTdlsPeers == 1)
15996 {
15997 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15998 if ((connPeer) &&
15999 (connPeer->isOffChannelSupported == TRUE) &&
16000 (connPeer->isOffChannelConfigured == TRUE))
16001 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053016002 connPeer->isOffChannelEstablished = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053016003 status = sme_SendTdlsChanSwitchReq(
16004 WLAN_HDD_GET_HAL_CTX(pAdapter),
16005 pAdapter->sessionId,
16006 connPeer->peerMac,
16007 connPeer->peerParams.channel,
16008 TDLS_OFF_CHANNEL_BW_OFFSET,
16009 TDLS_CHANNEL_SWITCH_ENABLE);
16010 if (status != VOS_STATUS_SUCCESS) {
16011 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
16012 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016013 }
16014 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16015 "%s: TDLS channel switch "
16016 "isOffChannelSupported %d "
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053016017 "isOffChannelConfigured %d "
16018 "isOffChannelEstablished %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016019 __func__,
16020 (connPeer ? connPeer->isOffChannelSupported : -1),
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053016021 (connPeer ? connPeer->isOffChannelConfigured : -1),
16022 (connPeer ? connPeer->isOffChannelEstablished : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016023 }
16024 else
16025 {
16026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16027 "%s: TDLS channel switch request not sent "
16028 "numCurrTdlsPeers %d ",
16029 __func__, numCurrTdlsPeers);
16030 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080016031 }
16032 else
16033 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16035 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080016036 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080016037 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070016038 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016039 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053016040 {
Atul Mittal115287b2014-07-08 13:26:33 +053016041 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053016042
Atul Mittal115287b2014-07-08 13:26:33 +053016043 if (0 != status)
16044 {
16045 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053016046 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053016047 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053016048 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053016049 break;
16050 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016051 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053016052 {
Atul Mittal115287b2014-07-08 13:26:33 +053016053 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
16054 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053016055 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053016056 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053016057
Atul Mittal115287b2014-07-08 13:26:33 +053016058 if (0 != status)
16059 {
16060 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053016061 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053016062 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053016063 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053016064 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053016065 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016066 case NL80211_TDLS_DISCOVERY_REQ:
16067 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053016069 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016070 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016071 return -ENOTSUPP;
16072 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016073 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16074 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016075 return -ENOTSUPP;
16076 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016077
16078 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016079 return 0;
16080}
Chilam NG571c65a2013-01-19 12:27:36 +053016081
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016082static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016083#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16084 const u8 *peer,
16085#else
16086 u8 *peer,
16087#endif
16088 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016089{
16090 int ret;
16091
16092 vos_ssr_protect(__func__);
16093 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
16094 vos_ssr_unprotect(__func__);
16095
16096 return ret;
16097}
16098
Chilam NG571c65a2013-01-19 12:27:36 +053016099int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
16100 struct net_device *dev, u8 *peer)
16101{
Arif Hussaina7c8e412013-11-20 11:06:42 -080016102 hddLog(VOS_TRACE_LEVEL_INFO,
16103 "tdls send discover req: "MAC_ADDRESS_STR,
16104 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053016105
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016106#if TDLS_MGMT_VERSION2
16107 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16108 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16109#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016110#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
16111 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16112 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
16113#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16114 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16115 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16116#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
16117 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16118 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16119#else
Chilam NG571c65a2013-01-19 12:27:36 +053016120 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16121 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016122#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016123#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053016124}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016125#endif
16126
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016127#ifdef WLAN_FEATURE_GTK_OFFLOAD
16128/*
16129 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
16130 * Callback rountine called upon receiving response for
16131 * get offload info
16132 */
16133void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
16134 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
16135{
16136
16137 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016138 tANI_U8 tempReplayCounter[8];
16139 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016140
16141 ENTER();
16142
16143 if (NULL == pAdapter)
16144 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053016145 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016146 "%s: HDD adapter is Null", __func__);
16147 return ;
16148 }
16149
16150 if (NULL == pGtkOffloadGetInfoRsp)
16151 {
16152 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16153 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
16154 return ;
16155 }
16156
16157 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
16158 {
16159 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16160 "%s: wlan Failed to get replay counter value",
16161 __func__);
16162 return ;
16163 }
16164
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016165 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16166 /* Update replay counter */
16167 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
16168 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
16169
16170 {
16171 /* changing from little to big endian since supplicant
16172 * works on big endian format
16173 */
16174 int i;
16175 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
16176
16177 for (i = 0; i < 8; i++)
16178 {
16179 tempReplayCounter[7-i] = (tANI_U8)p[i];
16180 }
16181 }
16182
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016183 /* Update replay counter to NL */
16184 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016185 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016186}
16187
16188/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016189 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016190 * This function is used to offload GTK rekeying job to the firmware.
16191 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016192int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016193 struct cfg80211_gtk_rekey_data *data)
16194{
16195 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16196 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16197 hdd_station_ctx_t *pHddStaCtx;
16198 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016199 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016200 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016201 eHalStatus status = eHAL_STATUS_FAILURE;
16202
16203 ENTER();
16204
16205 if (NULL == pAdapter)
16206 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016207 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016208 "%s: HDD adapter is Null", __func__);
16209 return -ENODEV;
16210 }
16211
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016212 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16213 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
16214 pAdapter->sessionId, pAdapter->device_mode));
16215
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016216 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016217 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016218 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016219 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016220 }
16221
16222 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16223 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
16224 if (NULL == hHal)
16225 {
16226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16227 "%s: HAL context is Null!!!", __func__);
16228 return -EAGAIN;
16229 }
16230
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016231 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
16232 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
16233 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
16234 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016235 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016236 {
16237 /* changing from big to little endian since driver
16238 * works on little endian format
16239 */
16240 tANI_U8 *p =
16241 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
16242 int i;
16243
16244 for (i = 0; i < 8; i++)
16245 {
16246 p[7-i] = data->replay_ctr[i];
16247 }
16248 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016249
16250 if (TRUE == pHddCtx->hdd_wlan_suspended)
16251 {
16252 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016253 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
16254 sizeof (tSirGtkOffloadParams));
16255 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016256 pAdapter->sessionId);
16257
16258 if (eHAL_STATUS_SUCCESS != status)
16259 {
16260 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16261 "%s: sme_SetGTKOffload failed, returned %d",
16262 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053016263
16264 /* Need to clear any trace of key value in the memory.
16265 * Thus zero out the memory even though it is local
16266 * variable.
16267 */
16268 vos_mem_zero(&hddGtkOffloadReqParams,
16269 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016270 return status;
16271 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16273 "%s: sme_SetGTKOffload successfull", __func__);
16274 }
16275 else
16276 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16278 "%s: wlan not suspended GTKOffload request is stored",
16279 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016280 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016281
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053016282 /* Need to clear any trace of key value in the memory.
16283 * Thus zero out the memory even though it is local
16284 * variable.
16285 */
16286 vos_mem_zero(&hddGtkOffloadReqParams,
16287 sizeof(hddGtkOffloadReqParams));
16288
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016289 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016290 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016291}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016292
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016293int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
16294 struct cfg80211_gtk_rekey_data *data)
16295{
16296 int ret;
16297
16298 vos_ssr_protect(__func__);
16299 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
16300 vos_ssr_unprotect(__func__);
16301
16302 return ret;
16303}
16304#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016305/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016306 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016307 * This function is used to set access control policy
16308 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016309static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16310 struct net_device *dev,
16311 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016312{
16313 int i;
16314 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16315 hdd_hostapd_state_t *pHostapdState;
16316 tsap_Config_t *pConfig;
16317 v_CONTEXT_t pVosContext = NULL;
16318 hdd_context_t *pHddCtx;
16319 int status;
16320
16321 ENTER();
16322
16323 if (NULL == pAdapter)
16324 {
16325 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16326 "%s: HDD adapter is Null", __func__);
16327 return -ENODEV;
16328 }
16329
16330 if (NULL == params)
16331 {
16332 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16333 "%s: params is Null", __func__);
16334 return -EINVAL;
16335 }
16336
16337 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16338 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016339 if (0 != status)
16340 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016341 return status;
16342 }
16343
16344 pVosContext = pHddCtx->pvosContext;
16345 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
16346
16347 if (NULL == pHostapdState)
16348 {
16349 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16350 "%s: pHostapdState is Null", __func__);
16351 return -EINVAL;
16352 }
16353
16354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
16355 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016356 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16357 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
16358 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016359
16360 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
16361 {
16362 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
16363
16364 /* default value */
16365 pConfig->num_accept_mac = 0;
16366 pConfig->num_deny_mac = 0;
16367
16368 /**
16369 * access control policy
16370 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
16371 * listed in hostapd.deny file.
16372 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
16373 * listed in hostapd.accept file.
16374 */
16375 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
16376 {
16377 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
16378 }
16379 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
16380 {
16381 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
16382 }
16383 else
16384 {
16385 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16386 "%s:Acl Policy : %d is not supported",
16387 __func__, params->acl_policy);
16388 return -ENOTSUPP;
16389 }
16390
16391 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
16392 {
16393 pConfig->num_accept_mac = params->n_acl_entries;
16394 for (i = 0; i < params->n_acl_entries; i++)
16395 {
16396 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16397 "** Add ACL MAC entry %i in WhiletList :"
16398 MAC_ADDRESS_STR, i,
16399 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16400
16401 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
16402 sizeof(qcmacaddr));
16403 }
16404 }
16405 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
16406 {
16407 pConfig->num_deny_mac = params->n_acl_entries;
16408 for (i = 0; i < params->n_acl_entries; i++)
16409 {
16410 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16411 "** Add ACL MAC entry %i in BlackList :"
16412 MAC_ADDRESS_STR, i,
16413 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16414
16415 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
16416 sizeof(qcmacaddr));
16417 }
16418 }
16419
16420 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
16421 {
16422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16423 "%s: SAP Set Mac Acl fail", __func__);
16424 return -EINVAL;
16425 }
16426 }
16427 else
16428 {
16429 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053016430 "%s: Invalid device_mode = %s (%d)",
16431 __func__, hdd_device_modetoString(pAdapter->device_mode),
16432 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016433 return -EINVAL;
16434 }
16435
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016436 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016437 return 0;
16438}
16439
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016440static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16441 struct net_device *dev,
16442 const struct cfg80211_acl_data *params)
16443{
16444 int ret;
16445 vos_ssr_protect(__func__);
16446 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
16447 vos_ssr_unprotect(__func__);
16448
16449 return ret;
16450}
16451
Leo Chang9056f462013-08-01 19:21:11 -070016452#ifdef WLAN_NL80211_TESTMODE
16453#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070016454void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070016455(
16456 void *pAdapter,
16457 void *indCont
16458)
16459{
Leo Changd9df8aa2013-09-26 13:32:26 -070016460 tSirLPHBInd *lphbInd;
16461 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053016462 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070016463
16464 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016465 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070016466
c_hpothu73f35e62014-04-18 13:40:08 +053016467 if (pAdapter == NULL)
16468 {
16469 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16470 "%s: pAdapter is NULL\n",__func__);
16471 return;
16472 }
16473
Leo Chang9056f462013-08-01 19:21:11 -070016474 if (NULL == indCont)
16475 {
16476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016477 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070016478 return;
16479 }
16480
c_hpothu73f35e62014-04-18 13:40:08 +053016481 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070016482 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070016483 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053016484 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070016485 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070016486 GFP_ATOMIC);
16487 if (!skb)
16488 {
16489 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16490 "LPHB timeout, NL buffer alloc fail");
16491 return;
16492 }
16493
Leo Changac3ba772013-10-07 09:47:04 -070016494 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070016495 {
16496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16497 "WLAN_HDD_TM_ATTR_CMD put fail");
16498 goto nla_put_failure;
16499 }
Leo Changac3ba772013-10-07 09:47:04 -070016500 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070016501 {
16502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16503 "WLAN_HDD_TM_ATTR_TYPE put fail");
16504 goto nla_put_failure;
16505 }
Leo Changac3ba772013-10-07 09:47:04 -070016506 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070016507 sizeof(tSirLPHBInd), lphbInd))
16508 {
16509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16510 "WLAN_HDD_TM_ATTR_DATA put fail");
16511 goto nla_put_failure;
16512 }
Leo Chang9056f462013-08-01 19:21:11 -070016513 cfg80211_testmode_event(skb, GFP_ATOMIC);
16514 return;
16515
16516nla_put_failure:
16517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16518 "NLA Put fail");
16519 kfree_skb(skb);
16520
16521 return;
16522}
16523#endif /* FEATURE_WLAN_LPHB */
16524
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016525static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070016526{
16527 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
16528 int err = 0;
16529#ifdef FEATURE_WLAN_LPHB
16530 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070016531 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016532
16533 ENTER();
16534
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016535 err = wlan_hdd_validate_context(pHddCtx);
16536 if (0 != err)
16537 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016538 return err;
16539 }
Leo Chang9056f462013-08-01 19:21:11 -070016540#endif /* FEATURE_WLAN_LPHB */
16541
16542 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
16543 if (err)
16544 {
16545 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16546 "%s Testmode INV ATTR", __func__);
16547 return err;
16548 }
16549
16550 if (!tb[WLAN_HDD_TM_ATTR_CMD])
16551 {
16552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16553 "%s Testmode INV CMD", __func__);
16554 return -EINVAL;
16555 }
16556
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016557 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16558 TRACE_CODE_HDD_CFG80211_TESTMODE,
16559 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070016560 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
16561 {
16562#ifdef FEATURE_WLAN_LPHB
16563 /* Low Power Heartbeat configuration request */
16564 case WLAN_HDD_TM_CMD_WLAN_HB:
16565 {
16566 int buf_len;
16567 void *buf;
16568 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080016569 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070016570
16571 if (!tb[WLAN_HDD_TM_ATTR_DATA])
16572 {
16573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16574 "%s Testmode INV DATA", __func__);
16575 return -EINVAL;
16576 }
16577
16578 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
16579 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080016580
16581 hb_params_temp =(tSirLPHBReq *)buf;
16582 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
16583 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
16584 return -EINVAL;
16585
Leo Chang9056f462013-08-01 19:21:11 -070016586 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
16587 if (NULL == hb_params)
16588 {
16589 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16590 "%s Request Buffer Alloc Fail", __func__);
16591 return -EINVAL;
16592 }
16593
16594 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070016595 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
16596 hb_params,
16597 wlan_hdd_cfg80211_lphb_ind_handler);
16598 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070016599 {
Leo Changd9df8aa2013-09-26 13:32:26 -070016600 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16601 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070016602 vos_mem_free(hb_params);
16603 }
Leo Chang9056f462013-08-01 19:21:11 -070016604 return 0;
16605 }
16606#endif /* FEATURE_WLAN_LPHB */
16607 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16609 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070016610 return -EOPNOTSUPP;
16611 }
16612
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016613 EXIT();
16614 return err;
Leo Chang9056f462013-08-01 19:21:11 -070016615}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016616
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053016617static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
16618#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
16619 struct wireless_dev *wdev,
16620#endif
16621 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016622{
16623 int ret;
16624
16625 vos_ssr_protect(__func__);
16626 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
16627 vos_ssr_unprotect(__func__);
16628
16629 return ret;
16630}
Leo Chang9056f462013-08-01 19:21:11 -070016631#endif /* CONFIG_NL80211_TESTMODE */
16632
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016633static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016634 struct net_device *dev,
16635 int idx, struct survey_info *survey)
16636{
16637 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16638 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053016639 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016640 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053016641 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016642 v_S7_t snr,rssi;
16643 int status, i, j, filled = 0;
16644
16645 ENTER();
16646
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016647 if (NULL == pAdapter)
16648 {
16649 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16650 "%s: HDD adapter is Null", __func__);
16651 return -ENODEV;
16652 }
16653
16654 if (NULL == wiphy)
16655 {
16656 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16657 "%s: wiphy is Null", __func__);
16658 return -ENODEV;
16659 }
16660
16661 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16662 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016663 if (0 != status)
16664 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016665 return status;
16666 }
16667
Mihir Sheted9072e02013-08-21 17:02:29 +053016668 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16669
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016670 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053016671 0 != pAdapter->survey_idx ||
16672 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016673 {
16674 /* The survey dump ops when implemented completely is expected to
16675 * return a survey of all channels and the ops is called by the
16676 * kernel with incremental values of the argument 'idx' till it
16677 * returns -ENONET. But we can only support the survey for the
16678 * operating channel for now. survey_idx is used to track
16679 * that the ops is called only once and then return -ENONET for
16680 * the next iteration
16681 */
16682 pAdapter->survey_idx = 0;
16683 return -ENONET;
16684 }
16685
Mukul Sharma9d5233b2015-06-11 20:28:20 +053016686 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
16687 {
16688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16689 "%s: Roaming in progress, hence return ", __func__);
16690 return -ENONET;
16691 }
16692
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016693 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16694
16695 wlan_hdd_get_snr(pAdapter, &snr);
16696 wlan_hdd_get_rssi(pAdapter, &rssi);
16697
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016698 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16699 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
16700 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016701 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
16702 hdd_wlan_get_freq(channel, &freq);
16703
16704
16705 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
16706 {
16707 if (NULL == wiphy->bands[i])
16708 {
16709 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
16710 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
16711 continue;
16712 }
16713
16714 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
16715 {
16716 struct ieee80211_supported_band *band = wiphy->bands[i];
16717
16718 if (band->channels[j].center_freq == (v_U16_t)freq)
16719 {
16720 survey->channel = &band->channels[j];
16721 /* The Rx BDs contain SNR values in dB for the received frames
16722 * while the supplicant expects noise. So we calculate and
16723 * return the value of noise (dBm)
16724 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
16725 */
16726 survey->noise = rssi - snr;
16727 survey->filled = SURVEY_INFO_NOISE_DBM;
16728 filled = 1;
16729 }
16730 }
16731 }
16732
16733 if (filled)
16734 pAdapter->survey_idx = 1;
16735 else
16736 {
16737 pAdapter->survey_idx = 0;
16738 return -ENONET;
16739 }
16740
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016741 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016742 return 0;
16743}
16744
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016745static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
16746 struct net_device *dev,
16747 int idx, struct survey_info *survey)
16748{
16749 int ret;
16750
16751 vos_ssr_protect(__func__);
16752 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
16753 vos_ssr_unprotect(__func__);
16754
16755 return ret;
16756}
16757
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016758/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016759 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016760 * this is called when cfg80211 driver resume
16761 * driver updates latest sched_scan scan result(if any) to cfg80211 database
16762 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016763int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016764{
16765 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16766 hdd_adapter_t *pAdapter;
16767 hdd_adapter_list_node_t *pAdapterNode, *pNext;
16768 VOS_STATUS status = VOS_STATUS_SUCCESS;
16769
16770 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016771
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016772 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016773 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016774 return 0;
16775 }
16776
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016777 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
16778 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016779 spin_lock(&pHddCtx->schedScan_lock);
16780 pHddCtx->isWiphySuspended = FALSE;
16781 if (TRUE != pHddCtx->isSchedScanUpdatePending)
16782 {
16783 spin_unlock(&pHddCtx->schedScan_lock);
16784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16785 "%s: Return resume is not due to PNO indication", __func__);
16786 return 0;
16787 }
16788 // Reset flag to avoid updatating cfg80211 data old results again
16789 pHddCtx->isSchedScanUpdatePending = FALSE;
16790 spin_unlock(&pHddCtx->schedScan_lock);
16791
16792 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
16793
16794 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
16795 {
16796 pAdapter = pAdapterNode->pAdapter;
16797 if ( (NULL != pAdapter) &&
16798 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
16799 {
16800 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016801 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16803 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016804 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016805 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016806 {
16807 /* Acquire wakelock to handle the case where APP's tries to
16808 * suspend immediately after updating the scan results. Whis
16809 * results in app's is in suspended state and not able to
16810 * process the connect request to AP
16811 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053016812 hdd_prevent_suspend_timeout(2000,
16813 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016814 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016815 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016816
16817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16818 "%s : cfg80211 scan result database updated", __func__);
16819
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016820 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016821 return 0;
16822
16823 }
16824 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16825 pAdapterNode = pNext;
16826 }
16827
16828 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16829 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016830 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016831 return 0;
16832}
16833
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016834int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
16835{
16836 int ret;
16837
16838 vos_ssr_protect(__func__);
16839 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
16840 vos_ssr_unprotect(__func__);
16841
16842 return ret;
16843}
16844
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016845/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016846 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016847 * this is called when cfg80211 driver suspends
16848 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016849int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016850 struct cfg80211_wowlan *wow)
16851{
16852 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016853 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016854
16855 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016856
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016857 ret = wlan_hdd_validate_context(pHddCtx);
16858 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016859 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016860 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016861 }
16862
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016863
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016864 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16865 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
16866 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016867 pHddCtx->isWiphySuspended = TRUE;
16868
16869 EXIT();
16870
16871 return 0;
16872}
16873
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016874int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
16875 struct cfg80211_wowlan *wow)
16876{
16877 int ret;
16878
16879 vos_ssr_protect(__func__);
16880 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
16881 vos_ssr_unprotect(__func__);
16882
16883 return ret;
16884}
Jeff Johnson295189b2012-06-20 16:38:30 -070016885/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016886static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070016887{
16888 .add_virtual_intf = wlan_hdd_add_virtual_intf,
16889 .del_virtual_intf = wlan_hdd_del_virtual_intf,
16890 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
16891 .change_station = wlan_hdd_change_station,
16892#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
16893 .add_beacon = wlan_hdd_cfg80211_add_beacon,
16894 .del_beacon = wlan_hdd_cfg80211_del_beacon,
16895 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016896#else
16897 .start_ap = wlan_hdd_cfg80211_start_ap,
16898 .change_beacon = wlan_hdd_cfg80211_change_beacon,
16899 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070016900#endif
16901 .change_bss = wlan_hdd_cfg80211_change_bss,
16902 .add_key = wlan_hdd_cfg80211_add_key,
16903 .get_key = wlan_hdd_cfg80211_get_key,
16904 .del_key = wlan_hdd_cfg80211_del_key,
16905 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016906#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070016907 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016908#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016909 .scan = wlan_hdd_cfg80211_scan,
16910 .connect = wlan_hdd_cfg80211_connect,
16911 .disconnect = wlan_hdd_cfg80211_disconnect,
16912 .join_ibss = wlan_hdd_cfg80211_join_ibss,
16913 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
16914 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
16915 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
16916 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070016917 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
16918 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053016919 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070016920#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16921 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
16922 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
16923 .set_txq_params = wlan_hdd_set_txq_params,
16924#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016925 .get_station = wlan_hdd_cfg80211_get_station,
16926 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
16927 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016928 .add_station = wlan_hdd_cfg80211_add_station,
16929#ifdef FEATURE_WLAN_LFR
16930 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
16931 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
16932 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
16933#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016934#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
16935 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
16936#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016937#ifdef FEATURE_WLAN_TDLS
16938 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
16939 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
16940#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016941#ifdef WLAN_FEATURE_GTK_OFFLOAD
16942 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
16943#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016944#ifdef FEATURE_WLAN_SCAN_PNO
16945 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
16946 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
16947#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016948 .resume = wlan_hdd_cfg80211_resume_wlan,
16949 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016950 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070016951#ifdef WLAN_NL80211_TESTMODE
16952 .testmode_cmd = wlan_hdd_cfg80211_testmode,
16953#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016954 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070016955};
16956