blob: f944e8bc8d34de340012b2e23401817bf22b7bed [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +053026 *
Kiet Lamaa8e15a2014-02-11 23:30:06 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Kiet Lama7f454d2014-07-24 12:04:06 -070030
31
Jeff Johnson295189b2012-06-20 16:38:30 -070032/**========================================================================
33
34 \file wlan_hdd_cfg80211.c
35
36 \brief WLAN Host Device Driver implementation
37
Jeff Johnson295189b2012-06-20 16:38:30 -070038 ========================================================================*/
39
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070040/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070041
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070042 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070043
44
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070045 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070047
48
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070049 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070050
51
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070052 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070053 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070054 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070055
56 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070057 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070058 ==========================================================================*/
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060
61#include <linux/version.h>
62#include <linux/module.h>
63#include <linux/kernel.h>
64#include <linux/init.h>
65#include <linux/wireless.h>
66#include <wlan_hdd_includes.h>
67#include <net/arp.h>
68#include <net/cfg80211.h>
69#include <linux/wireless.h>
70#include <wlan_hdd_wowl.h>
71#include <aniGlobal.h>
72#include "ccmApi.h"
73#include "sirParams.h"
74#include "dot11f.h"
75#include "wlan_hdd_assoc.h"
76#include "wlan_hdd_wext.h"
77#include "sme_Api.h"
78#include "wlan_hdd_p2p.h"
79#include "wlan_hdd_cfg80211.h"
80#include "wlan_hdd_hostapd.h"
81#include "sapInternal.h"
82#include "wlan_hdd_softap_tx_rx.h"
83#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053084#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053085#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053086#include "wlan_hdd_trace.h"
87#include "vos_types.h"
88#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070089#ifdef WLAN_BTAMP_FEATURE
90#include "bap_hdd_misc.h"
91#endif
92#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080093#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053094#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053095#include "wlan_qct_wda.h"
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053096#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070097#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070098
99#define g_mode_rates_size (12)
100#define a_mode_rates_size (8)
101#define FREQ_BASE_80211G (2407)
102#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700103#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530104#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800106 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
108#define HDD2GHZCHAN(freq, chan, flag) { \
109 .band = IEEE80211_BAND_2GHZ, \
110 .center_freq = (freq), \
111 .hw_value = (chan),\
112 .flags = (flag), \
113 .max_antenna_gain = 0 ,\
114 .max_power = 30, \
115}
116
117#define HDD5GHZCHAN(freq, chan, flag) { \
118 .band = IEEE80211_BAND_5GHZ, \
119 .center_freq = (freq), \
120 .hw_value = (chan),\
121 .flags = (flag), \
122 .max_antenna_gain = 0 ,\
123 .max_power = 30, \
124}
125
126#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
127{\
128 .bitrate = rate, \
129 .hw_value = rate_id, \
130 .flags = flag, \
131}
132
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530133#ifdef WLAN_FEATURE_VOWIFI_11R
134#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
135#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
136#endif
137
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530138#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530139#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530140
Sunil Duttc69bccb2014-05-26 21:30:20 +0530141#ifdef WLAN_FEATURE_LINK_LAYER_STATS
142/*
143 * Used to allocate the size of 4096 for the link layer stats.
144 * The size of 4096 is considered assuming that all data per
145 * respective event fit with in the limit.Please take a call
146 * on the limit based on the data requirements on link layer
147 * statistics.
148 */
149#define LL_STATS_EVENT_BUF_SIZE 4096
150#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530151#ifdef WLAN_FEATURE_EXTSCAN
152/*
153 * Used to allocate the size of 4096 for the EXTScan NL data.
154 * The size of 4096 is considered assuming that all data per
155 * respective event fit with in the limit.Please take a call
156 * on the limit based on the data requirements.
157 */
158
159#define EXTSCAN_EVENT_BUF_SIZE 4096
160#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
161#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530162
Atul Mittal115287b2014-07-08 13:26:33 +0530163/*EXT TDLS*/
164/*
165 * Used to allocate the size of 4096 for the TDLS.
166 * The size of 4096 is considered assuming that all data per
167 * respective event fit with in the limit.Please take a call
168 * on the limit based on the data requirements on link layer
169 * statistics.
170 */
171#define EXTTDLS_EVENT_BUF_SIZE 4096
172
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530173static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700174{
175 WLAN_CIPHER_SUITE_WEP40,
176 WLAN_CIPHER_SUITE_WEP104,
177 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800178#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700179#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
180 WLAN_CIPHER_SUITE_KRK,
181 WLAN_CIPHER_SUITE_CCMP,
182#else
183 WLAN_CIPHER_SUITE_CCMP,
184#endif
185#ifdef FEATURE_WLAN_WAPI
186 WLAN_CIPHER_SUITE_SMS4,
187#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700188#ifdef WLAN_FEATURE_11W
189 WLAN_CIPHER_SUITE_AES_CMAC,
190#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700191};
192
193static inline int is_broadcast_ether_addr(const u8 *addr)
194{
195 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
196 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
197}
198
199static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530200{
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 HDD2GHZCHAN(2412, 1, 0) ,
202 HDD2GHZCHAN(2417, 2, 0) ,
203 HDD2GHZCHAN(2422, 3, 0) ,
204 HDD2GHZCHAN(2427, 4, 0) ,
205 HDD2GHZCHAN(2432, 5, 0) ,
206 HDD2GHZCHAN(2437, 6, 0) ,
207 HDD2GHZCHAN(2442, 7, 0) ,
208 HDD2GHZCHAN(2447, 8, 0) ,
209 HDD2GHZCHAN(2452, 9, 0) ,
210 HDD2GHZCHAN(2457, 10, 0) ,
211 HDD2GHZCHAN(2462, 11, 0) ,
212 HDD2GHZCHAN(2467, 12, 0) ,
213 HDD2GHZCHAN(2472, 13, 0) ,
214 HDD2GHZCHAN(2484, 14, 0) ,
215};
216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
218{
219 HDD2GHZCHAN(2412, 1, 0) ,
220 HDD2GHZCHAN(2437, 6, 0) ,
221 HDD2GHZCHAN(2462, 11, 0) ,
222};
Jeff Johnson295189b2012-06-20 16:38:30 -0700223
224static struct ieee80211_channel hdd_channels_5_GHZ[] =
225{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700226 HDD5GHZCHAN(4920, 240, 0) ,
227 HDD5GHZCHAN(4940, 244, 0) ,
228 HDD5GHZCHAN(4960, 248, 0) ,
229 HDD5GHZCHAN(4980, 252, 0) ,
230 HDD5GHZCHAN(5040, 208, 0) ,
231 HDD5GHZCHAN(5060, 212, 0) ,
232 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 HDD5GHZCHAN(5180, 36, 0) ,
234 HDD5GHZCHAN(5200, 40, 0) ,
235 HDD5GHZCHAN(5220, 44, 0) ,
236 HDD5GHZCHAN(5240, 48, 0) ,
237 HDD5GHZCHAN(5260, 52, 0) ,
238 HDD5GHZCHAN(5280, 56, 0) ,
239 HDD5GHZCHAN(5300, 60, 0) ,
240 HDD5GHZCHAN(5320, 64, 0) ,
241 HDD5GHZCHAN(5500,100, 0) ,
242 HDD5GHZCHAN(5520,104, 0) ,
243 HDD5GHZCHAN(5540,108, 0) ,
244 HDD5GHZCHAN(5560,112, 0) ,
245 HDD5GHZCHAN(5580,116, 0) ,
246 HDD5GHZCHAN(5600,120, 0) ,
247 HDD5GHZCHAN(5620,124, 0) ,
248 HDD5GHZCHAN(5640,128, 0) ,
249 HDD5GHZCHAN(5660,132, 0) ,
250 HDD5GHZCHAN(5680,136, 0) ,
251 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800252#ifdef FEATURE_WLAN_CH144
253 HDD5GHZCHAN(5720,144, 0) ,
254#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 HDD5GHZCHAN(5745,149, 0) ,
256 HDD5GHZCHAN(5765,153, 0) ,
257 HDD5GHZCHAN(5785,157, 0) ,
258 HDD5GHZCHAN(5805,161, 0) ,
259 HDD5GHZCHAN(5825,165, 0) ,
260};
261
262static struct ieee80211_rate g_mode_rates[] =
263{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530264 HDD_G_MODE_RATETAB(10, 0x1, 0),
265 HDD_G_MODE_RATETAB(20, 0x2, 0),
266 HDD_G_MODE_RATETAB(55, 0x4, 0),
267 HDD_G_MODE_RATETAB(110, 0x8, 0),
268 HDD_G_MODE_RATETAB(60, 0x10, 0),
269 HDD_G_MODE_RATETAB(90, 0x20, 0),
270 HDD_G_MODE_RATETAB(120, 0x40, 0),
271 HDD_G_MODE_RATETAB(180, 0x80, 0),
272 HDD_G_MODE_RATETAB(240, 0x100, 0),
273 HDD_G_MODE_RATETAB(360, 0x200, 0),
274 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530276};
Jeff Johnson295189b2012-06-20 16:38:30 -0700277
278static struct ieee80211_rate a_mode_rates[] =
279{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530280 HDD_G_MODE_RATETAB(60, 0x10, 0),
281 HDD_G_MODE_RATETAB(90, 0x20, 0),
282 HDD_G_MODE_RATETAB(120, 0x40, 0),
283 HDD_G_MODE_RATETAB(180, 0x80, 0),
284 HDD_G_MODE_RATETAB(240, 0x100, 0),
285 HDD_G_MODE_RATETAB(360, 0x200, 0),
286 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 HDD_G_MODE_RATETAB(540, 0x800, 0),
288};
289
290static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
291{
292 .channels = hdd_channels_2_4_GHZ,
293 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
294 .band = IEEE80211_BAND_2GHZ,
295 .bitrates = g_mode_rates,
296 .n_bitrates = g_mode_rates_size,
297 .ht_cap.ht_supported = 1,
298 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
299 | IEEE80211_HT_CAP_GRN_FLD
300 | IEEE80211_HT_CAP_DSSSCCK40
301 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
302 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
303 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
304 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
305 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
306 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
307};
308
Jeff Johnson295189b2012-06-20 16:38:30 -0700309static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
310{
311 .channels = hdd_social_channels_2_4_GHZ,
312 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
313 .band = IEEE80211_BAND_2GHZ,
314 .bitrates = g_mode_rates,
315 .n_bitrates = g_mode_rates_size,
316 .ht_cap.ht_supported = 1,
317 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
318 | IEEE80211_HT_CAP_GRN_FLD
319 | IEEE80211_HT_CAP_DSSSCCK40
320 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
321 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
322 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
323 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
324 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
325 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
326};
Jeff Johnson295189b2012-06-20 16:38:30 -0700327
328static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
329{
330 .channels = hdd_channels_5_GHZ,
331 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
332 .band = IEEE80211_BAND_5GHZ,
333 .bitrates = a_mode_rates,
334 .n_bitrates = a_mode_rates_size,
335 .ht_cap.ht_supported = 1,
336 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
337 | IEEE80211_HT_CAP_GRN_FLD
338 | IEEE80211_HT_CAP_DSSSCCK40
339 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
340 | IEEE80211_HT_CAP_SGI_40
341 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
342 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
343 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
344 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
345 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
346 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
347};
348
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530349/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700350 TX/RX direction for each kind of interface */
351static const struct ieee80211_txrx_stypes
352wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
353 [NL80211_IFTYPE_STATION] = {
354 .tx = 0xffff,
355 .rx = BIT(SIR_MAC_MGMT_ACTION) |
356 BIT(SIR_MAC_MGMT_PROBE_REQ),
357 },
358 [NL80211_IFTYPE_AP] = {
359 .tx = 0xffff,
360 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
361 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
362 BIT(SIR_MAC_MGMT_PROBE_REQ) |
363 BIT(SIR_MAC_MGMT_DISASSOC) |
364 BIT(SIR_MAC_MGMT_AUTH) |
365 BIT(SIR_MAC_MGMT_DEAUTH) |
366 BIT(SIR_MAC_MGMT_ACTION),
367 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700368 [NL80211_IFTYPE_ADHOC] = {
369 .tx = 0xffff,
370 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
371 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
372 BIT(SIR_MAC_MGMT_PROBE_REQ) |
373 BIT(SIR_MAC_MGMT_DISASSOC) |
374 BIT(SIR_MAC_MGMT_AUTH) |
375 BIT(SIR_MAC_MGMT_DEAUTH) |
376 BIT(SIR_MAC_MGMT_ACTION),
377 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 [NL80211_IFTYPE_P2P_CLIENT] = {
379 .tx = 0xffff,
380 .rx = BIT(SIR_MAC_MGMT_ACTION) |
381 BIT(SIR_MAC_MGMT_PROBE_REQ),
382 },
383 [NL80211_IFTYPE_P2P_GO] = {
384 /* This is also same as for SoftAP */
385 .tx = 0xffff,
386 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
387 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
388 BIT(SIR_MAC_MGMT_PROBE_REQ) |
389 BIT(SIR_MAC_MGMT_DISASSOC) |
390 BIT(SIR_MAC_MGMT_AUTH) |
391 BIT(SIR_MAC_MGMT_DEAUTH) |
392 BIT(SIR_MAC_MGMT_ACTION),
393 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700394};
395
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800396#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800397static const struct ieee80211_iface_limit
398wlan_hdd_iface_limit[] = {
399 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800400 /* max = 3 ; Our driver create two interfaces during driver init
401 * wlan0 and p2p0 interfaces. p2p0 is considered as station
402 * interface until a group is formed. In JB architecture, once the
403 * group is formed, interface type of p2p0 is changed to P2P GO or
404 * Client.
405 * When supplicant remove the group, it first issue a set interface
406 * cmd to change the mode back to Station. In JB this works fine as
407 * we advertize two station type interface during driver init.
408 * Some vendors create separate interface for P2P GO/Client,
409 * after group formation(Third one). But while group remove
410 * supplicant first tries to change the mode(3rd interface) to STATION
411 * But as we advertized only two sta type interfaces nl80211 was
412 * returning error for the third one which was leading to failure in
413 * delete interface. Ideally while removing the group, supplicant
414 * should not try to change the 3rd interface mode to Station type.
415 * Till we get a fix in wpa_supplicant, we advertize max STA
416 * interface type to 3
417 */
418 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800419 .types = BIT(NL80211_IFTYPE_STATION),
420 },
421 {
422 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700423 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800424 },
425 {
426 .max = 1,
427 .types = BIT(NL80211_IFTYPE_P2P_GO) |
428 BIT(NL80211_IFTYPE_P2P_CLIENT),
429 },
430};
431
432/* By default, only single channel concurrency is allowed */
433static struct ieee80211_iface_combination
434wlan_hdd_iface_combination = {
435 .limits = wlan_hdd_iface_limit,
436 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800437 /*
438 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
439 * and p2p0 interfaces during driver init
440 * Some vendors create separate interface for P2P operations.
441 * wlan0: STA interface
442 * p2p0: P2P Device interface, action frames goes
443 * through this interface.
444 * p2p-xx: P2P interface, After GO negotiation this interface is
445 * created for p2p operations(GO/CLIENT interface).
446 */
447 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800448 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
449 .beacon_int_infra_match = false,
450};
451#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800452
Jeff Johnson295189b2012-06-20 16:38:30 -0700453static struct cfg80211_ops wlan_hdd_cfg80211_ops;
454
455/* Data rate 100KBPS based on IE Index */
456struct index_data_rate_type
457{
458 v_U8_t beacon_rate_index;
459 v_U16_t supported_rate[4];
460};
461
462/* 11B, 11G Rate table include Basic rate and Extended rate
463 The IDX field is the rate index
464 The HI field is the rate when RSSI is strong or being ignored
465 (in this case we report actual rate)
466 The MID field is the rate when RSSI is moderate
467 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
468 The LO field is the rate when RSSI is low
469 (in this case we don't report rates, actual current rate used)
470 */
471static const struct
472{
473 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700474 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700475} supported_data_rate[] =
476{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700477/* IDX HI HM LM LO (RSSI-based index */
478 {2, { 10, 10, 10, 0}},
479 {4, { 20, 20, 10, 0}},
480 {11, { 55, 20, 10, 0}},
481 {12, { 60, 55, 20, 0}},
482 {18, { 90, 55, 20, 0}},
483 {22, {110, 55, 20, 0}},
484 {24, {120, 90, 60, 0}},
485 {36, {180, 120, 60, 0}},
486 {44, {220, 180, 60, 0}},
487 {48, {240, 180, 90, 0}},
488 {66, {330, 180, 90, 0}},
489 {72, {360, 240, 90, 0}},
490 {96, {480, 240, 120, 0}},
491 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700492};
493
494/* MCS Based rate table */
495static struct index_data_rate_type supported_mcs_rate[] =
496{
497/* MCS L20 L40 S20 S40 */
498 {0, {65, 135, 72, 150}},
499 {1, {130, 270, 144, 300}},
500 {2, {195, 405, 217, 450}},
501 {3, {260, 540, 289, 600}},
502 {4, {390, 810, 433, 900}},
503 {5, {520, 1080, 578, 1200}},
504 {6, {585, 1215, 650, 1350}},
505 {7, {650, 1350, 722, 1500}}
506};
507
Leo Chang6f8870f2013-03-26 18:11:36 -0700508#ifdef WLAN_FEATURE_11AC
509
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530510#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700511
512struct index_vht_data_rate_type
513{
514 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530515 v_U16_t supported_VHT80_rate[2];
516 v_U16_t supported_VHT40_rate[2];
517 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700518};
519
520typedef enum
521{
522 DATA_RATE_11AC_MAX_MCS_7,
523 DATA_RATE_11AC_MAX_MCS_8,
524 DATA_RATE_11AC_MAX_MCS_9,
525 DATA_RATE_11AC_MAX_MCS_NA
526} eDataRate11ACMaxMcs;
527
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530528/* SSID broadcast type */
529typedef enum eSSIDBcastType
530{
531 eBCAST_UNKNOWN = 0,
532 eBCAST_NORMAL = 1,
533 eBCAST_HIDDEN = 2,
534} tSSIDBcastType;
535
Leo Chang6f8870f2013-03-26 18:11:36 -0700536/* MCS Based VHT rate table */
537static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
538{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530539/* MCS L80 S80 L40 S40 L20 S40*/
540 {0, {293, 325}, {135, 150}, {65, 72}},
541 {1, {585, 650}, {270, 300}, {130, 144}},
542 {2, {878, 975}, {405, 450}, {195, 217}},
543 {3, {1170, 1300}, {540, 600}, {260, 289}},
544 {4, {1755, 1950}, {810, 900}, {390, 433}},
545 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
546 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
547 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
548 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
549 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700550};
551#endif /* WLAN_FEATURE_11AC */
552
c_hpothu79aab322014-07-14 21:11:01 +0530553/*array index points to MCS and array value points respective rssi*/
554static int rssiMcsTbl[][10] =
555{
556/*MCS 0 1 2 3 4 5 6 7 8 9*/
557 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
558 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
559 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
560};
561
Jeff Johnson295189b2012-06-20 16:38:30 -0700562extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530563#ifdef FEATURE_WLAN_SCAN_PNO
564static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
565#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700566
Leo Chang9056f462013-08-01 19:21:11 -0700567#ifdef WLAN_NL80211_TESTMODE
568enum wlan_hdd_tm_attr
569{
570 WLAN_HDD_TM_ATTR_INVALID = 0,
571 WLAN_HDD_TM_ATTR_CMD = 1,
572 WLAN_HDD_TM_ATTR_DATA = 2,
573 WLAN_HDD_TM_ATTR_TYPE = 3,
574 /* keep last */
575 WLAN_HDD_TM_ATTR_AFTER_LAST,
576 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
577};
578
579enum wlan_hdd_tm_cmd
580{
581 WLAN_HDD_TM_CMD_WLAN_HB = 1,
582};
583
584#define WLAN_HDD_TM_DATA_MAX_LEN 5000
585
586static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
587{
588 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
589 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
590 .len = WLAN_HDD_TM_DATA_MAX_LEN },
591};
592#endif /* WLAN_NL80211_TESTMODE */
593
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800594#ifdef FEATURE_WLAN_CH_AVOID
595/*
596 * FUNCTION: wlan_hdd_send_avoid_freq_event
597 * This is called when wlan driver needs to send vendor specific
598 * avoid frequency range event to userspace
599 */
600int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
601 tHddAvoidFreqList *pAvoidFreqList)
602{
603 struct sk_buff *vendor_event;
604
605 ENTER();
606
607 if (!pHddCtx)
608 {
609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
610 "%s: HDD context is null", __func__);
611 return -1;
612 }
613
614 if (!pAvoidFreqList)
615 {
616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
617 "%s: pAvoidFreqList is null", __func__);
618 return -1;
619 }
620
621 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
622 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530623 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800624 GFP_KERNEL);
625 if (!vendor_event)
626 {
627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
628 "%s: cfg80211_vendor_event_alloc failed", __func__);
629 return -1;
630 }
631
632 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
633 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
634
635 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
636
637 EXIT();
638 return 0;
639}
640#endif /* FEATURE_WLAN_CH_AVOID */
641
Srinivas Dasari030bad32015-02-18 23:23:54 +0530642/*
643 * FUNCTION: __wlan_hdd_cfg80211_nan_request
644 * This is called when wlan driver needs to send vendor specific
645 * nan request event.
646 */
647static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
648 struct wireless_dev *wdev,
649 const void *data, int data_len)
650{
651 tNanRequestReq nan_req;
652 VOS_STATUS status;
653 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530654 struct net_device *dev = wdev->netdev;
655 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
656 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530657 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
658
659 if (0 == data_len)
660 {
661 hddLog(VOS_TRACE_LEVEL_ERROR,
662 FL("NAN - Invalid Request, length = 0"));
663 return ret_val;
664 }
665
666 if (NULL == data)
667 {
668 hddLog(VOS_TRACE_LEVEL_ERROR,
669 FL("NAN - Invalid Request, data is NULL"));
670 return ret_val;
671 }
672
673 status = wlan_hdd_validate_context(pHddCtx);
674 if (0 != status)
675 {
676 hddLog(VOS_TRACE_LEVEL_ERROR,
677 FL("HDD context is not valid"));
678 return -EINVAL;
679 }
680
681 hddLog(LOG1, FL("Received NAN command"));
682 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
683 (tANI_U8 *)data, data_len);
684
685 /* check the NAN Capability */
686 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
687 {
688 hddLog(VOS_TRACE_LEVEL_ERROR,
689 FL("NAN is not supported by Firmware"));
690 return -EINVAL;
691 }
692
693 nan_req.request_data_len = data_len;
694 nan_req.request_data = data;
695
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530696 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530697 if (VOS_STATUS_SUCCESS == status)
698 {
699 ret_val = 0;
700 }
701 return ret_val;
702}
703
704/*
705 * FUNCTION: wlan_hdd_cfg80211_nan_request
706 * Wrapper to protect the nan vendor command from ssr
707 */
708static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
709 struct wireless_dev *wdev,
710 const void *data, int data_len)
711{
712 int ret;
713
714 vos_ssr_protect(__func__);
715 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
716 vos_ssr_unprotect(__func__);
717
718 return ret;
719}
720
721/*
722 * FUNCTION: wlan_hdd_cfg80211_nan_callback
723 * This is a callback function and it gets called
724 * when we need to report nan response event to
725 * upper layers.
726 */
727static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
728{
729 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
730 struct sk_buff *vendor_event;
731 int status;
732 tSirNanEvent *data;
733
734 ENTER();
735 if (NULL == msg)
736 {
737 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
738 FL(" msg received here is null"));
739 return;
740 }
741 data = msg;
742
743 status = wlan_hdd_validate_context(pHddCtx);
744
745 if (0 != status)
746 {
747 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
748 FL("HDD context is not valid"));
749 return;
750 }
751
752 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
753 data->event_data_len +
754 NLMSG_HDRLEN,
755 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
756 GFP_KERNEL);
757
758 if (!vendor_event)
759 {
760 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
761 FL("cfg80211_vendor_event_alloc failed"));
762 return;
763 }
764 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
765 data->event_data_len, data->event_data))
766 {
767 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
768 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
769 kfree_skb(vendor_event);
770 return;
771 }
772 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
773 EXIT();
774}
775
776/*
777 * FUNCTION: wlan_hdd_cfg80211_nan_init
778 * This function is called to register the callback to sme layer
779 */
780inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
781{
782 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
783}
784
785
Sunil Duttc69bccb2014-05-26 21:30:20 +0530786#ifdef WLAN_FEATURE_LINK_LAYER_STATS
787
788static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
789 struct sk_buff *vendor_event)
790{
791 if (nla_put_u8(vendor_event,
792 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
793 stats->rate.preamble) ||
794 nla_put_u8(vendor_event,
795 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
796 stats->rate.nss) ||
797 nla_put_u8(vendor_event,
798 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
799 stats->rate.bw) ||
800 nla_put_u8(vendor_event,
801 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
802 stats->rate.rateMcsIdx) ||
803 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
804 stats->rate.bitrate ) ||
805 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
806 stats->txMpdu ) ||
807 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
808 stats->rxMpdu ) ||
809 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
810 stats->mpduLost ) ||
811 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
812 stats->retries) ||
813 nla_put_u32(vendor_event,
814 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
815 stats->retriesShort ) ||
816 nla_put_u32(vendor_event,
817 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
818 stats->retriesLong))
819 {
820 hddLog(VOS_TRACE_LEVEL_ERROR,
821 FL("QCA_WLAN_VENDOR_ATTR put fail"));
822 return FALSE;
823 }
824 return TRUE;
825}
826
827static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
828 struct sk_buff *vendor_event)
829{
830 u32 i = 0;
831 struct nlattr *rateInfo;
832 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
833 stats->type) ||
834 nla_put(vendor_event,
835 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
836 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
837 nla_put_u32(vendor_event,
838 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
839 stats->capabilities) ||
840 nla_put_u32(vendor_event,
841 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
842 stats->numRate))
843 {
844 hddLog(VOS_TRACE_LEVEL_ERROR,
845 FL("QCA_WLAN_VENDOR_ATTR put fail"));
846 goto error;
847 }
848
849 rateInfo = nla_nest_start(vendor_event,
850 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530851 if(!rateInfo)
852 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530853 for (i = 0; i < stats->numRate; i++)
854 {
855 struct nlattr *rates;
856 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
857 stats->rateStats +
858 (i * sizeof(tSirWifiRateStat)));
859 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530860 if(!rates)
861 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530862
863 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
864 {
865 hddLog(VOS_TRACE_LEVEL_ERROR,
866 FL("QCA_WLAN_VENDOR_ATTR put fail"));
867 return FALSE;
868 }
869 nla_nest_end(vendor_event, rates);
870 }
871 nla_nest_end(vendor_event, rateInfo);
872
873 return TRUE;
874error:
875 return FALSE;
876}
877
878static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
879 struct sk_buff *vendor_event)
880{
881 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
882 stats->ac ) ||
883 nla_put_u32(vendor_event,
884 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
885 stats->txMpdu ) ||
886 nla_put_u32(vendor_event,
887 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
888 stats->rxMpdu ) ||
889 nla_put_u32(vendor_event,
890 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
891 stats->txMcast ) ||
892 nla_put_u32(vendor_event,
893 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
894 stats->rxMcast ) ||
895 nla_put_u32(vendor_event,
896 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
897 stats->rxAmpdu ) ||
898 nla_put_u32(vendor_event,
899 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
900 stats->txAmpdu ) ||
901 nla_put_u32(vendor_event,
902 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
903 stats->mpduLost )||
904 nla_put_u32(vendor_event,
905 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
906 stats->retries ) ||
907 nla_put_u32(vendor_event,
908 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
909 stats->retriesShort ) ||
910 nla_put_u32(vendor_event,
911 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
912 stats->retriesLong ) ||
913 nla_put_u32(vendor_event,
914 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
915 stats->contentionTimeMin ) ||
916 nla_put_u32(vendor_event,
917 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
918 stats->contentionTimeMax ) ||
919 nla_put_u32(vendor_event,
920 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
921 stats->contentionTimeAvg ) ||
922 nla_put_u32(vendor_event,
923 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
924 stats->contentionNumSamples ))
925 {
926 hddLog(VOS_TRACE_LEVEL_ERROR,
927 FL("QCA_WLAN_VENDOR_ATTR put fail") );
928 return FALSE;
929 }
930 return TRUE;
931}
932
933static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
934 struct sk_buff *vendor_event)
935{
Dino Myclec8f3f332014-07-21 16:48:27 +0530936 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530937 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
938 nla_put(vendor_event,
939 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
940 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
941 nla_put_u32(vendor_event,
942 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
943 stats->state ) ||
944 nla_put_u32(vendor_event,
945 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
946 stats->roaming ) ||
947 nla_put_u32(vendor_event,
948 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
949 stats->capabilities ) ||
950 nla_put(vendor_event,
951 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
952 strlen(stats->ssid), stats->ssid) ||
953 nla_put(vendor_event,
954 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
955 WNI_CFG_BSSID_LEN, stats->bssid) ||
956 nla_put(vendor_event,
957 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
958 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
959 nla_put(vendor_event,
960 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
961 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
962 )
963 {
964 hddLog(VOS_TRACE_LEVEL_ERROR,
965 FL("QCA_WLAN_VENDOR_ATTR put fail") );
966 return FALSE;
967 }
968 return TRUE;
969}
970
Dino Mycle3b9536d2014-07-09 22:05:24 +0530971static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
972 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530973 struct sk_buff *vendor_event)
974{
975 int i = 0;
976 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530977 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
978 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530979 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530980
Sunil Duttc69bccb2014-05-26 21:30:20 +0530981 if (FALSE == put_wifi_interface_info(
982 &pWifiIfaceStat->info,
983 vendor_event))
984 {
985 hddLog(VOS_TRACE_LEVEL_ERROR,
986 FL("QCA_WLAN_VENDOR_ATTR put fail") );
987 return FALSE;
988
989 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530990 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
991 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
992 if (NULL == pWifiIfaceStatTL)
993 {
994 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
995 return FALSE;
996 }
997
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530998 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
999 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
1000 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
1001 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1002
1003 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1004 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1005 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1006 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301007
1008 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1009 {
1010 if (VOS_STATUS_SUCCESS ==
1011 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1012 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1013 {
1014 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1015 * obtained from TL structure
1016 */
1017
1018 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1019 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301020 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1021
Srinivas Dasari98947432014-11-07 19:41:24 +05301022 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1023 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1024 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1025 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1026 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1027 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1028 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1029 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301030
Srinivas Dasari98947432014-11-07 19:41:24 +05301031 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1032 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1033 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1034 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1035 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1036 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1037 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1038 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301039
Srinivas Dasari98947432014-11-07 19:41:24 +05301040 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1041 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1042 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1043 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1044 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1045 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1046 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1047 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301048 }
1049 else
1050 {
1051 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1052 }
1053
Dino Mycle3b9536d2014-07-09 22:05:24 +05301054 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1055 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1056 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1057 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1058 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1059 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1060 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1061 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1062 }
1063 else
1064 {
1065 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1066 }
1067
1068
Sunil Duttc69bccb2014-05-26 21:30:20 +05301069
1070 if (nla_put_u32(vendor_event,
1071 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1072 pWifiIfaceStat->beaconRx) ||
1073 nla_put_u32(vendor_event,
1074 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1075 pWifiIfaceStat->mgmtRx) ||
1076 nla_put_u32(vendor_event,
1077 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1078 pWifiIfaceStat->mgmtActionRx) ||
1079 nla_put_u32(vendor_event,
1080 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1081 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301082 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301083 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1084 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301085 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301086 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1087 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301088 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301089 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1090 pWifiIfaceStat->rssiAck))
1091 {
1092 hddLog(VOS_TRACE_LEVEL_ERROR,
1093 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301094 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301095 return FALSE;
1096 }
1097
1098 wmmInfo = nla_nest_start(vendor_event,
1099 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301100 if(!wmmInfo)
1101 {
1102 vos_mem_free(pWifiIfaceStatTL);
1103 return FALSE;
1104 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301105 for (i = 0; i < WIFI_AC_MAX; i++)
1106 {
1107 struct nlattr *wmmStats;
1108 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301109 if(!wmmStats)
1110 {
1111 vos_mem_free(pWifiIfaceStatTL);
1112 return FALSE;
1113 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301114 if (FALSE == put_wifi_wmm_ac_stat(
1115 &pWifiIfaceStat->AccessclassStats[i],
1116 vendor_event))
1117 {
1118 hddLog(VOS_TRACE_LEVEL_ERROR,
1119 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301120 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301121 return FALSE;
1122 }
1123
1124 nla_nest_end(vendor_event, wmmStats);
1125 }
1126 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301127 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301128 return TRUE;
1129}
1130
1131static tSirWifiInterfaceMode
1132 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1133{
1134 switch (deviceMode)
1135 {
1136 case WLAN_HDD_INFRA_STATION:
1137 return WIFI_INTERFACE_STA;
1138 case WLAN_HDD_SOFTAP:
1139 return WIFI_INTERFACE_SOFTAP;
1140 case WLAN_HDD_P2P_CLIENT:
1141 return WIFI_INTERFACE_P2P_CLIENT;
1142 case WLAN_HDD_P2P_GO:
1143 return WIFI_INTERFACE_P2P_GO;
1144 case WLAN_HDD_IBSS:
1145 return WIFI_INTERFACE_IBSS;
1146 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301147 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301148 }
1149}
1150
1151static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1152 tpSirWifiInterfaceInfo pInfo)
1153{
1154 v_U8_t *staMac = NULL;
1155 hdd_station_ctx_t *pHddStaCtx;
1156 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1157 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1158
1159 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1160
1161 vos_mem_copy(pInfo->macAddr,
1162 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1163
1164 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1165 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1166 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1167 {
1168 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1169 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1170 {
1171 pInfo->state = WIFI_DISCONNECTED;
1172 }
1173 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1174 {
1175 hddLog(VOS_TRACE_LEVEL_ERROR,
1176 "%s: Session ID %d, Connection is in progress", __func__,
1177 pAdapter->sessionId);
1178 pInfo->state = WIFI_ASSOCIATING;
1179 }
1180 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1181 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1182 {
1183 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1184 hddLog(VOS_TRACE_LEVEL_ERROR,
1185 "%s: client " MAC_ADDRESS_STR
1186 " is in the middle of WPS/EAPOL exchange.", __func__,
1187 MAC_ADDR_ARRAY(staMac));
1188 pInfo->state = WIFI_AUTHENTICATING;
1189 }
1190 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1191 {
1192 pInfo->state = WIFI_ASSOCIATED;
1193 vos_mem_copy(pInfo->bssid,
1194 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1195 vos_mem_copy(pInfo->ssid,
1196 pHddStaCtx->conn_info.SSID.SSID.ssId,
1197 pHddStaCtx->conn_info.SSID.SSID.length);
1198 //NULL Terminate the string.
1199 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1200 }
1201 }
1202 vos_mem_copy(pInfo->countryStr,
1203 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1204
1205 vos_mem_copy(pInfo->apCountryStr,
1206 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1207
1208 return TRUE;
1209}
1210
1211/*
1212 * hdd_link_layer_process_peer_stats () - This function is called after
1213 * receiving Link Layer Peer statistics from FW.This function converts
1214 * the firmware data to the NL data and sends the same to the kernel/upper
1215 * layers.
1216 */
1217static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1218 v_VOID_t *pData)
1219{
1220 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1221 tpSirWifiRateStat pWifiRateStat;
1222 tpSirWifiPeerStat pWifiPeerStat;
1223 tpSirWifiPeerInfo pWifiPeerInfo;
1224 struct nlattr *peerInfo;
1225 struct sk_buff *vendor_event;
1226 int status, i;
1227
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301228 ENTER();
1229
Sunil Duttc69bccb2014-05-26 21:30:20 +05301230 status = wlan_hdd_validate_context(pHddCtx);
1231 if (0 != status)
1232 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301233 return;
1234 }
1235
1236 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1237
1238 hddLog(VOS_TRACE_LEVEL_INFO,
1239 "LL_STATS_PEER_ALL : numPeers %u",
1240 pWifiPeerStat->numPeers);
1241 {
1242 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1243 {
1244 pWifiPeerInfo = (tpSirWifiPeerInfo)
1245 ((uint8 *)pWifiPeerStat->peerInfo +
1246 ( i * sizeof(tSirWifiPeerInfo)));
1247
Dasari Srinivas1be0c4e2014-10-19 13:03:41 +05301248 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) {
1249 pWifiPeerInfo->type = WIFI_PEER_AP;
1250 }
1251 if (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) {
1252 pWifiPeerInfo->type = WIFI_PEER_P2P_GO;
1253 }
1254
Sunil Duttc69bccb2014-05-26 21:30:20 +05301255 hddLog(VOS_TRACE_LEVEL_INFO,
1256 " %d) LL_STATS Channel Stats "
1257 " Peer Type %u "
1258 " peerMacAddress %pM "
1259 " capabilities 0x%x "
1260 " numRate %u ",
1261 i,
1262 pWifiPeerInfo->type,
1263 pWifiPeerInfo->peerMacAddress,
1264 pWifiPeerInfo->capabilities,
1265 pWifiPeerInfo->numRate);
1266 {
1267 int j;
1268 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1269 {
1270 pWifiRateStat = (tpSirWifiRateStat)
1271 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1272 ( j * sizeof(tSirWifiRateStat)));
1273
1274 hddLog(VOS_TRACE_LEVEL_INFO,
1275 " peer Rate Stats "
1276 " preamble %u "
1277 " nss %u "
1278 " bw %u "
1279 " rateMcsIdx %u "
1280 " reserved %u "
1281 " bitrate %u "
1282 " txMpdu %u "
1283 " rxMpdu %u "
1284 " mpduLost %u "
1285 " retries %u "
1286 " retriesShort %u "
1287 " retriesLong %u",
1288 pWifiRateStat->rate.preamble,
1289 pWifiRateStat->rate.nss,
1290 pWifiRateStat->rate.bw,
1291 pWifiRateStat->rate.rateMcsIdx,
1292 pWifiRateStat->rate.reserved,
1293 pWifiRateStat->rate.bitrate,
1294 pWifiRateStat->txMpdu,
1295 pWifiRateStat->rxMpdu,
1296 pWifiRateStat->mpduLost,
1297 pWifiRateStat->retries,
1298 pWifiRateStat->retriesShort,
1299 pWifiRateStat->retriesLong);
1300 }
1301 }
1302 }
1303 }
1304
1305 /*
1306 * Allocate a size of 4096 for the peer stats comprising
1307 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1308 * sizeof (tSirWifiRateStat).Each field is put with an
1309 * NL attribute.The size of 4096 is considered assuming
1310 * that number of rates shall not exceed beyond 50 with
1311 * the sizeof (tSirWifiRateStat) being 32.
1312 */
1313 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1314 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1315 QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX,
1316 GFP_KERNEL);
1317 if (!vendor_event)
1318 {
1319 hddLog(VOS_TRACE_LEVEL_ERROR,
1320 "%s: cfg80211_vendor_event_alloc failed",
1321 __func__);
1322 return;
1323 }
1324 if (nla_put_u32(vendor_event,
1325 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1326 pWifiPeerStat->numPeers))
1327 {
1328 hddLog(VOS_TRACE_LEVEL_ERROR,
1329 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1330 kfree_skb(vendor_event);
1331 return;
1332 }
1333
1334 peerInfo = nla_nest_start(vendor_event,
1335 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301336 if(!peerInfo)
1337 {
1338 hddLog(VOS_TRACE_LEVEL_ERROR,
1339 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1340 __func__);
1341 kfree_skb(vendor_event);
1342 return;
1343 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301344
1345 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1346 pWifiPeerStat->peerInfo);
1347
1348 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1349 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301350 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301351 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301352
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301353 if(!peers)
1354 {
1355 hddLog(VOS_TRACE_LEVEL_ERROR,
1356 "%s: peer stats put fail",
1357 __func__);
1358 kfree_skb(vendor_event);
1359 return;
1360 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301361 if (FALSE == put_wifi_peer_info(
1362 pWifiPeerInfo, vendor_event))
1363 {
1364 hddLog(VOS_TRACE_LEVEL_ERROR,
1365 "%s: put_wifi_peer_info put fail", __func__);
1366 kfree_skb(vendor_event);
1367 return;
1368 }
1369
1370 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1371 pWifiPeerStat->peerInfo +
1372 (i * sizeof(tSirWifiPeerInfo)) +
1373 (numRate * sizeof (tSirWifiRateStat)));
1374 nla_nest_end(vendor_event, peers);
1375 }
1376 nla_nest_end(vendor_event, peerInfo);
1377 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301378
1379 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301380}
1381
1382/*
1383 * hdd_link_layer_process_iface_stats () - This function is called after
1384 * receiving Link Layer Interface statistics from FW.This function converts
1385 * the firmware data to the NL data and sends the same to the kernel/upper
1386 * layers.
1387 */
1388static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1389 v_VOID_t *pData)
1390{
1391 tpSirWifiIfaceStat pWifiIfaceStat;
1392 struct sk_buff *vendor_event;
1393 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1394 int status;
1395
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301396 ENTER();
1397
Sunil Duttc69bccb2014-05-26 21:30:20 +05301398 status = wlan_hdd_validate_context(pHddCtx);
1399 if (0 != status)
1400 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301401 return;
1402 }
1403 /*
1404 * Allocate a size of 4096 for the interface stats comprising
1405 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1406 * assuming that all these fit with in the limit.Please take
1407 * a call on the limit based on the data requirements on
1408 * interface statistics.
1409 */
1410 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1411 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1412 QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX,
1413 GFP_KERNEL);
1414 if (!vendor_event)
1415 {
1416 hddLog(VOS_TRACE_LEVEL_ERROR,
1417 FL("cfg80211_vendor_event_alloc failed") );
1418 return;
1419 }
1420
1421 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1422
Dino Mycle3b9536d2014-07-09 22:05:24 +05301423
1424 if (FALSE == hdd_get_interface_info( pAdapter,
1425 &pWifiIfaceStat->info))
1426 {
1427 hddLog(VOS_TRACE_LEVEL_ERROR,
1428 FL("hdd_get_interface_info get fail") );
1429 kfree_skb(vendor_event);
1430 return;
1431 }
1432
1433 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1434 vendor_event))
1435 {
1436 hddLog(VOS_TRACE_LEVEL_ERROR,
1437 FL("put_wifi_iface_stats fail") );
1438 kfree_skb(vendor_event);
1439 return;
1440 }
1441
Sunil Duttc69bccb2014-05-26 21:30:20 +05301442 hddLog(VOS_TRACE_LEVEL_INFO,
1443 "WMI_LINK_STATS_IFACE Data");
1444
1445 hddLog(VOS_TRACE_LEVEL_INFO,
1446 "LL_STATS_IFACE: "
1447 " Mode %u "
1448 " MAC %pM "
1449 " State %u "
1450 " Roaming %u "
1451 " capabilities 0x%x "
1452 " SSID %s "
1453 " BSSID %pM",
1454 pWifiIfaceStat->info.mode,
1455 pWifiIfaceStat->info.macAddr,
1456 pWifiIfaceStat->info.state,
1457 pWifiIfaceStat->info.roaming,
1458 pWifiIfaceStat->info.capabilities,
1459 pWifiIfaceStat->info.ssid,
1460 pWifiIfaceStat->info.bssid);
1461
1462 hddLog(VOS_TRACE_LEVEL_INFO,
1463 " AP country str: %c%c%c",
1464 pWifiIfaceStat->info.apCountryStr[0],
1465 pWifiIfaceStat->info.apCountryStr[1],
1466 pWifiIfaceStat->info.apCountryStr[2]);
1467
1468
1469 hddLog(VOS_TRACE_LEVEL_INFO,
1470 " Country Str Association: %c%c%c",
1471 pWifiIfaceStat->info.countryStr[0],
1472 pWifiIfaceStat->info.countryStr[1],
1473 pWifiIfaceStat->info.countryStr[2]);
1474
1475 hddLog(VOS_TRACE_LEVEL_INFO,
1476 " beaconRx %u "
1477 " mgmtRx %u "
1478 " mgmtActionRx %u "
1479 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301480 " rssiMgmt %d "
1481 " rssiData %d "
1482 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301483 pWifiIfaceStat->beaconRx,
1484 pWifiIfaceStat->mgmtRx,
1485 pWifiIfaceStat->mgmtActionRx,
1486 pWifiIfaceStat->mgmtActionTx,
1487 pWifiIfaceStat->rssiMgmt,
1488 pWifiIfaceStat->rssiData,
1489 pWifiIfaceStat->rssiAck );
1490
1491
1492 {
1493 int i;
1494 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1495 {
1496 hddLog(VOS_TRACE_LEVEL_INFO,
1497
1498 " %d) LL_STATS IFACE: "
1499 " ac: %u txMpdu: %u "
1500 " rxMpdu: %u txMcast: %u "
1501 " rxMcast: %u rxAmpdu: %u "
1502 " txAmpdu: %u mpduLost: %u "
1503 " retries: %u retriesShort: %u "
1504 " retriesLong: %u contentionTimeMin: %u "
1505 " contentionTimeMax: %u contentionTimeAvg: %u "
1506 " contentionNumSamples: %u",
1507 i,
1508 pWifiIfaceStat->AccessclassStats[i].ac,
1509 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1510 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1511 pWifiIfaceStat->AccessclassStats[i].txMcast,
1512 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1513 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1514 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1515 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1516 pWifiIfaceStat->AccessclassStats[i].retries,
1517 pWifiIfaceStat->
1518 AccessclassStats[i].retriesShort,
1519 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1520 pWifiIfaceStat->
1521 AccessclassStats[i].contentionTimeMin,
1522 pWifiIfaceStat->
1523 AccessclassStats[i].contentionTimeMax,
1524 pWifiIfaceStat->
1525 AccessclassStats[i].contentionTimeAvg,
1526 pWifiIfaceStat->
1527 AccessclassStats[i].contentionNumSamples);
1528
1529 }
1530 }
1531
Sunil Duttc69bccb2014-05-26 21:30:20 +05301532 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301533
1534 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301535}
1536
1537/*
1538 * hdd_link_layer_process_radio_stats () - This function is called after
1539 * receiving Link Layer Radio statistics from FW.This function converts
1540 * the firmware data to the NL data and sends the same to the kernel/upper
1541 * layers.
1542 */
1543static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1544 v_VOID_t *pData)
1545{
1546 int status, i;
1547 tpSirWifiRadioStat pWifiRadioStat;
1548 tpSirWifiChannelStats pWifiChannelStats;
1549 struct sk_buff *vendor_event;
1550 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1551 struct nlattr *chList;
1552
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301553 ENTER();
1554
Sunil Duttc69bccb2014-05-26 21:30:20 +05301555 status = wlan_hdd_validate_context(pHddCtx);
1556 if (0 != status)
1557 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301558 return;
1559 }
1560 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1561
1562 hddLog(VOS_TRACE_LEVEL_INFO,
1563 "LL_STATS_RADIO"
1564 " radio is %d onTime is %u "
1565 " txTime is %u rxTime is %u "
1566 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301567 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301568 " onTimePnoScan is %u onTimeHs20 is %u "
1569 " numChannels is %u",
1570 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1571 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1572 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301573 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301574 pWifiRadioStat->onTimeRoamScan,
1575 pWifiRadioStat->onTimePnoScan,
1576 pWifiRadioStat->onTimeHs20,
1577 pWifiRadioStat->numChannels);
1578 /*
1579 * Allocate a size of 4096 for the Radio stats comprising
1580 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1581 * (tSirWifiChannelStats).Each channel data is put with an
1582 * NL attribute.The size of 4096 is considered assuming that
1583 * number of channels shall not exceed beyond 60 with the
1584 * sizeof (tSirWifiChannelStats) being 24 bytes.
1585 */
1586
1587 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1588 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN ,
1589 QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX,
1590 GFP_KERNEL);
1591
1592 if (!vendor_event)
1593 {
1594 hddLog(VOS_TRACE_LEVEL_ERROR,
1595 FL("cfg80211_vendor_event_alloc failed") );
1596 return;
1597 }
1598
1599 if (nla_put_u32(vendor_event,
1600 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1601 pWifiRadioStat->radio) ||
1602 nla_put_u32(vendor_event,
1603 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1604 pWifiRadioStat->onTime) ||
1605 nla_put_u32(vendor_event,
1606 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1607 pWifiRadioStat->txTime) ||
1608 nla_put_u32(vendor_event,
1609 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1610 pWifiRadioStat->rxTime) ||
1611 nla_put_u32(vendor_event,
1612 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1613 pWifiRadioStat->onTimeScan) ||
1614 nla_put_u32(vendor_event,
1615 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1616 pWifiRadioStat->onTimeNbd) ||
1617 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301618 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1619 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301620 nla_put_u32(vendor_event,
1621 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1622 pWifiRadioStat->onTimeRoamScan) ||
1623 nla_put_u32(vendor_event,
1624 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1625 pWifiRadioStat->onTimePnoScan) ||
1626 nla_put_u32(vendor_event,
1627 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1628 pWifiRadioStat->onTimeHs20) ||
1629 nla_put_u32(vendor_event,
1630 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1631 pWifiRadioStat->numChannels))
1632 {
1633 hddLog(VOS_TRACE_LEVEL_ERROR,
1634 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1635 kfree_skb(vendor_event);
1636 return ;
1637 }
1638
1639 chList = nla_nest_start(vendor_event,
1640 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301641 if(!chList)
1642 {
1643 hddLog(VOS_TRACE_LEVEL_ERROR,
1644 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1645 __func__);
1646 kfree_skb(vendor_event);
1647 return;
1648 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301649 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1650 {
1651 struct nlattr *chInfo;
1652
1653 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1654 pWifiRadioStat->channels +
1655 (i * sizeof(tSirWifiChannelStats)));
1656
1657 hddLog(VOS_TRACE_LEVEL_INFO,
1658 " %d) Channel Info"
1659 " width is %u "
1660 " CenterFreq %u "
1661 " CenterFreq0 %u "
1662 " CenterFreq1 %u "
1663 " onTime %u "
1664 " ccaBusyTime %u",
1665 i,
1666 pWifiChannelStats->channel.width,
1667 pWifiChannelStats->channel.centerFreq,
1668 pWifiChannelStats->channel.centerFreq0,
1669 pWifiChannelStats->channel.centerFreq1,
1670 pWifiChannelStats->onTime,
1671 pWifiChannelStats->ccaBusyTime);
1672
1673
1674 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301675 if(!chInfo)
1676 {
1677 hddLog(VOS_TRACE_LEVEL_ERROR,
1678 "%s: failed to put chInfo",
1679 __func__);
1680 kfree_skb(vendor_event);
1681 return;
1682 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301683
1684 if (nla_put_u32(vendor_event,
1685 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1686 pWifiChannelStats->channel.width) ||
1687 nla_put_u32(vendor_event,
1688 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1689 pWifiChannelStats->channel.centerFreq) ||
1690 nla_put_u32(vendor_event,
1691 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1692 pWifiChannelStats->channel.centerFreq0) ||
1693 nla_put_u32(vendor_event,
1694 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1695 pWifiChannelStats->channel.centerFreq1) ||
1696 nla_put_u32(vendor_event,
1697 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1698 pWifiChannelStats->onTime) ||
1699 nla_put_u32(vendor_event,
1700 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1701 pWifiChannelStats->ccaBusyTime))
1702 {
1703 hddLog(VOS_TRACE_LEVEL_ERROR,
1704 FL("cfg80211_vendor_event_alloc failed") );
1705 kfree_skb(vendor_event);
1706 return ;
1707 }
1708 nla_nest_end(vendor_event, chInfo);
1709 }
1710 nla_nest_end(vendor_event, chList);
1711
1712 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301713
1714 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301715 return;
1716}
1717
1718/*
1719 * hdd_link_layer_stats_ind_callback () - This function is called after
1720 * receiving Link Layer indications from FW.This callback converts the firmware
1721 * data to the NL data and send the same to the kernel/upper layers.
1722 */
1723static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1724 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301725 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301726{
Dino Mycled3d50022014-07-07 12:58:25 +05301727 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1728 hdd_adapter_t *pAdapter = NULL;
1729 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301730 int status;
1731
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301732 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301733
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301734 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301735 if (0 != status)
1736 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301737 return;
1738 }
1739
Dino Mycled3d50022014-07-07 12:58:25 +05301740 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1741 if (NULL == pAdapter)
1742 {
1743 hddLog(VOS_TRACE_LEVEL_ERROR,
1744 FL(" MAC address %pM does not exist with host"),
1745 macAddr);
1746 return;
1747 }
1748
Sunil Duttc69bccb2014-05-26 21:30:20 +05301749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301750 "%s: Interface: %s LLStats indType: %d", __func__,
1751 pAdapter->dev->name, indType);
1752
Sunil Duttc69bccb2014-05-26 21:30:20 +05301753 switch (indType)
1754 {
1755 case SIR_HAL_LL_STATS_RESULTS_RSP:
1756 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301757 hddLog(VOS_TRACE_LEVEL_INFO,
1758 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1759 hddLog(VOS_TRACE_LEVEL_INFO,
1760 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1761 linkLayerStatsResults->paramId);
1762 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301763 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1764 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301765 hddLog(VOS_TRACE_LEVEL_INFO,
1766 "LL_STATS RESULTS RESPONSE respId = %u",
1767 linkLayerStatsResults->respId);
1768 hddLog(VOS_TRACE_LEVEL_INFO,
1769 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1770 linkLayerStatsResults->moreResultToFollow);
1771 hddLog(VOS_TRACE_LEVEL_INFO,
1772 "LL_STATS RESULTS RESPONSE result = %p",
1773 linkLayerStatsResults->result);
1774 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1775 {
1776 hdd_link_layer_process_radio_stats(pAdapter,
1777 (v_VOID_t *)linkLayerStatsResults->result);
1778 }
1779 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1780 {
1781 hdd_link_layer_process_iface_stats(pAdapter,
1782 (v_VOID_t *)linkLayerStatsResults->result);
1783 }
1784 else if ( linkLayerStatsResults->paramId &
1785 WMI_LINK_STATS_ALL_PEER )
1786 {
1787 hdd_link_layer_process_peer_stats(pAdapter,
1788 (v_VOID_t *)linkLayerStatsResults->result);
1789 } /* WMI_LINK_STATS_ALL_PEER */
1790 else
1791 {
1792 hddLog(VOS_TRACE_LEVEL_ERROR,
1793 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1794 }
1795
1796 break;
1797 }
1798 default:
1799 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1800 break;
1801 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301802
1803 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301804 return;
1805}
1806
1807const struct
1808nla_policy
1809qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1810{
1811 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1812 { .type = NLA_U32 },
1813 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1814 { .type = NLA_U32 },
1815};
1816
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301817static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1818 struct wireless_dev *wdev,
1819 const void *data,
1820 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301821{
1822 int status;
1823 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301824 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301825 struct net_device *dev = wdev->netdev;
1826 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1827 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Srinivas Dasari98947432014-11-07 19:41:24 +05301828 hdd_station_ctx_t *pHddStaCtx;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301829
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301830 ENTER();
1831
Sunil Duttc69bccb2014-05-26 21:30:20 +05301832 status = wlan_hdd_validate_context(pHddCtx);
1833 if (0 != status)
1834 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301835 return -EINVAL;
1836 }
1837
1838 if (NULL == pAdapter)
1839 {
1840 hddLog(VOS_TRACE_LEVEL_ERROR,
1841 FL("HDD adapter is Null"));
1842 return -ENODEV;
1843 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301844 /* check the LLStats Capability */
1845 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1846 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1847 {
1848 hddLog(VOS_TRACE_LEVEL_ERROR,
1849 FL("Link Layer Statistics not supported by Firmware"));
1850 return -EINVAL;
1851 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301852
1853 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1854 (struct nlattr *)data,
1855 data_len, qca_wlan_vendor_ll_set_policy))
1856 {
1857 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1858 return -EINVAL;
1859 }
1860 if (!tb_vendor
1861 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1862 {
1863 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1864 return -EINVAL;
1865 }
1866 if (!tb_vendor[
1867 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1868 {
1869 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1870 return -EINVAL;
1871 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301872 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301873 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301874
Dino Mycledf0a5d92014-07-04 09:41:55 +05301875 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301876 nla_get_u32(
1877 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1878
Dino Mycledf0a5d92014-07-04 09:41:55 +05301879 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301880 nla_get_u32(
1881 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1882
Dino Mycled3d50022014-07-07 12:58:25 +05301883 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1884 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301885
1886
1887 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301888 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301889 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301890 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301891 hddLog(VOS_TRACE_LEVEL_INFO,
1892 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301893 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301894 hddLog(VOS_TRACE_LEVEL_INFO,
1895 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301896 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301897
1898 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1899 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301900 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301901 {
1902 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1903 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301904 return -EINVAL;
1905
1906 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301907
1908 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1909 if (VOS_STATUS_SUCCESS !=
1910 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1911 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE))
1912 {
1913 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1914 "WLANTL_ClearInterfaceStats Failed", __func__);
1915 return -EINVAL;
1916 }
1917
Sunil Duttc69bccb2014-05-26 21:30:20 +05301918 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301919 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301920 {
1921 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1922 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301923 return -EINVAL;
1924 }
1925
1926 pAdapter->isLinkLayerStatsSet = 1;
1927
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301928 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301929 return 0;
1930}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301931static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1932 struct wireless_dev *wdev,
1933 const void *data,
1934 int data_len)
1935{
1936 int ret = 0;
1937
1938 vos_ssr_protect(__func__);
1939 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1940 vos_ssr_unprotect(__func__);
1941
1942 return ret;
1943}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301944
1945const struct
1946nla_policy
1947qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1948{
1949 /* Unsigned 32bit value provided by the caller issuing the GET stats
1950 * command. When reporting
1951 * the stats results, the driver uses the same value to indicate
1952 * which GET request the results
1953 * correspond to.
1954 */
1955 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1956
1957 /* Unsigned 32bit value . bit mask to identify what statistics are
1958 requested for retrieval */
1959 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1960};
1961
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301962static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1963 struct wireless_dev *wdev,
1964 const void *data,
1965 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301966{
1967 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1968 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301969 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301970 struct net_device *dev = wdev->netdev;
1971 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1972 int status;
1973
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301974 ENTER();
1975
Sunil Duttc69bccb2014-05-26 21:30:20 +05301976 status = wlan_hdd_validate_context(pHddCtx);
1977 if (0 != status)
1978 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301979 return -EINVAL ;
1980 }
1981
1982 if (NULL == pAdapter)
1983 {
1984 hddLog(VOS_TRACE_LEVEL_FATAL,
1985 "%s: HDD adapter is Null", __func__);
1986 return -ENODEV;
1987 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301988 /* check the LLStats Capability */
1989 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1990 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1991 {
1992 hddLog(VOS_TRACE_LEVEL_ERROR,
1993 FL("Link Layer Statistics not supported by Firmware"));
1994 return -EINVAL;
1995 }
1996
Sunil Duttc69bccb2014-05-26 21:30:20 +05301997
1998 if (!pAdapter->isLinkLayerStatsSet)
1999 {
2000 hddLog(VOS_TRACE_LEVEL_FATAL,
2001 "%s: isLinkLayerStatsSet : %d",
2002 __func__, pAdapter->isLinkLayerStatsSet);
2003 return -EINVAL;
2004 }
2005
2006 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2007 (struct nlattr *)data,
2008 data_len, qca_wlan_vendor_ll_get_policy))
2009 {
2010 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2011 return -EINVAL;
2012 }
2013
2014 if (!tb_vendor
2015 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2016 {
2017 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2018 return -EINVAL;
2019 }
2020
2021 if (!tb_vendor
2022 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2023 {
2024 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
2025 return -EINVAL;
2026 }
2027
Sunil Duttc69bccb2014-05-26 21:30:20 +05302028
Dino Mycledf0a5d92014-07-04 09:41:55 +05302029 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302030 nla_get_u32( tb_vendor[
2031 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05302032 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302033 nla_get_u32( tb_vendor[
2034 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
2035
Dino Mycled3d50022014-07-07 12:58:25 +05302036 vos_mem_copy(linkLayerStatsGetReq.macAddr,
2037 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302038
2039 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302040 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302041 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302042 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302043 hddLog(VOS_TRACE_LEVEL_INFO,
2044 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302045 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302046
2047 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302048 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302049 {
2050 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2051 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302052 return -EINVAL;
2053 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302054
2055 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302056 return 0;
2057}
2058
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302059static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2060 struct wireless_dev *wdev,
2061 const void *data,
2062 int data_len)
2063{
2064 int ret = 0;
2065
2066 vos_ssr_protect(__func__);
2067 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
2068 vos_ssr_unprotect(__func__);
2069
2070 return ret;
2071}
2072
Sunil Duttc69bccb2014-05-26 21:30:20 +05302073const struct
2074nla_policy
2075qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
2076{
2077 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
2078 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
2079 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
2080 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
2081};
2082
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302083static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2084 struct wireless_dev *wdev,
2085 const void *data,
2086 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302087{
2088 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2089 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302090 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302091 struct net_device *dev = wdev->netdev;
2092 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2093 u32 statsClearReqMask;
2094 u8 stopReq;
2095 int status;
2096
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302097 ENTER();
2098
Sunil Duttc69bccb2014-05-26 21:30:20 +05302099 status = wlan_hdd_validate_context(pHddCtx);
2100 if (0 != status)
2101 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302102 return -EINVAL;
2103 }
2104
2105 if (NULL == pAdapter)
2106 {
2107 hddLog(VOS_TRACE_LEVEL_FATAL,
2108 "%s: HDD adapter is Null", __func__);
2109 return -ENODEV;
2110 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302111 /* check the LLStats Capability */
2112 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2113 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2114 {
2115 hddLog(VOS_TRACE_LEVEL_ERROR,
2116 FL("Enable LLStats Capability"));
2117 return -EINVAL;
2118 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302119
2120 if (!pAdapter->isLinkLayerStatsSet)
2121 {
2122 hddLog(VOS_TRACE_LEVEL_FATAL,
2123 "%s: isLinkLayerStatsSet : %d",
2124 __func__, pAdapter->isLinkLayerStatsSet);
2125 return -EINVAL;
2126 }
2127
2128 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2129 (struct nlattr *)data,
2130 data_len, qca_wlan_vendor_ll_clr_policy))
2131 {
2132 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2133 return -EINVAL;
2134 }
2135
2136 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2137
2138 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2139 {
2140 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2141 return -EINVAL;
2142
2143 }
2144
Sunil Duttc69bccb2014-05-26 21:30:20 +05302145
Dino Mycledf0a5d92014-07-04 09:41:55 +05302146 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302147 nla_get_u32(
2148 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2149
Dino Mycledf0a5d92014-07-04 09:41:55 +05302150 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302151 nla_get_u8(
2152 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2153
2154 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302155 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302156
Dino Mycled3d50022014-07-07 12:58:25 +05302157 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2158 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302159
2160 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302161 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302162 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302163 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302164 hddLog(VOS_TRACE_LEVEL_INFO,
2165 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302166 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302167 hddLog(VOS_TRACE_LEVEL_INFO,
2168 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302169 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302170
2171 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302172 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302173 {
2174 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302175 hdd_station_ctx_t *pHddStaCtx;
2176
2177 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2178 if (VOS_STATUS_SUCCESS !=
2179 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2180 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2181 {
2182 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2183 "WLANTL_ClearInterfaceStats Failed", __func__);
2184 return -EINVAL;
2185 }
2186 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2187 (statsClearReqMask & WIFI_STATS_IFACE)) {
2188 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2189 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2190 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2191 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2192 }
2193
Sunil Duttc69bccb2014-05-26 21:30:20 +05302194 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2195 2 * sizeof(u32) +
2196 NLMSG_HDRLEN);
2197
2198 if (temp_skbuff != NULL)
2199 {
2200
2201 if (nla_put_u32(temp_skbuff,
2202 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2203 statsClearReqMask) ||
2204 nla_put_u32(temp_skbuff,
2205 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2206 stopReq))
2207 {
2208 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2209 kfree_skb(temp_skbuff);
2210 return -EINVAL;
2211 }
2212 /* If the ask is to stop the stats collection as part of clear
2213 * (stopReq = 1) , ensure that no further requests of get
2214 * go to the firmware by having isLinkLayerStatsSet set to 0.
2215 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302216 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302217 * case the firmware is just asked to clear the statistics.
2218 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302219 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302220 pAdapter->isLinkLayerStatsSet = 0;
2221 return cfg80211_vendor_cmd_reply(temp_skbuff);
2222 }
2223 return -ENOMEM;
2224 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302225
2226 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302227 return -EINVAL;
2228}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302229static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2230 struct wireless_dev *wdev,
2231 const void *data,
2232 int data_len)
2233{
2234 int ret = 0;
2235
2236 vos_ssr_protect(__func__);
2237 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2238 vos_ssr_unprotect(__func__);
2239
2240 return ret;
2241
2242
2243}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302244#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2245
Dino Mycle6fb96c12014-06-10 11:52:40 +05302246#ifdef WLAN_FEATURE_EXTSCAN
2247static const struct nla_policy
2248wlan_hdd_extscan_config_policy
2249 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2250{
2251 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2252 { .type = NLA_U32 },
2253 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2254 { .type = NLA_U32 },
2255 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2256 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2257 { .type = NLA_U32 },
2258 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2259 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2260
2261 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2262 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2263 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2264 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2265 { .type = NLA_U8 },
2266 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2267 { .type = NLA_U32 },
2268 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2269 { .type = NLA_U32 },
2270 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2271 { .type = NLA_U32 },
2272 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] =
2273 { .type = NLA_U8 },
2274 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2275 { .type = NLA_U8 },
2276 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2277 { .type = NLA_U8 },
2278
2279 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2280 { .type = NLA_U32 },
2281 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2282 { .type = NLA_UNSPEC },
2283 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2284 { .type = NLA_S32 },
2285 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2286 { .type = NLA_S32 },
2287 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2288 { .type = NLA_U32 },
2289 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2290 { .type = NLA_U32 },
2291 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] =
2292 { .type = NLA_U32 },
2293 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]
2294 = { .type = NLA_U32 },
2295 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] =
2296 { .type = NLA_U32 },
2297 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type =
2298 NLA_U32 },
2299};
2300
2301static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg)
2302{
2303 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2304 struct sk_buff *skb = NULL;
2305 tpSirEXTScanCapabilitiesEvent pData =
2306 (tpSirEXTScanCapabilitiesEvent) pMsg;
2307
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302308 ENTER();
2309
2310 if (wlan_hdd_validate_context(pHddCtx))
2311 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302312 return;
2313 }
2314
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302315 if (!pMsg)
2316 {
2317 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2318 return;
2319 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302320 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2321 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2322 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
2323 GFP_KERNEL);
2324
2325 if (!skb) {
2326 hddLog(VOS_TRACE_LEVEL_ERROR,
2327 FL("cfg80211_vendor_event_alloc failed"));
2328 return;
2329 }
2330
2331 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2332 hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize);
2333 hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets);
2334 hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan);
2335 hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)",
2336 pData->maxRssiSampleSize);
2337 hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)",
2338 pData->maxScanReportingThreshold);
2339 hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs);
2340 hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)",
2341 pData->maxSignificantWifiChangeAPs);
2342 hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)",
2343 pData->maxBsidHistoryEntries);
2344
2345 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2346 pData->requestId) ||
2347 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) ||
2348 nla_put_u32(skb,
2349 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
2350 pData->scanCacheSize) ||
2351 nla_put_u32(skb,
2352 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
2353 pData->scanBuckets) ||
2354 nla_put_u32(skb,
2355 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
2356 pData->maxApPerScan) ||
2357 nla_put_u32(skb,
2358 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
2359 pData->maxRssiSampleSize) ||
2360 nla_put_u32(skb,
2361 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
2362 pData->maxScanReportingThreshold) ||
2363 nla_put_u32(skb,
2364 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS,
2365 pData->maxHotlistAPs) ||
2366 nla_put_u32(skb,
2367 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
2368 pData->maxSignificantWifiChangeAPs) ||
2369 nla_put_u32(skb,
2370 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
2371 pData->maxBsidHistoryEntries)) {
2372 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2373 goto nla_put_failure;
2374 }
2375
2376 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302377 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302378 return;
2379
2380nla_put_failure:
2381 kfree_skb(skb);
2382 return;
2383}
2384
2385
2386static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2387{
2388 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2389 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2390 struct sk_buff *skb = NULL;
2391 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
2392
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302393 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302394
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302395 if (wlan_hdd_validate_context(pHddCtx)){
2396 return;
2397 }
2398 if (!pMsg)
2399 {
2400 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302401 return;
2402 }
2403
2404 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2405 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2406 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
2407 GFP_KERNEL);
2408
2409 if (!skb) {
2410 hddLog(VOS_TRACE_LEVEL_ERROR,
2411 FL("cfg80211_vendor_event_alloc failed"));
2412 return;
2413 }
2414 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2415 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2416 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2417
2418 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2419 pData->requestId) ||
2420 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2421 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2422 goto nla_put_failure;
2423 }
2424
2425 /*
2426 * Store the Request ID for comparing with the requestID obtained
2427 * in other requests.HDD shall return a failure is the extscan_stop
2428 * request is issued with a different requestId as that of the
2429 * extscan_start request. Also, This requestId shall be used while
2430 * indicating the full scan results to the upper layers.
2431 * The requestId is stored with the assumption that the firmware
2432 * shall return the ext scan start request's requestId in ext scan
2433 * start response.
2434 */
2435 if (pData->status == 0)
2436 pMac->sme.extScanStartReqId = pData->requestId;
2437
2438
2439 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302440 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302441 return;
2442
2443nla_put_failure:
2444 kfree_skb(skb);
2445 return;
2446}
2447
2448
2449static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2450{
2451 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2452 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2453 struct sk_buff *skb = NULL;
2454
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302455 ENTER();
2456
2457 if (wlan_hdd_validate_context(pHddCtx)){
2458 return;
2459 }
2460 if (!pMsg)
2461 {
2462 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302463 return;
2464 }
2465
2466 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2467 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2468 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2469 GFP_KERNEL);
2470
2471 if (!skb) {
2472 hddLog(VOS_TRACE_LEVEL_ERROR,
2473 FL("cfg80211_vendor_event_alloc failed"));
2474 return;
2475 }
2476 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2477 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2478
2479 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2480 pData->requestId) ||
2481 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2482 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2483 goto nla_put_failure;
2484 }
2485
2486 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302487 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302488 return;
2489
2490nla_put_failure:
2491 kfree_skb(skb);
2492 return;
2493}
2494
2495
2496static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2497 void *pMsg)
2498{
2499 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2500 struct sk_buff *skb = NULL;
2501 tpSirEXTScanSetBssidHotListRspParams pData =
2502 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2503
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302504 ENTER();
2505
2506 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302507 return;
2508 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302509 if (!pMsg)
2510 {
2511 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2512 return;
2513 }
2514
Dino Mycle6fb96c12014-06-10 11:52:40 +05302515 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2516 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2517 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2518 GFP_KERNEL);
2519
2520 if (!skb) {
2521 hddLog(VOS_TRACE_LEVEL_ERROR,
2522 FL("cfg80211_vendor_event_alloc failed"));
2523 return;
2524 }
2525 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2526 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2527 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2528
2529 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2530 pData->requestId) ||
2531 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2532 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2533 goto nla_put_failure;
2534 }
2535
2536 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302537 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302538 return;
2539
2540nla_put_failure:
2541 kfree_skb(skb);
2542 return;
2543}
2544
2545static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2546 void *pMsg)
2547{
2548 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2549 struct sk_buff *skb = NULL;
2550 tpSirEXTScanResetBssidHotlistRspParams pData =
2551 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2552
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302553 ENTER();
2554
2555 if (wlan_hdd_validate_context(pHddCtx)) {
2556 return;
2557 }
2558 if (!pMsg)
2559 {
2560 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302561 return;
2562 }
2563
2564 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2565 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2566 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2567 GFP_KERNEL);
2568
2569 if (!skb) {
2570 hddLog(VOS_TRACE_LEVEL_ERROR,
2571 FL("cfg80211_vendor_event_alloc failed"));
2572 return;
2573 }
2574 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2575 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2576
2577 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2578 pData->requestId) ||
2579 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2580 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2581 goto nla_put_failure;
2582 }
2583
2584 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302585 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302586 return;
2587
2588nla_put_failure:
2589 kfree_skb(skb);
2590 return;
2591}
2592
2593
2594static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2595 void *pMsg)
2596{
2597 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2598 struct sk_buff *skb = NULL;
2599 tpSirEXTScanSetSignificantChangeRspParams pData =
2600 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2601
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302602 ENTER();
2603
2604 if (wlan_hdd_validate_context(pHddCtx)) {
2605 return;
2606 }
2607 if (!pMsg)
2608 {
2609 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302610 return;
2611 }
2612
2613 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2614 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2615 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2616 GFP_KERNEL);
2617
2618 if (!skb) {
2619 hddLog(VOS_TRACE_LEVEL_ERROR,
2620 FL("cfg80211_vendor_event_alloc failed"));
2621 return;
2622 }
2623 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2624 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2625 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2626
2627 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2628 pData->requestId) ||
2629 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2630 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2631 goto nla_put_failure;
2632 }
2633
2634 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302635 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302636 return;
2637
2638nla_put_failure:
2639 kfree_skb(skb);
2640 return;
2641}
2642
2643
2644static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2645 void *pMsg)
2646{
2647 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2648 struct sk_buff *skb = NULL;
2649 tpSirEXTScanResetSignificantChangeRspParams pData =
2650 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2651
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302652 ENTER();
2653
2654 if (wlan_hdd_validate_context(pHddCtx)) {
2655 return;
2656 }
2657 if (!pMsg)
2658 {
2659 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302660 return;
2661 }
2662
2663 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2664 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2665 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2666 GFP_KERNEL);
2667
2668 if (!skb) {
2669 hddLog(VOS_TRACE_LEVEL_ERROR,
2670 FL("cfg80211_vendor_event_alloc failed"));
2671 return;
2672 }
2673 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2674 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2675 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2676
2677 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2678 pData->requestId) ||
2679 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2680 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2681 goto nla_put_failure;
2682 }
2683
2684 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302685 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302686 return;
2687
2688nla_put_failure:
2689 kfree_skb(skb);
2690 return;
2691}
2692
2693static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2694 void *pMsg)
2695{
2696 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2697 struct sk_buff *skb = NULL;
2698 tANI_U32 i = 0, j, resultsPerEvent;
2699 tANI_S32 totalResults;
2700 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2701 tpSirWifiScanResult pSirWifiScanResult;
2702
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302703 ENTER();
2704
2705 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302706 return;
2707 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302708 if (!pMsg)
2709 {
2710 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2711 return;
2712 }
2713
Dino Mycle6fb96c12014-06-10 11:52:40 +05302714 totalResults = pData->numOfAps;
2715 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2716 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2717 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2718
2719 do{
2720 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2721 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2722 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2723
2724 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2725 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2726 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2727 GFP_KERNEL);
2728
2729 if (!skb) {
2730 hddLog(VOS_TRACE_LEVEL_ERROR,
2731 FL("cfg80211_vendor_event_alloc failed"));
2732 return;
2733 }
2734
2735 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2736
2737 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2738 pData->requestId) ||
2739 nla_put_u32(skb,
2740 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2741 resultsPerEvent)) {
2742 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2743 goto fail;
2744 }
2745 if (nla_put_u8(skb,
2746 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2747 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2748 {
2749 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2750 goto fail;
2751 }
2752
2753 if (resultsPerEvent) {
2754 struct nlattr *aps;
2755
2756 aps = nla_nest_start(skb,
2757 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2758 if (!aps)
2759 {
2760 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2761 goto fail;
2762 }
2763
2764 for (j = 0; j < resultsPerEvent; j++, i++) {
2765 struct nlattr *ap;
2766 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2767 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2768
2769 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2770 "Ssid (%s)"
2771 "Bssid: %pM "
2772 "Channel (%u)"
2773 "Rssi (%d)"
2774 "RTT (%u)"
2775 "RTT_SD (%u)",
2776 i,
2777 pSirWifiScanResult->ts,
2778 pSirWifiScanResult->ssid,
2779 pSirWifiScanResult->bssid,
2780 pSirWifiScanResult->channel,
2781 pSirWifiScanResult->rssi,
2782 pSirWifiScanResult->rtt,
2783 pSirWifiScanResult->rtt_sd);
2784
2785 ap = nla_nest_start(skb, j + 1);
2786 if (!ap)
2787 {
2788 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2789 goto fail;
2790 }
2791
2792 if (nla_put_u64(skb,
2793 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2794 pSirWifiScanResult->ts) )
2795 {
2796 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2797 goto fail;
2798 }
2799 if (nla_put(skb,
2800 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2801 sizeof(pSirWifiScanResult->ssid),
2802 pSirWifiScanResult->ssid) )
2803 {
2804 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2805 goto fail;
2806 }
2807 if (nla_put(skb,
2808 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2809 sizeof(pSirWifiScanResult->bssid),
2810 pSirWifiScanResult->bssid) )
2811 {
2812 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2813 goto fail;
2814 }
2815 if (nla_put_u32(skb,
2816 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2817 pSirWifiScanResult->channel) )
2818 {
2819 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2820 goto fail;
2821 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302822 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302823 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2824 pSirWifiScanResult->rssi) )
2825 {
2826 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2827 goto fail;
2828 }
2829 if (nla_put_u32(skb,
2830 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2831 pSirWifiScanResult->rtt) )
2832 {
2833 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2834 goto fail;
2835 }
2836 if (nla_put_u32(skb,
2837 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2838 pSirWifiScanResult->rtt_sd))
2839 {
2840 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2841 goto fail;
2842 }
2843
2844 nla_nest_end(skb, ap);
2845 }
2846 nla_nest_end(skb, aps);
2847
2848 }
2849 cfg80211_vendor_event(skb, GFP_KERNEL);
2850 } while (totalResults > 0);
2851
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302852 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302853 return;
2854fail:
2855 kfree_skb(skb);
2856 return;
2857}
2858
2859static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2860 void *pMsg)
2861{
2862 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2863 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2864 struct sk_buff *skb = NULL;
2865 tANI_U32 i;
2866
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302867 ENTER();
2868
2869 if (wlan_hdd_validate_context(pHddCtx)) {
2870 return;
2871 }
2872 if (!pMsg)
2873 {
2874 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302875 return;
2876 }
2877
2878 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2879 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2880 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
2881 GFP_KERNEL);
2882
2883 if (!skb) {
2884 hddLog(VOS_TRACE_LEVEL_ERROR,
2885 FL("cfg80211_vendor_event_alloc failed"));
2886 return;
2887 }
2888 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2889 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2890 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2891 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2892
2893 for (i = 0; i < pData->numOfAps; i++) {
2894 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2895 "Ssid (%s) "
2896 "Bssid (" MAC_ADDRESS_STR ") "
2897 "Channel (%u) "
2898 "Rssi (%d) "
2899 "RTT (%u) "
2900 "RTT_SD (%u) ",
2901 i,
2902 pData->ap[i].ts,
2903 pData->ap[i].ssid,
2904 MAC_ADDR_ARRAY(pData->ap[i].bssid),
2905 pData->ap[i].channel,
2906 pData->ap[i].rssi,
2907 pData->ap[i].rtt,
2908 pData->ap[i].rtt_sd);
2909 }
2910
2911 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2912 pData->requestId) ||
2913 nla_put_u32(skb,
2914 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2915 pData->numOfAps)) {
2916 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2917 goto fail;
2918 }
2919 if (pData->numOfAps) {
2920 struct nlattr *aps;
2921
2922 aps = nla_nest_start(skb,
2923 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2924 if (!aps)
2925 goto fail;
2926
2927 for (i = 0; i < pData->numOfAps; i++) {
2928 struct nlattr *ap;
2929
2930 ap = nla_nest_start(skb, i + 1);
2931 if (!ap)
2932 goto fail;
2933
2934 if (nla_put_u64(skb,
2935 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2936 pData->ap[i].ts) ||
2937 nla_put(skb,
2938 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2939 sizeof(pData->ap[i].ssid),
2940 pData->ap[i].ssid) ||
2941 nla_put(skb,
2942 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2943 sizeof(pData->ap[i].bssid),
2944 pData->ap[i].bssid) ||
2945 nla_put_u32(skb,
2946 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2947 pData->ap[i].channel) ||
2948 nla_put_s32(skb,
2949 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2950 pData->ap[i].rssi) ||
2951 nla_put_u32(skb,
2952 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2953 pData->ap[i].rtt) ||
2954 nla_put_u32(skb,
2955 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2956 pData->ap[i].rtt_sd))
2957 goto fail;
2958
2959 nla_nest_end(skb, ap);
2960 }
2961 nla_nest_end(skb, aps);
2962
2963 if (nla_put_u8(skb,
2964 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2965 pData->moreData))
2966 goto fail;
2967 }
2968
2969 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302970 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302971 return;
2972
2973fail:
2974 kfree_skb(skb);
2975 return;
2976
2977}
2978static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
2979 void *pMsg)
2980{
2981 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2982 struct sk_buff *skb = NULL;
2983 tANI_U32 i, j;
2984 tpSirWifiSignificantChangeEvent pData =
2985 (tpSirWifiSignificantChangeEvent) pMsg;
2986
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302987 ENTER();
2988
2989 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302990 return;
2991 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302992 if (!pMsg)
2993 {
2994 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2995 return;
2996 }
2997
Dino Mycle6fb96c12014-06-10 11:52:40 +05302998 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2999 EXTSCAN_EVENT_BUF_SIZE,
3000 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
3001 GFP_KERNEL);
3002
3003 if (!skb) {
3004 hddLog(VOS_TRACE_LEVEL_ERROR,
3005 FL("cfg80211_vendor_event_alloc failed"));
3006 return;
3007 }
3008 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3009 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3010 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
3011 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
3012 pData->numSigRssiBss);
3013 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
3014
3015 for (i = 0; i < pData->numSigRssiBss; i++) {
3016 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
3017 " num RSSI %u ",
3018 i, pData->sigRssiResult[i].bssid,
3019 pData->sigRssiResult[i].channel,
3020 pData->sigRssiResult[i].numRssi);
3021
3022 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
3023
3024 hddLog(VOS_TRACE_LEVEL_INFO,
3025 " [%d]",
Dino Myclec8f3f332014-07-21 16:48:27 +05303026 pData->sigRssiResult[i].rssi[j]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303027
3028 }
3029 }
3030
3031
3032 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3033 pData->requestId) ||
3034 nla_put_u32(skb,
3035 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3036 pData->numSigRssiBss)) {
3037 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3038 goto fail;
3039 }
3040
3041 if (pData->numSigRssiBss) {
3042 struct nlattr *aps;
3043 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3044 if (!aps)
3045 goto fail;
3046 for (i = 0; i < pData->numSigRssiBss; i++) {
3047 struct nlattr *ap;
3048
3049 ap = nla_nest_start(skb, i);
3050 if (!ap)
3051 goto fail;
3052 if (nla_put(skb,
3053 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
3054 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
3055 nla_put_u32(skb,
3056 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
3057 pData->sigRssiResult[i].channel) ||
3058 nla_put_u32(skb,
3059 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
3060 pData->sigRssiResult[i].numRssi) ||
3061 nla_put(skb,
3062 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
3063 sizeof(s32) * pData->sigRssiResult[i].numRssi,
3064 pData->sigRssiResult[i].rssi))
3065 goto fail;
3066 nla_nest_end(skb, ap);
3067 }
3068 nla_nest_end(skb, aps);
3069 if (nla_put_u8(skb,
3070 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3071 pData->moreData))
3072 goto fail;
3073 }
3074 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303075 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303076 return;
3077fail:
3078 kfree_skb(skb);
3079 return;
3080}
3081
3082static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3083 void *pMsg)
3084{
3085 struct sk_buff *skb;
3086 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3087 tpSirWifiFullScanResultEvent pData =
3088 (tpSirWifiFullScanResultEvent) (pMsg);
3089
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303090 ENTER();
3091
3092 if (wlan_hdd_validate_context(pHddCtx)) {
3093 return;
3094 }
3095 if (!pMsg)
3096 {
3097 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303098 return;
3099 }
3100
3101 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3102 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3103 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3104 GFP_KERNEL);
3105
3106 if (!skb) {
3107 hddLog(VOS_TRACE_LEVEL_ERROR,
3108 FL("cfg80211_vendor_event_alloc failed"));
3109 return;
3110 }
3111
3112 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3113 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3114 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3115 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3116 "Ssid (%s)"
3117 "Bssid (" MAC_ADDRESS_STR ")"
3118 "Channel (%u)"
3119 "Rssi (%d)"
3120 "RTT (%u)"
3121 "RTT_SD (%u)"),
3122 pData->ap.ts,
3123 pData->ap.ssid,
3124 MAC_ADDR_ARRAY(pData->ap.bssid),
3125 pData->ap.channel,
3126 pData->ap.rssi,
3127 pData->ap.rtt,
3128 pData->ap.rtt_sd);
3129 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3130 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3131 pData->requestId) ||
3132 nla_put_u64(skb,
3133 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3134 pData->ap.ts) ||
3135 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3136 sizeof(pData->ap.ssid),
3137 pData->ap.ssid) ||
3138 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3139 WNI_CFG_BSSID_LEN,
3140 pData->ap.bssid) ||
3141 nla_put_u32(skb,
3142 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3143 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303144 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303145 pData->ap.rssi) ||
3146 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3147 pData->ap.rtt) ||
3148 nla_put_u32(skb,
3149 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3150 pData->ap.rtt_sd) ||
3151 nla_put_u16(skb,
3152 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3153 pData->ap.beaconPeriod) ||
3154 nla_put_u16(skb,
3155 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3156 pData->ap.capability) ||
3157 nla_put_u32(skb,
3158 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3159 pData->ieLength))
3160 {
3161 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3162 goto nla_put_failure;
3163 }
3164 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3165 pData->ieLength,
3166 pData->ie))
3167 {
3168 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3169 goto nla_put_failure;
3170 }
3171
3172 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303173 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303174 return;
3175
3176nla_put_failure:
3177 kfree_skb(skb);
3178 return;
3179}
3180
3181static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3182 void *pMsg)
3183{
3184 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3185 struct sk_buff *skb = NULL;
3186 tpSirEXTScanResultsAvailableIndParams pData =
3187 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3188
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303189 ENTER();
3190
3191 if (wlan_hdd_validate_context(pHddCtx)){
3192 return;
3193 }
3194 if (!pMsg)
3195 {
3196 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303197 return;
3198 }
3199
3200 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3201 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3202 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3203 GFP_KERNEL);
3204
3205 if (!skb) {
3206 hddLog(VOS_TRACE_LEVEL_ERROR,
3207 FL("cfg80211_vendor_event_alloc failed"));
3208 return;
3209 }
3210
3211 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3212 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3213 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3214 pData->numResultsAvailable);
3215 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3216 pData->requestId) ||
3217 nla_put_u32(skb,
3218 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3219 pData->numResultsAvailable)) {
3220 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3221 goto nla_put_failure;
3222 }
3223
3224 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303225 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303226 return;
3227
3228nla_put_failure:
3229 kfree_skb(skb);
3230 return;
3231}
3232
3233static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3234{
3235 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3236 struct sk_buff *skb = NULL;
3237 tpSirEXTScanProgressIndParams pData =
3238 (tpSirEXTScanProgressIndParams) pMsg;
3239
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303240 ENTER();
3241
3242 if (wlan_hdd_validate_context(pHddCtx)){
3243 return;
3244 }
3245 if (!pMsg)
3246 {
3247 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303248 return;
3249 }
3250
3251 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3252 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3253 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3254 GFP_KERNEL);
3255
3256 if (!skb) {
3257 hddLog(VOS_TRACE_LEVEL_ERROR,
3258 FL("cfg80211_vendor_event_alloc failed"));
3259 return;
3260 }
3261 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3262 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3263 pData->extScanEventType);
3264 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3265 pData->status);
3266
3267 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3268 pData->extScanEventType) ||
3269 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303270 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3271 pData->requestId) ||
3272 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303273 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3274 pData->status)) {
3275 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3276 goto nla_put_failure;
3277 }
3278
3279 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303280 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303281 return;
3282
3283nla_put_failure:
3284 kfree_skb(skb);
3285 return;
3286}
3287
3288void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3289 void *pMsg)
3290{
3291 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3292
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303293 ENTER();
3294
Dino Mycle6fb96c12014-06-10 11:52:40 +05303295 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303296 return;
3297 }
3298
3299 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3300
3301
3302 switch(evType) {
3303 case SIR_HAL_EXTSCAN_START_RSP:
3304 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3305 break;
3306
3307 case SIR_HAL_EXTSCAN_STOP_RSP:
3308 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3309 break;
3310 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3311 /* There is no need to send this response to upper layer
3312 Just log the message */
3313 hddLog(VOS_TRACE_LEVEL_INFO,
3314 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3315 break;
3316 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3317 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3318 break;
3319
3320 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3321 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3322 break;
3323
3324 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
3325 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
3326 break;
3327
3328 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
3329 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
3330 break;
3331 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
3332 wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg);
3333 break;
3334 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3335 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3336 break;
3337 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3338 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3339 break;
3340 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3341 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3342 break;
3343 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3344 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3345 break;
3346 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
3347 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
3348 break;
3349 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3350 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3351 break;
3352 default:
3353 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3354 break;
3355 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303356 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303357}
3358
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303359static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3360 struct wireless_dev *wdev,
3361 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303362{
Dino Myclee8843b32014-07-04 14:21:45 +05303363 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303364 struct net_device *dev = wdev->netdev;
3365 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3366 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3367 struct nlattr
3368 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3369 eHalStatus status;
3370
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303371 ENTER();
3372
Dino Mycle6fb96c12014-06-10 11:52:40 +05303373 status = wlan_hdd_validate_context(pHddCtx);
3374 if (0 != status)
3375 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303376 return -EINVAL;
3377 }
Dino Myclee8843b32014-07-04 14:21:45 +05303378 /* check the EXTScan Capability */
3379 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3380 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3381 {
3382 hddLog(VOS_TRACE_LEVEL_ERROR,
3383 FL("EXTScan not enabled/supported by Firmware"));
3384 return -EINVAL;
3385 }
3386
Dino Mycle6fb96c12014-06-10 11:52:40 +05303387 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3388 data, dataLen,
3389 wlan_hdd_extscan_config_policy)) {
3390 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3391 return -EINVAL;
3392 }
3393
3394 /* Parse and fetch request Id */
3395 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3396 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3397 return -EINVAL;
3398 }
3399
Dino Mycle6fb96c12014-06-10 11:52:40 +05303400
Dino Myclee8843b32014-07-04 14:21:45 +05303401 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303402 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303403 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303404
Dino Myclee8843b32014-07-04 14:21:45 +05303405 reqMsg.sessionId = pAdapter->sessionId;
3406 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303407
Dino Myclee8843b32014-07-04 14:21:45 +05303408 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303409 if (!HAL_STATUS_SUCCESS(status)) {
3410 hddLog(VOS_TRACE_LEVEL_ERROR,
3411 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303412 return -EINVAL;
3413 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303414 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303415 return 0;
3416}
3417
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303418static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3419 struct wireless_dev *wdev,
3420 const void *data, int dataLen)
3421{
3422 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303423
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303424 vos_ssr_protect(__func__);
3425 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3426 vos_ssr_unprotect(__func__);
3427
3428 return ret;
3429}
3430
3431static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3432 struct wireless_dev *wdev,
3433 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303434{
Dino Myclee8843b32014-07-04 14:21:45 +05303435 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303436 struct net_device *dev = wdev->netdev;
3437 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3438 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3439 struct nlattr
3440 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3441 eHalStatus status;
3442
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303443 ENTER();
3444
Dino Mycle6fb96c12014-06-10 11:52:40 +05303445 status = wlan_hdd_validate_context(pHddCtx);
3446 if (0 != status)
3447 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303448 return -EINVAL;
3449 }
Dino Myclee8843b32014-07-04 14:21:45 +05303450 /* check the EXTScan Capability */
3451 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3452 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3453 {
3454 hddLog(VOS_TRACE_LEVEL_ERROR,
3455 FL("EXTScan not enabled/supported by Firmware"));
3456 return -EINVAL;
3457 }
3458
Dino Mycle6fb96c12014-06-10 11:52:40 +05303459 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3460 data, dataLen,
3461 wlan_hdd_extscan_config_policy)) {
3462 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3463 return -EINVAL;
3464 }
3465 /* Parse and fetch request Id */
3466 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3467 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3468 return -EINVAL;
3469 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303470
Dino Myclee8843b32014-07-04 14:21:45 +05303471 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303472 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3473
Dino Myclee8843b32014-07-04 14:21:45 +05303474 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303475
Dino Myclee8843b32014-07-04 14:21:45 +05303476 reqMsg.sessionId = pAdapter->sessionId;
3477 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303478
3479 /* Parse and fetch flush parameter */
3480 if (!tb
3481 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3482 {
3483 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3484 goto failed;
3485 }
Dino Myclee8843b32014-07-04 14:21:45 +05303486 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303487 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3488
Dino Myclee8843b32014-07-04 14:21:45 +05303489 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303490
Dino Myclee8843b32014-07-04 14:21:45 +05303491 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303492 if (!HAL_STATUS_SUCCESS(status)) {
3493 hddLog(VOS_TRACE_LEVEL_ERROR,
3494 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303495 return -EINVAL;
3496 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303497 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303498 return 0;
3499
3500failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303501 return -EINVAL;
3502}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303503static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3504 struct wireless_dev *wdev,
3505 const void *data, int dataLen)
3506{
3507 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303508
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303509 vos_ssr_protect(__func__);
3510 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3511 vos_ssr_unprotect(__func__);
3512
3513 return ret;
3514}
3515
3516static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303517 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303518 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303519{
3520 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3521 struct net_device *dev = wdev->netdev;
3522 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3523 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3524 struct nlattr
3525 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3526 struct nlattr
3527 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3528 struct nlattr *apTh;
3529 eHalStatus status;
3530 tANI_U8 i = 0;
3531 int rem;
3532
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303533 ENTER();
3534
Dino Mycle6fb96c12014-06-10 11:52:40 +05303535 status = wlan_hdd_validate_context(pHddCtx);
3536 if (0 != status)
3537 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303538 return -EINVAL;
3539 }
Dino Myclee8843b32014-07-04 14:21:45 +05303540 /* check the EXTScan Capability */
3541 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3542 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3543 {
3544 hddLog(VOS_TRACE_LEVEL_ERROR,
3545 FL("EXTScan not enabled/supported by Firmware"));
3546 return -EINVAL;
3547 }
3548
Dino Mycle6fb96c12014-06-10 11:52:40 +05303549 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3550 data, dataLen,
3551 wlan_hdd_extscan_config_policy)) {
3552 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3553 return -EINVAL;
3554 }
3555
3556 /* Parse and fetch request Id */
3557 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3558 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3559 return -EINVAL;
3560 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303561 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3562 vos_mem_malloc(sizeof(*pReqMsg));
3563 if (!pReqMsg) {
3564 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3565 return -ENOMEM;
3566 }
3567
Dino Myclee8843b32014-07-04 14:21:45 +05303568
Dino Mycle6fb96c12014-06-10 11:52:40 +05303569 pReqMsg->requestId = nla_get_u32(
3570 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3571 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3572
3573 /* Parse and fetch number of APs */
3574 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3575 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3576 goto fail;
3577 }
3578
3579 pReqMsg->sessionId = pAdapter->sessionId;
3580 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3581
3582 pReqMsg->numAp = nla_get_u32(
3583 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3584 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3585
3586 nla_for_each_nested(apTh,
3587 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3588 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3589 nla_data(apTh), nla_len(apTh),
3590 NULL)) {
3591 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3592 goto fail;
3593 }
3594
3595 /* Parse and fetch MAC address */
3596 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3597 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3598 goto fail;
3599 }
3600 memcpy(pReqMsg->ap[i].bssid, nla_data(
3601 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3602 sizeof(tSirMacAddr));
3603 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3604
3605 /* Parse and fetch low RSSI */
3606 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3607 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3608 goto fail;
3609 }
3610 pReqMsg->ap[i].low = nla_get_s32(
3611 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3612 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3613
3614 /* Parse and fetch high RSSI */
3615 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3616 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3617 goto fail;
3618 }
3619 pReqMsg->ap[i].high = nla_get_s32(
3620 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3621 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3622 pReqMsg->ap[i].high);
3623
3624 /* Parse and fetch channel */
3625 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3626 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3627 goto fail;
3628 }
3629 pReqMsg->ap[i].channel = nla_get_u32(
3630 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3631 hddLog(VOS_TRACE_LEVEL_INFO,
3632 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3633 i++;
3634 }
3635 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3636 if (!HAL_STATUS_SUCCESS(status)) {
3637 hddLog(VOS_TRACE_LEVEL_ERROR,
3638 FL("sme_SetBssHotlist failed(err=%d)"), status);
3639 vos_mem_free(pReqMsg);
3640 return -EINVAL;
3641 }
3642
Dino Myclee8843b32014-07-04 14:21:45 +05303643 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303644 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303645 return 0;
3646
3647fail:
3648 vos_mem_free(pReqMsg);
3649 return -EINVAL;
3650}
3651
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303652static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3653 struct wireless_dev *wdev,
3654 const void *data, int dataLen)
3655{
3656 int ret = 0;
3657
3658 vos_ssr_protect(__func__);
3659 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3660 dataLen);
3661 vos_ssr_unprotect(__func__);
3662
3663 return ret;
3664}
3665
3666static int __wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303667 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303668 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303669{
3670 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3671 struct net_device *dev = wdev->netdev;
3672 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3673 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3674 struct nlattr
3675 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3676 struct nlattr
3677 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3678 struct nlattr *apTh;
3679 eHalStatus status;
3680 int i = 0;
3681 int rem;
3682
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303683 ENTER();
3684
Dino Mycle6fb96c12014-06-10 11:52:40 +05303685 status = wlan_hdd_validate_context(pHddCtx);
3686 if (0 != status)
3687 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303688 return -EINVAL;
3689 }
Dino Myclee8843b32014-07-04 14:21:45 +05303690 /* check the EXTScan Capability */
3691 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3692 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3693 {
3694 hddLog(VOS_TRACE_LEVEL_ERROR,
3695 FL("EXTScan not enabled/supported by Firmware"));
3696 return -EINVAL;
3697 }
3698
Dino Mycle6fb96c12014-06-10 11:52:40 +05303699 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3700 data, dataLen,
3701 wlan_hdd_extscan_config_policy)) {
3702 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3703 return -EINVAL;
3704 }
3705
3706 /* Parse and fetch request Id */
3707 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3708 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3709 return -EINVAL;
3710 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303711 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303712 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303713 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303714 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3715 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303716 }
3717
Dino Myclee8843b32014-07-04 14:21:45 +05303718
3719
Dino Mycle6fb96c12014-06-10 11:52:40 +05303720 pReqMsg->requestId = nla_get_u32(
3721 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3722 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3723
3724 /* Parse and fetch RSSI sample size */
3725 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3726 {
3727 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3728 goto fail;
3729 }
3730 pReqMsg->rssiSampleSize = nla_get_u32(
3731 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3732 hddLog(VOS_TRACE_LEVEL_INFO,
3733 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3734
3735 /* Parse and fetch lost AP sample size */
3736 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3737 {
3738 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3739 goto fail;
3740 }
3741 pReqMsg->lostApSampleSize = nla_get_u32(
3742 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3743 hddLog(VOS_TRACE_LEVEL_INFO,
3744 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3745 /* Parse and fetch minimum Breaching */
3746 if (!tb
3747 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3748 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3749 goto fail;
3750 }
3751 pReqMsg->minBreaching = nla_get_u32(
3752 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3753 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3754
3755 /* Parse and fetch number of APs */
3756 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3757 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3758 goto fail;
3759 }
3760 pReqMsg->numAp = nla_get_u32(
3761 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3762 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3763
3764 pReqMsg->sessionId = pAdapter->sessionId;
3765 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3766
3767 nla_for_each_nested(apTh,
3768 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3769 if(nla_parse(tb2,
3770 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3771 nla_data(apTh), nla_len(apTh),
3772 NULL)) {
3773 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3774 goto fail;
3775 }
3776
3777 /* Parse and fetch MAC address */
3778 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3779 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3780 goto fail;
3781 }
3782 memcpy(pReqMsg->ap[i].bssid, nla_data(
3783 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3784 sizeof(tSirMacAddr));
3785
3786 /* Parse and fetch low RSSI */
3787 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3788 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3789 goto fail;
3790 }
3791 pReqMsg->ap[i].low = nla_get_s32(
3792 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3793 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3794
3795 /* Parse and fetch high RSSI */
3796 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3797 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3798 goto fail;
3799 }
3800 pReqMsg->ap[i].high = nla_get_s32(
3801 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3802 hddLog(VOS_TRACE_LEVEL_INFO,
3803 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
3804
3805 /* Parse and fetch channel */
3806 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3807 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3808 goto fail;
3809 }
3810 pReqMsg->ap[i].channel = nla_get_u32(
3811 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3812 hddLog(VOS_TRACE_LEVEL_INFO,
3813 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3814 i++;
3815 }
3816
3817 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
3818 if (!HAL_STATUS_SUCCESS(status)) {
3819 hddLog(VOS_TRACE_LEVEL_ERROR,
3820 FL("sme_SetSignificantChange failed(err=%d)"), status);
3821 vos_mem_free(pReqMsg);
3822 return -EINVAL;
3823 }
Dino Myclee8843b32014-07-04 14:21:45 +05303824 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303825 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303826 return 0;
3827
3828fail:
3829 vos_mem_free(pReqMsg);
3830 return -EINVAL;
3831}
3832
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303833static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
3834 struct wireless_dev *wdev,
3835 const void *data, int dataLen)
3836{
3837 int ret = 0;
3838
3839 vos_ssr_protect(__func__);
3840 ret = __wlan_hdd_cfg80211_extscan_set_significant_change(wiphy, wdev, data,
3841 dataLen);
3842 vos_ssr_unprotect(__func__);
3843
3844 return ret;
3845}
3846
3847static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303848 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303849 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303850{
3851 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3852 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3853 tANI_U8 numChannels = 0;
3854 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3855 tANI_U32 requestId;
3856 tWifiBand wifiBand;
3857 eHalStatus status;
3858 struct sk_buff *replySkb;
3859 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303860 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303861
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303862 ENTER();
3863
Dino Mycle6fb96c12014-06-10 11:52:40 +05303864 status = wlan_hdd_validate_context(pHddCtx);
3865 if (0 != status)
3866 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303867 return -EINVAL;
3868 }
Dino Myclee8843b32014-07-04 14:21:45 +05303869
Dino Mycle6fb96c12014-06-10 11:52:40 +05303870 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3871 data, dataLen,
3872 wlan_hdd_extscan_config_policy)) {
3873 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3874 return -EINVAL;
3875 }
3876
3877 /* Parse and fetch request Id */
3878 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3879 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3880 return -EINVAL;
3881 }
3882 requestId = nla_get_u32(
3883 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3884 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3885
3886 /* Parse and fetch wifi band */
3887 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3888 {
3889 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3890 return -EINVAL;
3891 }
3892 wifiBand = nla_get_u32(
3893 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3894 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3895
3896 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
3897 wifiBand, ChannelList,
3898 &numChannels);
3899 if (eHAL_STATUS_SUCCESS != status) {
3900 hddLog(VOS_TRACE_LEVEL_ERROR,
3901 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
3902 return -EINVAL;
3903 }
3904 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
3905 for (i = 0; i < numChannels; i++)
3906 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
3907
3908 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
3909 sizeof(u32) * numChannels +
3910 NLMSG_HDRLEN);
3911
3912 if (!replySkb) {
3913 hddLog(VOS_TRACE_LEVEL_ERROR,
3914 FL("valid channels: buffer alloc fail"));
3915 return -EINVAL;
3916 }
3917 if (nla_put_u32(replySkb,
3918 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
3919 numChannels) ||
3920 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
3921 sizeof(u32) * numChannels, ChannelList)) {
3922
3923 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3924 kfree_skb(replySkb);
3925 return -EINVAL;
3926 }
3927
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303928 ret = cfg80211_vendor_cmd_reply(replySkb);
3929
3930 EXIT();
3931 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303932}
3933
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303934static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
3935 struct wireless_dev *wdev,
3936 const void *data, int dataLen)
3937{
3938 int ret = 0;
3939
3940 vos_ssr_protect(__func__);
3941 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
3942 dataLen);
3943 vos_ssr_unprotect(__func__);
3944
3945 return ret;
3946}
3947
3948static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303949 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303950 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303951{
Dino Myclee8843b32014-07-04 14:21:45 +05303952 tpSirEXTScanStartReqParams pReqMsg = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303953 struct net_device *dev = wdev->netdev;
3954 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3955 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3956 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3957 struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3958 struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3959 struct nlattr *buckets;
3960 struct nlattr *channels;
3961 int rem1;
3962 int rem2;
3963 eHalStatus status;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303964 tANI_U32 j = 0, index = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303965
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303966 ENTER();
3967
Dino Mycle6fb96c12014-06-10 11:52:40 +05303968 status = wlan_hdd_validate_context(pHddCtx);
3969 if (0 != status)
3970 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303971 return -EINVAL;
3972 }
Dino Myclee8843b32014-07-04 14:21:45 +05303973 /* check the EXTScan Capability */
3974 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3975 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3976 {
3977 hddLog(VOS_TRACE_LEVEL_ERROR,
3978 FL("EXTScan not enabled/supported by Firmware"));
3979 return -EINVAL;
3980 }
3981
Dino Mycle6fb96c12014-06-10 11:52:40 +05303982 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3983 data, dataLen,
3984 wlan_hdd_extscan_config_policy)) {
3985 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3986 return -EINVAL;
3987 }
3988
3989 /* Parse and fetch request Id */
3990 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3991 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3992 return -EINVAL;
3993 }
3994
Dino Myclee8843b32014-07-04 14:21:45 +05303995 pReqMsg = (tpSirEXTScanStartReqParams)
3996 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303997 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303998 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3999 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304000 }
4001
4002 pReqMsg->requestId = nla_get_u32(
4003 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4004 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4005
4006 pReqMsg->sessionId = pAdapter->sessionId;
4007 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4008
4009 /* Parse and fetch base period */
4010 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) {
4011 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4012 goto fail;
4013 }
4014 pReqMsg->basePeriod = nla_get_u32(
4015 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]);
4016 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4017 pReqMsg->basePeriod);
4018
4019 /* Parse and fetch max AP per scan */
4020 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) {
4021 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4022 goto fail;
4023 }
4024 pReqMsg->maxAPperScan = nla_get_u32(
4025 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]);
4026 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4027 pReqMsg->maxAPperScan);
4028
4029 /* Parse and fetch report threshold */
4030 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) {
4031 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4032 goto fail;
4033 }
4034 pReqMsg->reportThreshold = nla_get_u8(
4035 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]);
4036 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
4037 pReqMsg->reportThreshold);
4038
4039 /* Parse and fetch number of buckets */
4040 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) {
4041 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4042 goto fail;
4043 }
4044 pReqMsg->numBuckets = nla_get_u8(
4045 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]);
4046 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4047 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4048 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4049 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4050 }
4051 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4052 pReqMsg->numBuckets);
4053 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4054 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4055 goto fail;
4056 }
4057
4058 nla_for_each_nested(buckets,
4059 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4060 if(nla_parse(bucket,
4061 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4062 nla_data(buckets), nla_len(buckets), NULL)) { //policy
4063 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4064 goto fail;
4065 }
4066
4067 /* Parse and fetch bucket spec */
4068 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4069 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed"));
4070 goto fail;
4071 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304072
4073 pReqMsg->buckets[index].bucket = nla_get_u8(
4074 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4075
4076 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"),
4077 pReqMsg->buckets[index].bucket);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304078
4079 /* Parse and fetch wifi band */
4080 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4081 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4082 goto fail;
4083 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304084 pReqMsg->buckets[index].band = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304085 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4086 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304087 pReqMsg->buckets[index].band);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304088
4089 /* Parse and fetch period */
4090 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4091 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed"));
4092 goto fail;
4093 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304094 pReqMsg->buckets[index].period = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304095 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4096 hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304097 pReqMsg->buckets[index].period);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304098
4099 /* Parse and fetch report events */
4100 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4101 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed"));
4102 goto fail;
4103 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304104 pReqMsg->buckets[index].reportEvents = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304105 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4106 hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304107 pReqMsg->buckets[index].reportEvents);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304108
4109 /* Parse and fetch number of channels */
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304110 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS])
4111 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304112 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed"));
4113 goto fail;
4114 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304115 pReqMsg->buckets[index].numChannels = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304116 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4117 hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304118 pReqMsg->buckets[index].numChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304119
4120 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4121 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed"));
4122 goto fail;
4123 }
4124
4125 j = 0;
4126 nla_for_each_nested(channels,
4127 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4128 if(nla_parse(channel,
4129 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4130 nla_data(channels), nla_len(channels),
4131 NULL)) { //wlan_hdd_extscan_config_policy here
4132 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4133 goto fail;
4134 }
4135
4136 /* Parse and fetch channel */
4137 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4138 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4139 goto fail;
4140 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304141 pReqMsg->buckets[index].channels[j].channel = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304142 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4143 hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304144 pReqMsg->buckets[index].channels[j].channel);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304145
4146 /* Parse and fetch dwell time */
4147 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4148 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed"));
4149 goto fail;
4150 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304151 pReqMsg->buckets[index].channels[j].dwellTimeMs = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304152 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4153 hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304154 pReqMsg->buckets[index].channels[j].dwellTimeMs);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304155
4156 /* Parse and fetch channel spec passive */
4157 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4158 hddLog(VOS_TRACE_LEVEL_ERROR,
4159 FL("attr channel spec passive failed"));
4160 goto fail;
4161 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304162 pReqMsg->buckets[index].channels[j].passive = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304163 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4164 hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304165 pReqMsg->buckets[index].channels[j].passive);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304166 j++;
4167 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304168 index++;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304169 }
4170 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4171 if (!HAL_STATUS_SUCCESS(status)) {
4172 hddLog(VOS_TRACE_LEVEL_ERROR,
4173 FL("sme_EXTScanStart failed(err=%d)"), status);
4174 vos_mem_free(pReqMsg);
4175 return -EINVAL;
4176 }
4177
Dino Myclee8843b32014-07-04 14:21:45 +05304178 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304179 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304180 return 0;
4181
4182fail:
4183 vos_mem_free(pReqMsg);
4184 return -EINVAL;
4185}
4186
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304187static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4188 struct wireless_dev *wdev,
4189 const void *data, int dataLen)
4190{
4191 int ret = 0;
4192
4193 vos_ssr_protect(__func__);
4194 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4195 vos_ssr_unprotect(__func__);
4196
4197 return ret;
4198}
4199
4200static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304201 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304202 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304203{
Dino Myclee8843b32014-07-04 14:21:45 +05304204 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304205 struct net_device *dev = wdev->netdev;
4206 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4207 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4208 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4209 eHalStatus status;
4210
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304211 ENTER();
4212
Dino Mycle6fb96c12014-06-10 11:52:40 +05304213 status = wlan_hdd_validate_context(pHddCtx);
4214 if (0 != status)
4215 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304216 return -EINVAL;
4217 }
Dino Myclee8843b32014-07-04 14:21:45 +05304218 /* check the EXTScan Capability */
4219 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4220 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4221 {
4222 hddLog(VOS_TRACE_LEVEL_ERROR,
4223 FL("EXTScan not enabled/supported by Firmware"));
4224 return -EINVAL;
4225 }
4226
Dino Mycle6fb96c12014-06-10 11:52:40 +05304227 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4228 data, dataLen,
4229 wlan_hdd_extscan_config_policy)) {
4230 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4231 return -EINVAL;
4232 }
4233
4234 /* Parse and fetch request Id */
4235 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4236 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4237 return -EINVAL;
4238 }
4239
Dino Myclee8843b32014-07-04 14:21:45 +05304240 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304241 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304242 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304243
Dino Myclee8843b32014-07-04 14:21:45 +05304244 reqMsg.sessionId = pAdapter->sessionId;
4245 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304246
Dino Myclee8843b32014-07-04 14:21:45 +05304247 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304248 if (!HAL_STATUS_SUCCESS(status)) {
4249 hddLog(VOS_TRACE_LEVEL_ERROR,
4250 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304251 return -EINVAL;
4252 }
4253
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304254 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304255 return 0;
4256}
4257
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304258static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4259 struct wireless_dev *wdev,
4260 const void *data, int dataLen)
4261{
4262 int ret = 0;
4263
4264 vos_ssr_protect(__func__);
4265 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4266 vos_ssr_unprotect(__func__);
4267
4268 return ret;
4269}
4270
4271static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304272 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304273 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304274{
Dino Myclee8843b32014-07-04 14:21:45 +05304275 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304276 struct net_device *dev = wdev->netdev;
4277 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4278 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4279 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4280 eHalStatus status;
4281
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304282 ENTER();
4283
Dino Mycle6fb96c12014-06-10 11:52:40 +05304284 status = wlan_hdd_validate_context(pHddCtx);
4285 if (0 != status)
4286 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304287 return -EINVAL;
4288 }
Dino Myclee8843b32014-07-04 14:21:45 +05304289 /* check the EXTScan Capability */
4290 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4291 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4292 {
4293 hddLog(VOS_TRACE_LEVEL_ERROR,
4294 FL("EXTScan not enabled/supported by Firmware"));
4295 return -EINVAL;
4296 }
4297
Dino Mycle6fb96c12014-06-10 11:52:40 +05304298 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4299 data, dataLen,
4300 wlan_hdd_extscan_config_policy)) {
4301 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4302 return -EINVAL;
4303 }
4304
4305 /* Parse and fetch request Id */
4306 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4307 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4308 return -EINVAL;
4309 }
4310
Dino Myclee8843b32014-07-04 14:21:45 +05304311 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304312 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304313 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304314
Dino Myclee8843b32014-07-04 14:21:45 +05304315 reqMsg.sessionId = pAdapter->sessionId;
4316 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304317
Dino Myclee8843b32014-07-04 14:21:45 +05304318 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304319 if (!HAL_STATUS_SUCCESS(status)) {
4320 hddLog(VOS_TRACE_LEVEL_ERROR,
4321 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304322 return -EINVAL;
4323 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304324 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304325 return 0;
4326}
4327
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304328static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4329 struct wireless_dev *wdev,
4330 const void *data, int dataLen)
4331{
4332 int ret = 0;
4333
4334 vos_ssr_protect(__func__);
4335 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4336 vos_ssr_unprotect(__func__);
4337
4338 return ret;
4339}
4340
4341static int __wlan_hdd_cfg80211_extscan_reset_significant_change(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304342 struct wiphy *wiphy,
4343 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304344 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304345{
Dino Myclee8843b32014-07-04 14:21:45 +05304346 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304347 struct net_device *dev = wdev->netdev;
4348 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4349 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4350 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4351 eHalStatus status;
4352
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304353 ENTER();
4354
Dino Mycle6fb96c12014-06-10 11:52:40 +05304355 status = wlan_hdd_validate_context(pHddCtx);
4356 if (0 != status)
4357 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304358 return -EINVAL;
4359 }
Dino Myclee8843b32014-07-04 14:21:45 +05304360 /* check the EXTScan Capability */
4361 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4362 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4363 {
4364 hddLog(VOS_TRACE_LEVEL_ERROR,
4365 FL("EXTScan not enabled/supported by Firmware"));
4366 return -EINVAL;
4367 }
4368
Dino Mycle6fb96c12014-06-10 11:52:40 +05304369 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4370 data, dataLen,
4371 wlan_hdd_extscan_config_policy)) {
4372 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4373 return -EINVAL;
4374 }
4375
4376 /* Parse and fetch request Id */
4377 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4378 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4379 return -EINVAL;
4380 }
4381
Dino Mycle6fb96c12014-06-10 11:52:40 +05304382
Dino Myclee8843b32014-07-04 14:21:45 +05304383 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304384 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304385 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304386
Dino Myclee8843b32014-07-04 14:21:45 +05304387 reqMsg.sessionId = pAdapter->sessionId;
4388 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304389
Dino Myclee8843b32014-07-04 14:21:45 +05304390 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304391 if (!HAL_STATUS_SUCCESS(status)) {
4392 hddLog(VOS_TRACE_LEVEL_ERROR,
4393 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304394 return -EINVAL;
4395 }
4396
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304397 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304398 return 0;
4399}
4400
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304401static int wlan_hdd_cfg80211_extscan_reset_significant_change(
4402 struct wiphy *wiphy,
4403 struct wireless_dev *wdev,
4404 const void *data, int dataLen)
4405{
4406 int ret = 0;
4407
4408 vos_ssr_protect(__func__);
4409 ret = __wlan_hdd_cfg80211_extscan_reset_significant_change(wiphy,
4410 wdev, data,
4411 dataLen);
4412 vos_ssr_unprotect(__func__);
4413
4414 return ret;
4415}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304416#endif /* WLAN_FEATURE_EXTSCAN */
4417
Atul Mittal115287b2014-07-08 13:26:33 +05304418/*EXT TDLS*/
4419static const struct nla_policy
4420wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4421{
4422 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4423 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4424 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4425 {.type = NLA_S32 },
4426 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4427 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4428
4429};
4430
4431static const struct nla_policy
4432wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4433{
4434 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4435
4436};
4437
4438static const struct nla_policy
4439wlan_hdd_tdls_config_state_change_policy[
4440 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4441{
4442 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4443 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4444 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304445 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4446 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4447 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304448
4449};
4450
4451static const struct nla_policy
4452wlan_hdd_tdls_config_get_status_policy[
4453 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4454{
4455 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4456 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4457 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304458 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4459 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4460 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304461
4462};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304463
4464static const struct nla_policy
4465wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4466{
4467 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4468};
4469
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304470static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304471 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304472 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304473 int data_len)
4474{
4475
4476 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4477 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4478
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304479 ENTER();
4480
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304481 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304482 return -EINVAL;
4483 }
4484 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
4485 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN disabled in ini"));
4486 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304487 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304488 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
4489 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN not supported by FW"));
4490 return -ENOTSUPP;
4491 }
4492
4493 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4494 data, data_len, wlan_hdd_mac_config)) {
4495 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4496 return -EINVAL;
4497 }
4498
4499 /* Parse and fetch mac address */
4500 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4501 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4502 return -EINVAL;
4503 }
4504
4505 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4506 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4507 VOS_MAC_ADDR_LAST_3_BYTES);
4508
Siddharth Bhal76972212014-10-15 16:22:51 +05304509 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4510
4511 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304512 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4513 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304514 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4515 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4516 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4517 {
4518 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4519 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4520 VOS_MAC_ADDRESS_LEN);
4521 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304522 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304523
Siddharth Bhal76972212014-10-15 16:22:51 +05304524 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
4525 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304526 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4527 }
4528
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304529 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304530 return 0;
4531}
4532
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304533static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4534 struct wireless_dev *wdev,
4535 const void *data,
4536 int data_len)
4537{
4538 int ret = 0;
4539
4540 vos_ssr_protect(__func__);
4541 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
4542 vos_ssr_unprotect(__func__);
4543
4544 return ret;
4545}
4546
4547static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304548 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304549 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304550 int data_len)
4551{
4552 u8 peer[6] = {0};
4553 struct net_device *dev = wdev->netdev;
4554 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4555 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4556 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4557 eHalStatus ret;
4558 tANI_S32 state;
4559 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304560 tANI_S32 global_operating_class = 0;
4561 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304562 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304563 int retVal;
4564
4565 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304566
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304567 if (!pAdapter) {
4568 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4569 return -EINVAL;
4570 }
4571
Atul Mittal115287b2014-07-08 13:26:33 +05304572 ret = wlan_hdd_validate_context(pHddCtx);
4573 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304574 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304575 return -EINVAL;
4576 }
4577 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304578 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304579 return -ENOTSUPP;
4580 }
4581 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4582 data, data_len,
4583 wlan_hdd_tdls_config_get_status_policy)) {
4584 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4585 return -EINVAL;
4586 }
4587
4588 /* Parse and fetch mac address */
4589 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4590 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4591 return -EINVAL;
4592 }
4593
4594 memcpy(peer, nla_data(
4595 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4596 sizeof(peer));
4597 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4598
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05304599 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05304600
Atul Mittal115287b2014-07-08 13:26:33 +05304601 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304602 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304603 NLMSG_HDRLEN);
4604
4605 if (!skb) {
4606 hddLog(VOS_TRACE_LEVEL_ERROR,
4607 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4608 return -EINVAL;
4609 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304610 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 +05304611 reason,
4612 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304613 global_operating_class,
4614 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304615 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304616 if (nla_put_s32(skb,
4617 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4618 state) ||
4619 nla_put_s32(skb,
4620 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4621 reason) ||
4622 nla_put_s32(skb,
4623 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4624 global_operating_class) ||
4625 nla_put_s32(skb,
4626 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4627 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304628
4629 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4630 goto nla_put_failure;
4631 }
4632
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304633 retVal = cfg80211_vendor_cmd_reply(skb);
4634 EXIT();
4635 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05304636
4637nla_put_failure:
4638 kfree_skb(skb);
4639 return -EINVAL;
4640}
4641
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304642static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4643 struct wireless_dev *wdev,
4644 const void *data,
4645 int data_len)
4646{
4647 int ret = 0;
4648
4649 vos_ssr_protect(__func__);
4650 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
4651 vos_ssr_unprotect(__func__);
4652
4653 return ret;
4654}
4655
Atul Mittal115287b2014-07-08 13:26:33 +05304656static int wlan_hdd_cfg80211_exttdls_callback(tANI_U8* mac,
4657 tANI_S32 state,
4658 tANI_S32 reason,
4659 void *ctx)
4660{
4661 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05304662 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304663 tANI_S32 global_operating_class = 0;
4664 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304665 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05304666
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304667 ENTER();
4668
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304669 if (!pAdapter) {
4670 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4671 return -EINVAL;
4672 }
4673
4674 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05304675 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304676 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304677 return -EINVAL;
4678 }
4679
4680 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304681 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304682 return -ENOTSUPP;
4683 }
4684 skb = cfg80211_vendor_event_alloc(
4685 pHddCtx->wiphy,
4686 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4687 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4688 GFP_KERNEL);
4689
4690 if (!skb) {
4691 hddLog(VOS_TRACE_LEVEL_ERROR,
4692 FL("cfg80211_vendor_event_alloc failed"));
4693 return -EINVAL;
4694 }
4695 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304696 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4697 reason,
4698 state,
4699 global_operating_class,
4700 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304701 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4702 MAC_ADDR_ARRAY(mac));
4703
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304704 if (nla_put(skb,
4705 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4706 VOS_MAC_ADDR_SIZE, mac) ||
4707 nla_put_s32(skb,
4708 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4709 state) ||
4710 nla_put_s32(skb,
4711 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4712 reason) ||
4713 nla_put_s32(skb,
4714 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4715 channel) ||
4716 nla_put_s32(skb,
4717 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4718 global_operating_class)
4719 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304720 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4721 goto nla_put_failure;
4722 }
4723
4724 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304725 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05304726 return (0);
4727
4728nla_put_failure:
4729 kfree_skb(skb);
4730 return -EINVAL;
4731}
4732
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304733static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304734 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304735 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304736 int data_len)
4737{
4738 u8 peer[6] = {0};
4739 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304740 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4741 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4742 eHalStatus status;
4743 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304744 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304745 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304746
4747 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304748
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304749 if (!dev) {
4750 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4751 return -EINVAL;
4752 }
4753
4754 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4755 if (!pAdapter) {
4756 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4757 return -EINVAL;
4758 }
4759
Atul Mittal115287b2014-07-08 13:26:33 +05304760 status = wlan_hdd_validate_context(pHddCtx);
4761 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304762 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304763 return -EINVAL;
4764 }
4765 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304766 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304767 return -ENOTSUPP;
4768 }
4769 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4770 data, data_len,
4771 wlan_hdd_tdls_config_enable_policy)) {
4772 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4773 return -EINVAL;
4774 }
4775
4776 /* Parse and fetch mac address */
4777 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4778 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4779 return -EINVAL;
4780 }
4781
4782 memcpy(peer, nla_data(
4783 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4784 sizeof(peer));
4785 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4786
4787 /* Parse and fetch channel */
4788 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4789 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4790 return -EINVAL;
4791 }
4792 pReqMsg.channel = nla_get_s32(
4793 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4794 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4795
4796 /* Parse and fetch global operating class */
4797 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4798 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4799 return -EINVAL;
4800 }
4801 pReqMsg.global_operating_class = nla_get_s32(
4802 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4803 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4804 pReqMsg.global_operating_class);
4805
4806 /* Parse and fetch latency ms */
4807 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4808 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4809 return -EINVAL;
4810 }
4811 pReqMsg.max_latency_ms = nla_get_s32(
4812 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4813 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4814 pReqMsg.max_latency_ms);
4815
4816 /* Parse and fetch required bandwidth kbps */
4817 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4818 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4819 return -EINVAL;
4820 }
4821
4822 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4823 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4824 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4825 pReqMsg.min_bandwidth_kbps);
4826
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304827 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05304828 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05304829 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304830 wlan_hdd_cfg80211_exttdls_callback);
4831
4832 EXIT();
4833 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304834}
4835
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304836static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4837 struct wireless_dev *wdev,
4838 const void *data,
4839 int data_len)
4840{
4841 int ret = 0;
4842
4843 vos_ssr_protect(__func__);
4844 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
4845 vos_ssr_unprotect(__func__);
4846
4847 return ret;
4848}
4849
4850static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304851 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304852 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304853 int data_len)
4854{
4855 u8 peer[6] = {0};
4856 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304857 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4858 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4859 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304860 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304861 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304862
4863 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304864
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304865 if (!dev) {
4866 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4867 return -EINVAL;
4868 }
4869
4870 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4871 if (!pAdapter) {
4872 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
4873 return -EINVAL;
4874 }
4875
Atul Mittal115287b2014-07-08 13:26:33 +05304876 status = wlan_hdd_validate_context(pHddCtx);
4877 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304878 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304879 return -EINVAL;
4880 }
4881 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304882 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304883 return -ENOTSUPP;
4884 }
4885 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4886 data, data_len,
4887 wlan_hdd_tdls_config_disable_policy)) {
4888 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4889 return -EINVAL;
4890 }
4891 /* Parse and fetch mac address */
4892 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
4893 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4894 return -EINVAL;
4895 }
4896
4897 memcpy(peer, nla_data(
4898 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
4899 sizeof(peer));
4900 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4901
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304902 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
4903
4904 EXIT();
4905 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304906}
4907
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304908static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
4909 struct wireless_dev *wdev,
4910 const void *data,
4911 int data_len)
4912{
4913 int ret = 0;
4914
4915 vos_ssr_protect(__func__);
4916 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
4917 vos_ssr_unprotect(__func__);
4918
4919 return ret;
4920}
4921
Dasari Srinivas7875a302014-09-26 17:50:57 +05304922static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304923__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05304924 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304925 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05304926{
4927 struct net_device *dev = wdev->netdev;
4928 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4929 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4930 struct sk_buff *skb = NULL;
4931 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304932 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05304933
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304934 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304935
4936 ret = wlan_hdd_validate_context(pHddCtx);
4937 if (0 != ret)
4938 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304939 return ret;
4940 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304941 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
4942 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
4943 fset |= WIFI_FEATURE_INFRA;
4944 }
4945
4946 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
4947 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
4948 fset |= WIFI_FEATURE_INFRA_5G;
4949 }
4950
4951#ifdef WLAN_FEATURE_P2P
4952 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
4953 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
4954 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
4955 fset |= WIFI_FEATURE_P2P;
4956 }
4957#endif
4958
4959 /* Soft-AP is supported currently by default */
4960 fset |= WIFI_FEATURE_SOFT_AP;
4961
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05304962 /* HOTSPOT is a supplicant feature, enable it by default */
4963 fset |= WIFI_FEATURE_HOTSPOT;
4964
Dasari Srinivas7875a302014-09-26 17:50:57 +05304965#ifdef WLAN_FEATURE_EXTSCAN
4966 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
4967 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
4968 hddLog(LOG1, FL("EXTScan is supported by firmware"));
4969 fset |= WIFI_FEATURE_EXTSCAN;
4970 }
4971#endif
4972
Dasari Srinivas7875a302014-09-26 17:50:57 +05304973 if (sme_IsFeatureSupportedByFW(NAN)) {
4974 hddLog(LOG1, FL("NAN is supported by firmware"));
4975 fset |= WIFI_FEATURE_NAN;
4976 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304977
4978 /* D2D RTT is not supported currently by default */
4979 if (sme_IsFeatureSupportedByFW(RTT)) {
4980 hddLog(LOG1, FL("RTT is supported by firmware"));
4981 fset |= WIFI_FEATURE_D2AP_RTT;
4982 }
4983
4984#ifdef FEATURE_WLAN_BATCH_SCAN
4985 if (fset & WIFI_FEATURE_EXTSCAN) {
4986 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
4987 fset &= ~WIFI_FEATURE_BATCH_SCAN;
4988 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
4989 hddLog(LOG1, FL("Batch scan is supported by firmware"));
4990 fset |= WIFI_FEATURE_BATCH_SCAN;
4991 }
4992#endif
4993
4994#ifdef FEATURE_WLAN_SCAN_PNO
4995 if (pHddCtx->cfg_ini->configPNOScanSupport &&
4996 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
4997 hddLog(LOG1, FL("PNO is supported by firmware"));
4998 fset |= WIFI_FEATURE_PNO;
4999 }
5000#endif
5001
5002 /* STA+STA is supported currently by default */
5003 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5004
5005#ifdef FEATURE_WLAN_TDLS
5006 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5007 sme_IsFeatureSupportedByFW(TDLS)) {
5008 hddLog(LOG1, FL("TDLS is supported by firmware"));
5009 fset |= WIFI_FEATURE_TDLS;
5010 }
5011
5012 /* TDLS_OFFCHANNEL is not supported currently by default */
5013#endif
5014
5015#ifdef WLAN_AP_STA_CONCURRENCY
5016 /* AP+STA concurrency is supported currently by default */
5017 fset |= WIFI_FEATURE_AP_STA;
5018#endif
5019
5020 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5021 NLMSG_HDRLEN);
5022
5023 if (!skb) {
5024 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5025 return -EINVAL;
5026 }
5027 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5028
5029 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5030 hddLog(LOGE, FL("nla put fail"));
5031 goto nla_put_failure;
5032 }
5033
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305034 ret = cfg80211_vendor_cmd_reply(skb);
5035 EXIT();
5036 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305037
5038nla_put_failure:
5039 kfree_skb(skb);
5040 return -EINVAL;
5041}
5042
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305043static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305044wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5045 struct wireless_dev *wdev,
5046 const void *data, int data_len)
5047{
5048 int ret = 0;
5049
5050 vos_ssr_protect(__func__);
5051 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5052 vos_ssr_unprotect(__func__);
5053
5054 return ret;
5055}
5056
5057static int
5058__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305059 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305060 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305061{
5062 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5063 uint8_t i, feature_sets, max_feature_sets;
5064 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5065 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305066 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5067 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305068
5069 ENTER();
5070
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305071 ret = wlan_hdd_validate_context(pHddCtx);
5072 if (0 != ret)
5073 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305074 return ret;
5075 }
5076
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305077 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5078 data, data_len, NULL)) {
5079 hddLog(LOGE, FL("Invalid ATTR"));
5080 return -EINVAL;
5081 }
5082
5083 /* Parse and fetch max feature set */
5084 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5085 hddLog(LOGE, FL("Attr max feature set size failed"));
5086 return -EINVAL;
5087 }
5088 max_feature_sets = nla_get_u32(
5089 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5090 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5091
5092 /* Fill feature combination matrix */
5093 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305094 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5095 WIFI_FEATURE_P2P;
5096
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305097 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5098 WIFI_FEATURE_SOFT_AP;
5099
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305100 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5101 WIFI_FEATURE_SOFT_AP;
5102
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305103 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5104 WIFI_FEATURE_SOFT_AP |
5105 WIFI_FEATURE_P2P;
5106
5107 /* Add more feature combinations here */
5108
5109 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5110 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5111 hddLog(LOG1, "Feature set matrix");
5112 for (i = 0; i < feature_sets; i++)
5113 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5114
5115 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5116 sizeof(u32) * feature_sets +
5117 NLMSG_HDRLEN);
5118
5119 if (reply_skb) {
5120 if (nla_put_u32(reply_skb,
5121 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5122 feature_sets) ||
5123 nla_put(reply_skb,
5124 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5125 sizeof(u32) * feature_sets, feature_set_matrix)) {
5126 hddLog(LOGE, FL("nla put fail"));
5127 kfree_skb(reply_skb);
5128 return -EINVAL;
5129 }
5130
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305131 ret = cfg80211_vendor_cmd_reply(reply_skb);
5132 EXIT();
5133 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305134 }
5135 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5136 return -ENOMEM;
5137
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305138}
5139
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305140static int
5141wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5142 struct wireless_dev *wdev,
5143 const void *data, int data_len)
5144{
5145 int ret = 0;
5146
5147 vos_ssr_protect(__func__);
5148 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5149 data_len);
5150 vos_ssr_unprotect(__func__);
5151
5152 return ret;
5153}
5154
Agarwal Ashish738843c2014-09-25 12:27:56 +05305155static const struct nla_policy
5156wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5157 +1] =
5158{
5159 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5160};
5161
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305162static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305163 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305164 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305165 int data_len)
5166{
5167 struct net_device *dev = wdev->netdev;
5168 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5169 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5170 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5171 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5172 eHalStatus status;
5173 u32 dfsFlag = 0;
5174
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305175 ENTER();
5176
Agarwal Ashish738843c2014-09-25 12:27:56 +05305177 status = wlan_hdd_validate_context(pHddCtx);
5178 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305179 return -EINVAL;
5180 }
5181 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5182 data, data_len,
5183 wlan_hdd_set_no_dfs_flag_config_policy)) {
5184 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5185 return -EINVAL;
5186 }
5187
5188 /* Parse and fetch required bandwidth kbps */
5189 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5190 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5191 return -EINVAL;
5192 }
5193
5194 dfsFlag = nla_get_u32(
5195 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5196 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
5197 dfsFlag);
5198
5199 pHddCtx->disable_dfs_flag = dfsFlag;
5200
5201 sme_disable_dfs_channel(hHal, dfsFlag);
5202 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305203
5204 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05305205 return 0;
5206}
Atul Mittal115287b2014-07-08 13:26:33 +05305207
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305208static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
5209 struct wireless_dev *wdev,
5210 const void *data,
5211 int data_len)
5212{
5213 int ret = 0;
5214
5215 vos_ssr_protect(__func__);
5216 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
5217 vos_ssr_unprotect(__func__);
5218
5219 return ret;
5220
5221}
5222
Mukul Sharma2a271632014-10-13 14:59:01 +05305223const struct
5224nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
5225{
5226 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
5227 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
5228};
5229
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305230static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05305231 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05305232{
5233
5234 u8 bssid[6] = {0};
5235 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5236 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5237 eHalStatus status = eHAL_STATUS_SUCCESS;
5238 v_U32_t isFwrRoamEnabled = FALSE;
5239 int ret;
5240
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305241 ENTER();
5242
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305243 ret = wlan_hdd_validate_context(pHddCtx);
5244 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305245 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05305246 }
5247
5248 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
5249 data, data_len,
5250 qca_wlan_vendor_attr);
5251 if (ret){
5252 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5253 return -EINVAL;
5254 }
5255
5256 /* Parse and fetch Enable flag */
5257 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
5258 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
5259 return -EINVAL;
5260 }
5261
5262 isFwrRoamEnabled = nla_get_u32(
5263 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
5264
5265 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
5266
5267 /* Parse and fetch bssid */
5268 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
5269 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
5270 return -EINVAL;
5271 }
5272
5273 memcpy(bssid, nla_data(
5274 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
5275 sizeof(bssid));
5276 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
5277
5278 //Update roaming
5279 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305280 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05305281 return status;
5282}
5283
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305284static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
5285 struct wireless_dev *wdev, const void *data, int data_len)
5286{
5287 int ret = 0;
5288
5289 vos_ssr_protect(__func__);
5290 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
5291 vos_ssr_unprotect(__func__);
5292
5293 return ret;
5294}
5295
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305296/**
5297 * __wlan_hdd_cfg80211_setband() - set band
5298 * @wiphy: Pointer to wireless phy
5299 * @wdev: Pointer to wireless device
5300 * @data: Pointer to data
5301 * @data_len: Data length
5302 *
5303 * Return: 0 on success, negative errno on failure
5304 */
5305static int
5306__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5307 struct wireless_dev *wdev,
5308 const void *data,
5309 int data_len)
5310{
5311 struct net_device *dev = wdev->netdev;
5312 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5313 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5314 int ret;
5315 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
5316 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
5317
5318 ENTER();
5319
5320 ret = wlan_hdd_validate_context(hdd_ctx);
5321 if (0 != ret) {
5322 hddLog(LOGE, FL("HDD context is not valid"));
5323 return ret;
5324 }
5325
5326 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
5327 policy)) {
5328 hddLog(LOGE, FL("Invalid ATTR"));
5329 return -EINVAL;
5330 }
5331
5332 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
5333 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
5334 return -EINVAL;
5335 }
5336
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05305337 hdd_ctx->isSetBandByNL = TRUE;
5338 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305339 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05305340 hdd_ctx->isSetBandByNL = FALSE;
5341
5342 EXIT();
5343 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305344}
5345
5346/**
5347 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
5348 * @wiphy: wiphy structure pointer
5349 * @wdev: Wireless device structure pointer
5350 * @data: Pointer to the data received
5351 * @data_len: Length of @data
5352 *
5353 * Return: 0 on success; errno on failure
5354 */
5355static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5356 struct wireless_dev *wdev,
5357 const void *data,
5358 int data_len)
5359{
5360 int ret = 0;
5361
5362 vos_ssr_protect(__func__);
5363 ret = __wlan_hdd_cfg80211_setband(wiphy,
5364 wdev, data, data_len);
5365 vos_ssr_unprotect(__func__);
5366
5367 return ret;
5368}
5369
Sunil Duttc69bccb2014-05-26 21:30:20 +05305370const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
5371{
Mukul Sharma2a271632014-10-13 14:59:01 +05305372 {
5373 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5374 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
5375 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5376 WIPHY_VENDOR_CMD_NEED_NETDEV |
5377 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305378 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05305379 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305380
5381 {
5382 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5383 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
5384 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5385 WIPHY_VENDOR_CMD_NEED_NETDEV |
5386 WIPHY_VENDOR_CMD_NEED_RUNNING,
5387 .doit = wlan_hdd_cfg80211_nan_request
5388 },
5389
Sunil Duttc69bccb2014-05-26 21:30:20 +05305390#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5391 {
5392 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5393 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
5394 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5395 WIPHY_VENDOR_CMD_NEED_NETDEV |
5396 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305397 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05305398 },
5399
5400 {
5401 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5402 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
5403 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5404 WIPHY_VENDOR_CMD_NEED_NETDEV |
5405 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305406 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05305407 },
5408
5409 {
5410 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5411 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
5412 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5413 WIPHY_VENDOR_CMD_NEED_NETDEV |
5414 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305415 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05305416 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305417#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305418#ifdef WLAN_FEATURE_EXTSCAN
5419 {
5420 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5421 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
5422 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5423 WIPHY_VENDOR_CMD_NEED_NETDEV |
5424 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305425 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05305426 },
5427 {
5428 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5429 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
5430 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5431 WIPHY_VENDOR_CMD_NEED_NETDEV |
5432 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305433 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05305434 },
5435 {
5436 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5437 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
5438 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5439 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305440 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05305441 },
5442 {
5443 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5444 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
5445 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5446 WIPHY_VENDOR_CMD_NEED_NETDEV |
5447 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305448 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05305449 },
5450 {
5451 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5452 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
5453 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5454 WIPHY_VENDOR_CMD_NEED_NETDEV |
5455 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305456 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05305457 },
5458 {
5459 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5460 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
5461 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5462 WIPHY_VENDOR_CMD_NEED_NETDEV |
5463 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305464 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305465 },
5466 {
5467 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5468 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
5469 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5470 WIPHY_VENDOR_CMD_NEED_NETDEV |
5471 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305472 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305473 },
5474 {
5475 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5476 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
5477 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5478 WIPHY_VENDOR_CMD_NEED_NETDEV |
5479 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305480 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305481 },
5482 {
5483 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5484 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
5485 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5486 WIPHY_VENDOR_CMD_NEED_NETDEV |
5487 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305488 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305489 },
5490#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305491/*EXT TDLS*/
5492 {
5493 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5494 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
5495 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5496 WIPHY_VENDOR_CMD_NEED_NETDEV |
5497 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305498 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05305499 },
5500 {
5501 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5502 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
5503 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5504 WIPHY_VENDOR_CMD_NEED_NETDEV |
5505 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305506 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05305507 },
5508 {
5509 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5510 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
5511 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5512 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305513 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05305514 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05305515 {
5516 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5517 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
5518 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5519 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305520 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05305521 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05305522 {
5523 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5524 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
5525 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5526 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305527 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05305528 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305529 {
5530 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5531 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
5532 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5533 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305534 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305535 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305536 {
5537 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5538 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
5539 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5540 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305541 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305542 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305543 {
5544 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5545 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
5546 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5547 WIPHY_VENDOR_CMD_NEED_NETDEV |
5548 WIPHY_VENDOR_CMD_NEED_RUNNING,
5549 .doit = wlan_hdd_cfg80211_setband
5550 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05305551};
5552
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005553/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05305554static const
5555struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005556{
5557#ifdef FEATURE_WLAN_CH_AVOID
5558 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05305559 .vendor_id = QCA_NL80211_VENDOR_ID,
5560 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005561 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305562#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
5563#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5564 {
5565 /* Index = 1*/
5566 .vendor_id = QCA_NL80211_VENDOR_ID,
5567 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
5568 },
5569 {
5570 /* Index = 2*/
5571 .vendor_id = QCA_NL80211_VENDOR_ID,
5572 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
5573 },
5574 {
5575 /* Index = 3*/
5576 .vendor_id = QCA_NL80211_VENDOR_ID,
5577 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
5578 },
5579 {
5580 /* Index = 4*/
5581 .vendor_id = QCA_NL80211_VENDOR_ID,
5582 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
5583 },
5584 {
5585 /* Index = 5*/
5586 .vendor_id = QCA_NL80211_VENDOR_ID,
5587 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
5588 },
5589 {
5590 /* Index = 6*/
5591 .vendor_id = QCA_NL80211_VENDOR_ID,
5592 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
5593 },
5594#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305595#ifdef WLAN_FEATURE_EXTSCAN
5596 {
5597 .vendor_id = QCA_NL80211_VENDOR_ID,
5598 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
5599 },
5600 {
5601 .vendor_id = QCA_NL80211_VENDOR_ID,
5602 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
5603 },
5604 {
5605 .vendor_id = QCA_NL80211_VENDOR_ID,
5606 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
5607 },
5608 {
5609 .vendor_id = QCA_NL80211_VENDOR_ID,
5610 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
5611 },
5612 {
5613 .vendor_id = QCA_NL80211_VENDOR_ID,
5614 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
5615 },
5616 {
5617 .vendor_id = QCA_NL80211_VENDOR_ID,
5618 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
5619 },
5620 {
5621 .vendor_id = QCA_NL80211_VENDOR_ID,
5622 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
5623 },
5624 {
5625 .vendor_id = QCA_NL80211_VENDOR_ID,
5626 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
5627 },
5628 {
5629 .vendor_id = QCA_NL80211_VENDOR_ID,
5630 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
5631 },
5632 {
5633 .vendor_id = QCA_NL80211_VENDOR_ID,
5634 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
5635 },
5636 {
5637 .vendor_id = QCA_NL80211_VENDOR_ID,
5638 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
5639 },
5640 {
5641 .vendor_id = QCA_NL80211_VENDOR_ID,
5642 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
5643 },
5644 {
5645 .vendor_id = QCA_NL80211_VENDOR_ID,
5646 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
5647 },
5648#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305649/*EXT TDLS*/
5650 {
5651 .vendor_id = QCA_NL80211_VENDOR_ID,
5652 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
5653 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305654
5655 {
5656 .vendor_id = QCA_NL80211_VENDOR_ID,
5657 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
5658 },
5659
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005660};
5661
Jeff Johnson295189b2012-06-20 16:38:30 -07005662/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305663 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305664 * This function is called by hdd_wlan_startup()
5665 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305666 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305668struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07005669{
5670 struct wiphy *wiphy;
5671 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305672 /*
5673 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07005674 */
5675 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
5676
5677 if (!wiphy)
5678 {
5679 /* Print error and jump into err label and free the memory */
5680 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
5681 return NULL;
5682 }
5683
Sunil Duttc69bccb2014-05-26 21:30:20 +05305684
Jeff Johnson295189b2012-06-20 16:38:30 -07005685 return wiphy;
5686}
5687
5688/*
5689 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305690 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07005691 * private ioctl to change the band value
5692 */
5693int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
5694{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305695 int i, j;
5696 eNVChannelEnabledType channelEnabledState;
5697
Jeff Johnsone7245742012-09-05 17:12:55 -07005698 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305699
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305700 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305702
5703 if (NULL == wiphy->bands[i])
5704 {
5705 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5706 __func__, i);
5707 continue;
5708 }
5709
5710 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5711 {
5712 struct ieee80211_supported_band *band = wiphy->bands[i];
5713
5714 channelEnabledState = vos_nv_getChannelEnabledState(
5715 band->channels[j].hw_value);
5716
5717 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
5718 {
Abhishek Singh678227a2014-11-04 10:52:38 +05305719 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305720 continue;
5721 }
5722 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
5723 {
5724 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5725 continue;
5726 }
5727
5728 if (NV_CHANNEL_DISABLE == channelEnabledState ||
5729 NV_CHANNEL_INVALID == channelEnabledState)
5730 {
5731 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5732 }
5733 else if (NV_CHANNEL_DFS == channelEnabledState)
5734 {
5735 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5736 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
5737 }
5738 else
5739 {
5740 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
5741 |IEEE80211_CHAN_RADAR);
5742 }
5743 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005744 }
5745 return 0;
5746}
5747/*
5748 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305749 * This function is called by hdd_wlan_startup()
5750 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07005751 * This function is used to initialize and register wiphy structure.
5752 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305753int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005754 struct wiphy *wiphy,
5755 hdd_config_t *pCfg
5756 )
5757{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305758 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305759 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5760
Jeff Johnsone7245742012-09-05 17:12:55 -07005761 ENTER();
5762
Jeff Johnson295189b2012-06-20 16:38:30 -07005763 /* Now bind the underlying wlan device with wiphy */
5764 set_wiphy_dev(wiphy, dev);
5765
5766 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005767
Kiet Lam6c583332013-10-14 05:37:09 +05305768#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07005769 /* the flag for the other case would be initialzed in
5770 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07005771 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05305772#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005773
Amar Singhalfddc28c2013-09-05 13:03:40 -07005774 /* This will disable updating of NL channels from passive to
5775 * active if a beacon is received on passive channel. */
5776 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -07005777
Amar Singhalfddc28c2013-09-05 13:03:40 -07005778
Amar Singhala49cbc52013-10-08 18:37:44 -07005779
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005780#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07005781 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
5782 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
5783 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07005784 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +05305785 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005786#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005787
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005788#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005789 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08005790#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005791 || pCfg->isFastRoamIniFeatureEnabled
5792#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005793#ifdef FEATURE_WLAN_ESE
5794 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005795#endif
5796 )
5797 {
5798 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
5799 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08005800#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005801#ifdef FEATURE_WLAN_TDLS
5802 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
5803 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
5804#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305805#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05305806 if (pCfg->configPNOScanSupport)
5807 {
5808 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
5809 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
5810 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
5811 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
5812 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305813#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005814
Abhishek Singh10d85972015-04-17 10:27:23 +05305815#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5816 wiphy->features |= NL80211_FEATURE_HT_IBSS;
5817#endif
5818
Amar Singhalfddc28c2013-09-05 13:03:40 -07005819#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005820 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
5821 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07005822 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005823 driver need to determine what to do with both
5824 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07005825
5826 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07005827#else
5828 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005829#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005830
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305831 wiphy->max_scan_ssids = MAX_SCAN_SSID;
5832
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05305833 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07005834
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305835 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
5836
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05305838 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
5839 | BIT(NL80211_IFTYPE_ADHOC)
5840 | BIT(NL80211_IFTYPE_P2P_CLIENT)
5841 | BIT(NL80211_IFTYPE_P2P_GO)
5842 | BIT(NL80211_IFTYPE_AP);
5843
5844 if (VOS_MONITOR_MODE == hdd_get_conparam())
5845 {
5846 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
5847 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005848
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305849 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005850 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305851#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5852 if( pCfg->enableMCC )
5853 {
5854 /* Currently, supports up to two channels */
5855 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005856
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305857 if( !pCfg->allowMCCGODiffBI )
5858 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005859
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305860 }
5861 wiphy->iface_combinations = &wlan_hdd_iface_combination;
5862 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005863#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305864 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005865
Jeff Johnson295189b2012-06-20 16:38:30 -07005866 /* Before registering we need to update the ht capabilitied based
5867 * on ini values*/
5868 if( !pCfg->ShortGI20MhzEnable )
5869 {
5870 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5871 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5872 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5873 }
5874
5875 if( !pCfg->ShortGI40MhzEnable )
5876 {
5877 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
5878 }
5879
5880 if( !pCfg->nChannelBondingMode5GHz )
5881 {
5882 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5883 }
5884
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305885 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305886 if (true == hdd_is_5g_supported(pHddCtx))
5887 {
5888 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
5889 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305890
5891 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
5892 {
5893
5894 if (NULL == wiphy->bands[i])
5895 {
5896 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5897 __func__, i);
5898 continue;
5899 }
5900
5901 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5902 {
5903 struct ieee80211_supported_band *band = wiphy->bands[i];
5904
5905 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
5906 {
5907 // Enable social channels for P2P
5908 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
5909 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5910 else
5911 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5912 continue;
5913 }
5914 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
5915 {
5916 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5917 continue;
5918 }
5919 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 }
5921 /*Initialise the supported cipher suite details*/
5922 wiphy->cipher_suites = hdd_cipher_suites;
5923 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
5924
5925 /*signal strength in mBm (100*dBm) */
5926 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
5927
5928#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05305929 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07005930#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005931
Sunil Duttc69bccb2014-05-26 21:30:20 +05305932 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
5933 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005934 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
5935 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
5936
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305937 EXIT();
5938 return 0;
5939}
5940
5941/* In this function we are registering wiphy. */
5942int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
5943{
5944 ENTER();
5945 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005946 if (0 > wiphy_register(wiphy))
5947 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305948 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07005949 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
5950 return -EIO;
5951 }
5952
5953 EXIT();
5954 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305955}
Jeff Johnson295189b2012-06-20 16:38:30 -07005956
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305957/* In this function we are updating channel list when,
5958 regulatory domain is FCC and country code is US.
5959 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
5960 As per FCC smart phone is not a indoor device.
5961 GO should not opeate on indoor channels */
5962void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
5963{
5964 int j;
5965 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5966 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
5967 //Default counrtycode from NV at the time of wiphy initialization.
5968 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
5969 &defaultCountryCode[0]))
5970 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005971 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305972 }
5973 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
5974 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305975 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
5976 {
5977 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
5978 return;
5979 }
5980 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
5981 {
5982 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
5983 // Mark UNII -1 band channel as passive
5984 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
5985 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
5986 }
5987 }
5988}
5989
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305990/* This function registers for all frame which supplicant is interested in */
5991void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005992{
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5994 /* Register for all P2P action, public action etc frames */
5995 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5996
Jeff Johnsone7245742012-09-05 17:12:55 -07005997 ENTER();
5998
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 /* Right now we are registering these frame when driver is getting
6000 initialized. Once we will move to 2.6.37 kernel, in which we have
6001 frame register ops, we will move this code as a part of that */
6002 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306003 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6005
6006 /* GAS Initial Response */
6007 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6008 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306009
Jeff Johnson295189b2012-06-20 16:38:30 -07006010 /* GAS Comeback Request */
6011 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6012 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6013
6014 /* GAS Comeback Response */
6015 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6016 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6017
6018 /* P2P Public Action */
6019 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306020 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 P2P_PUBLIC_ACTION_FRAME_SIZE );
6022
6023 /* P2P Action */
6024 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6025 (v_U8_t*)P2P_ACTION_FRAME,
6026 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07006027
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05306028 /* WNM BSS Transition Request frame */
6029 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6030 (v_U8_t*)WNM_BSS_ACTION_FRAME,
6031 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006032
6033 /* WNM-Notification */
6034 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6035 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6036 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006037}
6038
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05306039void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07006040{
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6042 /* Register for all P2P action, public action etc frames */
6043 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
6044
Jeff Johnsone7245742012-09-05 17:12:55 -07006045 ENTER();
6046
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 /* Right now we are registering these frame when driver is getting
6048 initialized. Once we will move to 2.6.37 kernel, in which we have
6049 frame register ops, we will move this code as a part of that */
6050 /* GAS Initial Request */
6051
6052 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6053 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6054
6055 /* GAS Initial Response */
6056 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6057 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306058
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 /* GAS Comeback Request */
6060 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6061 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6062
6063 /* GAS Comeback Response */
6064 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6065 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6066
6067 /* P2P Public Action */
6068 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306069 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006070 P2P_PUBLIC_ACTION_FRAME_SIZE );
6071
6072 /* P2P Action */
6073 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6074 (v_U8_t*)P2P_ACTION_FRAME,
6075 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006076 /* WNM-Notification */
6077 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6078 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6079 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006080}
6081
6082#ifdef FEATURE_WLAN_WAPI
6083void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
6084 const u8 *mac_addr, u8 *key , int key_Len)
6085{
6086 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6087 tCsrRoamSetKey setKey;
6088 v_BOOL_t isConnected = TRUE;
6089 int status = 0;
6090 v_U32_t roamId= 0xFF;
6091 tANI_U8 *pKeyPtr = NULL;
6092 int n = 0;
6093
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306094 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
6095 __func__, hdd_device_modetoString(pAdapter->device_mode),
6096 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006097
Gopichand Nakkalae7480202013-02-11 15:24:22 +05306098 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006099 setKey.keyId = key_index; // Store Key ID
6100 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
6101 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
6102 setKey.paeRole = 0 ; // the PAE role
6103 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
6104 {
6105 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
6106 }
6107 else
6108 {
6109 isConnected = hdd_connIsConnected(pHddStaCtx);
6110 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
6111 }
6112 setKey.keyLength = key_Len;
6113 pKeyPtr = setKey.Key;
6114 memcpy( pKeyPtr, key, key_Len);
6115
Arif Hussain6d2a3322013-11-17 19:50:10 -08006116 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 __func__, key_Len);
6118 for (n = 0 ; n < key_Len; n++)
6119 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
6120 __func__,n,setKey.Key[n]);
6121
6122 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6123 if ( isConnected )
6124 {
6125 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
6126 pAdapter->sessionId, &setKey, &roamId );
6127 }
6128 if ( status != 0 )
6129 {
6130 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6131 "[%4d] sme_RoamSetKey returned ERROR status= %d",
6132 __LINE__, status );
6133 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6134 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05306135 /* Need to clear any trace of key value in the memory.
6136 * Thus zero out the memory even though it is local
6137 * variable.
6138 */
6139 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006140}
6141#endif /* FEATURE_WLAN_WAPI*/
6142
6143#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306144int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006145 beacon_data_t **ppBeacon,
6146 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006147#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306148int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006149 beacon_data_t **ppBeacon,
6150 struct cfg80211_beacon_data *params,
6151 int dtim_period)
6152#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306153{
Jeff Johnson295189b2012-06-20 16:38:30 -07006154 int size;
6155 beacon_data_t *beacon = NULL;
6156 beacon_data_t *old = NULL;
6157 int head_len,tail_len;
6158
Jeff Johnsone7245742012-09-05 17:12:55 -07006159 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006160 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306161 {
6162 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6163 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006164 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006166
6167 old = pAdapter->sessionCtx.ap.beacon;
6168
6169 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306170 {
6171 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6172 FL("session(%d) old and new heads points to NULL"),
6173 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306175 }
6176
6177 if (params->tail && !params->tail_len)
6178 {
6179 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6180 FL("tail_len is zero but tail is not NULL"));
6181 return -EINVAL;
6182 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006183
Jeff Johnson295189b2012-06-20 16:38:30 -07006184#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
6185 /* Kernel 3.0 is not updating dtim_period for set beacon */
6186 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306187 {
6188 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6189 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306191 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006192#endif
6193
6194 if(params->head)
6195 head_len = params->head_len;
6196 else
6197 head_len = old->head_len;
6198
6199 if(params->tail || !old)
6200 tail_len = params->tail_len;
6201 else
6202 tail_len = old->tail_len;
6203
6204 size = sizeof(beacon_data_t) + head_len + tail_len;
6205
6206 beacon = kzalloc(size, GFP_KERNEL);
6207
6208 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306209 {
6210 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6211 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006212 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306213 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006214
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006215#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 if(params->dtim_period || !old )
6217 beacon->dtim_period = params->dtim_period;
6218 else
6219 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006220#else
6221 if(dtim_period || !old )
6222 beacon->dtim_period = dtim_period;
6223 else
6224 beacon->dtim_period = old->dtim_period;
6225#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306226
Jeff Johnson295189b2012-06-20 16:38:30 -07006227 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
6228 beacon->tail = beacon->head + head_len;
6229 beacon->head_len = head_len;
6230 beacon->tail_len = tail_len;
6231
6232 if(params->head) {
6233 memcpy (beacon->head,params->head,beacon->head_len);
6234 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306235 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 if(old)
6237 memcpy (beacon->head,old->head,beacon->head_len);
6238 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306239
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 if(params->tail) {
6241 memcpy (beacon->tail,params->tail,beacon->tail_len);
6242 }
6243 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306244 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 memcpy (beacon->tail,old->tail,beacon->tail_len);
6246 }
6247
6248 *ppBeacon = beacon;
6249
6250 kfree(old);
6251
6252 return 0;
6253
6254}
Jeff Johnson295189b2012-06-20 16:38:30 -07006255
6256v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
6257{
6258 int left = length;
6259 v_U8_t *ptr = pIes;
6260 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306261
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306263 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 elem_id = ptr[0];
6265 elem_len = ptr[1];
6266 left -= 2;
6267 if(elem_len > left)
6268 {
6269 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006270 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006271 eid,elem_len,left);
6272 return NULL;
6273 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306274 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006275 {
6276 return ptr;
6277 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306278
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 left -= elem_len;
6280 ptr += (elem_len + 2);
6281 }
6282 return NULL;
6283}
6284
Jeff Johnson295189b2012-06-20 16:38:30 -07006285/* Check if rate is 11g rate or not */
6286static int wlan_hdd_rate_is_11g(u8 rate)
6287{
Sanjay Devnani28322e22013-06-21 16:13:40 -07006288 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006289 u8 i;
6290 for (i = 0; i < 8; i++)
6291 {
6292 if(rate == gRateArray[i])
6293 return TRUE;
6294 }
6295 return FALSE;
6296}
6297
6298/* Check for 11g rate and set proper 11g only mode */
6299static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
6300 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
6301{
6302 u8 i, num_rates = pIe[0];
6303
6304 pIe += 1;
6305 for ( i = 0; i < num_rates; i++)
6306 {
6307 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
6308 {
6309 /* If rate set have 11g rate than change the mode to 11G */
6310 *pSapHw_mode = eSAP_DOT11_MODE_11g;
6311 if (pIe[i] & BASIC_RATE_MASK)
6312 {
6313 /* If we have 11g rate as basic rate, it means mode
6314 is 11g only mode.
6315 */
6316 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
6317 *pCheckRatesfor11g = FALSE;
6318 }
6319 }
6320 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
6321 {
6322 *require_ht = TRUE;
6323 }
6324 }
6325 return;
6326}
6327
6328static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
6329{
6330 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6331 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6332 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6333 u8 checkRatesfor11g = TRUE;
6334 u8 require_ht = FALSE;
6335 u8 *pIe=NULL;
6336
6337 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
6338
6339 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
6340 pBeacon->head_len, WLAN_EID_SUPP_RATES);
6341 if (pIe != NULL)
6342 {
6343 pIe += 1;
6344 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6345 &pConfig->SapHw_mode);
6346 }
6347
6348 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6349 WLAN_EID_EXT_SUPP_RATES);
6350 if (pIe != NULL)
6351 {
6352
6353 pIe += 1;
6354 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6355 &pConfig->SapHw_mode);
6356 }
6357
6358 if( pConfig->channel > 14 )
6359 {
6360 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
6361 }
6362
6363 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6364 WLAN_EID_HT_CAPABILITY);
6365
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306366 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006367 {
6368 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
6369 if(require_ht)
6370 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
6371 }
6372}
6373
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306374static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
6375 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
6376{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006377 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306378 v_U8_t *pIe = NULL;
6379 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6380
6381 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
6382 pBeacon->tail, pBeacon->tail_len);
6383
6384 if (pIe)
6385 {
6386 ielen = pIe[1] + 2;
6387 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6388 {
6389 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
6390 }
6391 else
6392 {
6393 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
6394 return -EINVAL;
6395 }
6396 *total_ielen += ielen;
6397 }
6398 return 0;
6399}
6400
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006401static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
6402 v_U8_t *genie, v_U8_t *total_ielen)
6403{
6404 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6405 int left = pBeacon->tail_len;
6406 v_U8_t *ptr = pBeacon->tail;
6407 v_U8_t elem_id, elem_len;
6408 v_U16_t ielen = 0;
6409
6410 if ( NULL == ptr || 0 == left )
6411 return;
6412
6413 while (left >= 2)
6414 {
6415 elem_id = ptr[0];
6416 elem_len = ptr[1];
6417 left -= 2;
6418 if (elem_len > left)
6419 {
6420 hddLog( VOS_TRACE_LEVEL_ERROR,
6421 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
6422 elem_id, elem_len, left);
6423 return;
6424 }
6425 if (IE_EID_VENDOR == elem_id)
6426 {
6427 /* skipping the VSIE's which we don't want to include or
6428 * it will be included by existing code
6429 */
6430 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
6431#ifdef WLAN_FEATURE_WFD
6432 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
6433#endif
6434 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6435 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6436 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
6437 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6438 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
6439 {
6440 ielen = ptr[1] + 2;
6441 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6442 {
6443 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
6444 *total_ielen += ielen;
6445 }
6446 else
6447 {
6448 hddLog( VOS_TRACE_LEVEL_ERROR,
6449 "IE Length is too big "
6450 "IEs eid=%d elem_len=%d total_ie_lent=%d",
6451 elem_id, elem_len, *total_ielen);
6452 }
6453 }
6454 }
6455
6456 left -= elem_len;
6457 ptr += (elem_len + 2);
6458 }
6459 return;
6460}
6461
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006462#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006463static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6464 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006465#else
6466static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6467 struct cfg80211_beacon_data *params)
6468#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006469{
6470 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306471 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006472 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07006473 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006474
6475 genie = vos_mem_malloc(MAX_GENIE_LEN);
6476
6477 if(genie == NULL) {
6478
6479 return -ENOMEM;
6480 }
6481
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306482 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6483 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006484 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306485 hddLog(LOGE,
6486 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306487 ret = -EINVAL;
6488 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006489 }
6490
6491#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306492 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6493 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
6494 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306495 hddLog(LOGE,
6496 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306497 ret = -EINVAL;
6498 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006499 }
6500#endif
6501
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306502 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6503 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006504 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306505 hddLog(LOGE,
6506 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306507 ret = -EINVAL;
6508 goto done;
6509 }
6510
6511 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
6512 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006513 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006515
6516 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6517 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
6518 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6519 {
6520 hddLog(LOGE,
6521 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006522 ret = -EINVAL;
6523 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006524 }
6525
6526 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6527 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6528 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6529 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6530 ==eHAL_STATUS_FAILURE)
6531 {
6532 hddLog(LOGE,
6533 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006534 ret = -EINVAL;
6535 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006536 }
6537
6538 // Added for ProResp IE
6539 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
6540 {
6541 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
6542 u8 probe_rsp_ie_len[3] = {0};
6543 u8 counter = 0;
6544 /* Check Probe Resp Length if it is greater then 255 then Store
6545 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
6546 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
6547 Store More then 255 bytes into One Variable.
6548 */
6549 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6550 {
6551 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6552 {
6553 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6554 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6555 }
6556 else
6557 {
6558 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6559 rem_probe_resp_ie_len = 0;
6560 }
6561 }
6562
6563 rem_probe_resp_ie_len = 0;
6564
6565 if (probe_rsp_ie_len[0] > 0)
6566 {
6567 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6568 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6569 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6570 probe_rsp_ie_len[0], NULL,
6571 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6572 {
6573 hddLog(LOGE,
6574 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006575 ret = -EINVAL;
6576 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006577 }
6578 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6579 }
6580
6581 if (probe_rsp_ie_len[1] > 0)
6582 {
6583 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6584 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6585 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6586 probe_rsp_ie_len[1], NULL,
6587 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6588 {
6589 hddLog(LOGE,
6590 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006591 ret = -EINVAL;
6592 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006593 }
6594 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6595 }
6596
6597 if (probe_rsp_ie_len[2] > 0)
6598 {
6599 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6600 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6601 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6602 probe_rsp_ie_len[2], NULL,
6603 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6604 {
6605 hddLog(LOGE,
6606 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006607 ret = -EINVAL;
6608 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 }
6610 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6611 }
6612
6613 if (probe_rsp_ie_len[1] == 0 )
6614 {
6615 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6616 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
6617 eANI_BOOLEAN_FALSE) )
6618 {
6619 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006620 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006621 }
6622 }
6623
6624 if (probe_rsp_ie_len[2] == 0 )
6625 {
6626 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6627 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
6628 eANI_BOOLEAN_FALSE) )
6629 {
6630 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006631 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 }
6633 }
6634
6635 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6636 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6637 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6638 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6639 == eHAL_STATUS_FAILURE)
6640 {
6641 hddLog(LOGE,
6642 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006643 ret = -EINVAL;
6644 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 }
6646 }
6647 else
6648 {
6649 // Reset WNI_CFG_PROBE_RSP Flags
6650 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
6651
6652 hddLog(VOS_TRACE_LEVEL_INFO,
6653 "%s: No Probe Response IE received in set beacon",
6654 __func__);
6655 }
6656
6657 // Added for AssocResp IE
6658 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
6659 {
6660 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6661 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
6662 params->assocresp_ies_len, NULL,
6663 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6664 {
6665 hddLog(LOGE,
6666 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006667 ret = -EINVAL;
6668 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006669 }
6670
6671 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6672 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
6673 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6674 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6675 == eHAL_STATUS_FAILURE)
6676 {
6677 hddLog(LOGE,
6678 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006679 ret = -EINVAL;
6680 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 }
6682 }
6683 else
6684 {
6685 hddLog(VOS_TRACE_LEVEL_INFO,
6686 "%s: No Assoc Response IE received in set beacon",
6687 __func__);
6688
6689 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6690 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6691 eANI_BOOLEAN_FALSE) )
6692 {
6693 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006694 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006695 }
6696 }
6697
Jeff Johnsone7245742012-09-05 17:12:55 -07006698done:
Jeff Johnson295189b2012-06-20 16:38:30 -07006699 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306700 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006701}
Jeff Johnson295189b2012-06-20 16:38:30 -07006702
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306703/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 * FUNCTION: wlan_hdd_validate_operation_channel
6705 * called by wlan_hdd_cfg80211_start_bss() and
6706 * wlan_hdd_cfg80211_set_channel()
6707 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306708 * channel list.
6709 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07006710VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006711{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306712
Jeff Johnson295189b2012-06-20 16:38:30 -07006713 v_U32_t num_ch = 0;
6714 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6715 u32 indx = 0;
6716 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306717 v_U8_t fValidChannel = FALSE, count = 0;
6718 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306719
Jeff Johnson295189b2012-06-20 16:38:30 -07006720 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6721
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306722 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006723 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306724 /* Validate the channel */
6725 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306727 if ( channel == rfChannels[count].channelNum )
6728 {
6729 fValidChannel = TRUE;
6730 break;
6731 }
6732 }
6733 if (fValidChannel != TRUE)
6734 {
6735 hddLog(VOS_TRACE_LEVEL_ERROR,
6736 "%s: Invalid Channel [%d]", __func__, channel);
6737 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006738 }
6739 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306740 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306742 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6743 valid_ch, &num_ch))
6744 {
6745 hddLog(VOS_TRACE_LEVEL_ERROR,
6746 "%s: failed to get valid channel list", __func__);
6747 return VOS_STATUS_E_FAILURE;
6748 }
6749 for (indx = 0; indx < num_ch; indx++)
6750 {
6751 if (channel == valid_ch[indx])
6752 {
6753 break;
6754 }
6755 }
6756
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306757 if (indx >= num_ch)
6758 {
6759 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6760 {
6761 eCsrBand band;
6762 unsigned int freq;
6763
6764 sme_GetFreqBand(hHal, &band);
6765
6766 if (eCSR_BAND_5G == band)
6767 {
6768#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
6769 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
6770 {
6771 freq = ieee80211_channel_to_frequency(channel,
6772 IEEE80211_BAND_2GHZ);
6773 }
6774 else
6775 {
6776 freq = ieee80211_channel_to_frequency(channel,
6777 IEEE80211_BAND_5GHZ);
6778 }
6779#else
6780 freq = ieee80211_channel_to_frequency(channel);
6781#endif
6782 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
6783 return VOS_STATUS_SUCCESS;
6784 }
6785 }
6786
6787 hddLog(VOS_TRACE_LEVEL_ERROR,
6788 "%s: Invalid Channel [%d]", __func__, channel);
6789 return VOS_STATUS_E_FAILURE;
6790 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006791 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306792
Jeff Johnson295189b2012-06-20 16:38:30 -07006793 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306794
Jeff Johnson295189b2012-06-20 16:38:30 -07006795}
6796
Viral Modi3a32cc52013-02-08 11:14:52 -08006797/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306798 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08006799 * This function is used to set the channel number
6800 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306801static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08006802 struct ieee80211_channel *chan,
6803 enum nl80211_channel_type channel_type
6804 )
6805{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306806 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08006807 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07006808 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08006809 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306810 hdd_context_t *pHddCtx;
6811 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006812
6813 ENTER();
6814
6815 if( NULL == dev )
6816 {
6817 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006818 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006819 return -ENODEV;
6820 }
6821 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306822
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306823 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6824 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
6825 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08006826 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306827 "%s: device_mode = %s (%d) freq = %d", __func__,
6828 hdd_device_modetoString(pAdapter->device_mode),
6829 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306830
6831 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6832 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306833 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08006834 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306835 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006836 }
6837
6838 /*
6839 * Do freq to chan conversion
6840 * TODO: for 11a
6841 */
6842
6843 channel = ieee80211_frequency_to_channel(freq);
6844
6845 /* Check freq range */
6846 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
6847 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
6848 {
6849 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006850 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08006851 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
6852 WNI_CFG_CURRENT_CHANNEL_STAMAX);
6853 return -EINVAL;
6854 }
6855
6856 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6857
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05306858 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
6859 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08006860 {
6861 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
6862 {
6863 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006864 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08006865 return -EINVAL;
6866 }
6867 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6868 "%s: set channel to [%d] for device mode =%d",
6869 __func__, channel,pAdapter->device_mode);
6870 }
6871 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08006872 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08006873 )
6874 {
6875 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6876 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
6877 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6878
6879 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
6880 {
6881 /* Link is up then return cant set channel*/
6882 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006883 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006884 return -EINVAL;
6885 }
6886
6887 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
6888 pHddStaCtx->conn_info.operationChannel = channel;
6889 pRoamProfile->ChannelInfo.ChannelList =
6890 &pHddStaCtx->conn_info.operationChannel;
6891 }
6892 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08006893 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08006894 )
6895 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306896 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6897 {
6898 if(VOS_STATUS_SUCCESS !=
6899 wlan_hdd_validate_operation_channel(pAdapter,channel))
6900 {
6901 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006902 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306903 return -EINVAL;
6904 }
6905 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6906 }
6907 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08006908 {
6909 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
6910
6911 /* If auto channel selection is configured as enable/ 1 then ignore
6912 channel set by supplicant
6913 */
6914 if ( cfg_param->apAutoChannelSelection )
6915 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306916 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
6917 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08006918 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306919 "%s: set channel to auto channel (0) for device mode =%s (%d)",
6920 __func__, hdd_device_modetoString(pAdapter->device_mode),
6921 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08006922 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306923 else
6924 {
6925 if(VOS_STATUS_SUCCESS !=
6926 wlan_hdd_validate_operation_channel(pAdapter,channel))
6927 {
6928 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006929 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306930 return -EINVAL;
6931 }
6932 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6933 }
Viral Modi3a32cc52013-02-08 11:14:52 -08006934 }
6935 }
6936 else
6937 {
6938 hddLog(VOS_TRACE_LEVEL_FATAL,
6939 "%s: Invalid device mode failed to set valid channel", __func__);
6940 return -EINVAL;
6941 }
6942 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306943 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006944}
6945
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306946static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
6947 struct net_device *dev,
6948 struct ieee80211_channel *chan,
6949 enum nl80211_channel_type channel_type
6950 )
6951{
6952 int ret;
6953
6954 vos_ssr_protect(__func__);
6955 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
6956 vos_ssr_unprotect(__func__);
6957
6958 return ret;
6959}
6960
Jeff Johnson295189b2012-06-20 16:38:30 -07006961#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
6962static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6963 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006964#else
6965static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6966 struct cfg80211_beacon_data *params,
6967 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05306968 enum nl80211_hidden_ssid hidden_ssid,
6969 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006970#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006971{
6972 tsap_Config_t *pConfig;
6973 beacon_data_t *pBeacon = NULL;
6974 struct ieee80211_mgmt *pMgmt_frame;
6975 v_U8_t *pIe=NULL;
6976 v_U16_t capab_info;
6977 eCsrAuthType RSNAuthType;
6978 eCsrEncryptionType RSNEncryptType;
6979 eCsrEncryptionType mcRSNEncryptType;
6980 int status = VOS_STATUS_SUCCESS;
6981 tpWLAN_SAPEventCB pSapEventCallback;
6982 hdd_hostapd_state_t *pHostapdState;
6983 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
6984 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306985 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006986 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306987 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006988 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08006989 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05306990 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07006991 v_BOOL_t MFPCapable = VOS_FALSE;
6992 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05306993 v_BOOL_t sapEnable11AC =
6994 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07006995 ENTER();
6996
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306997 iniConfig = pHddCtx->cfg_ini;
6998
Jeff Johnson295189b2012-06-20 16:38:30 -07006999 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
7000
7001 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
7002
7003 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
7004
7005 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
7006
7007 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
7008
7009 //channel is already set in the set_channel Call back
7010 //pConfig->channel = pCommitConfig->channel;
7011
7012 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307013 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07007014 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
7015
7016 pConfig->dtim_period = pBeacon->dtim_period;
7017
Arif Hussain6d2a3322013-11-17 19:50:10 -08007018 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07007019 pConfig->dtim_period);
7020
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08007021 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07007022 {
7023 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007024 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05307025 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
7026 {
7027 tANI_BOOLEAN restartNeeded;
7028 pConfig->ieee80211d = 1;
7029 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
7030 sme_setRegInfo(hHal, pConfig->countryCode);
7031 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
7032 }
7033 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07007034 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07007035 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007036 pConfig->ieee80211d = 1;
7037 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
7038 sme_setRegInfo(hHal, pConfig->countryCode);
7039 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07007040 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007041 else
7042 {
7043 pConfig->ieee80211d = 0;
7044 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307045 /*
7046 * If auto channel is configured i.e. channel is 0,
7047 * so skip channel validation.
7048 */
7049 if( AUTO_CHANNEL_SELECT != pConfig->channel )
7050 {
7051 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
7052 {
7053 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007054 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307055 return -EINVAL;
7056 }
7057 }
7058 else
7059 {
7060 if(1 != pHddCtx->is_dynamic_channel_range_set)
7061 {
7062 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
7063 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
7064 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
7065 }
7066 pHddCtx->is_dynamic_channel_range_set = 0;
7067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007068 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007069 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007070 {
7071 pConfig->ieee80211d = 0;
7072 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307073
7074#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7075 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7076 pConfig->authType = eSAP_OPEN_SYSTEM;
7077 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7078 pConfig->authType = eSAP_SHARED_KEY;
7079 else
7080 pConfig->authType = eSAP_AUTO_SWITCH;
7081#else
7082 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7083 pConfig->authType = eSAP_OPEN_SYSTEM;
7084 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7085 pConfig->authType = eSAP_SHARED_KEY;
7086 else
7087 pConfig->authType = eSAP_AUTO_SWITCH;
7088#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007089
7090 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307091
7092 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
7094
7095 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
7096
7097 /*Set wps station to configured*/
7098 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
7099
7100 if(pIe)
7101 {
7102 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
7103 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007104 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07007105 return -EINVAL;
7106 }
7107 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
7108 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007109 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07007110 /* Check 15 bit of WPS IE as it contain information for wps state
7111 * WPS state
7112 */
7113 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
7114 {
7115 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
7116 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
7117 {
7118 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
7119 }
7120 }
7121 }
7122 else
7123 {
7124 pConfig->wps_state = SAP_WPS_DISABLED;
7125 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307126 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07007127
c_hpothufe599e92014-06-16 11:38:55 +05307128 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7129 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7130 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
7131 eCSR_ENCRYPT_TYPE_NONE;
7132
Jeff Johnson295189b2012-06-20 16:38:30 -07007133 pConfig->RSNWPAReqIELength = 0;
7134 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307135 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007136 WLAN_EID_RSN);
7137 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307138 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007139 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7140 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7141 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307142 /* The actual processing may eventually be more extensive than
7143 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07007144 * by the app.
7145 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307146 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007147 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7148 &RSNEncryptType,
7149 &mcRSNEncryptType,
7150 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007151 &MFPCapable,
7152 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 pConfig->pRSNWPAReqIE[1]+2,
7154 pConfig->pRSNWPAReqIE );
7155
7156 if( VOS_STATUS_SUCCESS == status )
7157 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307158 /* Now copy over all the security attributes you have
7159 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007160 * */
7161 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7162 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7163 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7164 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307165 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007166 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007167 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7168 }
7169 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307170
Jeff Johnson295189b2012-06-20 16:38:30 -07007171 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7172 pBeacon->tail, pBeacon->tail_len);
7173
7174 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
7175 {
7176 if (pConfig->pRSNWPAReqIE)
7177 {
7178 /*Mixed mode WPA/WPA2*/
7179 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
7180 pConfig->RSNWPAReqIELength += pIe[1] + 2;
7181 }
7182 else
7183 {
7184 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7185 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7186 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307187 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007188 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7189 &RSNEncryptType,
7190 &mcRSNEncryptType,
7191 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007192 &MFPCapable,
7193 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007194 pConfig->pRSNWPAReqIE[1]+2,
7195 pConfig->pRSNWPAReqIE );
7196
7197 if( VOS_STATUS_SUCCESS == status )
7198 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307199 /* Now copy over all the security attributes you have
7200 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 * */
7202 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7203 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7204 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7205 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307206 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007207 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7209 }
7210 }
7211 }
7212
Jeff Johnson4416a782013-03-25 14:17:50 -07007213 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
7214 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
7215 return -EINVAL;
7216 }
7217
Jeff Johnson295189b2012-06-20 16:38:30 -07007218 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
7219
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007220#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 if (params->ssid != NULL)
7222 {
7223 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
7224 pConfig->SSIDinfo.ssid.length = params->ssid_len;
7225 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7226 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7227 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007228#else
7229 if (ssid != NULL)
7230 {
7231 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
7232 pConfig->SSIDinfo.ssid.length = ssid_len;
7233 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7234 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7235 }
7236#endif
7237
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307238 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07007239 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307240
Jeff Johnson295189b2012-06-20 16:38:30 -07007241 /* default value */
7242 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
7243 pConfig->num_accept_mac = 0;
7244 pConfig->num_deny_mac = 0;
7245
7246 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7247 pBeacon->tail, pBeacon->tail_len);
7248
7249 /* pIe for black list is following form:
7250 type : 1 byte
7251 length : 1 byte
7252 OUI : 4 bytes
7253 acl type : 1 byte
7254 no of mac addr in black list: 1 byte
7255 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307256 */
7257 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007258 {
7259 pConfig->SapMacaddr_acl = pIe[6];
7260 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007261 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007262 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307263 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
7264 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007265 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7266 for (i = 0; i < pConfig->num_deny_mac; i++)
7267 {
7268 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7269 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307270 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007271 }
7272 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7273 pBeacon->tail, pBeacon->tail_len);
7274
7275 /* pIe for white list is following form:
7276 type : 1 byte
7277 length : 1 byte
7278 OUI : 4 bytes
7279 acl type : 1 byte
7280 no of mac addr in white list: 1 byte
7281 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307282 */
7283 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007284 {
7285 pConfig->SapMacaddr_acl = pIe[6];
7286 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007287 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007288 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307289 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
7290 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007291 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7292 for (i = 0; i < pConfig->num_accept_mac; i++)
7293 {
7294 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7295 acl_entry++;
7296 }
7297 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307298
Jeff Johnson295189b2012-06-20 16:38:30 -07007299 wlan_hdd_set_sapHwmode(pHostapdAdapter);
7300
Jeff Johnsone7245742012-09-05 17:12:55 -07007301#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007302 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307303 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
7304 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05307305 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
7306 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007307 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
7308 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307309 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
7310 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07007311 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307312 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007313 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307314 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007315
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307316 /* If ACS disable and selected channel <= 14
7317 * OR
7318 * ACS enabled and ACS operating band is choosen as 2.4
7319 * AND
7320 * VHT in 2.4G Disabled
7321 * THEN
7322 * Fallback to 11N mode
7323 */
7324 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
7325 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05307326 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307327 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007328 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307329 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
7330 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007331 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
7332 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007333 }
7334#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307335
Jeff Johnson295189b2012-06-20 16:38:30 -07007336 // ht_capab is not what the name conveys,this is used for protection bitmap
7337 pConfig->ht_capab =
7338 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
7339
7340 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
7341 {
7342 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
7343 return -EINVAL;
7344 }
7345
7346 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307347 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07007348 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
7349 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307350 pConfig->obssProtEnabled =
7351 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07007352
Chet Lanctot8cecea22014-02-11 19:09:36 -08007353#ifdef WLAN_FEATURE_11W
7354 pConfig->mfpCapable = MFPCapable;
7355 pConfig->mfpRequired = MFPRequired;
7356 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
7357 pConfig->mfpCapable, pConfig->mfpRequired);
7358#endif
7359
Arif Hussain6d2a3322013-11-17 19:50:10 -08007360 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07007361 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007362 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
7363 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
7364 (int)pConfig->channel);
7365 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
7366 pConfig->SapHw_mode, pConfig->privacy,
7367 pConfig->authType);
7368 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
7369 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
7370 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
7371 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07007372
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307373 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007374 {
7375 //Bss already started. just return.
7376 //TODO Probably it should update some beacon params.
7377 hddLog( LOGE, "Bss Already started...Ignore the request");
7378 EXIT();
7379 return 0;
7380 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307381
Agarwal Ashish51325b52014-06-16 16:50:49 +05307382 if (vos_max_concurrent_connections_reached()) {
7383 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7384 return -EINVAL;
7385 }
7386
Jeff Johnson295189b2012-06-20 16:38:30 -07007387 pConfig->persona = pHostapdAdapter->device_mode;
7388
Peng Xu2446a892014-09-05 17:21:18 +05307389 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
7390 if ( NULL != psmeConfig)
7391 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307392 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05307393 sme_GetConfigParam(hHal, psmeConfig);
7394 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307395#ifdef WLAN_FEATURE_AP_HT40_24G
7396 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
7397 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
7398 && pHddCtx->cfg_ini->apHT40_24GEnabled)
7399 {
7400 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
7401 sme_UpdateConfig (hHal, psmeConfig);
7402 }
7403#endif
Peng Xu2446a892014-09-05 17:21:18 +05307404 vos_mem_free(psmeConfig);
7405 }
Peng Xuafc34e32014-09-25 13:23:55 +05307406 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05307407
Jeff Johnson295189b2012-06-20 16:38:30 -07007408 pSapEventCallback = hdd_hostapd_SAPEventCB;
7409 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
7410 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
7411 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007412 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007413 return -EINVAL;
7414 }
7415
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307416 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07007417 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
7418
7419 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307420
Jeff Johnson295189b2012-06-20 16:38:30 -07007421 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307422 {
7423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007424 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07007425 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007426 VOS_ASSERT(0);
7427 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307428
Jeff Johnson295189b2012-06-20 16:38:30 -07007429 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05307430 /* Initialize WMM configuation */
7431 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307432 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007433
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007434#ifdef WLAN_FEATURE_P2P_DEBUG
7435 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
7436 {
7437 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
7438 {
7439 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7440 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007441 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007442 }
7443 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
7444 {
7445 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7446 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007447 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007448 }
7449 }
7450#endif
7451
Jeff Johnson295189b2012-06-20 16:38:30 -07007452 pHostapdState->bCommit = TRUE;
7453 EXIT();
7454
7455 return 0;
7456}
7457
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007458#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307459static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307460 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007461 struct beacon_parameters *params)
7462{
7463 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307464 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307465 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007466
7467 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307468
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307469 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7470 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
7471 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307472 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
7473 hdd_device_modetoString(pAdapter->device_mode),
7474 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007475
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307476 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7477 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307478 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007479 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307480 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007481 }
7482
Agarwal Ashish51325b52014-06-16 16:50:49 +05307483 if (vos_max_concurrent_connections_reached()) {
7484 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7485 return -EINVAL;
7486 }
7487
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307488 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007489 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 )
7491 {
7492 beacon_data_t *old,*new;
7493
7494 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307495
Jeff Johnson295189b2012-06-20 16:38:30 -07007496 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307497 {
7498 hddLog(VOS_TRACE_LEVEL_WARN,
7499 FL("already beacon info added to session(%d)"),
7500 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007503
7504 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7505
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307506 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07007507 {
7508 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007509 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007510 return -EINVAL;
7511 }
7512
7513 pAdapter->sessionCtx.ap.beacon = new;
7514
7515 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7516 }
7517
7518 EXIT();
7519 return status;
7520}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307521
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307522static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
7523 struct net_device *dev,
7524 struct beacon_parameters *params)
7525{
7526 int ret;
7527
7528 vos_ssr_protect(__func__);
7529 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
7530 vos_ssr_unprotect(__func__);
7531
7532 return ret;
7533}
7534
7535static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007536 struct net_device *dev,
7537 struct beacon_parameters *params)
7538{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307539 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307540 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7541 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307542 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007543
7544 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307545
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307546 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7547 TRACE_CODE_HDD_CFG80211_SET_BEACON,
7548 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
7549 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7550 __func__, hdd_device_modetoString(pAdapter->device_mode),
7551 pAdapter->device_mode);
7552
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307553 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7554 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307555 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007556 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307557 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007558 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307559
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307560 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007561 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307562 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007563 {
7564 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307565
Jeff Johnson295189b2012-06-20 16:38:30 -07007566 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307567
Jeff Johnson295189b2012-06-20 16:38:30 -07007568 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307569 {
7570 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7571 FL("session(%d) old and new heads points to NULL"),
7572 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007573 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007575
7576 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7577
7578 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307579 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007580 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007581 return -EINVAL;
7582 }
7583
7584 pAdapter->sessionCtx.ap.beacon = new;
7585
7586 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7587 }
7588
7589 EXIT();
7590 return status;
7591}
7592
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307593static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
7594 struct net_device *dev,
7595 struct beacon_parameters *params)
7596{
7597 int ret;
7598
7599 vos_ssr_protect(__func__);
7600 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
7601 vos_ssr_unprotect(__func__);
7602
7603 return ret;
7604}
7605
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007606#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7607
7608#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307609static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007610 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007611#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307612static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007613 struct net_device *dev)
7614#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007615{
7616 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07007617 hdd_context_t *pHddCtx = NULL;
7618 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307619 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307620 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007621
7622 ENTER();
7623
7624 if (NULL == pAdapter)
7625 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307626 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007627 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007628 return -ENODEV;
7629 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007630
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307631 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7632 TRACE_CODE_HDD_CFG80211_STOP_AP,
7633 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307634 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7635 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307636 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007637 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307638 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07007639 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007640
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007641 pScanInfo = &pHddCtx->scan_info;
7642
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307643 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7644 __func__, hdd_device_modetoString(pAdapter->device_mode),
7645 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007646
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307647 ret = wlan_hdd_scan_abort(pAdapter);
7648
Girish Gowli4bf7a632014-06-12 13:42:11 +05307649 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07007650 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307651 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7652 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307653
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307654 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07007655 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7657 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08007658
Jeff Johnsone7245742012-09-05 17:12:55 -07007659 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307660 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07007661 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307662 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07007663 }
7664
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05307665 /* Delete all associated STAs before stopping AP/P2P GO */
7666 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05307667 hdd_hostapd_stop(dev);
7668
Jeff Johnson295189b2012-06-20 16:38:30 -07007669 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007670 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 )
7672 {
7673 beacon_data_t *old;
7674
7675 old = pAdapter->sessionCtx.ap.beacon;
7676
7677 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307678 {
7679 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7680 FL("session(%d) beacon data points to NULL"),
7681 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007682 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007684
Jeff Johnson295189b2012-06-20 16:38:30 -07007685 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007686
7687 mutex_lock(&pHddCtx->sap_lock);
7688 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7689 {
Jeff Johnson4416a782013-03-25 14:17:50 -07007690 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007691 {
7692 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7693
7694 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
7695
7696 if (!VOS_IS_STATUS_SUCCESS(status))
7697 {
7698 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007699 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007700 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307701 }
7702 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007703 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307704 /* BSS stopped, clear the active sessions for this device mode */
7705 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007706 }
7707 mutex_unlock(&pHddCtx->sap_lock);
7708
7709 if(status != VOS_STATUS_SUCCESS)
7710 {
7711 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007712 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007713 return -EINVAL;
7714 }
7715
Jeff Johnson4416a782013-03-25 14:17:50 -07007716 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007717 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
7718 ==eHAL_STATUS_FAILURE)
7719 {
7720 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007721 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007722 }
7723
Jeff Johnson4416a782013-03-25 14:17:50 -07007724 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007725 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7726 eANI_BOOLEAN_FALSE) )
7727 {
7728 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007729 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007730 }
7731
7732 // Reset WNI_CFG_PROBE_RSP Flags
7733 wlan_hdd_reset_prob_rspies(pAdapter);
7734
7735 pAdapter->sessionCtx.ap.beacon = NULL;
7736 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007737#ifdef WLAN_FEATURE_P2P_DEBUG
7738 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
7739 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
7740 {
7741 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
7742 "GO got removed");
7743 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
7744 }
7745#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007746 }
7747 EXIT();
7748 return status;
7749}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007750
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307751#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7752static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
7753 struct net_device *dev)
7754{
7755 int ret;
7756
7757 vos_ssr_protect(__func__);
7758 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
7759 vos_ssr_unprotect(__func__);
7760
7761 return ret;
7762}
7763#else
7764static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
7765 struct net_device *dev)
7766{
7767 int ret;
7768
7769 vos_ssr_protect(__func__);
7770 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
7771 vos_ssr_unprotect(__func__);
7772
7773 return ret;
7774}
7775#endif
7776
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007777#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
7778
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307779static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307780 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007781 struct cfg80211_ap_settings *params)
7782{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307783 hdd_adapter_t *pAdapter;
7784 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307785 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007786
7787 ENTER();
7788
Girish Gowlib143d7a2015-02-18 19:39:55 +05307789 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007790 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307791 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05307792 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307793 return -ENODEV;
7794 }
7795
7796 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7797 if (NULL == pAdapter)
7798 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307799 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307800 "%s: HDD adapter is Null", __func__);
7801 return -ENODEV;
7802 }
7803
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307804 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7805 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
7806 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307807 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
7808 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307809 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307810 "%s: HDD adapter magic is invalid", __func__);
7811 return -ENODEV;
7812 }
7813
7814 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307815 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307816 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307817 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307818 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307819 }
7820
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307821 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
7822 __func__, hdd_device_modetoString(pAdapter->device_mode),
7823 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307824
7825 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007826 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007827 )
7828 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307829 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007830
7831 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307832
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007833 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307834 {
7835 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7836 FL("already beacon info added to session(%d)"),
7837 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007838 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307839 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007840
Girish Gowlib143d7a2015-02-18 19:39:55 +05307841#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7842 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7843 &new,
7844 &params->beacon);
7845#else
7846 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7847 &new,
7848 &params->beacon,
7849 params->dtim_period);
7850#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007851
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307852 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007853 {
7854 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307855 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007856 return -EINVAL;
7857 }
7858 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08007859#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07007860 wlan_hdd_cfg80211_set_channel(wiphy, dev,
7861#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
7862 params->channel, params->channel_type);
7863#else
7864 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
7865#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08007866#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007867 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307868 params->ssid_len, params->hidden_ssid,
7869 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007870 }
7871
7872 EXIT();
7873 return status;
7874}
7875
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307876static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
7877 struct net_device *dev,
7878 struct cfg80211_ap_settings *params)
7879{
7880 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007881
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307882 vos_ssr_protect(__func__);
7883 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
7884 vos_ssr_unprotect(__func__);
7885
7886 return ret;
7887}
7888
7889static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007890 struct net_device *dev,
7891 struct cfg80211_beacon_data *params)
7892{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307893 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307894 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307895 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007896
7897 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307898
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307899 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7900 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
7901 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007902 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007903 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307904
7905 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7906 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307907 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007908 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307909 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007910 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007911
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307912 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007913 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307914 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007915 {
7916 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307917
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007918 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307919
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007920 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307921 {
7922 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7923 FL("session(%d) beacon data points to NULL"),
7924 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007925 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307926 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007927
7928 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
7929
7930 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307931 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007932 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007933 return -EINVAL;
7934 }
7935
7936 pAdapter->sessionCtx.ap.beacon = new;
7937
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307938 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
7939 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007940 }
7941
7942 EXIT();
7943 return status;
7944}
7945
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307946static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
7947 struct net_device *dev,
7948 struct cfg80211_beacon_data *params)
7949{
7950 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007951
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307952 vos_ssr_protect(__func__);
7953 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
7954 vos_ssr_unprotect(__func__);
7955
7956 return ret;
7957}
7958
7959#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007960
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307961static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007962 struct net_device *dev,
7963 struct bss_parameters *params)
7964{
7965 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307966 hdd_context_t *pHddCtx;
7967 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007968
7969 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307970
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307971 if (NULL == pAdapter)
7972 {
7973 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7974 "%s: HDD adapter is Null", __func__);
7975 return -ENODEV;
7976 }
7977 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307978 ret = wlan_hdd_validate_context(pHddCtx);
7979 if (0 != ret)
7980 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307981 return ret;
7982 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307983 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7984 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
7985 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307986 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7987 __func__, hdd_device_modetoString(pAdapter->device_mode),
7988 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007989
7990 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007991 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307992 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007993 {
7994 /* ap_isolate == -1 means that in change bss, upper layer doesn't
7995 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307996 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07007997 {
7998 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307999 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008000 }
8001
8002 EXIT();
8003 return 0;
8004}
8005
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308006static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
8007 struct net_device *dev,
8008 struct bss_parameters *params)
8009{
8010 int ret;
8011
8012 vos_ssr_protect(__func__);
8013 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
8014 vos_ssr_unprotect(__func__);
8015
8016 return ret;
8017}
Kiet Lam10841362013-11-01 11:36:50 +05308018/* FUNCTION: wlan_hdd_change_country_code_cd
8019* to wait for contry code completion
8020*/
8021void* wlan_hdd_change_country_code_cb(void *pAdapter)
8022{
8023 hdd_adapter_t *call_back_pAdapter = pAdapter;
8024 complete(&call_back_pAdapter->change_country_code);
8025 return NULL;
8026}
8027
Jeff Johnson295189b2012-06-20 16:38:30 -07008028/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308029 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07008030 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
8031 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308032int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008033 struct net_device *ndev,
8034 enum nl80211_iftype type,
8035 u32 *flags,
8036 struct vif_params *params
8037 )
8038{
8039 struct wireless_dev *wdev;
8040 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008041 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07008042 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008043 tCsrRoamProfile *pRoamProfile = NULL;
8044 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308045 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008046 eMib_dot11DesiredBssType connectedBssType;
8047 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308048 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008049
8050 ENTER();
8051
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308052 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008053 {
8054 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8055 "%s: Adapter context is null", __func__);
8056 return VOS_STATUS_E_FAILURE;
8057 }
8058
8059 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8060 if (!pHddCtx)
8061 {
8062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8063 "%s: HDD context is null", __func__);
8064 return VOS_STATUS_E_FAILURE;
8065 }
8066
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308067 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8068 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
8069 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308070 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308071 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07008072 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308073 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008074 }
8075
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308076 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8077 __func__, hdd_device_modetoString(pAdapter->device_mode),
8078 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008079
Agarwal Ashish51325b52014-06-16 16:50:49 +05308080 if (vos_max_concurrent_connections_reached()) {
8081 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
8082 return -EINVAL;
8083 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308084 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07008085 wdev = ndev->ieee80211_ptr;
8086
8087#ifdef WLAN_BTAMP_FEATURE
8088 if((NL80211_IFTYPE_P2P_CLIENT == type)||
8089 (NL80211_IFTYPE_ADHOC == type)||
8090 (NL80211_IFTYPE_AP == type)||
8091 (NL80211_IFTYPE_P2P_GO == type))
8092 {
8093 pHddCtx->isAmpAllowed = VOS_FALSE;
8094 // stop AMP traffic
8095 status = WLANBAP_StopAmp();
8096 if(VOS_STATUS_SUCCESS != status )
8097 {
8098 pHddCtx->isAmpAllowed = VOS_TRUE;
8099 hddLog(VOS_TRACE_LEVEL_FATAL,
8100 "%s: Failed to stop AMP", __func__);
8101 return -EINVAL;
8102 }
8103 }
8104#endif //WLAN_BTAMP_FEATURE
8105 /* Reset the current device mode bit mask*/
8106 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
8107
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05308108 /* Notify Mode change in case of concurrency.
8109 * Below function invokes TDLS teardown Functionality Since TDLS is
8110 * not Supported in case of concurrency i.e Once P2P session
8111 * is detected disable offchannel and teardown TDLS links
8112 */
8113 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
8114
Jeff Johnson295189b2012-06-20 16:38:30 -07008115 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008116 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07008117 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07008118 )
8119 {
8120 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008121 if (!pWextState)
8122 {
8123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8124 "%s: pWextState is null", __func__);
8125 return VOS_STATUS_E_FAILURE;
8126 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008127 pRoamProfile = &pWextState->roamProfile;
8128 LastBSSType = pRoamProfile->BSSType;
8129
8130 switch (type)
8131 {
8132 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008133 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008134 hddLog(VOS_TRACE_LEVEL_INFO,
8135 "%s: setting interface Type to INFRASTRUCTURE", __func__);
8136 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07008137#ifdef WLAN_FEATURE_11AC
8138 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
8139 {
8140 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
8141 }
8142#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308143 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07008144 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008145 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008146 //Check for sub-string p2p to confirm its a p2p interface
8147 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308148 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008149 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8150 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8151 }
8152 else
8153 {
8154 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008155 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008157 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05308158
Jeff Johnson295189b2012-06-20 16:38:30 -07008159 case NL80211_IFTYPE_ADHOC:
8160 hddLog(VOS_TRACE_LEVEL_INFO,
8161 "%s: setting interface Type to ADHOC", __func__);
8162 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
8163 pRoamProfile->phyMode =
8164 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07008165 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008166 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +05308167 hdd_set_ibss_ops( pAdapter );
8168 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +05308169
8170 status = hdd_sta_id_hash_attach(pAdapter);
8171 if (VOS_STATUS_SUCCESS != status) {
8172 hddLog(VOS_TRACE_LEVEL_ERROR,
8173 FL("Failed to initialize hash for IBSS"));
8174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008175 break;
8176
8177 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008178 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008179 {
8180 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8181 "%s: setting interface Type to %s", __func__,
8182 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
8183
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008184 //Cancel any remain on channel for GO mode
8185 if (NL80211_IFTYPE_P2P_GO == type)
8186 {
8187 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
8188 }
Mohit Khanna0f232092012-09-11 14:46:08 -07008189 if (NL80211_IFTYPE_AP == type)
8190 {
8191 /* As Loading WLAN Driver one interface being created for p2p device
8192 * address. This will take one HW STA and the max number of clients
8193 * that can connect to softAP will be reduced by one. so while changing
8194 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
8195 * interface as it is not required in SoftAP mode.
8196 */
8197
8198 // Get P2P Adapter
8199 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
8200
8201 if (pP2pAdapter)
8202 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05308203 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +05308204 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07008205 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
8206 }
8207 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05308208 //Disable IMPS & BMPS for SAP/GO
8209 if(VOS_STATUS_E_FAILURE ==
8210 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
8211 {
8212 //Fail to Exit BMPS
8213 VOS_ASSERT(0);
8214 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05308215
8216 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
8217
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308218#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07008219
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308220 /* A Mutex Lock is introduced while changing the mode to
8221 * protect the concurrent access for the Adapters by TDLS
8222 * module.
8223 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308224 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308225#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008226 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +05308227 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008228 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07008229 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8230 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308231#ifdef FEATURE_WLAN_TDLS
8232 mutex_unlock(&pHddCtx->tdls_lock);
8233#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008234 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
8235 (pConfig->apRandomBssidEnabled))
8236 {
8237 /* To meet Android requirements create a randomized
8238 MAC address of the form 02:1A:11:Fx:xx:xx */
8239 get_random_bytes(&ndev->dev_addr[3], 3);
8240 ndev->dev_addr[0] = 0x02;
8241 ndev->dev_addr[1] = 0x1A;
8242 ndev->dev_addr[2] = 0x11;
8243 ndev->dev_addr[3] |= 0xF0;
8244 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
8245 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08008246 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
8247 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008248 }
8249
Jeff Johnson295189b2012-06-20 16:38:30 -07008250 hdd_set_ap_ops( pAdapter->dev );
8251
Kiet Lam10841362013-11-01 11:36:50 +05308252 /* This is for only SAP mode where users can
8253 * control country through ini.
8254 * P2P GO follows station country code
8255 * acquired during the STA scanning. */
8256 if((NL80211_IFTYPE_AP == type) &&
8257 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
8258 {
8259 int status = 0;
8260 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
8261 "%s: setting country code from INI ", __func__);
8262 init_completion(&pAdapter->change_country_code);
8263 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
8264 (void *)(tSmeChangeCountryCallback)
8265 wlan_hdd_change_country_code_cb,
8266 pConfig->apCntryCode, pAdapter,
8267 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05308268 eSIR_FALSE,
8269 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05308270 if (eHAL_STATUS_SUCCESS == status)
8271 {
8272 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308273 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05308274 &pAdapter->change_country_code,
8275 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308276 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05308277 {
8278 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308279 FL("SME Timed out while setting country code %ld"),
8280 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08008281
8282 if (pHddCtx->isLogpInProgress)
8283 {
8284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8285 "%s: LOGP in Progress. Ignore!!!", __func__);
8286 return -EAGAIN;
8287 }
Kiet Lam10841362013-11-01 11:36:50 +05308288 }
8289 }
8290 else
8291 {
8292 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008293 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05308294 return -EINVAL;
8295 }
8296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008297 status = hdd_init_ap_mode(pAdapter);
8298 if(status != VOS_STATUS_SUCCESS)
8299 {
8300 hddLog(VOS_TRACE_LEVEL_FATAL,
8301 "%s: Error initializing the ap mode", __func__);
8302 return -EINVAL;
8303 }
8304 hdd_set_conparam(1);
8305
Nirav Shah7e3c8132015-06-22 23:51:42 +05308306 status = hdd_sta_id_hash_attach(pAdapter);
8307 if (VOS_STATUS_SUCCESS != status)
8308 {
8309 hddLog(VOS_TRACE_LEVEL_ERROR,
8310 FL("Failed to initialize hash for AP"));
8311 return -EINVAL;
8312 }
8313
Jeff Johnson295189b2012-06-20 16:38:30 -07008314 /*interface type changed update in wiphy structure*/
8315 if(wdev)
8316 {
8317 wdev->iftype = type;
8318 pHddCtx->change_iface = type;
8319 }
8320 else
8321 {
8322 hddLog(VOS_TRACE_LEVEL_ERROR,
8323 "%s: ERROR !!!! Wireless dev is NULL", __func__);
8324 return -EINVAL;
8325 }
8326 goto done;
8327 }
8328
8329 default:
8330 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8331 __func__);
8332 return -EOPNOTSUPP;
8333 }
8334 }
8335 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008336 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07008337 )
8338 {
8339 switch(type)
8340 {
8341 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008342 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008343 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05308344
8345 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308346#ifdef FEATURE_WLAN_TDLS
8347
8348 /* A Mutex Lock is introduced while changing the mode to
8349 * protect the concurrent access for the Adapters by TDLS
8350 * module.
8351 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308352 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308353#endif
c_hpothu002231a2015-02-05 14:58:51 +05308354 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008355 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008356 //Check for sub-string p2p to confirm its a p2p interface
8357 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008358 {
8359 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8360 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8361 }
8362 else
8363 {
8364 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008365 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008366 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008367 hdd_set_conparam(0);
8368 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
8370 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308371#ifdef FEATURE_WLAN_TDLS
8372 mutex_unlock(&pHddCtx->tdls_lock);
8373#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05308374 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008375 if( VOS_STATUS_SUCCESS != status )
8376 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07008377 /* In case of JB, for P2P-GO, only change interface will be called,
8378 * This is the right place to enable back bmps_imps()
8379 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308380 if (pHddCtx->hdd_wlan_suspended)
8381 {
8382 hdd_set_pwrparams(pHddCtx);
8383 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008384 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008385 goto done;
8386 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008387 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008388 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008389 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8390 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008391 goto done;
8392 default:
8393 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8394 __func__);
8395 return -EOPNOTSUPP;
8396
8397 }
8398
8399 }
8400 else
8401 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308402 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
8403 __func__, hdd_device_modetoString(pAdapter->device_mode),
8404 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008405 return -EOPNOTSUPP;
8406 }
8407
8408
8409 if(pRoamProfile)
8410 {
8411 if ( LastBSSType != pRoamProfile->BSSType )
8412 {
8413 /*interface type changed update in wiphy structure*/
8414 wdev->iftype = type;
8415
8416 /*the BSS mode changed, We need to issue disconnect
8417 if connected or in IBSS disconnect state*/
8418 if ( hdd_connGetConnectedBssType(
8419 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
8420 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
8421 {
8422 /*need to issue a disconnect to CSR.*/
8423 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8424 if( eHAL_STATUS_SUCCESS ==
8425 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8426 pAdapter->sessionId,
8427 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
8428 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308429 ret = wait_for_completion_interruptible_timeout(
8430 &pAdapter->disconnect_comp_var,
8431 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8432 if (ret <= 0)
8433 {
8434 hddLog(VOS_TRACE_LEVEL_ERROR,
8435 FL("wait on disconnect_comp_var failed %ld"), ret);
8436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008437 }
8438 }
8439 }
8440 }
8441
8442done:
8443 /*set bitmask based on updated value*/
8444 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07008445
8446 /* Only STA mode support TM now
8447 * all other mode, TM feature should be disabled */
8448 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
8449 (~VOS_STA & pHddCtx->concurrency_mode) )
8450 {
8451 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
8452 }
8453
Jeff Johnson295189b2012-06-20 16:38:30 -07008454#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308455 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05308456 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07008457 {
8458 //we are ok to do AMP
8459 pHddCtx->isAmpAllowed = VOS_TRUE;
8460 }
8461#endif //WLAN_BTAMP_FEATURE
8462 EXIT();
8463 return 0;
8464}
8465
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308466/*
8467 * FUNCTION: wlan_hdd_cfg80211_change_iface
8468 * wrapper function to protect the actual implementation from SSR.
8469 */
8470int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
8471 struct net_device *ndev,
8472 enum nl80211_iftype type,
8473 u32 *flags,
8474 struct vif_params *params
8475 )
8476{
8477 int ret;
8478
8479 vos_ssr_protect(__func__);
8480 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
8481 vos_ssr_unprotect(__func__);
8482
8483 return ret;
8484}
8485
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008486#ifdef FEATURE_WLAN_TDLS
8487static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
8488 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
8489{
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008490 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008491 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308492 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308493 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308494 hdd_adapter_t *pAdapter;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008495
8496 ENTER();
8497
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308498 if (!dev) {
8499 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
8500 return -EINVAL;
8501 }
8502
8503 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8504 if (!pAdapter) {
8505 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
8506 return -EINVAL;
8507 }
8508
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308509 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008510 {
8511 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8512 "Invalid arguments");
8513 return -EINVAL;
8514 }
Hoonki Lee27511902013-03-14 18:19:06 -07008515
8516 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
8517 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
8518 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308519 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -07008520 "%s: TDLS mode is disabled OR not enabled in FW."
8521 MAC_ADDRESS_STR " Request declined.",
8522 __func__, MAC_ADDR_ARRAY(mac));
8523 return -ENOTSUPP;
8524 }
8525
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008526 if (pHddCtx->isLogpInProgress)
8527 {
8528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8529 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05308530 wlan_hdd_tdls_set_link_status(pAdapter,
8531 mac,
8532 eTDLS_LINK_IDLE,
8533 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008534 return -EBUSY;
8535 }
8536
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308537 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05308538 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008539
8540 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308541 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008542 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
8543 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308544 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008545 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008546 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308547 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008548
8549 /* in add station, we accept existing valid staId if there is */
8550 if ((0 == update) &&
8551 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
8552 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008553 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308554 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008555 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008556 " link_status %d. staId %d. add station ignored.",
8557 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
8558 return 0;
8559 }
8560 /* in change station, we accept only when staId is valid */
8561 if ((1 == update) &&
8562 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
8563 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
8564 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308565 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008566 "%s: " MAC_ADDRESS_STR
8567 " link status %d. staId %d. change station %s.",
8568 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
8569 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
8570 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008571 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008572
8573 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05308574 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008575 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008576 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8577 "%s: " MAC_ADDRESS_STR
8578 " TDLS setup is ongoing. Request declined.",
8579 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07008580 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008581 }
8582
8583 /* first to check if we reached to maximum supported TDLS peer.
8584 TODO: for now, return -EPERM looks working fine,
8585 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308586 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
8587 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008588 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008589 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8590 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308591 " TDLS Max peer already connected. Request declined."
8592 " Num of peers (%d), Max allowed (%d).",
8593 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
8594 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008595 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008596 }
8597 else
8598 {
8599 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308600 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008601 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008602 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008603 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8604 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
8605 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008606 return -EPERM;
8607 }
8608 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008609 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05308610 wlan_hdd_tdls_set_link_status(pAdapter,
8611 mac,
8612 eTDLS_LINK_CONNECTING,
8613 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008614
Jeff Johnsond75fe012013-04-06 10:53:06 -07008615 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308616 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008617 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008619 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008620 if(StaParams->htcap_present)
8621 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008623 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008625 "ht_capa->extended_capabilities: %0x",
8626 StaParams->HTCap.extendedHtCapInfo);
8627 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008629 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008631 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008632 if(StaParams->vhtcap_present)
8633 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308634 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008635 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
8636 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
8637 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
8638 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008639 {
8640 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008641 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008642 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308643 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008644 "[%d]: %x ", i, StaParams->supported_rates[i]);
8645 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07008646 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308647 else if ((1 == update) && (NULL == StaParams))
8648 {
8649 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8650 "%s : update is true, but staParams is NULL. Error!", __func__);
8651 return -EPERM;
8652 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008653
8654 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
8655
8656 if (!update)
8657 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308658 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008659 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308660 if (ret != eHAL_STATUS_SUCCESS) {
8661 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to add TDLS peer STA"));
8662 return -EPERM;
8663 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008664 }
8665 else
8666 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308667 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008668 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308669 if (ret != eHAL_STATUS_SUCCESS) {
8670 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
8671 return -EPERM;
8672 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008673 }
8674
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308675 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008676 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
8677
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308678 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008679 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308681 "%s: timeout waiting for tdls add station indication %ld",
8682 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008683 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008684 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308685
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008686 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
8687 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008689 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008690 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008691 }
8692
8693 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008694
8695error:
Atul Mittal115287b2014-07-08 13:26:33 +05308696 wlan_hdd_tdls_set_link_status(pAdapter,
8697 mac,
8698 eTDLS_LINK_IDLE,
8699 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008700 return -EPERM;
8701
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008702}
8703#endif
8704
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308705static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008706 struct net_device *dev,
8707 u8 *mac,
8708 struct station_parameters *params)
8709{
8710 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308711 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308712 hdd_context_t *pHddCtx;
8713 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008714 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308715 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008716#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008717 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008718 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308719 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008720#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008721
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308722 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308723
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308724 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308725 if ((NULL == pAdapter))
8726 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308728 "invalid adapter ");
8729 return -EINVAL;
8730 }
8731
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308732 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8733 TRACE_CODE_HDD_CHANGE_STATION,
8734 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05308735 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308736
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308737 ret = wlan_hdd_validate_context(pHddCtx);
8738 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +05308739 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308740 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308741 }
8742
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308743 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8744
8745 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008746 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8748 "invalid HDD station context");
8749 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008751 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
8752
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008753 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
8754 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07008755 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008756 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07008757 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308758 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008759 WLANTL_STA_AUTHENTICATED);
8760
Gopichand Nakkala29149562013-05-10 21:43:41 +05308761 if (status != VOS_STATUS_SUCCESS)
8762 {
8763 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8764 "%s: Not able to change TL state to AUTHENTICATED", __func__);
8765 return -EINVAL;
8766 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008767 }
8768 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07008769 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
8770 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308771#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008772 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
8773 StaParams.capability = params->capability;
8774 StaParams.uapsd_queues = params->uapsd_queues;
8775 StaParams.max_sp = params->max_sp;
8776
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308777 /* Convert (first channel , number of channels) tuple to
8778 * the total list of channels. This goes with the assumption
8779 * that if the first channel is < 14, then the next channels
8780 * are an incremental of 1 else an incremental of 4 till the number
8781 * of channels.
8782 */
8783 if (0 != params->supported_channels_len) {
8784 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
8785 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
8786 {
8787 int wifi_chan_index;
8788 StaParams.supported_channels[j] = params->supported_channels[i];
8789 wifi_chan_index =
8790 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
8791 no_of_channels = params->supported_channels[i+1];
8792 for(k=1; k <= no_of_channels; k++)
8793 {
8794 StaParams.supported_channels[j+1] =
8795 StaParams.supported_channels[j] + wifi_chan_index;
8796 j+=1;
8797 }
8798 }
8799 StaParams.supported_channels_len = j;
8800 }
8801 vos_mem_copy(StaParams.supported_oper_classes,
8802 params->supported_oper_classes,
8803 params->supported_oper_classes_len);
8804 StaParams.supported_oper_classes_len =
8805 params->supported_oper_classes_len;
8806
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008807 if (0 != params->ext_capab_len)
8808 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
8809 sizeof(StaParams.extn_capability));
8810
8811 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008812 {
8813 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008814 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008815 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008816
8817 StaParams.supported_rates_len = params->supported_rates_len;
8818
8819 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
8820 * The supported_rates array , for all the structures propogating till Add Sta
8821 * to the firmware has to be modified , if the supplicant (ieee80211) is
8822 * modified to send more rates.
8823 */
8824
8825 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
8826 */
8827 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
8828 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
8829
8830 if (0 != StaParams.supported_rates_len) {
8831 int i = 0;
8832 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
8833 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008834 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008835 "Supported Rates with Length %d", StaParams.supported_rates_len);
8836 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008837 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008838 "[%d]: %0x", i, StaParams.supported_rates[i]);
8839 }
8840
8841 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008842 {
8843 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008844 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008845 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008846
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008847 if (0 != params->ext_capab_len ) {
8848 /*Define A Macro : TODO Sunil*/
8849 if ((1<<4) & StaParams.extn_capability[3]) {
8850 isBufSta = 1;
8851 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308852 /* TDLS Channel Switching Support */
8853 if ((1<<6) & StaParams.extn_capability[3]) {
8854 isOffChannelSupported = 1;
8855 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008856 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308857 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
8858 &StaParams, isBufSta,
8859 isOffChannelSupported);
8860
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308861 if (VOS_STATUS_SUCCESS != status) {
8862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8863 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
8864 return -EINVAL;
8865 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008866 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
8867
8868 if (VOS_STATUS_SUCCESS != status) {
8869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8870 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
8871 return -EINVAL;
8872 }
8873 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008874#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05308875 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008876 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008877 return status;
8878}
8879
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308880static int wlan_hdd_change_station(struct wiphy *wiphy,
8881 struct net_device *dev,
8882 u8 *mac,
8883 struct station_parameters *params)
8884{
8885 int ret;
8886
8887 vos_ssr_protect(__func__);
8888 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
8889 vos_ssr_unprotect(__func__);
8890
8891 return ret;
8892}
8893
Jeff Johnson295189b2012-06-20 16:38:30 -07008894/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308895 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008896 * This function is used to initialize the key information
8897 */
8898#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308899static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008900 struct net_device *ndev,
8901 u8 key_index, bool pairwise,
8902 const u8 *mac_addr,
8903 struct key_params *params
8904 )
8905#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308906static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008907 struct net_device *ndev,
8908 u8 key_index, const u8 *mac_addr,
8909 struct key_params *params
8910 )
8911#endif
8912{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008913 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07008914 tCsrRoamSetKey setKey;
8915 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308916 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008917 v_U32_t roamId= 0xFF;
8918 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008919 hdd_hostapd_state_t *pHostapdState;
8920 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008921 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308922 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008923
8924 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308925
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308926 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8927 TRACE_CODE_HDD_CFG80211_ADD_KEY,
8928 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308929 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8930 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308931 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008932 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308933 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008934 }
8935
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308936 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8937 __func__, hdd_device_modetoString(pAdapter->device_mode),
8938 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008939
8940 if (CSR_MAX_NUM_KEY <= key_index)
8941 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008942 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008943 key_index);
8944
8945 return -EINVAL;
8946 }
8947
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008948 if (CSR_MAX_KEY_LEN < params->key_len)
8949 {
8950 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
8951 params->key_len);
8952
8953 return -EINVAL;
8954 }
8955
8956 hddLog(VOS_TRACE_LEVEL_INFO,
8957 "%s: called with key index = %d & key length %d",
8958 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07008959
8960 /*extract key idx, key len and key*/
8961 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8962 setKey.keyId = key_index;
8963 setKey.keyLength = params->key_len;
8964 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
8965
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008966 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07008967 {
8968 case WLAN_CIPHER_SUITE_WEP40:
8969 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
8970 break;
8971
8972 case WLAN_CIPHER_SUITE_WEP104:
8973 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
8974 break;
8975
8976 case WLAN_CIPHER_SUITE_TKIP:
8977 {
8978 u8 *pKey = &setKey.Key[0];
8979 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
8980
8981 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
8982
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008983 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07008984
8985 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008986 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008987 |--------------|----------|----------|
8988 <---16bytes---><--8bytes--><--8bytes-->
8989
8990 */
8991 /*Sme expects the 32 bytes key to be in the below order
8992
8993 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008994 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008995 |--------------|----------|----------|
8996 <---16bytes---><--8bytes--><--8bytes-->
8997 */
8998 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008999 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07009000
9001 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009002 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009003
9004 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009005 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009006
9007
9008 break;
9009 }
9010
9011 case WLAN_CIPHER_SUITE_CCMP:
9012 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
9013 break;
9014
9015#ifdef FEATURE_WLAN_WAPI
9016 case WLAN_CIPHER_SUITE_SMS4:
9017 {
9018 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9019 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
9020 params->key, params->key_len);
9021 return 0;
9022 }
9023#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009024
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009025#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009026 case WLAN_CIPHER_SUITE_KRK:
9027 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
9028 break;
9029#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009030
9031#ifdef WLAN_FEATURE_11W
9032 case WLAN_CIPHER_SUITE_AES_CMAC:
9033 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07009034 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07009035#endif
9036
Jeff Johnson295189b2012-06-20 16:38:30 -07009037 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009038 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07009039 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309040 status = -EOPNOTSUPP;
9041 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009042 }
9043
9044 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
9045 __func__, setKey.encType);
9046
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009047 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07009048#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9049 (!pairwise)
9050#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009051 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07009052#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009053 )
9054 {
9055 /* set group key*/
9056 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9057 "%s- %d: setting Broadcast key",
9058 __func__, __LINE__);
9059 setKey.keyDirection = eSIR_RX_ONLY;
9060 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9061 }
9062 else
9063 {
9064 /* set pairwise key*/
9065 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9066 "%s- %d: setting pairwise key",
9067 __func__, __LINE__);
9068 setKey.keyDirection = eSIR_TX_RX;
9069 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9070 }
9071 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
9072 {
9073 setKey.keyDirection = eSIR_TX_RX;
9074 /*Set the group key*/
9075 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9076 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009077
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009078 if ( 0 != status )
9079 {
9080 hddLog(VOS_TRACE_LEVEL_ERROR,
9081 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309082 status = -EINVAL;
9083 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009084 }
9085 /*Save the keys here and call sme_RoamSetKey for setting
9086 the PTK after peer joins the IBSS network*/
9087 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
9088 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309089 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009090 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05309091 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
9092 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
9093 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009094 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009095 if( pHostapdState->bssState == BSS_START )
9096 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009097 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9098 vos_status = wlan_hdd_check_ula_done(pAdapter);
9099
9100 if ( vos_status != VOS_STATUS_SUCCESS )
9101 {
9102 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9103 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9104 __LINE__, vos_status );
9105
9106 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9107
9108 status = -EINVAL;
9109 goto end;
9110 }
9111
Jeff Johnson295189b2012-06-20 16:38:30 -07009112 status = WLANSAP_SetKeySta( pVosContext, &setKey);
9113
9114 if ( status != eHAL_STATUS_SUCCESS )
9115 {
9116 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9117 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9118 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309119 status = -EINVAL;
9120 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009121 }
9122 }
9123
9124 /* Saving WEP keys */
9125 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
9126 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
9127 {
9128 //Save the wep key in ap context. Issue setkey after the BSS is started.
9129 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9130 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
9131 }
9132 else
9133 {
9134 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009135 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009136 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
9137 }
9138 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009139 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9140 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009141 {
9142 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9143 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9144
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309145#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9146 if (!pairwise)
9147#else
9148 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9149#endif
9150 {
9151 /* set group key*/
9152 if (pHddStaCtx->roam_info.deferKeyComplete)
9153 {
9154 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9155 "%s- %d: Perform Set key Complete",
9156 __func__, __LINE__);
9157 hdd_PerformRoamSetKeyComplete(pAdapter);
9158 }
9159 }
9160
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
9162
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08009163 pWextState->roamProfile.Keys.defaultIndex = key_index;
9164
9165
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009166 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009167 params->key, params->key_len);
9168
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309169
Jeff Johnson295189b2012-06-20 16:38:30 -07009170 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9171
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309172 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009173 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309174 __func__, setKey.peerMac[0], setKey.peerMac[1],
9175 setKey.peerMac[2], setKey.peerMac[3],
9176 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009177 setKey.keyDirection);
9178
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009179 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +05309180
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009181 if ( vos_status != VOS_STATUS_SUCCESS )
9182 {
9183 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009184 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9185 __LINE__, vos_status );
9186
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009187 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009188
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009189 status = -EINVAL;
9190 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009191
9192 }
9193
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009194#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309195 /* The supplicant may attempt to set the PTK once pre-authentication
9196 is done. Save the key in the UMAC and include it in the ADD BSS
9197 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009198 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309199 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009200 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309201 hddLog(VOS_TRACE_LEVEL_INFO_MED,
9202 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309203 status = 0;
9204 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309205 }
9206 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
9207 {
9208 hddLog(VOS_TRACE_LEVEL_ERROR,
9209 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309210 status = -EINVAL;
9211 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009212 }
9213#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07009214
9215 /* issue set key request to SME*/
9216 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9217 pAdapter->sessionId, &setKey, &roamId );
9218
9219 if ( 0 != status )
9220 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309221 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009222 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
9223 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309224 status = -EINVAL;
9225 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009226 }
9227
9228
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309229 /* in case of IBSS as there was no information available about WEP keys during
9230 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07009231 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309232 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
9233 !( ( IW_AUTH_KEY_MGMT_802_1X
9234 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07009235 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
9236 )
9237 &&
9238 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
9239 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
9240 )
9241 )
9242 {
9243 setKey.keyDirection = eSIR_RX_ONLY;
9244 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9245
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309246 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009247 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309248 __func__, setKey.peerMac[0], setKey.peerMac[1],
9249 setKey.peerMac[2], setKey.peerMac[3],
9250 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009251 setKey.keyDirection);
9252
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309253 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009254 pAdapter->sessionId, &setKey, &roamId );
9255
9256 if ( 0 != status )
9257 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309258 hddLog(VOS_TRACE_LEVEL_ERROR,
9259 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009260 __func__, status);
9261 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309262 status = -EINVAL;
9263 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009264 }
9265 }
9266 }
9267
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309268end:
9269 /* Need to clear any trace of key value in the memory.
9270 * Thus zero out the memory even though it is local
9271 * variable.
9272 */
9273 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309274 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309275 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009276}
9277
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309278#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9279static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9280 struct net_device *ndev,
9281 u8 key_index, bool pairwise,
9282 const u8 *mac_addr,
9283 struct key_params *params
9284 )
9285#else
9286static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9287 struct net_device *ndev,
9288 u8 key_index, const u8 *mac_addr,
9289 struct key_params *params
9290 )
9291#endif
9292{
9293 int ret;
9294 vos_ssr_protect(__func__);
9295#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9296 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
9297 mac_addr, params);
9298#else
9299 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
9300 params);
9301#endif
9302 vos_ssr_unprotect(__func__);
9303
9304 return ret;
9305}
9306
Jeff Johnson295189b2012-06-20 16:38:30 -07009307/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309308 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009309 * This function is used to get the key information
9310 */
9311#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309312static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309313 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009314 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309315 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009316 const u8 *mac_addr, void *cookie,
9317 void (*callback)(void *cookie, struct key_params*)
9318 )
9319#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309320static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309321 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009322 struct net_device *ndev,
9323 u8 key_index, const u8 *mac_addr, void *cookie,
9324 void (*callback)(void *cookie, struct key_params*)
9325 )
9326#endif
9327{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309328 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309329 hdd_wext_state_t *pWextState = NULL;
9330 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009331 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309332 hdd_context_t *pHddCtx;
9333 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009334
9335 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309336
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309337 if (NULL == pAdapter)
9338 {
9339 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9340 "%s: HDD adapter is Null", __func__);
9341 return -ENODEV;
9342 }
9343
9344 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9345 ret = wlan_hdd_validate_context(pHddCtx);
9346 if (0 != ret)
9347 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309348 return ret;
9349 }
9350
9351 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9352 pRoamProfile = &(pWextState->roamProfile);
9353
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309354 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9355 __func__, hdd_device_modetoString(pAdapter->device_mode),
9356 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309357
Jeff Johnson295189b2012-06-20 16:38:30 -07009358 memset(&params, 0, sizeof(params));
9359
9360 if (CSR_MAX_NUM_KEY <= key_index)
9361 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309362 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07009363 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309364 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009365
9366 switch(pRoamProfile->EncryptionType.encryptionType[0])
9367 {
9368 case eCSR_ENCRYPT_TYPE_NONE:
9369 params.cipher = IW_AUTH_CIPHER_NONE;
9370 break;
9371
9372 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
9373 case eCSR_ENCRYPT_TYPE_WEP40:
9374 params.cipher = WLAN_CIPHER_SUITE_WEP40;
9375 break;
9376
9377 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
9378 case eCSR_ENCRYPT_TYPE_WEP104:
9379 params.cipher = WLAN_CIPHER_SUITE_WEP104;
9380 break;
9381
9382 case eCSR_ENCRYPT_TYPE_TKIP:
9383 params.cipher = WLAN_CIPHER_SUITE_TKIP;
9384 break;
9385
9386 case eCSR_ENCRYPT_TYPE_AES:
9387 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
9388 break;
9389
9390 default:
9391 params.cipher = IW_AUTH_CIPHER_NONE;
9392 break;
9393 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309394
c_hpothuaaf19692014-05-17 17:01:48 +05309395 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9396 TRACE_CODE_HDD_CFG80211_GET_KEY,
9397 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309398
Jeff Johnson295189b2012-06-20 16:38:30 -07009399 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
9400 params.seq_len = 0;
9401 params.seq = NULL;
9402 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
9403 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309404 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009405 return 0;
9406}
9407
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309408#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9409static int wlan_hdd_cfg80211_get_key(
9410 struct wiphy *wiphy,
9411 struct net_device *ndev,
9412 u8 key_index, bool pairwise,
9413 const u8 *mac_addr, void *cookie,
9414 void (*callback)(void *cookie, struct key_params*)
9415 )
9416#else
9417static int wlan_hdd_cfg80211_get_key(
9418 struct wiphy *wiphy,
9419 struct net_device *ndev,
9420 u8 key_index, const u8 *mac_addr, void *cookie,
9421 void (*callback)(void *cookie, struct key_params*)
9422 )
9423#endif
9424{
9425 int ret;
9426
9427 vos_ssr_protect(__func__);
9428#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9429 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
9430 mac_addr, cookie, callback);
9431#else
9432 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
9433 callback);
9434#endif
9435 vos_ssr_unprotect(__func__);
9436
9437 return ret;
9438}
9439
Jeff Johnson295189b2012-06-20 16:38:30 -07009440/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309441 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009442 * This function is used to delete the key information
9443 */
9444#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309445static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009446 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309447 u8 key_index,
9448 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009449 const u8 *mac_addr
9450 )
9451#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309452static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009453 struct net_device *ndev,
9454 u8 key_index,
9455 const u8 *mac_addr
9456 )
9457#endif
9458{
9459 int status = 0;
9460
9461 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309462 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009463 //it is observed that this is invalidating peer
9464 //key index whenever re-key is done. This is affecting data link.
9465 //It should be ok to ignore del_key.
9466#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309467 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
9468 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009469 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
9470 tCsrRoamSetKey setKey;
9471 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309472
Jeff Johnson295189b2012-06-20 16:38:30 -07009473 ENTER();
9474
9475 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
9476 __func__,pAdapter->device_mode);
9477
9478 if (CSR_MAX_NUM_KEY <= key_index)
9479 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309480 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009481 key_index);
9482
9483 return -EINVAL;
9484 }
9485
9486 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9487 setKey.keyId = key_index;
9488
9489 if (mac_addr)
9490 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9491 else
9492 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
9493
9494 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
9495
9496 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009497 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309498 )
9499 {
9500
9501 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07009502 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9503 if( pHostapdState->bssState == BSS_START)
9504 {
9505 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309506
Jeff Johnson295189b2012-06-20 16:38:30 -07009507 if ( status != eHAL_STATUS_SUCCESS )
9508 {
9509 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9510 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9511 __LINE__, status );
9512 }
9513 }
9514 }
9515 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309516 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07009517 )
9518 {
9519 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9520
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309521 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9522
9523 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009524 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309525 __func__, setKey.peerMac[0], setKey.peerMac[1],
9526 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07009527 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309528 if(pAdapter->sessionCtx.station.conn_info.connState ==
9529 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07009530 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309531 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009532 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309533
Jeff Johnson295189b2012-06-20 16:38:30 -07009534 if ( 0 != status )
9535 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309536 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009537 "%s: sme_RoamSetKey failure, returned %d",
9538 __func__, status);
9539 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9540 return -EINVAL;
9541 }
9542 }
9543 }
9544#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07009545 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009546 return status;
9547}
9548
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309549#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9550static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9551 struct net_device *ndev,
9552 u8 key_index,
9553 bool pairwise,
9554 const u8 *mac_addr
9555 )
9556#else
9557static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9558 struct net_device *ndev,
9559 u8 key_index,
9560 const u8 *mac_addr
9561 )
9562#endif
9563{
9564 int ret;
9565
9566 vos_ssr_protect(__func__);
9567#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9568 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
9569 mac_addr);
9570#else
9571 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
9572#endif
9573 vos_ssr_unprotect(__func__);
9574
9575 return ret;
9576}
9577
Jeff Johnson295189b2012-06-20 16:38:30 -07009578/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309579 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009580 * This function is used to set the default tx key index
9581 */
9582#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309583static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009584 struct net_device *ndev,
9585 u8 key_index,
9586 bool unicast, bool multicast)
9587#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309588static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009589 struct net_device *ndev,
9590 u8 key_index)
9591#endif
9592{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309593 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309594 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05309595 hdd_wext_state_t *pWextState;
9596 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309597 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009598
9599 ENTER();
9600
Gopichand Nakkala29149562013-05-10 21:43:41 +05309601 if ((NULL == pAdapter))
9602 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05309604 "invalid adapter");
9605 return -EINVAL;
9606 }
9607
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309608 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9609 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
9610 pAdapter->sessionId, key_index));
9611
Gopichand Nakkala29149562013-05-10 21:43:41 +05309612 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9613 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9614
9615 if ((NULL == pWextState) || (NULL == pHddStaCtx))
9616 {
9617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9618 "invalid Wext state or HDD context");
9619 return -EINVAL;
9620 }
9621
Arif Hussain6d2a3322013-11-17 19:50:10 -08009622 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009623 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309624
Jeff Johnson295189b2012-06-20 16:38:30 -07009625 if (CSR_MAX_NUM_KEY <= key_index)
9626 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309627 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009628 key_index);
9629
9630 return -EINVAL;
9631 }
9632
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309633 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9634 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309635 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009636 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309637 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009638 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309639
Jeff Johnson295189b2012-06-20 16:38:30 -07009640 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07009641 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309642 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009643 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05309644 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08009645 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309646 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08009647 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309649 {
9650 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07009651 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309652
Jeff Johnson295189b2012-06-20 16:38:30 -07009653 tCsrRoamSetKey setKey;
9654 v_U32_t roamId= 0xFF;
9655 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309656
9657 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009658 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309659
Jeff Johnson295189b2012-06-20 16:38:30 -07009660 Keys->defaultIndex = (u8)key_index;
9661 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9662 setKey.keyId = key_index;
9663 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309664
9665 vos_mem_copy(&setKey.Key[0],
9666 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009667 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309668
Gopichand Nakkala29149562013-05-10 21:43:41 +05309669 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309670
9671 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07009672 &pHddStaCtx->conn_info.bssId[0],
9673 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309674
Gopichand Nakkala29149562013-05-10 21:43:41 +05309675 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
9676 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
9677 eCSR_ENCRYPT_TYPE_WEP104)
9678 {
9679 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
9680 even though ap is configured for WEP-40 encryption. In this canse the key length
9681 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
9682 type(104) and switching encryption type to 40*/
9683 pWextState->roamProfile.EncryptionType.encryptionType[0] =
9684 eCSR_ENCRYPT_TYPE_WEP40;
9685 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
9686 eCSR_ENCRYPT_TYPE_WEP40;
9687 }
9688
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309689 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07009690 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309691
Jeff Johnson295189b2012-06-20 16:38:30 -07009692 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309693 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009694 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309695
Jeff Johnson295189b2012-06-20 16:38:30 -07009696 if ( 0 != status )
9697 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309698 hddLog(VOS_TRACE_LEVEL_ERROR,
9699 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009700 status);
9701 return -EINVAL;
9702 }
9703 }
9704 }
9705
9706 /* In SoftAp mode setting key direction for default mode */
9707 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
9708 {
9709 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
9710 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
9711 (eCSR_ENCRYPT_TYPE_AES !=
9712 pWextState->roamProfile.EncryptionType.encryptionType[0])
9713 )
9714 {
9715 /* Saving key direction for default key index to TX default */
9716 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9717 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
9718 }
9719 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309720 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009721 return status;
9722}
9723
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309724#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9725static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9726 struct net_device *ndev,
9727 u8 key_index,
9728 bool unicast, bool multicast)
9729#else
9730static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9731 struct net_device *ndev,
9732 u8 key_index)
9733#endif
9734{
9735 int ret;
9736 vos_ssr_protect(__func__);
9737#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9738 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
9739 multicast);
9740#else
9741 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
9742#endif
9743 vos_ssr_unprotect(__func__);
9744
9745 return ret;
9746}
9747
Jeff Johnson295189b2012-06-20 16:38:30 -07009748/*
9749 * FUNCTION: wlan_hdd_cfg80211_inform_bss
9750 * This function is used to inform the BSS details to nl80211 interface.
9751 */
9752static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
9753 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
9754{
9755 struct net_device *dev = pAdapter->dev;
9756 struct wireless_dev *wdev = dev->ieee80211_ptr;
9757 struct wiphy *wiphy = wdev->wiphy;
9758 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
9759 int chan_no;
9760 int ie_length;
9761 const char *ie;
9762 unsigned int freq;
9763 struct ieee80211_channel *chan;
9764 int rssi = 0;
9765 struct cfg80211_bss *bss = NULL;
9766
Jeff Johnson295189b2012-06-20 16:38:30 -07009767 if( NULL == pBssDesc )
9768 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009769 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009770 return bss;
9771 }
9772
9773 chan_no = pBssDesc->channelId;
9774 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
9775 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
9776
9777 if( NULL == ie )
9778 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009779 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009780 return bss;
9781 }
9782
9783#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
9784 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
9785 {
9786 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9787 }
9788 else
9789 {
9790 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9791 }
9792#else
9793 freq = ieee80211_channel_to_frequency(chan_no);
9794#endif
9795
9796 chan = __ieee80211_get_channel(wiphy, freq);
9797
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05309798 if (!chan) {
9799 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
9800 return NULL;
9801 }
9802
Abhishek Singhaee43942014-06-16 18:55:47 +05309803 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07009804
Abhishek Singhaee43942014-06-16 18:55:47 +05309805 return cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309806 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07009807 pBssDesc->capabilityInfo,
9808 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05309809 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07009810}
9811
9812
9813
9814/*
9815 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
9816 * This function is used to inform the BSS details to nl80211 interface.
9817 */
9818struct cfg80211_bss*
9819wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
9820 tSirBssDescription *bss_desc
9821 )
9822{
9823 /*
9824 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
9825 already exists in bss data base of cfg80211 for that particular BSS ID.
9826 Using cfg80211_inform_bss_frame to update the bss entry instead of
9827 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
9828 now there is no possibility to get the mgmt(probe response) frame from PE,
9829 converting bss_desc to ieee80211_mgmt(probe response) and passing to
9830 cfg80211_inform_bss_frame.
9831 */
9832 struct net_device *dev = pAdapter->dev;
9833 struct wireless_dev *wdev = dev->ieee80211_ptr;
9834 struct wiphy *wiphy = wdev->wiphy;
9835 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009836#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9837 qcom_ie_age *qie_age = NULL;
9838 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
9839#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009840 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009841#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009842 const char *ie =
9843 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
9844 unsigned int freq;
9845 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309846 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009847 struct cfg80211_bss *bss_status = NULL;
9848 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
9849 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07009850 hdd_context_t *pHddCtx;
9851 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07009852#ifdef WLAN_OPEN_SOURCE
9853 struct timespec ts;
9854#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009855
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309856
Wilson Yangf80a0542013-10-07 13:02:37 -07009857 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9858 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -07009859 if (0 != status)
9860 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009861 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009862 }
9863
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309864 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07009865 if (!mgmt)
9866 {
9867 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9868 "%s: memory allocation failed ", __func__);
9869 return NULL;
9870 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009871
Jeff Johnson295189b2012-06-20 16:38:30 -07009872 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07009873
9874#ifdef WLAN_OPEN_SOURCE
9875 /* Android does not want the timestamp from the frame.
9876 Instead it wants a monotonic increasing value */
9877 get_monotonic_boottime(&ts);
9878 mgmt->u.probe_resp.timestamp =
9879 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
9880#else
9881 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
9883 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07009884
9885#endif
9886
Jeff Johnson295189b2012-06-20 16:38:30 -07009887 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
9888 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009889
9890#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9891 /* GPS Requirement: need age ie per entry. Using vendor specific. */
9892 /* Assuming this is the last IE, copy at the end */
9893 ie_length -=sizeof(qcom_ie_age);
9894 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
9895 qie_age->element_id = QCOM_VENDOR_IE_ID;
9896 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
9897 qie_age->oui_1 = QCOM_OUI1;
9898 qie_age->oui_2 = QCOM_OUI2;
9899 qie_age->oui_3 = QCOM_OUI3;
9900 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
9901 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
9902#endif
9903
Jeff Johnson295189b2012-06-20 16:38:30 -07009904 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05309905 if (bss_desc->fProbeRsp)
9906 {
9907 mgmt->frame_control |=
9908 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
9909 }
9910 else
9911 {
9912 mgmt->frame_control |=
9913 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
9914 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009915
9916#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309917 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
9919 {
9920 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9921 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309922 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009923 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
9924
9925 {
9926 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9927 }
9928 else
9929 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309930 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
9931 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07009932 kfree(mgmt);
9933 return NULL;
9934 }
9935#else
9936 freq = ieee80211_channel_to_frequency(chan_no);
9937#endif
9938 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009939 /*when the band is changed on the fly using the GUI, three things are done
9940 * 1. scan abort 2.flush scan results from cache 3.update the band with the new band user specified(refer to the hdd_setBand_helper function)
9941 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
9942 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
9943 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
9944 * and discards the channels correponding to previous band and calls back with zero bss results.
9945 * but if the time between band update and scan done callback is very small then band change will not reflect in SME and SME reports to HDD
9946 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
9947 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
9948 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
9949 * So drop the bss and continue to next bss.
9950 */
9951 if(chan == NULL)
9952 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309953 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07009954 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009955 return NULL;
9956 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +05309957 /*To keep the rssi icon of the connected AP in the scan window
9958 *and the rssi icon of the wireless networks in sync
9959 * */
9960 if (( eConnectionState_Associated ==
9961 pAdapter->sessionCtx.station.conn_info.connState ) &&
9962 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
9963 pAdapter->sessionCtx.station.conn_info.bssId,
9964 WNI_CFG_BSSID_LEN)) &&
9965 (pHddCtx->hdd_wlan_suspended == FALSE))
9966 {
9967 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
9968 rssi = (pAdapter->rssi * 100);
9969 }
9970 else
9971 {
9972 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
9973 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009974
Nirav Shah20ac06f2013-12-12 18:14:06 +05309975 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +05309976 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
9977 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +05309978
Jeff Johnson295189b2012-06-20 16:38:30 -07009979 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
9980 frame_len, rssi, GFP_KERNEL);
9981 kfree(mgmt);
9982 return bss_status;
9983}
9984
9985/*
9986 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
9987 * This function is used to update the BSS data base of CFG8011
9988 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309989struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07009990 tCsrRoamInfo *pRoamInfo
9991 )
9992{
9993 tCsrRoamConnectedProfile roamProfile;
9994 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9995 struct cfg80211_bss *bss = NULL;
9996
9997 ENTER();
9998
9999 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
10000 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
10001
10002 if (NULL != roamProfile.pBssDesc)
10003 {
Girish Gowlif4b68022014-08-28 23:18:57 +053010004 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10005 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010006
10007 if (NULL == bss)
10008 {
10009 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
10010 __func__);
10011 }
10012
10013 sme_RoamFreeConnectProfile(hHal, &roamProfile);
10014 }
10015 else
10016 {
10017 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
10018 __func__);
10019 }
10020 return bss;
10021}
10022
10023/*
10024 * FUNCTION: wlan_hdd_cfg80211_update_bss
10025 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010026static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
10027 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070010028 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010029{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010030 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010031 tCsrScanResultInfo *pScanResult;
10032 eHalStatus status = 0;
10033 tScanResultHandle pResult;
10034 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070010035 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010036 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070010037 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010038
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010039 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10040 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
10041 NO_SESSION, pAdapter->sessionId));
10042
Wilson Yangf80a0542013-10-07 13:02:37 -070010043 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10044
10045 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -070010046 {
Wilson Yangf80a0542013-10-07 13:02:37 -070010047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10048 "%s:LOGP in Progress. Ignore!!!",__func__);
10049 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010050 }
10051
Wilson Yangf80a0542013-10-07 13:02:37 -070010052
10053 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +053010054 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -070010055 {
10056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10057 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
10058 return VOS_STATUS_E_PERM;
10059 }
10060
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010061 if (pAdapter->request != NULL)
10062 {
10063 if ((pAdapter->request->n_ssids == 1)
10064 && (pAdapter->request->ssids != NULL)
10065 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
10066 is_p2p_scan = true;
10067 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010068 /*
10069 * start getting scan results and populate cgf80211 BSS database
10070 */
10071 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
10072
10073 /* no scan results */
10074 if (NULL == pResult)
10075 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010076 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
10077 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053010078 wlan_hdd_get_frame_logs(pAdapter,
10079 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070010080 return status;
10081 }
10082
10083 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
10084
10085 while (pScanResult)
10086 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010087 /*
10088 * cfg80211_inform_bss() is not updating ie field of bss entry, if
10089 * entry already exists in bss data base of cfg80211 for that
10090 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
10091 * bss entry instead of cfg80211_inform_bss, But this call expects
10092 * mgmt packet as input. As of now there is no possibility to get
10093 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070010094 * ieee80211_mgmt(probe response) and passing to c
10095 * fg80211_inform_bss_frame.
10096 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010097 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
10098 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
10099 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010100 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10101 continue; //Skip the non p2p bss entries
10102 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010103 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10104 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010105
Jeff Johnson295189b2012-06-20 16:38:30 -070010106
10107 if (NULL == bss_status)
10108 {
10109 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010110 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010111 }
10112 else
10113 {
Yue Maf49ba872013-08-19 12:04:25 -070010114 cfg80211_put_bss(
10115#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10116 wiphy,
10117#endif
10118 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010119 }
10120
10121 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10122 }
10123
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010124 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010125 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010126 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010127}
10128
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010129void
10130hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
10131{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010132 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080010133 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010134} /****** end hddPrintMacAddr() ******/
10135
10136void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010137hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010138{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010139 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010140 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010141 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
10142 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
10143 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010144} /****** end hddPrintPmkId() ******/
10145
10146//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
10147//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
10148
10149//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
10150//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
10151
10152#define dump_bssid(bssid) \
10153 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010154 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
10155 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010156 }
10157
10158#define dump_pmkid(pMac, pmkid) \
10159 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010160 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
10161 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010162 }
10163
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070010164#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010165/*
10166 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
10167 * This function is used to notify the supplicant of a new PMKSA candidate.
10168 */
10169int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010170 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010171 int index, bool preauth )
10172{
Jeff Johnsone7245742012-09-05 17:12:55 -070010173#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010174 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010175 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010176
10177 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070010178 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010179
10180 if( NULL == pRoamInfo )
10181 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010182 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010183 return -EINVAL;
10184 }
10185
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010186 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
10187 {
10188 dump_bssid(pRoamInfo->bssid);
10189 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010190 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010191 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010192#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010193 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010194}
10195#endif //FEATURE_WLAN_LFR
10196
Yue Maef608272013-04-08 23:09:17 -070010197#ifdef FEATURE_WLAN_LFR_METRICS
10198/*
10199 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
10200 * 802.11r/LFR metrics reporting function to report preauth initiation
10201 *
10202 */
10203#define MAX_LFR_METRICS_EVENT_LENGTH 100
10204VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
10205 tCsrRoamInfo *pRoamInfo)
10206{
10207 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10208 union iwreq_data wrqu;
10209
10210 ENTER();
10211
10212 if (NULL == pAdapter)
10213 {
10214 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10215 return VOS_STATUS_E_FAILURE;
10216 }
10217
10218 /* create the event */
10219 memset(&wrqu, 0, sizeof(wrqu));
10220 memset(metrics_notification, 0, sizeof(metrics_notification));
10221
10222 wrqu.data.pointer = metrics_notification;
10223 wrqu.data.length = scnprintf(metrics_notification,
10224 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
10225 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10226
10227 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10228
10229 EXIT();
10230
10231 return VOS_STATUS_SUCCESS;
10232}
10233
10234/*
10235 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
10236 * 802.11r/LFR metrics reporting function to report preauth completion
10237 * or failure
10238 */
10239VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
10240 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
10241{
10242 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10243 union iwreq_data wrqu;
10244
10245 ENTER();
10246
10247 if (NULL == pAdapter)
10248 {
10249 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10250 return VOS_STATUS_E_FAILURE;
10251 }
10252
10253 /* create the event */
10254 memset(&wrqu, 0, sizeof(wrqu));
10255 memset(metrics_notification, 0, sizeof(metrics_notification));
10256
10257 scnprintf(metrics_notification, sizeof(metrics_notification),
10258 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
10259 MAC_ADDR_ARRAY(pRoamInfo->bssid));
10260
10261 if (1 == preauth_status)
10262 strncat(metrics_notification, " TRUE", 5);
10263 else
10264 strncat(metrics_notification, " FALSE", 6);
10265
10266 wrqu.data.pointer = metrics_notification;
10267 wrqu.data.length = strlen(metrics_notification);
10268
10269 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10270
10271 EXIT();
10272
10273 return VOS_STATUS_SUCCESS;
10274}
10275
10276/*
10277 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
10278 * 802.11r/LFR metrics reporting function to report handover initiation
10279 *
10280 */
10281VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
10282 tCsrRoamInfo *pRoamInfo)
10283{
10284 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10285 union iwreq_data wrqu;
10286
10287 ENTER();
10288
10289 if (NULL == pAdapter)
10290 {
10291 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10292 return VOS_STATUS_E_FAILURE;
10293 }
10294
10295 /* create the event */
10296 memset(&wrqu, 0, sizeof(wrqu));
10297 memset(metrics_notification, 0, sizeof(metrics_notification));
10298
10299 wrqu.data.pointer = metrics_notification;
10300 wrqu.data.length = scnprintf(metrics_notification,
10301 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
10302 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10303
10304 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10305
10306 EXIT();
10307
10308 return VOS_STATUS_SUCCESS;
10309}
10310#endif
10311
Jeff Johnson295189b2012-06-20 16:38:30 -070010312/*
10313 * FUNCTION: hdd_cfg80211_scan_done_callback
10314 * scanning callback function, called after finishing scan
10315 *
10316 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010317static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070010318 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
10319{
10320 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010321 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070010322 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010323 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010324 struct cfg80211_scan_request *req = NULL;
10325 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010326 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010327 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010328 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010329 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010330
10331 ENTER();
10332
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010333 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053010334 if (NULL == pHddCtx) {
10335 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010336 goto allow_suspend;
10337 }
10338
10339 pScanInfo = &pHddCtx->scan_info;
10340
Jeff Johnson295189b2012-06-20 16:38:30 -070010341 hddLog(VOS_TRACE_LEVEL_INFO,
10342 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080010343 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010344 __func__, halHandle, pContext, (int) scanId, (int) status);
10345
Kiet Lamac06e2c2013-10-23 16:25:07 +053010346 pScanInfo->mScanPendingCounter = 0;
10347
Jeff Johnson295189b2012-06-20 16:38:30 -070010348 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010349 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070010350 &pScanInfo->scan_req_completion_event,
10351 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010352 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070010353 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010354 hddLog(VOS_TRACE_LEVEL_ERROR,
10355 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070010356 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010357 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010358 }
10359
Yue Maef608272013-04-08 23:09:17 -070010360 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010361 {
10362 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010363 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010364 }
10365
10366 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010367 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070010368 {
10369 hddLog(VOS_TRACE_LEVEL_INFO,
10370 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010371 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070010372 (int) scanId);
10373 }
10374
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010375 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010376 pAdapter);
10377
10378 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010379 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010380
10381
10382 /* If any client wait scan result through WEXT
10383 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010384 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070010385 {
10386 /* The other scan request waiting for current scan finish
10387 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010388 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010389 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010390 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070010391 }
10392 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010393 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010394 {
10395 struct net_device *dev = pAdapter->dev;
10396 union iwreq_data wrqu;
10397 int we_event;
10398 char *msg;
10399
10400 memset(&wrqu, '\0', sizeof(wrqu));
10401 we_event = SIOCGIWSCAN;
10402 msg = NULL;
10403 wireless_send_event(dev, we_event, &wrqu, msg);
10404 }
10405 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010406 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010407
10408 /* Get the Scan Req */
10409 req = pAdapter->request;
10410
10411 if (!req)
10412 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010413 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010414 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010415 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010416 }
10417
Jeff Johnson295189b2012-06-20 16:38:30 -070010418 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070010419 /* Scan is no longer pending */
10420 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010421
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010422 /* last_scan_timestamp is used to decide if new scan
10423 * is needed or not on station interface. If last station
10424 * scan time and new station scan time is less then
10425 * last_scan_timestamp ; driver will return cached scan.
10426 */
10427 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
10428 {
10429 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
10430
10431 if ( req->n_channels )
10432 {
10433 for (i = 0; i < req->n_channels ; i++ )
10434 {
10435 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
10436 }
10437 /* store no of channel scanned */
10438 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
10439 }
10440
10441 }
10442
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070010443 /*
10444 * cfg80211_scan_done informing NL80211 about completion
10445 * of scanning
10446 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010447 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
10448 {
10449 aborted = true;
10450 }
10451 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080010452 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070010453
Siddharth Bhal76972212014-10-15 16:22:51 +053010454 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
10455 /* Generate new random mac addr for next scan */
10456 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
10457 hdd_processSpoofMacAddrRequest(pHddCtx);
10458 }
10459
Jeff Johnsone7245742012-09-05 17:12:55 -070010460allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010461 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010462 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070010463
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010464 /* Acquire wakelock to handle the case where APP's tries to suspend
10465 * immediatly after the driver gets connect request(i.e after scan)
10466 * from supplicant, this result in app's is suspending and not able
10467 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010468 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010469
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010470#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010471 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010472#endif
10473
Jeff Johnson295189b2012-06-20 16:38:30 -070010474 EXIT();
10475 return 0;
10476}
10477
10478/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053010479 * FUNCTION: hdd_isConnectionInProgress
10480 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010481 *
10482 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010483v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010484{
10485 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10486 hdd_station_ctx_t *pHddStaCtx = NULL;
10487 hdd_adapter_t *pAdapter = NULL;
10488 VOS_STATUS status = 0;
10489 v_U8_t staId = 0;
10490 v_U8_t *staMac = NULL;
10491
c_hpothu9b781ba2013-12-30 20:57:45 +053010492 if (TRUE == pHddCtx->btCoexModeSet)
10493 {
10494 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053010495 FL("BTCoex Mode operation in progress"));
10496 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053010497 }
10498
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010499 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10500
10501 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10502 {
10503 pAdapter = pAdapterNode->pAdapter;
10504
10505 if( pAdapter )
10506 {
10507 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010508 "%s: Adapter with device mode %s (%d) exists",
10509 __func__, hdd_device_modetoString(pAdapter->device_mode),
10510 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010511 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053010512 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10513 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
10514 (eConnectionState_Connecting ==
10515 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
10516 {
10517 hddLog(VOS_TRACE_LEVEL_ERROR,
10518 "%s: %p(%d) Connection is in progress", __func__,
10519 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10520 return VOS_TRUE;
10521 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010522 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053010523 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010524 {
10525 hddLog(VOS_TRACE_LEVEL_ERROR,
10526 "%s: %p(%d) Reassociation is in progress", __func__,
10527 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10528 return VOS_TRUE;
10529 }
10530 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010531 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10532 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010533 {
10534 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10535 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010536 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010537 {
10538 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
10539 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010540 "%s: client " MAC_ADDRESS_STR
10541 " is in the middle of WPS/EAPOL exchange.", __func__,
10542 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010543 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010544 }
10545 }
10546 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
10547 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
10548 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010549 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10550 ptSapContext pSapCtx = NULL;
10551 pSapCtx = VOS_GET_SAP_CB(pVosContext);
10552 if(pSapCtx == NULL){
10553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10554 FL("psapCtx is NULL"));
10555 return VOS_FALSE;
10556 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010557 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
10558 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010559 if ((pSapCtx->aStaInfo[staId].isUsed) &&
10560 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010561 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010562 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010563
10564 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010565 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
10566 "middle of WPS/EAPOL exchange.", __func__,
10567 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010568 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010569 }
10570 }
10571 }
10572 }
10573 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10574 pAdapterNode = pNext;
10575 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053010576 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010577}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010578
10579/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010580 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070010581 * this scan respond to scan trigger and update cfg80211 scan database
10582 * later, scan dump command can be used to recieve scan results
10583 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010584int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010585#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10586 struct net_device *dev,
10587#endif
10588 struct cfg80211_scan_request *request)
10589{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010590 hdd_adapter_t *pAdapter = NULL;
10591 hdd_context_t *pHddCtx = NULL;
10592 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010593 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010594 tCsrScanRequest scanRequest;
10595 tANI_U8 *channelList = NULL, i;
10596 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010597 int status;
10598 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010599 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010600 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053010601 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010602 bool is_p2p_scan = false;
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010603 v_S7_t rssi=0;
10604 hdd_station_ctx_t *pHddStaCtx=NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010605
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010606#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
10607 struct net_device *dev = NULL;
10608 if (NULL == request)
10609 {
10610 hddLog(VOS_TRACE_LEVEL_ERROR,
10611 "%s: scan req param null", __func__);
10612 return -EINVAL;
10613 }
10614 dev = request->wdev->netdev;
10615#endif
10616
10617 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
10618 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
10619 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10620
Jeff Johnson295189b2012-06-20 16:38:30 -070010621 ENTER();
10622
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010623 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10624 __func__, hdd_device_modetoString(pAdapter->device_mode),
10625 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010626
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010627 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010628 if (0 != status)
10629 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010630 return status;
10631 }
10632
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010633 if (NULL == pwextBuf)
10634 {
10635 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
10636 __func__);
10637 return -EIO;
10638 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010639 cfg_param = pHddCtx->cfg_ini;
10640 pScanInfo = &pHddCtx->scan_info;
10641
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010642 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10643 if ( (pHddStaCtx != NULL) && (TRUE == hdd_connIsConnected(pHddStaCtx)))
10644 {
10645 wlan_hdd_get_roam_rssi(pAdapter, &rssi);
10646 hddLog(VOS_TRACE_LEVEL_INFO, FL("rssi: %d"), rssi);
10647 }
10648
Jeff Johnson295189b2012-06-20 16:38:30 -070010649#ifdef WLAN_BTAMP_FEATURE
10650 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010651 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070010652 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010653 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010654 "%s: No scanning when AMP is on", __func__);
10655 return -EOPNOTSUPP;
10656 }
10657#endif
10658 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010659 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010660 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010661 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010662 "%s: Not scanning on device_mode = %s (%d)",
10663 __func__, hdd_device_modetoString(pAdapter->device_mode),
10664 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010665 return -EOPNOTSUPP;
10666 }
10667
10668 if (TRUE == pScanInfo->mScanPending)
10669 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010670 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
10671 {
10672 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
10673 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010674 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010675 }
10676
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010677 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070010678 //Channel and action frame is pending
10679 //Otherwise Cancel Remain On Channel and allow Scan
10680 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010681 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070010682 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010683 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010684 return -EBUSY;
10685 }
10686
Jeff Johnson295189b2012-06-20 16:38:30 -070010687 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
10688 {
10689 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080010690 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010691 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010692 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010693 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
10694 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010695 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010696 "%s: MAX TM Level Scan not allowed", __func__);
10697 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010698 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010699 }
10700 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
10701
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010702 /* Check if scan is allowed at this point of time.
10703 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010704 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010705 {
10706 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
10707 return -EBUSY;
10708 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010709
Jeff Johnson295189b2012-06-20 16:38:30 -070010710 vos_mem_zero( &scanRequest, sizeof(scanRequest));
10711
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010712 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
10713 * Becasue of this, driver is assuming that this is not wildcard scan and so
10714 * is not aging out the scan results.
10715 */
10716 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070010717 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010718 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010719 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010720
10721 if ((request->ssids) && (0 < request->n_ssids))
10722 {
10723 tCsrSSIDInfo *SsidInfo;
10724 int j;
10725 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
10726 /* Allocate num_ssid tCsrSSIDInfo structure */
10727 SsidInfo = scanRequest.SSIDs.SSIDList =
10728 ( tCsrSSIDInfo *)vos_mem_malloc(
10729 request->n_ssids*sizeof(tCsrSSIDInfo));
10730
10731 if(NULL == scanRequest.SSIDs.SSIDList)
10732 {
10733 hddLog(VOS_TRACE_LEVEL_ERROR,
10734 "%s: memory alloc failed SSIDInfo buffer", __func__);
10735 return -ENOMEM;
10736 }
10737
10738 /* copy all the ssid's and their length */
10739 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
10740 {
10741 /* get the ssid length */
10742 SsidInfo->SSID.length = request->ssids[j].ssid_len;
10743 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
10744 SsidInfo->SSID.length);
10745 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
10746 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
10747 j, SsidInfo->SSID.ssId);
10748 }
10749 /* set the scan type to active */
10750 scanRequest.scanType = eSIR_ACTIVE_SCAN;
10751 }
10752 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070010753 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010754 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10755 TRACE_CODE_HDD_CFG80211_SCAN,
10756 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070010757 /* set the scan type to active */
10758 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010759 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010760 else
10761 {
10762 /*Set the scan type to default type, in this case it is ACTIVE*/
10763 scanRequest.scanType = pScanInfo->scan_mode;
10764 }
10765 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
10766 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070010767
10768 /* set BSSType to default type */
10769 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
10770
10771 /*TODO: scan the requested channels only*/
10772
10773 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010774 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070010775 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010776 hddLog(VOS_TRACE_LEVEL_WARN,
10777 "No of Scan Channels exceeded limit: %d", request->n_channels);
10778 request->n_channels = MAX_CHANNEL;
10779 }
10780
10781 hddLog(VOS_TRACE_LEVEL_INFO,
10782 "No of Scan Channels: %d", request->n_channels);
10783
10784
10785 if( request->n_channels )
10786 {
10787 char chList [(request->n_channels*5)+1];
10788 int len;
10789 channelList = vos_mem_malloc( request->n_channels );
10790 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053010791 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010792 hddLog(VOS_TRACE_LEVEL_ERROR,
10793 "%s: memory alloc failed channelList", __func__);
10794 status = -ENOMEM;
10795 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053010796 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010797
10798 for( i = 0, len = 0; i < request->n_channels ; i++ )
10799 {
10800 channelList[i] = request->channels[i]->hw_value;
10801 len += snprintf(chList+len, 5, "%d ", channelList[i]);
10802 }
10803
Nirav Shah20ac06f2013-12-12 18:14:06 +053010804 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010805 "Channel-List: %s ", chList);
10806 }
c_hpothu53512302014-04-15 18:49:53 +053010807
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010808 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
10809 scanRequest.ChannelInfo.ChannelList = channelList;
10810
10811 /* set requestType to full scan */
10812 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
10813
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010814 /* if there is back to back scan happening in driver with in
10815 * nDeferScanTimeInterval interval driver should defer new scan request
10816 * and should provide last cached scan results instead of new channel list.
10817 * This rule is not applicable if scan is p2p scan.
10818 * This condition will work only in case when last request no of channels
10819 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053010820 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053010821 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010822 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010823
Sushant Kaushik86592172015-04-27 16:35:03 +053010824 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
10825 /* if wps ie is NULL , then only defer scan */
10826 if ( pWpsIe == NULL &&
10827 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053010828 {
10829 if ( pScanInfo->last_scan_timestamp !=0 &&
10830 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
10831 {
10832 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
10833 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
10834 vos_mem_compare(pScanInfo->last_scan_channelList,
10835 channelList, pScanInfo->last_scan_numChannels))
10836 {
10837 hddLog(VOS_TRACE_LEVEL_WARN,
10838 " New and old station scan time differ is less then %u",
10839 pHddCtx->cfg_ini->nDeferScanTimeInterval);
10840
10841 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010842 pAdapter);
10843
Agarwal Ashish57e84372014-12-05 18:26:53 +053010844 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010845 "Return old cached scan as all channels and no of channels are same");
10846
Agarwal Ashish57e84372014-12-05 18:26:53 +053010847 if (0 > ret)
10848 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010849
Agarwal Ashish57e84372014-12-05 18:26:53 +053010850 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010851
10852 status = eHAL_STATUS_SUCCESS;
10853 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053010854 }
10855 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010856 }
10857
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010858 /* Flush the scan results(only p2p beacons) for STA scan and P2P
10859 * search (Flush on both full scan and social scan but not on single
10860 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
10861 */
10862
10863 /* Supplicant does single channel scan after 8-way handshake
10864 * and in that case driver shoudnt flush scan results. If
10865 * driver flushes the scan results here and unfortunately if
10866 * the AP doesnt respond to our probe req then association
10867 * fails which is not desired
10868 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010869 if ((request->n_ssids == 1)
10870 && (request->ssids != NULL)
10871 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
10872 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010873
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010874 if( is_p2p_scan ||
10875 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010876 {
10877 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
10878 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
10879 pAdapter->sessionId );
10880 }
10881
10882 if( request->ie_len )
10883 {
10884 /* save this for future association (join requires this) */
10885 /*TODO: Array needs to be converted to dynamic allocation,
10886 * as multiple ie.s can be sent in cfg80211_scan_request structure
10887 * CR 597966
10888 */
10889 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
10890 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
10891 pScanInfo->scanAddIE.length = request->ie_len;
10892
10893 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
10894 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10895 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010896 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053010897 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070010898 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010899 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
10900 memcpy( pwextBuf->roamProfile.addIEScan,
10901 request->ie, request->ie_len);
10902 }
10903 else
10904 {
10905 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
10906 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070010907 }
10908
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010909 }
10910 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
10911 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
10912
10913 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
10914 request->ie_len);
10915 if (pP2pIe != NULL)
10916 {
10917#ifdef WLAN_FEATURE_P2P_DEBUG
10918 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
10919 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
10920 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053010921 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010922 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
10923 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10924 "Go nego completed to Connection is started");
10925 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10926 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053010927 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010928 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
10929 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010930 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010931 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
10932 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10933 "Disconnected state to Connection is started");
10934 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10935 "for 4way Handshake");
10936 }
10937#endif
10938
10939 /* no_cck will be set during p2p find to disable 11b rates */
10940 if(TRUE == request->no_cck)
10941 {
10942 hddLog(VOS_TRACE_LEVEL_INFO,
10943 "%s: This is a P2P Search", __func__);
10944 scanRequest.p2pSearch = 1;
10945
10946 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053010947 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010948 /* set requestType to P2P Discovery */
10949 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
10950 }
10951
10952 /*
10953 Skip Dfs Channel in case of P2P Search
10954 if it is set in ini file
10955 */
10956 if(cfg_param->skipDfsChnlInP2pSearch)
10957 {
10958 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010959 }
10960 else
10961 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010962 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010963 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010964
Agarwal Ashish4f616132013-12-30 23:32:50 +053010965 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010966 }
10967 }
10968
10969 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
10970
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010971#ifdef FEATURE_WLAN_TDLS
10972 /* if tdls disagree scan right now, return immediately.
10973 tdls will schedule the scan when scan is allowed. (return SUCCESS)
10974 or will reject the scan if any TDLS is in progress. (return -EBUSY)
10975 */
10976 status = wlan_hdd_tdls_scan_callback (pAdapter,
10977 wiphy,
10978#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10979 dev,
10980#endif
10981 request);
10982 if(status <= 0)
10983 {
10984 if(!status)
10985 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
10986 "scan rejected %d", __func__, status);
10987 else
10988 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
10989 __func__, status);
10990
10991 return status;
10992 }
10993#endif
10994
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010995 /* acquire the wakelock to avoid the apps suspend during the scan. To
10996 * address the following issues.
10997 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
10998 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
10999 * for long time, this result in apps running at full power for long time.
11000 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
11001 * be stuck in full power because of resume BMPS
11002 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011003 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070011004
Nirav Shah20ac06f2013-12-12 18:14:06 +053011005 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
11006 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011007 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
11008 scanRequest.requestType, scanRequest.scanType,
11009 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053011010 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
11011
Siddharth Bhal76972212014-10-15 16:22:51 +053011012 if (pHddCtx->spoofMacAddr.isEnabled)
11013 {
11014 hddLog(VOS_TRACE_LEVEL_INFO,
11015 "%s: MAC Spoofing enabled for current scan", __func__);
11016 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
11017 * to fill TxBds for probe request during current scan
11018 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011019 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053011020 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011021
11022 if(status != VOS_STATUS_SUCCESS)
11023 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011024 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011025 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053011026#ifdef FEATURE_WLAN_TDLS
11027 wlan_hdd_tdls_scan_done_callback(pAdapter);
11028#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011029 goto free_mem;
11030 }
Siddharth Bhal76972212014-10-15 16:22:51 +053011031 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053011032 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070011033 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011034 pAdapter->sessionId, &scanRequest, &scanId,
11035 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070011036
Jeff Johnson295189b2012-06-20 16:38:30 -070011037 if (eHAL_STATUS_SUCCESS != status)
11038 {
11039 hddLog(VOS_TRACE_LEVEL_ERROR,
11040 "%s: sme_ScanRequest returned error %d", __func__, status);
11041 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011042 if(eHAL_STATUS_RESOURCES == status)
11043 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053011044 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
11045 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011046 status = -EBUSY;
11047 } else {
11048 status = -EIO;
11049 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011050 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053011051
11052#ifdef FEATURE_WLAN_TDLS
11053 wlan_hdd_tdls_scan_done_callback(pAdapter);
11054#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011055 goto free_mem;
11056 }
11057
11058 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053011059 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011060 pAdapter->request = request;
11061 pScanInfo->scanId = scanId;
11062
11063 complete(&pScanInfo->scan_req_completion_event);
11064
11065free_mem:
11066 if( scanRequest.SSIDs.SSIDList )
11067 {
11068 vos_mem_free(scanRequest.SSIDs.SSIDList);
11069 }
11070
11071 if( channelList )
11072 vos_mem_free( channelList );
11073
11074 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011075 return status;
11076}
11077
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011078int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
11079#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11080 struct net_device *dev,
11081#endif
11082 struct cfg80211_scan_request *request)
11083{
11084 int ret;
11085
11086 vos_ssr_protect(__func__);
11087 ret = __wlan_hdd_cfg80211_scan(wiphy,
11088#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11089 dev,
11090#endif
11091 request);
11092 vos_ssr_unprotect(__func__);
11093
11094 return ret;
11095}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011096
11097void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
11098{
11099 v_U8_t iniDot11Mode =
11100 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
11101 eHddDot11Mode hddDot11Mode = iniDot11Mode;
11102
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011103 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
11104 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011105 switch ( iniDot11Mode )
11106 {
11107 case eHDD_DOT11_MODE_AUTO:
11108 case eHDD_DOT11_MODE_11ac:
11109 case eHDD_DOT11_MODE_11ac_ONLY:
11110#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053011111 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
11112 sme_IsFeatureSupportedByFW(DOT11AC) )
11113 hddDot11Mode = eHDD_DOT11_MODE_11ac;
11114 else
11115 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011116#else
11117 hddDot11Mode = eHDD_DOT11_MODE_11n;
11118#endif
11119 break;
11120 case eHDD_DOT11_MODE_11n:
11121 case eHDD_DOT11_MODE_11n_ONLY:
11122 hddDot11Mode = eHDD_DOT11_MODE_11n;
11123 break;
11124 default:
11125 hddDot11Mode = iniDot11Mode;
11126 break;
11127 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011128#ifdef WLAN_FEATURE_AP_HT40_24G
11129 if (operationChannel > SIR_11B_CHANNEL_END)
11130#endif
11131 {
11132 /* This call decides required channel bonding mode */
11133 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011134 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
11135 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011136 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011137}
11138
Jeff Johnson295189b2012-06-20 16:38:30 -070011139/*
11140 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011141 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011142 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011143int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011144 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070011145{
11146 int status = 0;
11147 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080011148 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011149 v_U32_t roamId;
11150 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070011151 eCsrAuthType RSNAuthType;
11152
11153 ENTER();
11154
11155 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080011156 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11157
11158 status = wlan_hdd_validate_context(pHddCtx);
11159 if (status)
11160 {
Yue Mae36e3552014-03-05 17:06:20 -080011161 return status;
11162 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011163
Jeff Johnson295189b2012-06-20 16:38:30 -070011164 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
11165 {
11166 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
11167 return -EINVAL;
11168 }
11169
11170 pRoamProfile = &pWextState->roamProfile;
11171
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011172 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070011173 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011174 hdd_station_ctx_t *pHddStaCtx;
11175 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011176
Siddharth Bhalda0d1622015-04-24 15:47:49 +053011177 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
11178
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011179 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070011180 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
11181 {
11182 /*QoS not enabled in cfg file*/
11183 pRoamProfile->uapsd_mask = 0;
11184 }
11185 else
11186 {
11187 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011188 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070011189 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
11190 }
11191
11192 pRoamProfile->SSIDs.numOfSSIDs = 1;
11193 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
11194 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011195 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070011196 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
11197 ssid, ssid_len);
11198
11199 if (bssid)
11200 {
11201 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
11202 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
11203 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011204 /* Save BSSID in seperate variable as well, as RoamProfile
11205 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070011206 case of join failure we should send valid BSSID to supplicant
11207 */
11208 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
11209 WNI_CFG_BSSID_LEN);
11210 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070011211 else
11212 {
11213 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
11214 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011215
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011216 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
11217 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011218 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
11219 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011220 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011221 /*set gen ie*/
11222 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
11223 /*set auth*/
11224 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
11225 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011226#ifdef FEATURE_WLAN_WAPI
11227 if (pAdapter->wapi_info.nWapiMode)
11228 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011229 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011230 switch (pAdapter->wapi_info.wapiAuthMode)
11231 {
11232 case WAPI_AUTH_MODE_PSK:
11233 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011234 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011235 pAdapter->wapi_info.wapiAuthMode);
11236 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
11237 break;
11238 }
11239 case WAPI_AUTH_MODE_CERT:
11240 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011241 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011242 pAdapter->wapi_info.wapiAuthMode);
11243 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
11244 break;
11245 }
11246 } // End of switch
11247 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
11248 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
11249 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011250 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011251 pRoamProfile->AuthType.numEntries = 1;
11252 pRoamProfile->EncryptionType.numEntries = 1;
11253 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11254 pRoamProfile->mcEncryptionType.numEntries = 1;
11255 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11256 }
11257 }
11258#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011259#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011260 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011261 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11262 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
11263 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011264 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
11265 sizeof (tSirGtkOffloadParams));
11266 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011267 }
11268#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011269 pRoamProfile->csrPersona = pAdapter->device_mode;
11270
Jeff Johnson32d95a32012-09-10 13:15:23 -070011271 if( operatingChannel )
11272 {
11273 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
11274 pRoamProfile->ChannelInfo.numOfChannels = 1;
11275 }
Chet Lanctot186b5732013-03-18 10:26:30 -070011276 else
11277 {
11278 pRoamProfile->ChannelInfo.ChannelList = NULL;
11279 pRoamProfile->ChannelInfo.numOfChannels = 0;
11280 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011281 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
11282 {
11283 hdd_select_cbmode(pAdapter,operatingChannel);
11284 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011285
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011286 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
11287 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011288 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011289 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011290 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
11291 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011292 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11293 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053011294 {
11295 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11296 "%s: Set HDD connState to eConnectionState_Connecting",
11297 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011298 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
11299 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053011300 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011301 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011302 pAdapter->sessionId, pRoamProfile, &roamId);
11303
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011304 if ((eHAL_STATUS_SUCCESS != status) &&
11305 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11306 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011307
11308 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011309 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
11310 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
11311 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011312 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011313 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011314 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011315
11316 pRoamProfile->ChannelInfo.ChannelList = NULL;
11317 pRoamProfile->ChannelInfo.numOfChannels = 0;
11318
Jeff Johnson295189b2012-06-20 16:38:30 -070011319 }
11320 else
11321 {
11322 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
11323 return -EINVAL;
11324 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080011325 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011326 return status;
11327}
11328
11329/*
11330 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
11331 * This function is used to set the authentication type (OPEN/SHARED).
11332 *
11333 */
11334static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
11335 enum nl80211_auth_type auth_type)
11336{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011337 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011338 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11339
11340 ENTER();
11341
11342 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011343 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070011344 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011345 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011346 hddLog(VOS_TRACE_LEVEL_INFO,
11347 "%s: set authentication type to AUTOSWITCH", __func__);
11348 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
11349 break;
11350
11351 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011352#ifdef WLAN_FEATURE_VOWIFI_11R
11353 case NL80211_AUTHTYPE_FT:
11354#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011355 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011356 "%s: set authentication type to OPEN", __func__);
11357 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11358 break;
11359
11360 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011361 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011362 "%s: set authentication type to SHARED", __func__);
11363 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
11364 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011365#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011366 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011367 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011368 "%s: set authentication type to CCKM WPA", __func__);
11369 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
11370 break;
11371#endif
11372
11373
11374 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011375 hddLog(VOS_TRACE_LEVEL_ERROR,
11376 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011377 auth_type);
11378 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
11379 return -EINVAL;
11380 }
11381
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011382 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011383 pHddStaCtx->conn_info.authType;
11384 return 0;
11385}
11386
11387/*
11388 * FUNCTION: wlan_hdd_set_akm_suite
11389 * This function is used to set the key mgmt type(PSK/8021x).
11390 *
11391 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011392static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011393 u32 key_mgmt
11394 )
11395{
11396 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11397 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053011398 /* Should be in ieee802_11_defs.h */
11399#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
11400#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070011401 /*set key mgmt type*/
11402 switch(key_mgmt)
11403 {
11404 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053011405 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011406#ifdef WLAN_FEATURE_VOWIFI_11R
11407 case WLAN_AKM_SUITE_FT_PSK:
11408#endif
11409 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070011410 __func__);
11411 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
11412 break;
11413
11414 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053011415 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011416#ifdef WLAN_FEATURE_VOWIFI_11R
11417 case WLAN_AKM_SUITE_FT_8021X:
11418#endif
11419 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011420 __func__);
11421 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11422 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011423#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011424#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
11425#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
11426 case WLAN_AKM_SUITE_CCKM:
11427 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
11428 __func__);
11429 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
11430 break;
11431#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070011432#ifndef WLAN_AKM_SUITE_OSEN
11433#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
11434 case WLAN_AKM_SUITE_OSEN:
11435 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
11436 __func__);
11437 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11438 break;
11439#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011440
11441 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011442 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011443 __func__, key_mgmt);
11444 return -EINVAL;
11445
11446 }
11447 return 0;
11448}
11449
11450/*
11451 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011452 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070011453 * (NONE/WEP40/WEP104/TKIP/CCMP).
11454 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011455static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
11456 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070011457 bool ucast
11458 )
11459{
11460 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011461 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011462 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11463
11464 ENTER();
11465
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011466 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011467 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011468 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070011469 __func__, cipher);
11470 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11471 }
11472 else
11473 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011474
Jeff Johnson295189b2012-06-20 16:38:30 -070011475 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011476 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011477 {
11478 case IW_AUTH_CIPHER_NONE:
11479 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11480 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011481
Jeff Johnson295189b2012-06-20 16:38:30 -070011482 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011483 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070011484 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011485
Jeff Johnson295189b2012-06-20 16:38:30 -070011486 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011487 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070011488 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011489
Jeff Johnson295189b2012-06-20 16:38:30 -070011490 case WLAN_CIPHER_SUITE_TKIP:
11491 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
11492 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011493
Jeff Johnson295189b2012-06-20 16:38:30 -070011494 case WLAN_CIPHER_SUITE_CCMP:
11495 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11496 break;
11497#ifdef FEATURE_WLAN_WAPI
11498 case WLAN_CIPHER_SUITE_SMS4:
11499 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
11500 break;
11501#endif
11502
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011503#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011504 case WLAN_CIPHER_SUITE_KRK:
11505 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
11506 break;
11507#endif
11508 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011509 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011510 __func__, cipher);
11511 return -EOPNOTSUPP;
11512 }
11513 }
11514
11515 if (ucast)
11516 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011517 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011518 __func__, encryptionType);
11519 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11520 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011521 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011522 encryptionType;
11523 }
11524 else
11525 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011526 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011527 __func__, encryptionType);
11528 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
11529 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
11530 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
11531 }
11532
11533 return 0;
11534}
11535
11536
11537/*
11538 * FUNCTION: wlan_hdd_cfg80211_set_ie
11539 * This function is used to parse WPA/RSN IE's.
11540 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011541int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
11542 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -070011543 size_t ie_len
11544 )
11545{
11546 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11547 u8 *genie = ie;
11548 v_U16_t remLen = ie_len;
11549#ifdef FEATURE_WLAN_WAPI
11550 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
11551 u16 *tmp;
11552 v_U16_t akmsuiteCount;
11553 int *akmlist;
11554#endif
11555 ENTER();
11556
11557 /* clear previous assocAddIE */
11558 pWextState->assocAddIE.length = 0;
11559 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011560 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011561
11562 while (remLen >= 2)
11563 {
11564 v_U16_t eLen = 0;
11565 v_U8_t elementId;
11566 elementId = *genie++;
11567 eLen = *genie++;
11568 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011569
Arif Hussain6d2a3322013-11-17 19:50:10 -080011570 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070011571 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011572
11573 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070011574 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011575 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011576 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 -070011577 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011578 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011579 "%s: Invalid WPA IE", __func__);
11580 return -EINVAL;
11581 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011582 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070011583 {
11584 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011585 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011586 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011587
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011588 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011589 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011590 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
11591 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011592 VOS_ASSERT(0);
11593 return -ENOMEM;
11594 }
11595 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11596 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11597 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011598
Jeff Johnson295189b2012-06-20 16:38:30 -070011599 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
11600 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11601 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11602 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011603 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
11604 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011605 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
11606 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11607 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
11608 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
11609 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
11610 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011611 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053011612 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070011613 {
11614 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011615 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011616 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011617
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011618 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011619 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011620 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11621 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011622 VOS_ASSERT(0);
11623 return -ENOMEM;
11624 }
11625 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11626 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11627 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011628
Jeff Johnson295189b2012-06-20 16:38:30 -070011629 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11630 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11631 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011632#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011633 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
11634 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011635 /*Consider WFD IE, only for P2P Client */
11636 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
11637 {
11638 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011639 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011640 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011641
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011642 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011643 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011644 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11645 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011646 VOS_ASSERT(0);
11647 return -ENOMEM;
11648 }
11649 // WFD IE is saved to Additional IE ; it should be accumulated to handle
11650 // WPS IE + P2P IE + WFD IE
11651 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11652 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011653
Jeff Johnson295189b2012-06-20 16:38:30 -070011654 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11655 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11656 }
11657#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011658 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011659 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011660 HS20_OUI_TYPE_SIZE)) )
11661 {
11662 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011663 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011664 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011665
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011666 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011667 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011668 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11669 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011670 VOS_ASSERT(0);
11671 return -ENOMEM;
11672 }
11673 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11674 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011675
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011676 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11677 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11678 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011679 /* Appending OSEN Information Element in Assiciation Request */
11680 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
11681 OSEN_OUI_TYPE_SIZE)) )
11682 {
11683 v_U16_t curAddIELen = pWextState->assocAddIE.length;
11684 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
11685 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011686
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011687 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011688 {
11689 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11690 "Need bigger buffer space");
11691 VOS_ASSERT(0);
11692 return -ENOMEM;
11693 }
11694 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11695 pWextState->assocAddIE.length += eLen + 2;
11696
11697 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
11698 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11699 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11700 }
11701
Abhishek Singh4322e622015-06-10 15:42:54 +053011702 /* Update only for WPA IE */
11703 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
11704 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011705
11706 /* populating as ADDIE in beacon frames */
11707 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11708 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
11709 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
11710 {
11711 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11712 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
11713 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11714 {
11715 hddLog(LOGE,
11716 "Coldn't pass "
11717 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
11718 }
11719 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
11720 else
11721 hddLog(LOGE,
11722 "Could not pass on "
11723 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
11724
11725 /* IBSS mode doesn't contain params->proberesp_ies still
11726 beaconIE's need to be populated in probe response frames */
11727 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
11728 {
11729 u16 rem_probe_resp_ie_len = eLen + 2;
11730 u8 probe_rsp_ie_len[3] = {0};
11731 u8 counter = 0;
11732
11733 /* Check Probe Resp Length if it is greater then 255 then
11734 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
11735 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
11736 not able Store More then 255 bytes into One Variable */
11737
11738 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
11739 {
11740 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
11741 {
11742 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
11743 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
11744 }
11745 else
11746 {
11747 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
11748 rem_probe_resp_ie_len = 0;
11749 }
11750 }
11751
11752 rem_probe_resp_ie_len = 0;
11753
11754 if (probe_rsp_ie_len[0] > 0)
11755 {
11756 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11757 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
11758 (tANI_U8*)(genie - 2),
11759 probe_rsp_ie_len[0], NULL,
11760 eANI_BOOLEAN_FALSE)
11761 == eHAL_STATUS_FAILURE)
11762 {
11763 hddLog(LOGE,
11764 "Could not pass"
11765 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
11766 }
11767 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
11768 }
11769
11770 if (probe_rsp_ie_len[1] > 0)
11771 {
11772 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11773 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
11774 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11775 probe_rsp_ie_len[1], NULL,
11776 eANI_BOOLEAN_FALSE)
11777 == eHAL_STATUS_FAILURE)
11778 {
11779 hddLog(LOGE,
11780 "Could not pass"
11781 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
11782 }
11783 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
11784 }
11785
11786 if (probe_rsp_ie_len[2] > 0)
11787 {
11788 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11789 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
11790 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11791 probe_rsp_ie_len[2], NULL,
11792 eANI_BOOLEAN_FALSE)
11793 == eHAL_STATUS_FAILURE)
11794 {
11795 hddLog(LOGE,
11796 "Could not pass"
11797 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
11798 }
11799 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
11800 }
11801
11802 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11803 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
11804 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11805 {
11806 hddLog(LOGE,
11807 "Could not pass"
11808 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
11809 }
11810 }
11811 else
11812 {
11813 // Reset WNI_CFG_PROBE_RSP Flags
11814 wlan_hdd_reset_prob_rspies(pAdapter);
11815
11816 hddLog(VOS_TRACE_LEVEL_INFO,
11817 "%s: No Probe Response IE received in set beacon",
11818 __func__);
11819 }
11820 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070011821 break;
11822 case DOT11F_EID_RSN:
11823 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
11824 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11825 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
11826 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
11827 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
11828 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053011829
11830 /* Appending Extended Capabilities with Interworking bit set
11831 * in Assoc Req.
11832 *
11833 * In assoc req this EXT Cap will only be taken into account if
11834 * interworkingService bit is set to 1. Currently
11835 * driver is only interested in interworkingService capability
11836 * from supplicant. If in future any other EXT Cap info is
11837 * required from supplicat, it needs to be handled while
11838 * sending Assoc Req in LIM.
11839 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011840 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011841 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011842 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011843 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011844 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011845
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011846 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011847 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011848 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11849 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011850 VOS_ASSERT(0);
11851 return -ENOMEM;
11852 }
11853 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11854 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011855
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011856 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11857 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11858 break;
11859 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011860#ifdef FEATURE_WLAN_WAPI
11861 case WLAN_EID_WAPI:
11862 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011863 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070011864 pAdapter->wapi_info.nWapiMode);
11865 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011866 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070011867 akmsuiteCount = WPA_GET_LE16(tmp);
11868 tmp = tmp + 1;
11869 akmlist = (int *)(tmp);
11870 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
11871 {
11872 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
11873 }
11874 else
11875 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011876 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070011877 VOS_ASSERT(0);
11878 return -EINVAL;
11879 }
11880
11881 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
11882 {
11883 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011884 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011885 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011886 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011887 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011888 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011889 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011890 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011891 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
11892 }
11893 break;
11894#endif
11895 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011896 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011897 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011898 /* when Unknown IE is received we should break and continue
11899 * to the next IE in the buffer instead we were returning
11900 * so changing this to break */
11901 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011902 }
11903 genie += eLen;
11904 remLen -= eLen;
11905 }
11906 EXIT();
11907 return 0;
11908}
11909
11910/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053011911 * FUNCTION: hdd_isWPAIEPresent
11912 * Parse the received IE to find the WPA IE
11913 *
11914 */
11915static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
11916{
11917 v_U8_t eLen = 0;
11918 v_U16_t remLen = ie_len;
11919 v_U8_t elementId = 0;
11920
11921 while (remLen >= 2)
11922 {
11923 elementId = *ie++;
11924 eLen = *ie++;
11925 remLen -= 2;
11926 if (eLen > remLen)
11927 {
11928 hddLog(VOS_TRACE_LEVEL_ERROR,
11929 "%s: IE length is wrong %d", __func__, eLen);
11930 return FALSE;
11931 }
11932 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
11933 {
11934 /* OUI - 0x00 0X50 0XF2
11935 WPA Information Element - 0x01
11936 WPA version - 0x01*/
11937 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
11938 return TRUE;
11939 }
11940 ie += eLen;
11941 remLen -= eLen;
11942 }
11943 return FALSE;
11944}
11945
11946/*
Jeff Johnson295189b2012-06-20 16:38:30 -070011947 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011948 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070011949 * parameters during connect operation.
11950 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011951int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011952 struct cfg80211_connect_params *req
11953 )
11954{
11955 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011956 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011957 ENTER();
11958
11959 /*set wpa version*/
11960 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11961
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011962 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011963 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053011964 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011965 {
11966 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
11967 }
11968 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
11969 {
11970 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
11971 }
11972 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011973
11974 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011975 pWextState->wpaVersion);
11976
11977 /*set authentication type*/
11978 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
11979
11980 if (0 > status)
11981 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011982 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011983 "%s: failed to set authentication type ", __func__);
11984 return status;
11985 }
11986
11987 /*set key mgmt type*/
11988 if (req->crypto.n_akm_suites)
11989 {
11990 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
11991 if (0 > status)
11992 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011993 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070011994 __func__);
11995 return status;
11996 }
11997 }
11998
11999 /*set pairwise cipher type*/
12000 if (req->crypto.n_ciphers_pairwise)
12001 {
12002 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
12003 req->crypto.ciphers_pairwise[0], true);
12004 if (0 > status)
12005 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012006 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012007 "%s: failed to set unicast cipher type", __func__);
12008 return status;
12009 }
12010 }
12011 else
12012 {
12013 /*Reset previous cipher suite to none*/
12014 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
12015 if (0 > status)
12016 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012017 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012018 "%s: failed to set unicast cipher type", __func__);
12019 return status;
12020 }
12021 }
12022
12023 /*set group cipher type*/
12024 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
12025 false);
12026
12027 if (0 > status)
12028 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012029 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070012030 __func__);
12031 return status;
12032 }
12033
Chet Lanctot186b5732013-03-18 10:26:30 -070012034#ifdef WLAN_FEATURE_11W
12035 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
12036#endif
12037
Jeff Johnson295189b2012-06-20 16:38:30 -070012038 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
12039 if (req->ie_len)
12040 {
12041 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
12042 if ( 0 > status)
12043 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012044 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012045 __func__);
12046 return status;
12047 }
12048 }
12049
12050 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012051 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012052 {
12053 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
12054 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
12055 )
12056 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012057 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070012058 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
12059 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012060 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012061 __func__);
12062 return -EOPNOTSUPP;
12063 }
12064 else
12065 {
12066 u8 key_len = req->key_len;
12067 u8 key_idx = req->key_idx;
12068
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012069 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012070 && (CSR_MAX_NUM_KEY > key_idx)
12071 )
12072 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012073 hddLog(VOS_TRACE_LEVEL_INFO,
12074 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012075 __func__, key_idx, key_len);
12076 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012077 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012078 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012079 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070012080 (u8)key_len;
12081 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
12082 }
12083 }
12084 }
12085 }
12086
12087 return status;
12088}
12089
12090/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012091 * FUNCTION: wlan_hdd_try_disconnect
12092 * This function is used to disconnect from previous
12093 * connection
12094 */
12095static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
12096{
12097 long ret = 0;
12098 hdd_station_ctx_t *pHddStaCtx;
12099 eMib_dot11DesiredBssType connectedBssType;
12100
12101 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12102
12103 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
12104
12105 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
12106 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
12107 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
12108 {
12109 /* Issue disconnect to CSR */
12110 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12111 if( eHAL_STATUS_SUCCESS ==
12112 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12113 pAdapter->sessionId,
12114 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
12115 {
12116 ret = wait_for_completion_interruptible_timeout(
12117 &pAdapter->disconnect_comp_var,
12118 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12119 if (0 >= ret)
12120 {
12121 hddLog(LOGE, FL("Failed to receive disconnect event"));
12122 return -EALREADY;
12123 }
12124 }
12125 }
12126 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
12127 {
12128 ret = wait_for_completion_interruptible_timeout(
12129 &pAdapter->disconnect_comp_var,
12130 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12131 if (0 >= ret)
12132 {
12133 hddLog(LOGE, FL("Failed to receive disconnect event"));
12134 return -EALREADY;
12135 }
12136 }
12137
12138 return 0;
12139}
12140
12141/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053012142 * FUNCTION: __wlan_hdd_cfg80211_connect
12143 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070012144 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012145static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012146 struct net_device *ndev,
12147 struct cfg80211_connect_params *req
12148 )
12149{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012150 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012151 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012152 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053012153 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012154
12155 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012156
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012157 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12158 TRACE_CODE_HDD_CFG80211_CONNECT,
12159 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012160 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012161 "%s: device_mode = %s (%d)", __func__,
12162 hdd_device_modetoString(pAdapter->device_mode),
12163 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012164
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012165 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012166 if (!pHddCtx)
12167 {
12168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12169 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053012170 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012171 }
12172
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012173 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012174 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012175 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012176 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012177 }
12178
Agarwal Ashish51325b52014-06-16 16:50:49 +053012179 if (vos_max_concurrent_connections_reached()) {
12180 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12181 return -ECONNREFUSED;
12182 }
12183
Jeff Johnson295189b2012-06-20 16:38:30 -070012184#ifdef WLAN_BTAMP_FEATURE
12185 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012186 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070012187 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012188 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012189 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080012190 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012191 }
12192#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012193
12194 //If Device Mode is Station Concurrent Sessions Exit BMps
12195 //P2P Mode will be taken care in Open/close adapter
12196 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012197 (vos_concurrent_open_sessions_running())) {
12198 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
12199 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012200 }
12201
12202 /*Try disconnecting if already in connected state*/
12203 status = wlan_hdd_try_disconnect(pAdapter);
12204 if ( 0 > status)
12205 {
12206 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12207 " connection"));
12208 return -EALREADY;
12209 }
12210
Jeff Johnson295189b2012-06-20 16:38:30 -070012211 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012212 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070012213
12214 if ( 0 > status)
12215 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012216 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070012217 __func__);
12218 return status;
12219 }
Mohit Khanna765234a2012-09-11 15:08:35 -070012220 if ( req->channel )
12221 {
12222 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
12223 req->ssid_len, req->bssid,
12224 req->channel->hw_value);
12225 }
12226 else
12227 {
12228 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012229 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070012230 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012231
Sushant Kaushikd7083982015-03-18 14:33:24 +053012232 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012233 {
12234 //ReEnable BMPS if disabled
12235 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
12236 (NULL != pHddCtx))
12237 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012238 if (pHddCtx->hdd_wlan_suspended)
12239 {
12240 hdd_set_pwrparams(pHddCtx);
12241 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012242 //ReEnable Bmps and Imps back
12243 hdd_enable_bmps_imps(pHddCtx);
12244 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053012245 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012246 return status;
12247 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012248 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012249 EXIT();
12250 return status;
12251}
12252
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012253static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
12254 struct net_device *ndev,
12255 struct cfg80211_connect_params *req)
12256{
12257 int ret;
12258 vos_ssr_protect(__func__);
12259 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
12260 vos_ssr_unprotect(__func__);
12261
12262 return ret;
12263}
Jeff Johnson295189b2012-06-20 16:38:30 -070012264
12265/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012266 * FUNCTION: wlan_hdd_disconnect
12267 * This function is used to issue a disconnect request to SME
12268 */
12269int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
12270{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012271 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012272 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012273 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012274 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012275
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012276 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012277
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012278 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012279 if (0 != status)
12280 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012281 return status;
12282 }
12283
Sushant Kaushikb4834d22015-07-15 15:29:05 +053012284 if (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)
12285 {
12286 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
12287 pAdapter->sessionId);
12288 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012289 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012290
Agarwal Ashish47d18112014-08-04 19:55:07 +053012291 /* Need to apply spin lock before decreasing active sessions
12292 * as there can be chance for double decrement if context switch
12293 * Calls hdd_DisConnectHandler.
12294 */
12295
12296 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012297 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
12298 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012299 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
12300 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053012301 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
12302 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012303
Abhishek Singhf4669da2014-05-26 15:07:49 +053012304 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053012305 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
12306
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012307 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012308
Mihir Shete182a0b22014-08-18 16:08:48 +053012309 /*
12310 * stop tx queues before deleting STA/BSS context from the firmware.
12311 * tx has to be disabled because the firmware can get busy dropping
12312 * the tx frames after BSS/STA has been deleted and will not send
12313 * back a response resulting in WDI timeout
12314 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053012315 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053012316 netif_tx_disable(pAdapter->dev);
12317 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012318
Mihir Shete182a0b22014-08-18 16:08:48 +053012319 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012320 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12321 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012322 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
12323 {
12324 hddLog(VOS_TRACE_LEVEL_INFO,
12325 FL("status = %d, already disconnected"),
12326 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012327
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012328 }
12329 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012330 {
12331 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012332 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012333 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012334 result = -EINVAL;
12335 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012336 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012337 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012338 &pAdapter->disconnect_comp_var,
12339 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012340 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012341 {
12342 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012343 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012344 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012345 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012346 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012347 {
12348 hddLog(VOS_TRACE_LEVEL_ERROR,
12349 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012350 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012351 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012352disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012353 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12354 FL("Set HDD connState to eConnectionState_NotConnected"));
12355 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
12356
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012357 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012358 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012359}
12360
12361
12362/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012363 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070012364 * This function is used to issue a disconnect request to SME
12365 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012366static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012367 struct net_device *dev,
12368 u16 reason
12369 )
12370{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012371 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012372 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012373 tCsrRoamProfile *pRoamProfile;
12374 hdd_station_ctx_t *pHddStaCtx;
12375 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012376#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012377 tANI_U8 staIdx;
12378#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012379
Jeff Johnson295189b2012-06-20 16:38:30 -070012380 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012381
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012382 if (!pAdapter) {
12383 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
12384 return -EINVAL;
12385 }
12386
12387 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12388 if (!pHddStaCtx) {
12389 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
12390 return -EINVAL;
12391 }
12392
12393 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12394 status = wlan_hdd_validate_context(pHddCtx);
12395 if (0 != status)
12396 {
12397 return status;
12398 }
12399
12400 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
12401
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012402 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12403 TRACE_CODE_HDD_CFG80211_DISCONNECT,
12404 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012405 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
12406 __func__, hdd_device_modetoString(pAdapter->device_mode),
12407 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012408
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012409 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
12410 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070012411
Jeff Johnson295189b2012-06-20 16:38:30 -070012412 if (NULL != pRoamProfile)
12413 {
12414 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012415 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
12416 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070012417 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012418 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070012419 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012420 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012421 switch(reason)
12422 {
12423 case WLAN_REASON_MIC_FAILURE:
12424 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
12425 break;
12426
12427 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
12428 case WLAN_REASON_DISASSOC_AP_BUSY:
12429 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
12430 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
12431 break;
12432
12433 case WLAN_REASON_PREV_AUTH_NOT_VALID:
12434 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053012435 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070012436 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
12437 break;
12438
Jeff Johnson295189b2012-06-20 16:38:30 -070012439 default:
12440 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
12441 break;
12442 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012443 pScanInfo = &pHddCtx->scan_info;
12444 if (pScanInfo->mScanPending)
12445 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012446 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012447 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053012448 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012449 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012450 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012451
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012452#ifdef FEATURE_WLAN_TDLS
12453 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012454 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012455 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012456 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
12457 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012458 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012459 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012460 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012461 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012462 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012463 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012464 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012465 status = sme_DeleteTdlsPeerSta(
12466 WLAN_HDD_GET_HAL_CTX(pAdapter),
12467 pAdapter->sessionId,
12468 mac);
12469 if (status != eHAL_STATUS_SUCCESS) {
12470 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
12471 return -EPERM;
12472 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012473 }
12474 }
12475#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012476 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012477 status = wlan_hdd_disconnect(pAdapter, reasonCode);
12478 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070012479 {
12480 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012481 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012482 __func__, (int)status );
12483 return -EINVAL;
12484 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012485 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012486 else
12487 {
12488 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
12489 "called while in %d state", __func__,
12490 pHddStaCtx->conn_info.connState);
12491 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012492 }
12493 else
12494 {
12495 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
12496 }
12497
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012498 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012499 return status;
12500}
12501
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012502static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
12503 struct net_device *dev,
12504 u16 reason
12505 )
12506{
12507 int ret;
12508 vos_ssr_protect(__func__);
12509 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
12510 vos_ssr_unprotect(__func__);
12511
12512 return ret;
12513}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012514
Jeff Johnson295189b2012-06-20 16:38:30 -070012515/*
12516 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012517 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012518 * settings in IBSS mode.
12519 */
12520static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012521 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012522 struct cfg80211_ibss_params *params
12523 )
12524{
12525 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012526 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012527 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
12528 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012529
Jeff Johnson295189b2012-06-20 16:38:30 -070012530 ENTER();
12531
12532 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070012533 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070012534
12535 if (params->ie_len && ( NULL != params->ie) )
12536 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012537 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12538 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012539 {
12540 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12541 encryptionType = eCSR_ENCRYPT_TYPE_AES;
12542 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012543 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012544 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012545 tDot11fIEWPA dot11WPAIE;
12546 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012547 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012548
Wilson Yang00256342013-10-10 23:13:38 -070012549 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012550 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12551 params->ie_len, DOT11F_EID_WPA);
12552 if ( NULL != ie )
12553 {
12554 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12555 // Unpack the WPA IE
12556 //Skip past the EID byte and length byte - and four byte WiFi OUI
12557 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
12558 &ie[2+4],
12559 ie[1] - 4,
12560 &dot11WPAIE);
12561 /*Extract the multicast cipher, the encType for unicast
12562 cipher for wpa-none is none*/
12563 encryptionType =
12564 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
12565 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012566 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012567
Jeff Johnson295189b2012-06-20 16:38:30 -070012568 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
12569
12570 if (0 > status)
12571 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012572 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012573 __func__);
12574 return status;
12575 }
12576 }
12577
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012578 pWextState->roamProfile.AuthType.authType[0] =
12579 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012580 eCSR_AUTH_TYPE_OPEN_SYSTEM;
12581
12582 if (params->privacy)
12583 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012584 /* Security enabled IBSS, At this time there is no information available
12585 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070012586 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012587 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070012588 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012589 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070012590 *enable privacy bit in beacons */
12591
12592 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
12593 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012594 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
12595 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012596 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
12597 pWextState->roamProfile.EncryptionType.numEntries = 1;
12598 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012599 return status;
12600}
12601
12602/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012603 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012604 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012605 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012606static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012607 struct net_device *dev,
12608 struct cfg80211_ibss_params *params
12609 )
12610{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012611 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012612 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12613 tCsrRoamProfile *pRoamProfile;
12614 int status;
krunal sonie9002db2013-11-25 14:24:17 -080012615 bool alloc_bssid = VOS_FALSE;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012616 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12617 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012618
12619 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012620
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012621 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12622 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
12623 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012624 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012625 "%s: device_mode = %s (%d)", __func__,
12626 hdd_device_modetoString(pAdapter->device_mode),
12627 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012628
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012629 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012630 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012631 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012632 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012633 }
12634
12635 if (NULL == pWextState)
12636 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012637 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012638 __func__);
12639 return -EIO;
12640 }
12641
Agarwal Ashish51325b52014-06-16 16:50:49 +053012642 if (vos_max_concurrent_connections_reached()) {
12643 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12644 return -ECONNREFUSED;
12645 }
12646
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012647 /*Try disconnecting if already in connected state*/
12648 status = wlan_hdd_try_disconnect(pAdapter);
12649 if ( 0 > status)
12650 {
12651 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12652 " IBSS connection"));
12653 return -EALREADY;
12654 }
12655
Jeff Johnson295189b2012-06-20 16:38:30 -070012656 pRoamProfile = &pWextState->roamProfile;
12657
12658 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
12659 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012660 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012661 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012662 return -EINVAL;
12663 }
12664
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012665 /* BSSID is provided by upper layers hence no need to AUTO generate */
12666 if (NULL != params->bssid) {
12667 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12668 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
12669 hddLog (VOS_TRACE_LEVEL_ERROR,
12670 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12671 return -EIO;
12672 }
12673 }
krunal sonie9002db2013-11-25 14:24:17 -080012674 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
12675 {
12676 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12677 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
12678 {
12679 hddLog (VOS_TRACE_LEVEL_ERROR,
12680 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12681 return -EIO;
12682 }
Sachin Ahuja46ff4912015-03-23 22:48:43 +053012683 params->bssid = vos_mem_malloc(VOS_MAC_ADDR_SIZE);
krunal sonie9002db2013-11-25 14:24:17 -080012684 if (!params->bssid)
12685 {
12686 hddLog (VOS_TRACE_LEVEL_ERROR,
12687 "%s:Failed memory allocation", __func__);
12688 return -EIO;
12689 }
12690 vos_mem_copy((v_U8_t *)params->bssid,
12691 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
12692 VOS_MAC_ADDR_SIZE);
12693 alloc_bssid = VOS_TRUE;
12694 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012695
Jeff Johnson295189b2012-06-20 16:38:30 -070012696 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070012697 if (NULL !=
12698#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12699 params->chandef.chan)
12700#else
12701 params->channel)
12702#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012703 {
12704 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012705 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12706 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
12707 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12708 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012709
12710 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012711 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070012712 ieee80211_frequency_to_channel(
12713#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12714 params->chandef.chan->center_freq);
12715#else
12716 params->channel->center_freq);
12717#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012718
12719 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
12720 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070012721 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012722 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
12723 __func__);
12724 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070012725 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012726
12727 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012728 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012729 if (channelNum == validChan[indx])
12730 {
12731 break;
12732 }
12733 }
12734 if (indx >= numChans)
12735 {
12736 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012737 __func__, channelNum);
12738 return -EINVAL;
12739 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012740 /* Set the Operational Channel */
12741 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
12742 channelNum);
12743 pRoamProfile->ChannelInfo.numOfChannels = 1;
12744 pHddStaCtx->conn_info.operationChannel = channelNum;
12745 pRoamProfile->ChannelInfo.ChannelList =
12746 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070012747 }
12748
12749 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012750 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070012751 if (status < 0)
12752 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012753 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070012754 __func__);
12755 return status;
12756 }
12757
12758 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012759 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012760 params->ssid_len, params->bssid,
12761 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070012762
12763 if (0 > status)
12764 {
12765 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
12766 return status;
12767 }
12768
krunal sonie9002db2013-11-25 14:24:17 -080012769 if (NULL != params->bssid &&
12770 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
12771 alloc_bssid == VOS_TRUE)
12772 {
12773 vos_mem_free(params->bssid);
12774 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012775 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012776 return 0;
12777}
12778
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012779static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
12780 struct net_device *dev,
12781 struct cfg80211_ibss_params *params
12782 )
12783{
12784 int ret = 0;
12785
12786 vos_ssr_protect(__func__);
12787 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
12788 vos_ssr_unprotect(__func__);
12789
12790 return ret;
12791}
12792
Jeff Johnson295189b2012-06-20 16:38:30 -070012793/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012794 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012795 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012796 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012797static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012798 struct net_device *dev
12799 )
12800{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012801 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012802 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12803 tCsrRoamProfile *pRoamProfile;
12804 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012805 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012806
12807 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012808
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012809 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12810 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
12811 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012812 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012813 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012814 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012815 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012816 }
12817
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012818 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
12819 hdd_device_modetoString(pAdapter->device_mode),
12820 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012821 if (NULL == pWextState)
12822 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012823 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012824 __func__);
12825 return -EIO;
12826 }
12827
12828 pRoamProfile = &pWextState->roamProfile;
12829
12830 /* Issue disconnect only if interface type is set to IBSS */
12831 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
12832 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012833 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070012834 __func__);
12835 return -EINVAL;
12836 }
12837
12838 /* Issue Disconnect request */
12839 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12840 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
12841 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
12842
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012843 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012844 return 0;
12845}
12846
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012847static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
12848 struct net_device *dev
12849 )
12850{
12851 int ret = 0;
12852
12853 vos_ssr_protect(__func__);
12854 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
12855 vos_ssr_unprotect(__func__);
12856
12857 return ret;
12858}
12859
Jeff Johnson295189b2012-06-20 16:38:30 -070012860/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012861 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070012862 * This function is used to set the phy parameters
12863 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
12864 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012865static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012866 u32 changed)
12867{
12868 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
12869 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012870 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012871
12872 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012873
12874 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012875 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
12876 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012877
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012878 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012879 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012880 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012881 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012882 }
12883
Jeff Johnson295189b2012-06-20 16:38:30 -070012884 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
12885 {
12886 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
12887 WNI_CFG_RTS_THRESHOLD_STAMAX :
12888 wiphy->rts_threshold;
12889
12890 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012891 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070012892 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012893 hddLog(VOS_TRACE_LEVEL_ERROR,
12894 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012895 __func__, rts_threshold);
12896 return -EINVAL;
12897 }
12898
12899 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
12900 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012901 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012902 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012903 hddLog(VOS_TRACE_LEVEL_ERROR,
12904 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012905 __func__, rts_threshold);
12906 return -EIO;
12907 }
12908
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012909 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012910 rts_threshold);
12911 }
12912
12913 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
12914 {
12915 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
12916 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
12917 wiphy->frag_threshold;
12918
12919 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012920 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012921 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012922 hddLog(VOS_TRACE_LEVEL_ERROR,
12923 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012924 frag_threshold);
12925 return -EINVAL;
12926 }
12927
12928 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
12929 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012930 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012931 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012932 hddLog(VOS_TRACE_LEVEL_ERROR,
12933 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012934 __func__, frag_threshold);
12935 return -EIO;
12936 }
12937
12938 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
12939 frag_threshold);
12940 }
12941
12942 if ((changed & WIPHY_PARAM_RETRY_SHORT)
12943 || (changed & WIPHY_PARAM_RETRY_LONG))
12944 {
12945 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
12946 wiphy->retry_short :
12947 wiphy->retry_long;
12948
12949 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
12950 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
12951 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012952 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012953 __func__, retry_value);
12954 return -EINVAL;
12955 }
12956
12957 if (changed & WIPHY_PARAM_RETRY_SHORT)
12958 {
12959 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
12960 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012961 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012962 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012963 hddLog(VOS_TRACE_LEVEL_ERROR,
12964 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012965 __func__, retry_value);
12966 return -EIO;
12967 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012968 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012969 __func__, retry_value);
12970 }
12971 else if (changed & WIPHY_PARAM_RETRY_SHORT)
12972 {
12973 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
12974 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012975 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012976 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012977 hddLog(VOS_TRACE_LEVEL_ERROR,
12978 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012979 __func__, retry_value);
12980 return -EIO;
12981 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012982 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012983 __func__, retry_value);
12984 }
12985 }
12986
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012987 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012988 return 0;
12989}
12990
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012991static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
12992 u32 changed)
12993{
12994 int ret;
12995
12996 vos_ssr_protect(__func__);
12997 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
12998 vos_ssr_unprotect(__func__);
12999
13000 return ret;
13001}
13002
Jeff Johnson295189b2012-06-20 16:38:30 -070013003/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013004 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013005 * This function is used to set the txpower
13006 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013007static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013008#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13009 struct wireless_dev *wdev,
13010#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013011#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013012 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013013#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013014 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013015#endif
13016 int dbm)
13017{
13018 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013019 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013020 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
13021 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013022 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013023
13024 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013025
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013026 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13027 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
13028 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013029 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013030 if (0 != status)
13031 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013032 return status;
13033 }
13034
13035 hHal = pHddCtx->hHal;
13036
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013037 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
13038 dbm, ccmCfgSetCallback,
13039 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013040 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013041 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013042 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
13043 return -EIO;
13044 }
13045
13046 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
13047 dbm);
13048
13049 switch(type)
13050 {
13051 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
13052 /* Fall through */
13053 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
13054 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
13055 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013056 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
13057 __func__);
13058 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070013059 }
13060 break;
13061 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013062 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070013063 __func__);
13064 return -EOPNOTSUPP;
13065 break;
13066 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013067 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
13068 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070013069 return -EIO;
13070 }
13071
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013072 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013073 return 0;
13074}
13075
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013076static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
13077#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13078 struct wireless_dev *wdev,
13079#endif
13080#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13081 enum tx_power_setting type,
13082#else
13083 enum nl80211_tx_power_setting type,
13084#endif
13085 int dbm)
13086{
13087 int ret;
13088 vos_ssr_protect(__func__);
13089 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
13090#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13091 wdev,
13092#endif
13093#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13094 type,
13095#else
13096 type,
13097#endif
13098 dbm);
13099 vos_ssr_unprotect(__func__);
13100
13101 return ret;
13102}
13103
Jeff Johnson295189b2012-06-20 16:38:30 -070013104/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013105 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013106 * This function is used to read the txpower
13107 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013108static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013109#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13110 struct wireless_dev *wdev,
13111#endif
13112 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070013113{
13114
13115 hdd_adapter_t *pAdapter;
13116 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013117 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013118
Jeff Johnsone7245742012-09-05 17:12:55 -070013119 ENTER();
13120
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013121 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013122 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013123 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013124 *dbm = 0;
13125 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013126 }
13127
Jeff Johnson295189b2012-06-20 16:38:30 -070013128 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
13129 if (NULL == pAdapter)
13130 {
13131 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
13132 return -ENOENT;
13133 }
13134
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053013135 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13136 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
13137 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070013138 wlan_hdd_get_classAstats(pAdapter);
13139 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
13140
Jeff Johnsone7245742012-09-05 17:12:55 -070013141 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013142 return 0;
13143}
13144
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013145static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
13146#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13147 struct wireless_dev *wdev,
13148#endif
13149 int *dbm)
13150{
13151 int ret;
13152
13153 vos_ssr_protect(__func__);
13154 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
13155#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13156 wdev,
13157#endif
13158 dbm);
13159 vos_ssr_unprotect(__func__);
13160
13161 return ret;
13162}
13163
13164
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013165static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070013166 u8* mac, struct station_info *sinfo)
13167{
13168 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13169 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13170 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053013171 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013172
13173 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
13174 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070013175
13176 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
13177 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
13178 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
13179 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
13180 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
13181 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
13182 tANI_U16 maxRate = 0;
13183 tANI_U16 myRate;
13184 tANI_U16 currentRate = 0;
13185 tANI_U8 maxSpeedMCS = 0;
13186 tANI_U8 maxMCSIdx = 0;
13187 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053013188 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013189 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013190 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013191
Leo Chang6f8870f2013-03-26 18:11:36 -070013192#ifdef WLAN_FEATURE_11AC
13193 tANI_U32 vht_mcs_map;
13194 eDataRate11ACMaxMcs vhtMaxMcs;
13195#endif /* WLAN_FEATURE_11AC */
13196
Jeff Johnsone7245742012-09-05 17:12:55 -070013197 ENTER();
13198
Jeff Johnson295189b2012-06-20 16:38:30 -070013199 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
13200 (0 == ssidlen))
13201 {
13202 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
13203 " Invalid ssidlen, %d", __func__, ssidlen);
13204 /*To keep GUI happy*/
13205 return 0;
13206 }
13207
Mukul Sharma811205f2014-07-09 21:07:30 +053013208 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
13209 {
13210 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13211 "%s: Roaming in progress, so unable to proceed this request", __func__);
13212 return 0;
13213 }
13214
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013215 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013216 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013217 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013218 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013219 }
13220
Jeff Johnson295189b2012-06-20 16:38:30 -070013221
Kiet Lam3b17fc82013-09-27 05:24:08 +053013222 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
13223 sinfo->filled |= STATION_INFO_SIGNAL;
13224
c_hpothu09f19542014-05-30 21:53:31 +053013225 wlan_hdd_get_station_stats(pAdapter);
13226 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
13227
13228 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053013229 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
13230 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053013231 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053013232 {
13233 rate_flags = pAdapter->maxRateFlags;
13234 }
c_hpothu44ff4e02014-05-08 00:13:57 +053013235
Jeff Johnson295189b2012-06-20 16:38:30 -070013236 //convert to the UI units of 100kbps
13237 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
13238
13239#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070013240 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 -070013241 sinfo->signal,
13242 pCfg->reportMaxLinkSpeed,
13243 myRate,
13244 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013245 (int) pCfg->linkSpeedRssiMid,
13246 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070013247 (int) rate_flags,
13248 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013249#endif //LINKSPEED_DEBUG_ENABLED
13250
13251 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
13252 {
13253 // we do not want to necessarily report the current speed
13254 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
13255 {
13256 // report the max possible speed
13257 rssidx = 0;
13258 }
13259 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
13260 {
13261 // report the max possible speed with RSSI scaling
13262 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
13263 {
13264 // report the max possible speed
13265 rssidx = 0;
13266 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013267 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070013268 {
13269 // report middle speed
13270 rssidx = 1;
13271 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013272 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
13273 {
13274 // report middle speed
13275 rssidx = 2;
13276 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013277 else
13278 {
13279 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013280 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070013281 }
13282 }
13283 else
13284 {
13285 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
13286 hddLog(VOS_TRACE_LEVEL_ERROR,
13287 "%s: Invalid value for reportMaxLinkSpeed: %u",
13288 __func__, pCfg->reportMaxLinkSpeed);
13289 rssidx = 0;
13290 }
13291
13292 maxRate = 0;
13293
13294 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013295 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
13296 OperationalRates, &ORLeng))
13297 {
13298 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13299 /*To keep GUI happy*/
13300 return 0;
13301 }
13302
Jeff Johnson295189b2012-06-20 16:38:30 -070013303 for (i = 0; i < ORLeng; i++)
13304 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013305 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013306 {
13307 /* Validate Rate Set */
13308 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
13309 {
13310 currentRate = supported_data_rate[j].supported_rate[rssidx];
13311 break;
13312 }
13313 }
13314 /* Update MAX rate */
13315 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13316 }
13317
13318 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013319 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
13320 ExtendedRates, &ERLeng))
13321 {
13322 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13323 /*To keep GUI happy*/
13324 return 0;
13325 }
13326
Jeff Johnson295189b2012-06-20 16:38:30 -070013327 for (i = 0; i < ERLeng; i++)
13328 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013329 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013330 {
13331 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
13332 {
13333 currentRate = supported_data_rate[j].supported_rate[rssidx];
13334 break;
13335 }
13336 }
13337 /* Update MAX rate */
13338 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13339 }
c_hpothu79aab322014-07-14 21:11:01 +053013340
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013341 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053013342 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013343 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053013344 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070013345 {
c_hpothu79aab322014-07-14 21:11:01 +053013346 if (rate_flags & eHAL_TX_RATE_VHT80)
13347 mode = 2;
13348 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
13349 mode = 1;
13350 else
13351 mode = 0;
13352
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013353 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
13354 MCSRates, &MCSLeng))
13355 {
13356 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13357 /*To keep GUI happy*/
13358 return 0;
13359 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013360 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070013361#ifdef WLAN_FEATURE_11AC
13362 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013363 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070013364 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013365 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013366 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070013367 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070013368 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013369 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013370 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013371 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070013372 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013373 maxMCSIdx = 7;
13374 }
13375 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
13376 {
13377 maxMCSIdx = 8;
13378 }
13379 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
13380 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013381 //VHT20 is supporting 0~8
13382 if (rate_flags & eHAL_TX_RATE_VHT20)
13383 maxMCSIdx = 8;
13384 else
13385 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070013386 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013387
c_hpothu79aab322014-07-14 21:11:01 +053013388 if (0 != rssidx)/*check for scaled */
13389 {
13390 //get middle rate MCS index if rssi=1/2
13391 for (i=0; i <= maxMCSIdx; i++)
13392 {
13393 if (sinfo->signal <= rssiMcsTbl[mode][i])
13394 {
13395 maxMCSIdx = i;
13396 break;
13397 }
13398 }
13399 }
13400
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013401 if (rate_flags & eHAL_TX_RATE_VHT80)
13402 {
13403 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
13404 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
13405 }
13406 else if (rate_flags & eHAL_TX_RATE_VHT40)
13407 {
13408 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
13409 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
13410 }
13411 else if (rate_flags & eHAL_TX_RATE_VHT20)
13412 {
13413 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
13414 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
13415 }
13416
Leo Chang6f8870f2013-03-26 18:11:36 -070013417 maxSpeedMCS = 1;
13418 if (currentRate > maxRate)
13419 {
13420 maxRate = currentRate;
13421 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013422
Leo Chang6f8870f2013-03-26 18:11:36 -070013423 }
13424 else
13425#endif /* WLAN_FEATURE_11AC */
13426 {
13427 if (rate_flags & eHAL_TX_RATE_HT40)
13428 {
13429 rateFlag |= 1;
13430 }
13431 if (rate_flags & eHAL_TX_RATE_SGI)
13432 {
13433 rateFlag |= 2;
13434 }
13435
Girish Gowli01abcee2014-07-31 20:18:55 +053013436 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053013437 if (rssidx == 1 || rssidx == 2)
13438 {
13439 //get middle rate MCS index if rssi=1/2
13440 for (i=0; i <= 7; i++)
13441 {
13442 if (sinfo->signal <= rssiMcsTbl[mode][i])
13443 {
13444 temp = i+1;
13445 break;
13446 }
13447 }
13448 }
c_hpothu79aab322014-07-14 21:11:01 +053013449
13450 for (i = 0; i < MCSLeng; i++)
13451 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013452 for (j = 0; j < temp; j++)
13453 {
13454 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
13455 {
13456 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013457 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013458 break;
13459 }
13460 }
13461 if ((j < temp) && (currentRate > maxRate))
13462 {
13463 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070013464 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013465 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013466 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013467 }
13468 }
13469
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013470 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
13471 {
13472 maxRate = myRate;
13473 maxSpeedMCS = 1;
13474 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13475 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013476 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053013477 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070013478 {
13479 maxRate = myRate;
13480 if (rate_flags & eHAL_TX_RATE_LEGACY)
13481 {
13482 maxSpeedMCS = 0;
13483 }
13484 else
13485 {
13486 maxSpeedMCS = 1;
13487 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13488 }
13489 }
13490
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013491 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 {
13493 sinfo->txrate.legacy = maxRate;
13494#ifdef LINKSPEED_DEBUG_ENABLED
13495 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
13496#endif //LINKSPEED_DEBUG_ENABLED
13497 }
13498 else
13499 {
13500 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070013501#ifdef WLAN_FEATURE_11AC
13502 sinfo->txrate.nss = 1;
13503 if (rate_flags & eHAL_TX_RATE_VHT80)
13504 {
13505 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013506 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070013507 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013508 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070013509 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013510 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13511 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13512 }
13513 else if (rate_flags & eHAL_TX_RATE_VHT20)
13514 {
13515 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13516 }
13517#endif /* WLAN_FEATURE_11AC */
13518 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
13519 {
13520 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13521 if (rate_flags & eHAL_TX_RATE_HT40)
13522 {
13523 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13524 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013525 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013526 if (rate_flags & eHAL_TX_RATE_SGI)
13527 {
13528 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13529 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013530
Jeff Johnson295189b2012-06-20 16:38:30 -070013531#ifdef LINKSPEED_DEBUG_ENABLED
13532 pr_info("Reporting MCS rate %d flags %x\n",
13533 sinfo->txrate.mcs,
13534 sinfo->txrate.flags );
13535#endif //LINKSPEED_DEBUG_ENABLED
13536 }
13537 }
13538 else
13539 {
13540 // report current rate instead of max rate
13541
13542 if (rate_flags & eHAL_TX_RATE_LEGACY)
13543 {
13544 //provide to the UI in units of 100kbps
13545 sinfo->txrate.legacy = myRate;
13546#ifdef LINKSPEED_DEBUG_ENABLED
13547 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
13548#endif //LINKSPEED_DEBUG_ENABLED
13549 }
13550 else
13551 {
13552 //must be MCS
13553 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013554#ifdef WLAN_FEATURE_11AC
13555 sinfo->txrate.nss = 1;
13556 if (rate_flags & eHAL_TX_RATE_VHT80)
13557 {
13558 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13559 }
13560 else
13561#endif /* WLAN_FEATURE_11AC */
13562 {
13563 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13564 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013565 if (rate_flags & eHAL_TX_RATE_SGI)
13566 {
13567 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13568 }
13569 if (rate_flags & eHAL_TX_RATE_HT40)
13570 {
13571 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13572 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013573#ifdef WLAN_FEATURE_11AC
13574 else if (rate_flags & eHAL_TX_RATE_VHT80)
13575 {
13576 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
13577 }
13578#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070013579#ifdef LINKSPEED_DEBUG_ENABLED
13580 pr_info("Reporting actual MCS rate %d flags %x\n",
13581 sinfo->txrate.mcs,
13582 sinfo->txrate.flags );
13583#endif //LINKSPEED_DEBUG_ENABLED
13584 }
13585 }
13586 sinfo->filled |= STATION_INFO_TX_BITRATE;
13587
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013588 sinfo->tx_packets =
13589 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
13590 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
13591 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
13592 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
13593
13594 sinfo->tx_retries =
13595 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
13596 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
13597 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
13598 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
13599
13600 sinfo->tx_failed =
13601 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
13602 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
13603 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
13604 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
13605
13606 sinfo->filled |=
13607 STATION_INFO_TX_PACKETS |
13608 STATION_INFO_TX_RETRIES |
13609 STATION_INFO_TX_FAILED;
13610
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013611 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13612 TRACE_CODE_HDD_CFG80211_GET_STA,
13613 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013614 EXIT();
13615 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013616}
13617
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013618static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13619 u8* mac, struct station_info *sinfo)
13620{
13621 int ret;
13622
13623 vos_ssr_protect(__func__);
13624 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
13625 vos_ssr_unprotect(__func__);
13626
13627 return ret;
13628}
13629
13630static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070013631 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070013632{
13633 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013634 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013635 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013636 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013637
Jeff Johnsone7245742012-09-05 17:12:55 -070013638 ENTER();
13639
Jeff Johnson295189b2012-06-20 16:38:30 -070013640 if (NULL == pAdapter)
13641 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013642 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013643 return -ENODEV;
13644 }
13645
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013646 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13647 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
13648 pAdapter->sessionId, timeout));
13649
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013650 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013651 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013652 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013653 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013654 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013655 }
13656
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013657 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
13658 (TRUE == pHddCtx->hdd_wlan_suspended) &&
13659 (pHddCtx->cfg_ini->fhostArpOffload) &&
13660 (eConnectionState_Associated ==
13661 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13662 {
Amar Singhald53568e2013-09-26 11:03:45 -070013663
13664 hddLog(VOS_TRACE_LEVEL_INFO,
13665 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053013666 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013667 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13668 {
13669 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013670 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013671 __func__, vos_status);
13672 }
13673 }
13674
Jeff Johnson295189b2012-06-20 16:38:30 -070013675 /**The get power cmd from the supplicant gets updated by the nl only
13676 *on successful execution of the function call
13677 *we are oppositely mapped w.r.t mode in the driver
13678 **/
13679 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
13680
13681 if (VOS_STATUS_E_FAILURE == vos_status)
13682 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013683 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13684 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013685 return -EINVAL;
13686 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013687 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013688 return 0;
13689}
13690
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013691static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
13692 struct net_device *dev, bool mode, int timeout)
13693{
13694 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013695
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013696 vos_ssr_protect(__func__);
13697 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
13698 vos_ssr_unprotect(__func__);
13699
13700 return ret;
13701}
Jeff Johnson295189b2012-06-20 16:38:30 -070013702#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013703static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
13704 struct net_device *netdev,
13705 u8 key_index)
13706{
13707 ENTER();
13708 return 0;
13709}
13710
Jeff Johnson295189b2012-06-20 16:38:30 -070013711static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013712 struct net_device *netdev,
13713 u8 key_index)
13714{
13715 int ret;
13716 vos_ssr_protect(__func__);
13717 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
13718 vos_ssr_unprotect(__func__);
13719 return ret;
13720}
13721#endif //LINUX_VERSION_CODE
13722
13723#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13724static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13725 struct net_device *dev,
13726 struct ieee80211_txq_params *params)
13727{
13728 ENTER();
13729 return 0;
13730}
13731#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13732static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13733 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013734{
Jeff Johnsone7245742012-09-05 17:12:55 -070013735 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070013736 return 0;
13737}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013738#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070013739
13740#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13741static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013742 struct net_device *dev,
13743 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013744{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013745 int ret;
13746
13747 vos_ssr_protect(__func__);
13748 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
13749 vos_ssr_unprotect(__func__);
13750 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013751}
13752#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13753static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
13754 struct ieee80211_txq_params *params)
13755{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013756 int ret;
13757
13758 vos_ssr_protect(__func__);
13759 ret = __wlan_hdd_set_txq_params(wiphy, params);
13760 vos_ssr_unprotect(__func__);
13761 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013762}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013763#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013764
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013765static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013766 struct net_device *dev,
13767 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070013768{
13769 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013770 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013771 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013772 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013773 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013774 v_CONTEXT_t pVosContext = NULL;
13775 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013776
Jeff Johnsone7245742012-09-05 17:12:55 -070013777 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013778
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013779 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070013780 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013781 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013782 return -EINVAL;
13783 }
13784
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013785 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13786 TRACE_CODE_HDD_CFG80211_DEL_STA,
13787 pAdapter->sessionId, pAdapter->device_mode));
13788
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013789 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13790 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013791 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013792 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013793 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013794 }
13795
Jeff Johnson295189b2012-06-20 16:38:30 -070013796 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013797 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013798 )
13799 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013800 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13801 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13802 if(pSapCtx == NULL){
13803 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13804 FL("psapCtx is NULL"));
13805 return -ENOENT;
13806 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013807 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070013808 {
13809 v_U16_t i;
13810 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
13811 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013812 if ((pSapCtx->aStaInfo[i].isUsed) &&
13813 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070013814 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013815 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013816 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013817 ETHER_ADDR_LEN);
13818
Jeff Johnson295189b2012-06-20 16:38:30 -070013819 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013820 "%s: Delete STA with MAC::"
13821 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013822 __func__,
13823 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
13824 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070013825 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013826 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013827 }
13828 }
13829 }
13830 else
13831 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013832
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013833 vos_status = hdd_softap_GetStaId(pAdapter,
13834 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013835 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13836 {
13837 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013838 "%s: Skip this DEL STA as this is not used::"
13839 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013840 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013841 return -ENOENT;
13842 }
13843
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013844 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013845 {
13846 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013847 "%s: Skip this DEL STA as deauth is in progress::"
13848 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013849 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013850 return -ENOENT;
13851 }
13852
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013853 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013854
Jeff Johnson295189b2012-06-20 16:38:30 -070013855 hddLog(VOS_TRACE_LEVEL_INFO,
13856 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013857 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013858 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013859 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013860
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013861 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013862 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13863 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013864 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013865 hddLog(VOS_TRACE_LEVEL_INFO,
13866 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013867 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013868 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013869 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013870 return -ENOENT;
13871 }
13872
Jeff Johnson295189b2012-06-20 16:38:30 -070013873 }
13874 }
13875
13876 EXIT();
13877
13878 return 0;
13879}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013880
13881#ifdef CFG80211_DEL_STA_V2
13882static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13883 struct net_device *dev,
13884 struct station_del_parameters *param)
13885#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013886static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13887 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013888#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013889{
13890 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013891 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070013892
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013893 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013894
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013895#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013896 if (NULL == param) {
13897 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013898 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013899 return -EINVAL;
13900 }
13901
13902 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
13903 param->subtype, &delStaParams);
13904
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013905#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053013906 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013907 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013908#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013909 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
13910
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013911 vos_ssr_unprotect(__func__);
13912
13913 return ret;
13914}
13915
13916static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013917 struct net_device *dev, u8 *mac, struct station_parameters *params)
13918{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013919 hdd_adapter_t *pAdapter;
13920 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013921 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013922#ifdef FEATURE_WLAN_TDLS
13923 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013924
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013925 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013926
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013927 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13928 if (NULL == pAdapter)
13929 {
13930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13931 "%s: Adapter is NULL",__func__);
13932 return -EINVAL;
13933 }
13934 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13935 status = wlan_hdd_validate_context(pHddCtx);
13936 if (0 != status)
13937 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013938 return status;
13939 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013940
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013941 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13942 TRACE_CODE_HDD_CFG80211_ADD_STA,
13943 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013944 mask = params->sta_flags_mask;
13945
13946 set = params->sta_flags_set;
13947
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053013948 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013949 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
13950 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013951
13952 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
13953 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013954 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013955 }
13956 }
13957#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013958 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013959 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013960}
13961
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013962static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
13963 struct net_device *dev, u8 *mac, struct station_parameters *params)
13964{
13965 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013966
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013967 vos_ssr_protect(__func__);
13968 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
13969 vos_ssr_unprotect(__func__);
13970
13971 return ret;
13972}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013973#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070013974
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013975static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070013976 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013977{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013978 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13979 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013980 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013981 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013982 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013983 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070013984
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013985 ENTER();
13986
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013987 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013988 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013989 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013990 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013991 return -EINVAL;
13992 }
13993
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013994 if (!pmksa) {
13995 hddLog(LOGE, FL("pmksa is NULL"));
13996 return -EINVAL;
13997 }
13998
13999 if (!pmksa->bssid || !pmksa->pmkid) {
14000 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
14001 pmksa->bssid, pmksa->pmkid);
14002 return -EINVAL;
14003 }
14004
14005 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
14006 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14007
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014008 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14009 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014010 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014011 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014012 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014013 }
14014
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014015 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014016 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14017
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014018 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
14019 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014020
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014021 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014022 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014023 &pmk_id, 1, FALSE);
14024
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014025 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14026 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
14027 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014028
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014029 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014030 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014031}
14032
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014033static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
14034 struct cfg80211_pmksa *pmksa)
14035{
14036 int ret;
14037
14038 vos_ssr_protect(__func__);
14039 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
14040 vos_ssr_unprotect(__func__);
14041
14042 return ret;
14043}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014044
Wilson Yang6507c4e2013-10-01 20:11:19 -070014045
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014046static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070014047 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014048{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014049 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14050 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014051 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014052 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014053
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014054 ENTER();
14055
Wilson Yang6507c4e2013-10-01 20:11:19 -070014056 /* Validate pAdapter */
14057 if (NULL == pAdapter)
14058 {
14059 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
14060 return -EINVAL;
14061 }
14062
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014063 if (!pmksa) {
14064 hddLog(LOGE, FL("pmksa is NULL"));
14065 return -EINVAL;
14066 }
14067
14068 if (!pmksa->bssid) {
14069 hddLog(LOGE, FL("pmksa->bssid is NULL"));
14070 return -EINVAL;
14071 }
14072
Kiet Lam98c46a12014-10-31 15:34:57 -070014073 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
14074 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14075
Wilson Yang6507c4e2013-10-01 20:11:19 -070014076 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14077 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014078 if (0 != status)
14079 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014080 return status;
14081 }
14082
14083 /*Retrieve halHandle*/
14084 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14085
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014086 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14087 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
14088 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014089 /* Delete the PMKID CSR cache */
14090 if (eHAL_STATUS_SUCCESS !=
14091 sme_RoamDelPMKIDfromCache(halHandle,
14092 pAdapter->sessionId, pmksa->bssid, FALSE)) {
14093 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
14094 MAC_ADDR_ARRAY(pmksa->bssid));
14095 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014096 }
14097
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014098 EXIT();
14099 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014100}
14101
Wilson Yang6507c4e2013-10-01 20:11:19 -070014102
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014103static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
14104 struct cfg80211_pmksa *pmksa)
14105{
14106 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014107
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014108 vos_ssr_protect(__func__);
14109 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
14110 vos_ssr_unprotect(__func__);
14111
14112 return ret;
14113
14114}
14115
14116static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014117{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014118 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14119 tHalHandle halHandle;
14120 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014121 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014122
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014123 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070014124
14125 /* Validate pAdapter */
14126 if (NULL == pAdapter)
14127 {
14128 hddLog(VOS_TRACE_LEVEL_ERROR,
14129 "%s: Invalid Adapter" ,__func__);
14130 return -EINVAL;
14131 }
14132
14133 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14134 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014135 if (0 != status)
14136 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014137 return status;
14138 }
14139
14140 /*Retrieve halHandle*/
14141 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14142
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014143 /* Flush the PMKID cache in CSR */
14144 if (eHAL_STATUS_SUCCESS !=
14145 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
14146 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
14147 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014148 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014149 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080014150 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014151}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014152
14153static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
14154{
14155 int ret;
14156
14157 vos_ssr_protect(__func__);
14158 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
14159 vos_ssr_unprotect(__func__);
14160
14161 return ret;
14162}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014163#endif
14164
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014165#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014166static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14167 struct net_device *dev,
14168 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014169{
14170 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14171 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014172 hdd_context_t *pHddCtx;
14173 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014174
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014175 ENTER();
14176
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014177 if (NULL == pAdapter)
14178 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014179 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014180 return -ENODEV;
14181 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014182 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14183 ret = wlan_hdd_validate_context(pHddCtx);
14184 if (0 != ret)
14185 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014186 return ret;
14187 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014188 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014189 if (NULL == pHddStaCtx)
14190 {
14191 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
14192 return -EINVAL;
14193 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014194
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014195 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14196 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
14197 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014198 // Added for debug on reception of Re-assoc Req.
14199 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
14200 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014201 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014202 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080014203 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014204 }
14205
14206#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080014207 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014208 ftie->ie_len);
14209#endif
14210
14211 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014212 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14213 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014214 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014215
14216 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014217 return 0;
14218}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014219
14220static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14221 struct net_device *dev,
14222 struct cfg80211_update_ft_ies_params *ftie)
14223{
14224 int ret;
14225
14226 vos_ssr_protect(__func__);
14227 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
14228 vos_ssr_unprotect(__func__);
14229
14230 return ret;
14231}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014232#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014233
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014234#ifdef FEATURE_WLAN_SCAN_PNO
14235
14236void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
14237 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
14238{
14239 int ret;
14240 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
14241 hdd_context_t *pHddCtx;
14242
Nirav Shah80830bf2013-12-31 16:35:12 +053014243 ENTER();
14244
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014245 if (NULL == pAdapter)
14246 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014247 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014248 "%s: HDD adapter is Null", __func__);
14249 return ;
14250 }
14251
14252 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14253 if (NULL == pHddCtx)
14254 {
14255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14256 "%s: HDD context is Null!!!", __func__);
14257 return ;
14258 }
14259
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014260 spin_lock(&pHddCtx->schedScan_lock);
14261 if (TRUE == pHddCtx->isWiphySuspended)
14262 {
14263 pHddCtx->isSchedScanUpdatePending = TRUE;
14264 spin_unlock(&pHddCtx->schedScan_lock);
14265 hddLog(VOS_TRACE_LEVEL_INFO,
14266 "%s: Update cfg80211 scan database after it resume", __func__);
14267 return ;
14268 }
14269 spin_unlock(&pHddCtx->schedScan_lock);
14270
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014271 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
14272
14273 if (0 > ret)
14274 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
14275
14276 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014277 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14278 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014279}
14280
14281/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014282 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014283 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014284 */
14285static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
14286{
14287 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
14288 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014289 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014290 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14291 int status = 0;
14292 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
14293
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014294 /* The current firmware design does not allow PNO during any
14295 * active sessions. Hence, determine the active sessions
14296 * and return a failure.
14297 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014298 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
14299 {
14300 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014301 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014302
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014303 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
14304 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
14305 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
14306 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
14307 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053014308 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014309 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014310 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014311 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014312 }
14313 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14314 pAdapterNode = pNext;
14315 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014316 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014317}
14318
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014319void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
14320{
14321 hdd_adapter_t *pAdapter = callbackContext;
14322 hdd_context_t *pHddCtx;
14323
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014324 ENTER();
14325
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014326 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
14327 {
14328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14329 FL("Invalid adapter or adapter has invalid magic"));
14330 return;
14331 }
14332
14333 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14334 if (0 != wlan_hdd_validate_context(pHddCtx))
14335 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014336 return;
14337 }
14338
c_hpothub53c45d2014-08-18 16:53:14 +053014339 if (VOS_STATUS_SUCCESS != status)
14340 {
14341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014342 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053014343 pHddCtx->isPnoEnable = FALSE;
14344 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014345
14346 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
14347 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014348 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014349}
14350
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014351/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014352 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
14353 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014354 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014355static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014356 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14357{
14358 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014359 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014360 hdd_context_t *pHddCtx;
14361 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014362 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053014363 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
14364 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014365 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14366 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014367 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014368 hdd_config_t *pConfig = NULL;
14369 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014370
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014371 ENTER();
14372
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014373 if (NULL == pAdapter)
14374 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014375 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014376 "%s: HDD adapter is Null", __func__);
14377 return -ENODEV;
14378 }
14379
14380 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014381 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014382
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014383 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014384 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014385 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014386 }
14387
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014388 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014389 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14390 if (NULL == hHal)
14391 {
14392 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14393 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014394 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014395 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014396 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14397 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
14398 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053014399 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014400 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053014401 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014402 {
14403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14404 "%s: aborting the existing scan is unsuccessfull", __func__);
14405 return -EBUSY;
14406 }
14407
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014408 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014409 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014411 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014412 return -EBUSY;
14413 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014414
c_hpothu37f21312014-04-09 21:49:54 +053014415 if (TRUE == pHddCtx->isPnoEnable)
14416 {
14417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14418 FL("already PNO is enabled"));
14419 return -EBUSY;
14420 }
c_hpothu225aa7c2014-10-22 17:45:13 +053014421
14422 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
14423 {
14424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14425 "%s: abort ROC failed ", __func__);
14426 return -EBUSY;
14427 }
14428
c_hpothu37f21312014-04-09 21:49:54 +053014429 pHddCtx->isPnoEnable = TRUE;
14430
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014431 pnoRequest.enable = 1; /*Enable PNO */
14432 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014433
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014434 if (( !pnoRequest.ucNetworksCount ) ||
14435 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014436 {
14437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014438 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014439 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014440 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014441 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014442 goto error;
14443 }
14444
14445 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
14446 {
14447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014448 "%s: Incorrect number of channels %d",
14449 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014450 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014451 goto error;
14452 }
14453
14454 /* Framework provides one set of channels(all)
14455 * common for all saved profile */
14456 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14457 channels_allowed, &num_channels_allowed))
14458 {
14459 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14460 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014461 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014462 goto error;
14463 }
14464 /* Checking each channel against allowed channel list */
14465 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053014466 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014467 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014468 char chList [(request->n_channels*5)+1];
14469 int len;
14470 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014471 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014472 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014473 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014474 if (request->channels[i]->hw_value == channels_allowed[indx])
14475 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014476 if ((!pConfig->enableDFSPnoChnlScan) &&
14477 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
14478 {
14479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14480 "%s : Dropping DFS channel : %d",
14481 __func__,channels_allowed[indx]);
14482 num_ignore_dfs_ch++;
14483 break;
14484 }
14485
Nirav Shah80830bf2013-12-31 16:35:12 +053014486 valid_ch[num_ch++] = request->channels[i]->hw_value;
14487 len += snprintf(chList+len, 5, "%d ",
14488 request->channels[i]->hw_value);
14489 break ;
14490 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014491 }
14492 }
Nirav Shah80830bf2013-12-31 16:35:12 +053014493 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014494
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014495 /*If all channels are DFS and dropped, then ignore the PNO request*/
14496 if (num_ignore_dfs_ch == request->n_channels)
14497 {
14498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14499 "%s : All requested channels are DFS channels", __func__);
14500 ret = -EINVAL;
14501 goto error;
14502 }
14503 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014504
14505 pnoRequest.aNetworks =
14506 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14507 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014508 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014509 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14510 FL("failed to allocate memory aNetworks %u"),
14511 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14512 goto error;
14513 }
14514 vos_mem_zero(pnoRequest.aNetworks,
14515 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14516
14517 /* Filling per profile params */
14518 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
14519 {
14520 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014521 request->match_sets[i].ssid.ssid_len;
14522
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014523 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
14524 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014525 {
14526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014527 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014528 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014529 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014530 goto error;
14531 }
14532
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014533 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014534 request->match_sets[i].ssid.ssid,
14535 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014536 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14537 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014538 i, pnoRequest.aNetworks[i].ssId.ssId);
14539 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
14540 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
14541 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014542
14543 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014544 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
14545 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014546
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014547 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014548 }
14549
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014550 for (i = 0; i < request->n_ssids; i++)
14551 {
14552 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014553 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014554 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014555 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014556 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014557 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014558 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014559 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014560 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014561 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014562 break;
14563 }
14564 j++;
14565 }
14566 }
14567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14568 "Number of hidden networks being Configured = %d",
14569 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014570 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080014571 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014572
14573 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14574 if (pnoRequest.p24GProbeTemplate == NULL)
14575 {
14576 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14577 FL("failed to allocate memory p24GProbeTemplate %u"),
14578 SIR_PNO_MAX_PB_REQ_SIZE);
14579 goto error;
14580 }
14581
14582 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14583 if (pnoRequest.p5GProbeTemplate == NULL)
14584 {
14585 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14586 FL("failed to allocate memory p5GProbeTemplate %u"),
14587 SIR_PNO_MAX_PB_REQ_SIZE);
14588 goto error;
14589 }
14590
14591 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14592 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14593
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053014594 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
14595 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014596 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014597 pnoRequest.us24GProbeTemplateLen = request->ie_len;
14598 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
14599 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014600
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014601 pnoRequest.us5GProbeTemplateLen = request->ie_len;
14602 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
14603 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014604 }
14605
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014606 /* Driver gets only one time interval which is hardcoded in
14607 * supplicant for 10000ms. Taking power consumption into account 6 timers
14608 * will be used, Timervalue is increased exponentially i.e 10,20,40,
14609 * 80,160,320 secs. And number of scan cycle for each timer
14610 * is configurable through INI param gPNOScanTimerRepeatValue.
14611 * If it is set to 0 only one timer will be used and PNO scan cycle
14612 * will be repeated after each interval specified by supplicant
14613 * till PNO is disabled.
14614 */
14615 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014616 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014617 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014618 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014619 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
14620
14621 tempInterval = (request->interval)/1000;
14622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14623 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
14624 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014625 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014626 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014627 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014628 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014629 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014630 tempInterval *= 2;
14631 }
14632 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014633 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014634
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014635 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014636
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014637 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014638 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
14639 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014640 pAdapter->pno_req_status = 0;
14641
Nirav Shah80830bf2013-12-31 16:35:12 +053014642 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14643 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014644 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
14645 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053014646
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014647 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014648 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014649 hdd_cfg80211_sched_scan_done_callback, pAdapter);
14650 if (eHAL_STATUS_SUCCESS != status)
14651 {
14652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014653 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014654 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014655 goto error;
14656 }
14657
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014658 ret = wait_for_completion_timeout(
14659 &pAdapter->pno_comp_var,
14660 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
14661 if (0 >= ret)
14662 {
14663 // Did not receive the response for PNO enable in time.
14664 // Assuming the PNO enable was success.
14665 // Returning error from here, because we timeout, results
14666 // in side effect of Wifi (Wifi Setting) not to work.
14667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14668 FL("Timed out waiting for PNO to be Enabled"));
14669 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014670 }
14671
14672 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053014673 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014674
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014675error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014676 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14677 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053014678 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014679 if (pnoRequest.aNetworks)
14680 vos_mem_free(pnoRequest.aNetworks);
14681 if (pnoRequest.p24GProbeTemplate)
14682 vos_mem_free(pnoRequest.p24GProbeTemplate);
14683 if (pnoRequest.p5GProbeTemplate)
14684 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014685
14686 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014687 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014688}
14689
14690/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014691 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
14692 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014693 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014694static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
14695 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14696{
14697 int ret;
14698
14699 vos_ssr_protect(__func__);
14700 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
14701 vos_ssr_unprotect(__func__);
14702
14703 return ret;
14704}
14705
14706/*
14707 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
14708 * Function to disable PNO
14709 */
14710static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014711 struct net_device *dev)
14712{
14713 eHalStatus status = eHAL_STATUS_FAILURE;
14714 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14715 hdd_context_t *pHddCtx;
14716 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014717 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014718 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014719
14720 ENTER();
14721
14722 if (NULL == pAdapter)
14723 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014724 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014725 "%s: HDD adapter is Null", __func__);
14726 return -ENODEV;
14727 }
14728
14729 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014730
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014731 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014732 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014733 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014734 "%s: HDD context is Null", __func__);
14735 return -ENODEV;
14736 }
14737
14738 /* The return 0 is intentional when isLogpInProgress and
14739 * isLoadUnloadInProgress. We did observe a crash due to a return of
14740 * failure in sched_scan_stop , especially for a case where the unload
14741 * of the happens at the same time. The function __cfg80211_stop_sched_scan
14742 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
14743 * success. If it returns a failure , then its next invocation due to the
14744 * clean up of the second interface will have the dev pointer corresponding
14745 * to the first one leading to a crash.
14746 */
14747 if (pHddCtx->isLogpInProgress)
14748 {
14749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14750 "%s: LOGP in Progress. Ignore!!!", __func__);
14751 return ret;
14752 }
14753
Mihir Shete18156292014-03-11 15:38:30 +053014754 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014755 {
14756 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14757 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14758 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014759 }
14760
14761 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14762 if (NULL == hHal)
14763 {
14764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14765 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014766 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014767 }
14768
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014769 pnoRequest.enable = 0; /* Disable PNO */
14770 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014771
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014772 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14773 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
14774 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014775 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014776 pAdapter->sessionId,
14777 NULL, pAdapter);
14778 if (eHAL_STATUS_SUCCESS != status)
14779 {
14780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14781 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014782 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014783 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014784 }
c_hpothu37f21312014-04-09 21:49:54 +053014785 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014786
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014787error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014788 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014789 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014790
14791 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014792 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014793}
14794
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014795/*
14796 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
14797 * NL interface to disable PNO
14798 */
14799static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
14800 struct net_device *dev)
14801{
14802 int ret;
14803
14804 vos_ssr_protect(__func__);
14805 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
14806 vos_ssr_unprotect(__func__);
14807
14808 return ret;
14809}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014810#endif /*FEATURE_WLAN_SCAN_PNO*/
14811
14812
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014813#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014814#if TDLS_MGMT_VERSION2
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014815static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014816 u8 *peer, u8 action_code, u8 dialog_token,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014817 u16 status_code, u32 peer_capability, const u8 *buf, size_t len)
14818#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014819static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014820 u8 *peer, u8 action_code, u8 dialog_token,
14821 u16 status_code, const u8 *buf, size_t len)
14822#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014823{
14824
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014825 hdd_adapter_t *pAdapter;
14826 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014827 u8 peerMac[6];
14828 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070014829 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080014830 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070014831 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014832 int ret;
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014833#if !(TDLS_MGMT_VERSION2)
14834 u32 peer_capability = 0;
14835#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014836 tANI_U16 numCurrTdlsPeers;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014837
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014838 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14839 if (NULL == pAdapter)
14840 {
14841 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14842 "%s: Adapter is NULL",__func__);
14843 return -EINVAL;
14844 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014845 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14846 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
14847 pAdapter->sessionId, action_code));
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014848 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014849 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014850 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014851 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014852 "Invalid arguments");
14853 return -EINVAL;
14854 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014855 if (pHddCtx->isLogpInProgress)
14856 {
14857 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14858 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053014859 wlan_hdd_tdls_set_link_status(pAdapter,
14860 peer,
14861 eTDLS_LINK_IDLE,
14862 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014863 return -EBUSY;
14864 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014865 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
14866 {
14867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14868 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14869 return -EAGAIN;
14870 }
Hoonki Lee27511902013-03-14 18:19:06 -070014871 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014872 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014873 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070014874 "%s: TDLS mode is disabled OR not enabled in FW."
14875 MAC_ADDRESS_STR " action %d declined.",
14876 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014877 return -ENOTSUPP;
14878 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014879
Hoonki Lee27511902013-03-14 18:19:06 -070014880 /* other than teardown frame, other mgmt frames are not sent if disabled */
14881 if (SIR_MAC_TDLS_TEARDOWN != action_code)
14882 {
14883 /* if tdls_mode is disabled to respond to peer's request */
14884 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
14885 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014886 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070014887 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014888 " TDLS mode is disabled. action %d declined.",
14889 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070014890
14891 return -ENOTSUPP;
14892 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053014893
14894 if (vos_max_concurrent_connections_reached())
14895 {
14896 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
14897 return -EINVAL;
14898 }
Hoonki Lee27511902013-03-14 18:19:06 -070014899 }
14900
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014901 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
14902 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053014903 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014904 {
14905 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014906 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014907 " TDLS setup is ongoing. action %d declined.",
14908 __func__, MAC_ADDR_ARRAY(peer), action_code);
14909 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014910 }
14911 }
14912
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014913 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
14914 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080014915 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014916 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
14917 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080014918 {
14919 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
14920 we return error code at 'add_station()'. Hence we have this
14921 check again in addtion to add_station().
14922 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014923 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080014924 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014925 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14926 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014927 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
14928 __func__, MAC_ADDR_ARRAY(peer), action_code,
14929 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053014930 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080014931 }
14932 else
14933 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014934 /* maximum reached. tweak to send error code to peer and return
14935 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080014936 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014937 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14938 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014939 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
14940 __func__, MAC_ADDR_ARRAY(peer), status_code,
14941 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070014942 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014943 /* fall through to send setup resp with failure status
14944 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080014945 }
14946 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014947 else
14948 {
14949 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053014950 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014951 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014952 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014953 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014954 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
14955 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014956 return -EPERM;
14957 }
14958 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014959 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014960 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014961
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014962 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053014963 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014964 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
14965 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014966
Hoonki Leea34dd892013-02-05 22:56:02 -080014967 /*Except teardown responder will not be used so just make 0*/
14968 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014969 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080014970 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014971
14972 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053014973 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014974
14975 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
14976 responder = pTdlsPeer->is_responder;
14977 else
Hoonki Leea34dd892013-02-05 22:56:02 -080014978 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014979 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053014980 "%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 -070014981 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
14982 dialog_token, status_code, len);
14983 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080014984 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014985 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014986
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014987 /* For explicit trigger of DIS_REQ come out of BMPS for
14988 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070014989 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014990 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
14991 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070014992 {
14993 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
14994 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014995 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014996 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014997 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
14998 if (status != VOS_STATUS_SUCCESS) {
14999 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
15000 }
Hoonki Lee14621352013-04-16 17:51:19 -070015001 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015002 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
15003 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED)) {
15004 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
15005 }
15006 }
Hoonki Lee14621352013-04-16 17:51:19 -070015007 }
15008
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015009 /* make sure doesn't call send_mgmt() while it is pending */
15010 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
15011 {
15012 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015013 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015014 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015015 ret = -EBUSY;
15016 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015017 }
15018
15019 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015020 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
15021
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015022 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053015023 peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015024
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015025 if (VOS_STATUS_SUCCESS != status)
15026 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15028 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015029 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015030 ret = -EINVAL;
15031 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015032 }
15033
Hoonki Leed37cbb32013-04-20 00:31:14 -070015034 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
15035 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
15036
15037 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015038 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070015039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070015040 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070015041 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015042 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080015043
15044 if (pHddCtx->isLogpInProgress)
15045 {
15046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15047 "%s: LOGP in Progress. Ignore!!!", __func__);
15048 return -EAGAIN;
15049 }
15050
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015051 ret = -EINVAL;
15052 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015053 }
15054
Gopichand Nakkala05922802013-03-14 12:23:19 -070015055 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070015056 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015057 ret = max_sta_failed;
15058 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070015059 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015060
Hoonki Leea34dd892013-02-05 22:56:02 -080015061 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
15062 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015063 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE)) {
15064 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15065 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015066 }
15067 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
15068 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015069 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE)) {
15070 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15071 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015072 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015073
15074 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015075
15076tx_failed:
15077 /* add_station will be called before sending TDLS_SETUP_REQ and
15078 * TDLS_SETUP_RSP and as part of add_station driver will enable
15079 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
15080 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
15081 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
15082 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
15083 */
15084
15085 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
15086 (SIR_MAC_TDLS_SETUP_RSP == action_code))
15087 wlan_hdd_tdls_check_bmps(pAdapter);
15088 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015089}
15090
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015091#if TDLS_MGMT_VERSION2
15092static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15093 u8 *peer, u8 action_code, u8 dialog_token,
15094 u16 status_code, u32 peer_capability,
15095 const u8 *buf, size_t len)
15096#else
15097static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15098 u8 *peer, u8 action_code, u8 dialog_token,
15099 u16 status_code, const u8 *buf, size_t len)
15100#endif
15101{
15102 int ret;
15103
15104 vos_ssr_protect(__func__);
15105#if TDLS_MGMT_VERSION2
15106 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, dialog_token,
15107 status_code, peer_capability, buf, len);
15108#else
15109 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, dialog_token,
15110 status_code, buf, len);
15111#endif
15112 vos_ssr_unprotect(__func__);
15113
15114 return ret;
15115}
Atul Mittal115287b2014-07-08 13:26:33 +053015116
15117int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
15118 u8 *peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015119 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053015120 cfg80211_exttdls_callback callback)
15121{
15122
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015123 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053015124 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015125 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053015126 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15127 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
15128 __func__, MAC_ADDR_ARRAY(peer));
15129
15130 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15131 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15132
15133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015134 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15135 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15136 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015137 return -ENOTSUPP;
15138 }
15139
15140 /* To cater the requirement of establishing the TDLS link
15141 * irrespective of the data traffic , get an entry of TDLS peer.
15142 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015143 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015144 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
15145 if (pTdlsPeer == NULL) {
15146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15147 "%s: peer " MAC_ADDRESS_STR " not existing",
15148 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015149 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015150 return -EINVAL;
15151 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015152 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015153
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015154 /* check FW TDLS Off Channel capability */
15155 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015156 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015157 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015158 {
15159 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
15160 pTdlsPeer->peerParams.global_operating_class =
15161 tdls_peer_params->global_operating_class;
15162 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
15163 pTdlsPeer->peerParams.min_bandwidth_kbps =
15164 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015165 /* check configured channel is valid, non dfs and
15166 * not current operating channel */
15167 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
15168 tdls_peer_params->channel)) &&
15169 (pHddStaCtx) &&
15170 (tdls_peer_params->channel !=
15171 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015172 {
15173 pTdlsPeer->isOffChannelConfigured = TRUE;
15174 }
15175 else
15176 {
15177 pTdlsPeer->isOffChannelConfigured = FALSE;
15178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15179 "%s: Configured Tdls Off Channel is not valid", __func__);
15180
15181 }
15182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015183 "%s: tdls_off_channel %d isOffChannelConfigured %d "
15184 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015185 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015186 pTdlsPeer->isOffChannelConfigured,
15187 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015188 }
15189 else
15190 {
15191 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015192 "%s: TDLS off channel FW capability %d, "
15193 "host capab %d or Invalid TDLS Peer Params", __func__,
15194 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
15195 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015196 }
15197
Atul Mittal115287b2014-07-08 13:26:33 +053015198 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
15199
15200 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15201 " %s TDLS Add Force Peer Failed",
15202 __func__);
15203 return -EINVAL;
15204 }
15205 /*EXT TDLS*/
15206
15207 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
15208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15209 " %s TDLS set callback Failed",
15210 __func__);
15211 return -EINVAL;
15212 }
15213
15214 return(0);
15215
15216}
15217
15218int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter, u8 *peer)
15219{
15220
15221 hddTdlsPeer_t *pTdlsPeer;
15222 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15224 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
15225 __func__, MAC_ADDR_ARRAY(peer));
15226
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015227 if (0 != wlan_hdd_validate_context(pHddCtx)) {
15228 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
15229 return -EINVAL;
15230 }
15231
Atul Mittal115287b2014-07-08 13:26:33 +053015232 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15233 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15234
15235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015236 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15237 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15238 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015239 return -ENOTSUPP;
15240 }
15241
15242
15243 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15244
15245 if ( NULL == pTdlsPeer ) {
15246 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015247 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053015248 __func__, MAC_ADDR_ARRAY(peer));
15249 return -EINVAL;
15250 }
15251 else {
15252 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
15253 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015254 /* if channel switch is configured, reset
15255 the channel for this peer */
15256 if (TRUE == pTdlsPeer->isOffChannelConfigured)
15257 {
15258 pTdlsPeer->peerParams.channel = 0;
15259 pTdlsPeer->isOffChannelConfigured = FALSE;
15260 }
Atul Mittal115287b2014-07-08 13:26:33 +053015261 }
15262
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015263 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
15264 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053015265 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015266 }
Atul Mittal115287b2014-07-08 13:26:33 +053015267
15268 /*EXT TDLS*/
15269
15270 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
15271
15272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15273 " %s TDLS set callback Failed",
15274 __func__);
15275 return -EINVAL;
15276 }
15277 return(0);
15278
15279}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015280static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015281 u8 *peer, enum nl80211_tdls_operation oper)
15282{
15283 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15284 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015285 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015286 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015287
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015288 ENTER();
15289
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015290 if (!pAdapter) {
15291 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15292 return -EINVAL;
15293 }
15294
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015295 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15296 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
15297 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015298 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015299 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015300 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070015301 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015302 return -EINVAL;
15303 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015304
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015305 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015306 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015307 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015308 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015309 }
15310
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015311
15312 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015313 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015314 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015315 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015316 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
15317 "Cannot process TDLS commands",
15318 pHddCtx->cfg_ini->fEnableTDLSSupport,
15319 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015320 return -ENOTSUPP;
15321 }
15322
15323 switch (oper) {
15324 case NL80211_TDLS_ENABLE_LINK:
15325 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015326 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015327 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015328 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053015329 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015330 tANI_U16 numCurrTdlsPeers = 0;
15331 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015332 tANI_U8 suppChannelLen = 0;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015333
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15335 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
15336 __func__, MAC_ADDR_ARRAY(peer));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015337 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015338 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015339 if ( NULL == pTdlsPeer ) {
15340 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15341 " (oper %d) not exsting. ignored",
15342 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15343 return -EINVAL;
15344 }
15345
15346 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15347 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15348 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15349 "NL80211_TDLS_ENABLE_LINK");
15350
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070015351 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
15352 {
15353 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
15354 MAC_ADDRESS_STR " failed",
15355 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
15356 return -EINVAL;
15357 }
15358
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015359 /* before starting tdls connection, set tdls
15360 * off channel established status to default value */
15361 pTdlsPeer->isOffChannelEstablished = FALSE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015362 /* TDLS Off Channel, Disable tdls channel switch,
15363 when there are more than one tdls link */
15364 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053015365 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015366 {
15367 /* get connected peer and send disable tdls off chan */
15368 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015369 if ((connPeer) &&
15370 (connPeer->isOffChannelSupported == TRUE) &&
15371 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015372 {
15373 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15374 "%s: More then one peer connected, Disable "
15375 "TDLS channel switch", __func__);
15376
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015377 connPeer->isOffChannelEstablished = FALSE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015378 ret = sme_SendTdlsChanSwitchReq(
15379 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015380 pAdapter->sessionId,
15381 connPeer->peerMac,
15382 connPeer->peerParams.channel,
15383 TDLS_OFF_CHANNEL_BW_OFFSET,
15384 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015385 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015386 hddLog(VOS_TRACE_LEVEL_ERROR,
15387 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015388 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015389 }
15390 else
15391 {
15392 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15393 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015394 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015395 "isOffChannelConfigured %d",
15396 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015397 (connPeer ? (connPeer->isOffChannelSupported)
15398 : -1),
15399 (connPeer ? (connPeer->isOffChannelConfigured)
15400 : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015401 }
15402 }
15403
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015404 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015405 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015406 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053015407
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015408 if (0 != wlan_hdd_tdls_get_link_establish_params(
15409 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015410 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015411 return -EINVAL;
15412 }
15413 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015414
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015415 ret = sme_SendTdlsLinkEstablishParams(
15416 WLAN_HDD_GET_HAL_CTX(pAdapter),
15417 pAdapter->sessionId, peer,
15418 &tdlsLinkEstablishParams);
15419 if (ret != VOS_STATUS_SUCCESS) {
15420 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
15421 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015422 /* Send TDLS peer UAPSD capabilities to the firmware and
15423 * register with the TL on after the response for this operation
15424 * is received .
15425 */
15426 ret = wait_for_completion_interruptible_timeout(
15427 &pAdapter->tdls_link_establish_req_comp,
15428 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
15429 if (ret <= 0)
15430 {
15431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015432 FL("Link Establish Request Failed Status %ld"),
15433 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015434 return -EINVAL;
15435 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015436 }
Atul Mittal115287b2014-07-08 13:26:33 +053015437 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15438 eTDLS_LINK_CONNECTED,
15439 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015440 staDesc.ucSTAId = pTdlsPeer->staId;
15441 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015442 ret = WLANTL_UpdateTdlsSTAClient(
15443 pHddCtx->pvosContext,
15444 &staDesc);
15445 if (ret != VOS_STATUS_SUCCESS) {
15446 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
15447 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053015448
Gopichand Nakkala471708b2013-06-04 20:03:01 +053015449 /* Mark TDLS client Authenticated .*/
15450 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
15451 pTdlsPeer->staId,
15452 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015453 if (VOS_STATUS_SUCCESS == status)
15454 {
Hoonki Lee14621352013-04-16 17:51:19 -070015455 if (pTdlsPeer->is_responder == 0)
15456 {
15457 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
15458
15459 wlan_hdd_tdls_timer_restart(pAdapter,
15460 &pTdlsPeer->initiatorWaitTimeoutTimer,
15461 WAIT_TIME_TDLS_INITIATOR);
15462 /* suspend initiator TX until it receives direct packet from the
15463 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015464 ret = WLANTL_SuspendDataTx(
15465 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15466 &staId, NULL);
15467 if (ret != VOS_STATUS_SUCCESS) {
15468 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
15469 }
Hoonki Lee14621352013-04-16 17:51:19 -070015470 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015471
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015472 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015473 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015474 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015475 suppChannelLen =
15476 tdlsLinkEstablishParams.supportedChannelsLen;
15477
15478 if ((suppChannelLen > 0) &&
15479 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
15480 {
15481 tANI_U8 suppPeerChannel = 0;
15482 int i = 0;
15483 for (i = 0U; i < suppChannelLen; i++)
15484 {
15485 suppPeerChannel =
15486 tdlsLinkEstablishParams.supportedChannels[i];
15487
15488 pTdlsPeer->isOffChannelSupported = FALSE;
15489 if (suppPeerChannel ==
15490 pTdlsPeer->peerParams.channel)
15491 {
15492 pTdlsPeer->isOffChannelSupported = TRUE;
15493 break;
15494 }
15495 }
15496 }
15497 else
15498 {
15499 pTdlsPeer->isOffChannelSupported = FALSE;
15500 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015501 }
15502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15503 "%s: TDLS channel switch request for channel "
15504 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015505 "%d isOffChannelSupported %d", __func__,
15506 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015507 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015508 suppChannelLen,
15509 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015510
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015511 /* TDLS Off Channel, Enable tdls channel switch,
15512 when their is only one tdls link and it supports */
15513 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15514 if ((numCurrTdlsPeers == 1) &&
15515 (TRUE == pTdlsPeer->isOffChannelSupported) &&
15516 (TRUE == pTdlsPeer->isOffChannelConfigured))
15517 {
15518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15519 "%s: Send TDLS channel switch request for channel %d",
15520 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015521
15522 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015523 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
15524 pAdapter->sessionId,
15525 pTdlsPeer->peerMac,
15526 pTdlsPeer->peerParams.channel,
15527 TDLS_OFF_CHANNEL_BW_OFFSET,
15528 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015529 if (ret != VOS_STATUS_SUCCESS) {
15530 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
15531 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015532 }
15533 else
15534 {
15535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15536 "%s: TDLS channel switch request not sent"
15537 " numCurrTdlsPeers %d "
15538 "isOffChannelSupported %d "
15539 "isOffChannelConfigured %d",
15540 __func__, numCurrTdlsPeers,
15541 pTdlsPeer->isOffChannelSupported,
15542 pTdlsPeer->isOffChannelConfigured);
15543 }
15544
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015545 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015546 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015547
15548 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015549 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
15550 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015551 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015552 int ac;
15553 uint8 ucAc[4] = { WLANTL_AC_VO,
15554 WLANTL_AC_VI,
15555 WLANTL_AC_BK,
15556 WLANTL_AC_BE };
15557 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
15558 for(ac=0; ac < 4; ac++)
15559 {
15560 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15561 pTdlsPeer->staId, ucAc[ac],
15562 tlTid[ac], tlTid[ac], 0, 0,
15563 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015564 if (status != VOS_STATUS_SUCCESS) {
15565 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
15566 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015567 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015568 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015569 }
15570
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015571 }
15572 break;
15573 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080015574 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015575 tANI_U16 numCurrTdlsPeers = 0;
15576 hddTdlsPeer_t *connPeer = NULL;
15577
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15579 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
15580 __func__, MAC_ADDR_ARRAY(peer));
15581
Sunil Dutt41de4e22013-11-14 18:09:02 +053015582 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15583
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015584
Sunil Dutt41de4e22013-11-14 18:09:02 +053015585 if ( NULL == pTdlsPeer ) {
15586 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15587 " (oper %d) not exsting. ignored",
15588 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15589 return -EINVAL;
15590 }
15591
15592 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15593 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15594 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15595 "NL80211_TDLS_DISABLE_LINK");
15596
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015597 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080015598 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015599 long status;
15600
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015601 /* set tdls off channel status to false for this peer */
15602 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053015603 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15604 eTDLS_LINK_TEARING,
15605 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
15606 eTDLS_LINK_UNSPECIFIED:
15607 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015608 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
15609
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015610 status = sme_DeleteTdlsPeerSta(
15611 WLAN_HDD_GET_HAL_CTX(pAdapter),
15612 pAdapter->sessionId, peer );
15613 if (status != VOS_STATUS_SUCCESS) {
15614 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15615 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015616
15617 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
15618 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053015619 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053015620 eTDLS_LINK_IDLE,
15621 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015622 if (status <= 0)
15623 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015624 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15625 "%s: Del station failed status %ld",
15626 __func__, status);
15627 return -EPERM;
15628 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015629
15630 /* TDLS Off Channel, Enable tdls channel switch,
15631 when their is only one tdls link and it supports */
15632 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15633 if (numCurrTdlsPeers == 1)
15634 {
15635 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15636 if ((connPeer) &&
15637 (connPeer->isOffChannelSupported == TRUE) &&
15638 (connPeer->isOffChannelConfigured == TRUE))
15639 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015640 connPeer->isOffChannelEstablished = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015641 status = sme_SendTdlsChanSwitchReq(
15642 WLAN_HDD_GET_HAL_CTX(pAdapter),
15643 pAdapter->sessionId,
15644 connPeer->peerMac,
15645 connPeer->peerParams.channel,
15646 TDLS_OFF_CHANNEL_BW_OFFSET,
15647 TDLS_CHANNEL_SWITCH_ENABLE);
15648 if (status != VOS_STATUS_SUCCESS) {
15649 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
15650 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015651 }
15652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15653 "%s: TDLS channel switch "
15654 "isOffChannelSupported %d "
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015655 "isOffChannelConfigured %d "
15656 "isOffChannelEstablished %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015657 __func__,
15658 (connPeer ? connPeer->isOffChannelSupported : -1),
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015659 (connPeer ? connPeer->isOffChannelConfigured : -1),
15660 (connPeer ? connPeer->isOffChannelEstablished : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015661 }
15662 else
15663 {
15664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15665 "%s: TDLS channel switch request not sent "
15666 "numCurrTdlsPeers %d ",
15667 __func__, numCurrTdlsPeers);
15668 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015669 }
15670 else
15671 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15673 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080015674 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015675 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015676 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015677 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015678 {
Atul Mittal115287b2014-07-08 13:26:33 +053015679 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015680
Atul Mittal115287b2014-07-08 13:26:33 +053015681 if (0 != status)
15682 {
15683 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015684 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053015685 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015686 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053015687 break;
15688 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015689 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015690 {
Atul Mittal115287b2014-07-08 13:26:33 +053015691 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
15692 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015693 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053015694 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015695
Atul Mittal115287b2014-07-08 13:26:33 +053015696 if (0 != status)
15697 {
15698 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015699 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053015700 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053015701 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053015702 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015703 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015704 case NL80211_TDLS_DISCOVERY_REQ:
15705 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015706 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015707 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015708 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015709 return -ENOTSUPP;
15710 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015711 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15712 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015713 return -ENOTSUPP;
15714 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015715
15716 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015717 return 0;
15718}
Chilam NG571c65a2013-01-19 12:27:36 +053015719
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015720static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
15721 u8 *peer, enum nl80211_tdls_operation oper)
15722{
15723 int ret;
15724
15725 vos_ssr_protect(__func__);
15726 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
15727 vos_ssr_unprotect(__func__);
15728
15729 return ret;
15730}
15731
Chilam NG571c65a2013-01-19 12:27:36 +053015732int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
15733 struct net_device *dev, u8 *peer)
15734{
Arif Hussaina7c8e412013-11-20 11:06:42 -080015735 hddLog(VOS_TRACE_LEVEL_INFO,
15736 "tdls send discover req: "MAC_ADDRESS_STR,
15737 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053015738
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015739#if TDLS_MGMT_VERSION2
15740 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15741 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
15742#else
Chilam NG571c65a2013-01-19 12:27:36 +053015743 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15744 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015745#endif
Chilam NG571c65a2013-01-19 12:27:36 +053015746}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015747#endif
15748
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015749#ifdef WLAN_FEATURE_GTK_OFFLOAD
15750/*
15751 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
15752 * Callback rountine called upon receiving response for
15753 * get offload info
15754 */
15755void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
15756 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
15757{
15758
15759 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015760 tANI_U8 tempReplayCounter[8];
15761 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015762
15763 ENTER();
15764
15765 if (NULL == pAdapter)
15766 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053015767 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015768 "%s: HDD adapter is Null", __func__);
15769 return ;
15770 }
15771
15772 if (NULL == pGtkOffloadGetInfoRsp)
15773 {
15774 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15775 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
15776 return ;
15777 }
15778
15779 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
15780 {
15781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15782 "%s: wlan Failed to get replay counter value",
15783 __func__);
15784 return ;
15785 }
15786
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015787 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15788 /* Update replay counter */
15789 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
15790 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
15791
15792 {
15793 /* changing from little to big endian since supplicant
15794 * works on big endian format
15795 */
15796 int i;
15797 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
15798
15799 for (i = 0; i < 8; i++)
15800 {
15801 tempReplayCounter[7-i] = (tANI_U8)p[i];
15802 }
15803 }
15804
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015805 /* Update replay counter to NL */
15806 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015807 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015808}
15809
15810/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015811 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015812 * This function is used to offload GTK rekeying job to the firmware.
15813 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015814int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015815 struct cfg80211_gtk_rekey_data *data)
15816{
15817 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15818 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
15819 hdd_station_ctx_t *pHddStaCtx;
15820 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015821 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015822 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015823 eHalStatus status = eHAL_STATUS_FAILURE;
15824
15825 ENTER();
15826
15827 if (NULL == pAdapter)
15828 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015829 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015830 "%s: HDD adapter is Null", __func__);
15831 return -ENODEV;
15832 }
15833
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015834 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15835 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
15836 pAdapter->sessionId, pAdapter->device_mode));
15837
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015838 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015839 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015840 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015841 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015842 }
15843
15844 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15845 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
15846 if (NULL == hHal)
15847 {
15848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15849 "%s: HAL context is Null!!!", __func__);
15850 return -EAGAIN;
15851 }
15852
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015853 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
15854 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
15855 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
15856 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015857 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015858 {
15859 /* changing from big to little endian since driver
15860 * works on little endian format
15861 */
15862 tANI_U8 *p =
15863 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
15864 int i;
15865
15866 for (i = 0; i < 8; i++)
15867 {
15868 p[7-i] = data->replay_ctr[i];
15869 }
15870 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015871
15872 if (TRUE == pHddCtx->hdd_wlan_suspended)
15873 {
15874 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015875 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
15876 sizeof (tSirGtkOffloadParams));
15877 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015878 pAdapter->sessionId);
15879
15880 if (eHAL_STATUS_SUCCESS != status)
15881 {
15882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15883 "%s: sme_SetGTKOffload failed, returned %d",
15884 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053015885
15886 /* Need to clear any trace of key value in the memory.
15887 * Thus zero out the memory even though it is local
15888 * variable.
15889 */
15890 vos_mem_zero(&hddGtkOffloadReqParams,
15891 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015892 return status;
15893 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015894 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15895 "%s: sme_SetGTKOffload successfull", __func__);
15896 }
15897 else
15898 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15900 "%s: wlan not suspended GTKOffload request is stored",
15901 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015902 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015903
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053015904 /* Need to clear any trace of key value in the memory.
15905 * Thus zero out the memory even though it is local
15906 * variable.
15907 */
15908 vos_mem_zero(&hddGtkOffloadReqParams,
15909 sizeof(hddGtkOffloadReqParams));
15910
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015911 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015912 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015913}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015914
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015915int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
15916 struct cfg80211_gtk_rekey_data *data)
15917{
15918 int ret;
15919
15920 vos_ssr_protect(__func__);
15921 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
15922 vos_ssr_unprotect(__func__);
15923
15924 return ret;
15925}
15926#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015927/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015928 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015929 * This function is used to set access control policy
15930 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015931static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
15932 struct net_device *dev,
15933 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015934{
15935 int i;
15936 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15937 hdd_hostapd_state_t *pHostapdState;
15938 tsap_Config_t *pConfig;
15939 v_CONTEXT_t pVosContext = NULL;
15940 hdd_context_t *pHddCtx;
15941 int status;
15942
15943 ENTER();
15944
15945 if (NULL == pAdapter)
15946 {
15947 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15948 "%s: HDD adapter is Null", __func__);
15949 return -ENODEV;
15950 }
15951
15952 if (NULL == params)
15953 {
15954 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15955 "%s: params is Null", __func__);
15956 return -EINVAL;
15957 }
15958
15959 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15960 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015961 if (0 != status)
15962 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015963 return status;
15964 }
15965
15966 pVosContext = pHddCtx->pvosContext;
15967 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
15968
15969 if (NULL == pHostapdState)
15970 {
15971 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15972 "%s: pHostapdState is Null", __func__);
15973 return -EINVAL;
15974 }
15975
15976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
15977 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053015978 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15979 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
15980 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015981
15982 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
15983 {
15984 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
15985
15986 /* default value */
15987 pConfig->num_accept_mac = 0;
15988 pConfig->num_deny_mac = 0;
15989
15990 /**
15991 * access control policy
15992 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
15993 * listed in hostapd.deny file.
15994 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
15995 * listed in hostapd.accept file.
15996 */
15997 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
15998 {
15999 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
16000 }
16001 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
16002 {
16003 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
16004 }
16005 else
16006 {
16007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16008 "%s:Acl Policy : %d is not supported",
16009 __func__, params->acl_policy);
16010 return -ENOTSUPP;
16011 }
16012
16013 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
16014 {
16015 pConfig->num_accept_mac = params->n_acl_entries;
16016 for (i = 0; i < params->n_acl_entries; i++)
16017 {
16018 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16019 "** Add ACL MAC entry %i in WhiletList :"
16020 MAC_ADDRESS_STR, i,
16021 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16022
16023 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
16024 sizeof(qcmacaddr));
16025 }
16026 }
16027 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
16028 {
16029 pConfig->num_deny_mac = params->n_acl_entries;
16030 for (i = 0; i < params->n_acl_entries; i++)
16031 {
16032 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16033 "** Add ACL MAC entry %i in BlackList :"
16034 MAC_ADDRESS_STR, i,
16035 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16036
16037 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
16038 sizeof(qcmacaddr));
16039 }
16040 }
16041
16042 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
16043 {
16044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16045 "%s: SAP Set Mac Acl fail", __func__);
16046 return -EINVAL;
16047 }
16048 }
16049 else
16050 {
16051 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053016052 "%s: Invalid device_mode = %s (%d)",
16053 __func__, hdd_device_modetoString(pAdapter->device_mode),
16054 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016055 return -EINVAL;
16056 }
16057
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016058 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016059 return 0;
16060}
16061
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016062static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16063 struct net_device *dev,
16064 const struct cfg80211_acl_data *params)
16065{
16066 int ret;
16067 vos_ssr_protect(__func__);
16068 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
16069 vos_ssr_unprotect(__func__);
16070
16071 return ret;
16072}
16073
Leo Chang9056f462013-08-01 19:21:11 -070016074#ifdef WLAN_NL80211_TESTMODE
16075#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070016076void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070016077(
16078 void *pAdapter,
16079 void *indCont
16080)
16081{
Leo Changd9df8aa2013-09-26 13:32:26 -070016082 tSirLPHBInd *lphbInd;
16083 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053016084 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070016085
16086 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016087 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070016088
c_hpothu73f35e62014-04-18 13:40:08 +053016089 if (pAdapter == NULL)
16090 {
16091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16092 "%s: pAdapter is NULL\n",__func__);
16093 return;
16094 }
16095
Leo Chang9056f462013-08-01 19:21:11 -070016096 if (NULL == indCont)
16097 {
16098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016099 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070016100 return;
16101 }
16102
c_hpothu73f35e62014-04-18 13:40:08 +053016103 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070016104 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070016105 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053016106 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070016107 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070016108 GFP_ATOMIC);
16109 if (!skb)
16110 {
16111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16112 "LPHB timeout, NL buffer alloc fail");
16113 return;
16114 }
16115
Leo Changac3ba772013-10-07 09:47:04 -070016116 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070016117 {
16118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16119 "WLAN_HDD_TM_ATTR_CMD put fail");
16120 goto nla_put_failure;
16121 }
Leo Changac3ba772013-10-07 09:47:04 -070016122 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070016123 {
16124 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16125 "WLAN_HDD_TM_ATTR_TYPE put fail");
16126 goto nla_put_failure;
16127 }
Leo Changac3ba772013-10-07 09:47:04 -070016128 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070016129 sizeof(tSirLPHBInd), lphbInd))
16130 {
16131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16132 "WLAN_HDD_TM_ATTR_DATA put fail");
16133 goto nla_put_failure;
16134 }
Leo Chang9056f462013-08-01 19:21:11 -070016135 cfg80211_testmode_event(skb, GFP_ATOMIC);
16136 return;
16137
16138nla_put_failure:
16139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16140 "NLA Put fail");
16141 kfree_skb(skb);
16142
16143 return;
16144}
16145#endif /* FEATURE_WLAN_LPHB */
16146
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016147static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070016148{
16149 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
16150 int err = 0;
16151#ifdef FEATURE_WLAN_LPHB
16152 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070016153 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016154
16155 ENTER();
16156
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016157 err = wlan_hdd_validate_context(pHddCtx);
16158 if (0 != err)
16159 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016160 return err;
16161 }
Leo Chang9056f462013-08-01 19:21:11 -070016162#endif /* FEATURE_WLAN_LPHB */
16163
16164 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
16165 if (err)
16166 {
16167 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16168 "%s Testmode INV ATTR", __func__);
16169 return err;
16170 }
16171
16172 if (!tb[WLAN_HDD_TM_ATTR_CMD])
16173 {
16174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16175 "%s Testmode INV CMD", __func__);
16176 return -EINVAL;
16177 }
16178
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016179 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16180 TRACE_CODE_HDD_CFG80211_TESTMODE,
16181 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070016182 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
16183 {
16184#ifdef FEATURE_WLAN_LPHB
16185 /* Low Power Heartbeat configuration request */
16186 case WLAN_HDD_TM_CMD_WLAN_HB:
16187 {
16188 int buf_len;
16189 void *buf;
16190 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080016191 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070016192
16193 if (!tb[WLAN_HDD_TM_ATTR_DATA])
16194 {
16195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16196 "%s Testmode INV DATA", __func__);
16197 return -EINVAL;
16198 }
16199
16200 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
16201 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080016202
16203 hb_params_temp =(tSirLPHBReq *)buf;
16204 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
16205 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
16206 return -EINVAL;
16207
Leo Chang9056f462013-08-01 19:21:11 -070016208 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
16209 if (NULL == hb_params)
16210 {
16211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16212 "%s Request Buffer Alloc Fail", __func__);
16213 return -EINVAL;
16214 }
16215
16216 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070016217 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
16218 hb_params,
16219 wlan_hdd_cfg80211_lphb_ind_handler);
16220 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070016221 {
Leo Changd9df8aa2013-09-26 13:32:26 -070016222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16223 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070016224 vos_mem_free(hb_params);
16225 }
Leo Chang9056f462013-08-01 19:21:11 -070016226 return 0;
16227 }
16228#endif /* FEATURE_WLAN_LPHB */
16229 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16231 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070016232 return -EOPNOTSUPP;
16233 }
16234
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016235 EXIT();
16236 return err;
Leo Chang9056f462013-08-01 19:21:11 -070016237}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016238
16239static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
16240{
16241 int ret;
16242
16243 vos_ssr_protect(__func__);
16244 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
16245 vos_ssr_unprotect(__func__);
16246
16247 return ret;
16248}
Leo Chang9056f462013-08-01 19:21:11 -070016249#endif /* CONFIG_NL80211_TESTMODE */
16250
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016251static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016252 struct net_device *dev,
16253 int idx, struct survey_info *survey)
16254{
16255 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16256 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053016257 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016258 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053016259 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016260 v_S7_t snr,rssi;
16261 int status, i, j, filled = 0;
16262
16263 ENTER();
16264
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016265 if (NULL == pAdapter)
16266 {
16267 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16268 "%s: HDD adapter is Null", __func__);
16269 return -ENODEV;
16270 }
16271
16272 if (NULL == wiphy)
16273 {
16274 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16275 "%s: wiphy is Null", __func__);
16276 return -ENODEV;
16277 }
16278
16279 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16280 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016281 if (0 != status)
16282 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016283 return status;
16284 }
16285
Mihir Sheted9072e02013-08-21 17:02:29 +053016286 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16287
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016288 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053016289 0 != pAdapter->survey_idx ||
16290 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016291 {
16292 /* The survey dump ops when implemented completely is expected to
16293 * return a survey of all channels and the ops is called by the
16294 * kernel with incremental values of the argument 'idx' till it
16295 * returns -ENONET. But we can only support the survey for the
16296 * operating channel for now. survey_idx is used to track
16297 * that the ops is called only once and then return -ENONET for
16298 * the next iteration
16299 */
16300 pAdapter->survey_idx = 0;
16301 return -ENONET;
16302 }
16303
Mukul Sharma9d5233b2015-06-11 20:28:20 +053016304 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
16305 {
16306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16307 "%s: Roaming in progress, hence return ", __func__);
16308 return -ENONET;
16309 }
16310
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016311 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16312
16313 wlan_hdd_get_snr(pAdapter, &snr);
16314 wlan_hdd_get_rssi(pAdapter, &rssi);
16315
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016316 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16317 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
16318 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016319 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
16320 hdd_wlan_get_freq(channel, &freq);
16321
16322
16323 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
16324 {
16325 if (NULL == wiphy->bands[i])
16326 {
16327 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
16328 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
16329 continue;
16330 }
16331
16332 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
16333 {
16334 struct ieee80211_supported_band *band = wiphy->bands[i];
16335
16336 if (band->channels[j].center_freq == (v_U16_t)freq)
16337 {
16338 survey->channel = &band->channels[j];
16339 /* The Rx BDs contain SNR values in dB for the received frames
16340 * while the supplicant expects noise. So we calculate and
16341 * return the value of noise (dBm)
16342 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
16343 */
16344 survey->noise = rssi - snr;
16345 survey->filled = SURVEY_INFO_NOISE_DBM;
16346 filled = 1;
16347 }
16348 }
16349 }
16350
16351 if (filled)
16352 pAdapter->survey_idx = 1;
16353 else
16354 {
16355 pAdapter->survey_idx = 0;
16356 return -ENONET;
16357 }
16358
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016359 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016360 return 0;
16361}
16362
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016363static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
16364 struct net_device *dev,
16365 int idx, struct survey_info *survey)
16366{
16367 int ret;
16368
16369 vos_ssr_protect(__func__);
16370 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
16371 vos_ssr_unprotect(__func__);
16372
16373 return ret;
16374}
16375
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016376/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016377 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016378 * this is called when cfg80211 driver resume
16379 * driver updates latest sched_scan scan result(if any) to cfg80211 database
16380 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016381int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016382{
16383 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16384 hdd_adapter_t *pAdapter;
16385 hdd_adapter_list_node_t *pAdapterNode, *pNext;
16386 VOS_STATUS status = VOS_STATUS_SUCCESS;
16387
16388 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016389
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016390 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016391 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016392 return 0;
16393 }
16394
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016395 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
16396 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016397 spin_lock(&pHddCtx->schedScan_lock);
16398 pHddCtx->isWiphySuspended = FALSE;
16399 if (TRUE != pHddCtx->isSchedScanUpdatePending)
16400 {
16401 spin_unlock(&pHddCtx->schedScan_lock);
16402 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16403 "%s: Return resume is not due to PNO indication", __func__);
16404 return 0;
16405 }
16406 // Reset flag to avoid updatating cfg80211 data old results again
16407 pHddCtx->isSchedScanUpdatePending = FALSE;
16408 spin_unlock(&pHddCtx->schedScan_lock);
16409
16410 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
16411
16412 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
16413 {
16414 pAdapter = pAdapterNode->pAdapter;
16415 if ( (NULL != pAdapter) &&
16416 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
16417 {
16418 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016419 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16421 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016422 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016423 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016424 {
16425 /* Acquire wakelock to handle the case where APP's tries to
16426 * suspend immediately after updating the scan results. Whis
16427 * results in app's is in suspended state and not able to
16428 * process the connect request to AP
16429 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053016430 hdd_prevent_suspend_timeout(2000,
16431 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016432 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016433 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016434
16435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16436 "%s : cfg80211 scan result database updated", __func__);
16437
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016438 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016439 return 0;
16440
16441 }
16442 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16443 pAdapterNode = pNext;
16444 }
16445
16446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16447 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016448 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016449 return 0;
16450}
16451
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016452int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
16453{
16454 int ret;
16455
16456 vos_ssr_protect(__func__);
16457 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
16458 vos_ssr_unprotect(__func__);
16459
16460 return ret;
16461}
16462
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016463/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016464 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016465 * this is called when cfg80211 driver suspends
16466 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016467int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016468 struct cfg80211_wowlan *wow)
16469{
16470 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016471 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016472
16473 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016474
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016475 ret = wlan_hdd_validate_context(pHddCtx);
16476 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016477 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016478 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016479 }
16480
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016481
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016482 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16483 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
16484 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016485 pHddCtx->isWiphySuspended = TRUE;
16486
16487 EXIT();
16488
16489 return 0;
16490}
16491
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016492int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
16493 struct cfg80211_wowlan *wow)
16494{
16495 int ret;
16496
16497 vos_ssr_protect(__func__);
16498 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
16499 vos_ssr_unprotect(__func__);
16500
16501 return ret;
16502}
Jeff Johnson295189b2012-06-20 16:38:30 -070016503/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016504static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070016505{
16506 .add_virtual_intf = wlan_hdd_add_virtual_intf,
16507 .del_virtual_intf = wlan_hdd_del_virtual_intf,
16508 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
16509 .change_station = wlan_hdd_change_station,
16510#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
16511 .add_beacon = wlan_hdd_cfg80211_add_beacon,
16512 .del_beacon = wlan_hdd_cfg80211_del_beacon,
16513 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016514#else
16515 .start_ap = wlan_hdd_cfg80211_start_ap,
16516 .change_beacon = wlan_hdd_cfg80211_change_beacon,
16517 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070016518#endif
16519 .change_bss = wlan_hdd_cfg80211_change_bss,
16520 .add_key = wlan_hdd_cfg80211_add_key,
16521 .get_key = wlan_hdd_cfg80211_get_key,
16522 .del_key = wlan_hdd_cfg80211_del_key,
16523 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016524#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070016525 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016526#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016527 .scan = wlan_hdd_cfg80211_scan,
16528 .connect = wlan_hdd_cfg80211_connect,
16529 .disconnect = wlan_hdd_cfg80211_disconnect,
16530 .join_ibss = wlan_hdd_cfg80211_join_ibss,
16531 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
16532 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
16533 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
16534 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070016535 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
16536 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053016537 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070016538#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16539 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
16540 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
16541 .set_txq_params = wlan_hdd_set_txq_params,
16542#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016543 .get_station = wlan_hdd_cfg80211_get_station,
16544 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
16545 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016546 .add_station = wlan_hdd_cfg80211_add_station,
16547#ifdef FEATURE_WLAN_LFR
16548 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
16549 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
16550 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
16551#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016552#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
16553 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
16554#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016555#ifdef FEATURE_WLAN_TDLS
16556 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
16557 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
16558#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016559#ifdef WLAN_FEATURE_GTK_OFFLOAD
16560 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
16561#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016562#ifdef FEATURE_WLAN_SCAN_PNO
16563 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
16564 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
16565#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016566 .resume = wlan_hdd_cfg80211_resume_wlan,
16567 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016568 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070016569#ifdef WLAN_NL80211_TESTMODE
16570 .testmode_cmd = wlan_hdd_cfg80211_testmode,
16571#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016572 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070016573};
16574