blob: ab23e734d7eee2deeb4282d593125c019e90acbd [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +053026 *
Kiet Lamaa8e15a2014-02-11 23:30:06 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Kiet Lama7f454d2014-07-24 12:04:06 -070030
31
Jeff Johnson295189b2012-06-20 16:38:30 -070032/**========================================================================
33
34 \file wlan_hdd_cfg80211.c
35
36 \brief WLAN Host Device Driver implementation
37
Jeff Johnson295189b2012-06-20 16:38:30 -070038 ========================================================================*/
39
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070040/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070041
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070042 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070043
44
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070045 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070047
48
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070049 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070050
51
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070052 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070053 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070054 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070055
56 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070057 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070058 ==========================================================================*/
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060
61#include <linux/version.h>
62#include <linux/module.h>
63#include <linux/kernel.h>
64#include <linux/init.h>
65#include <linux/wireless.h>
66#include <wlan_hdd_includes.h>
67#include <net/arp.h>
68#include <net/cfg80211.h>
69#include <linux/wireless.h>
70#include <wlan_hdd_wowl.h>
71#include <aniGlobal.h>
72#include "ccmApi.h"
73#include "sirParams.h"
74#include "dot11f.h"
75#include "wlan_hdd_assoc.h"
76#include "wlan_hdd_wext.h"
77#include "sme_Api.h"
78#include "wlan_hdd_p2p.h"
79#include "wlan_hdd_cfg80211.h"
80#include "wlan_hdd_hostapd.h"
81#include "sapInternal.h"
82#include "wlan_hdd_softap_tx_rx.h"
83#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053084#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053085#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053086#include "wlan_hdd_trace.h"
87#include "vos_types.h"
88#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070089#ifdef WLAN_BTAMP_FEATURE
90#include "bap_hdd_misc.h"
91#endif
92#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080093#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053094#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053095#include "wlan_qct_wda.h"
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053096#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070097#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070098
99#define g_mode_rates_size (12)
100#define a_mode_rates_size (8)
101#define FREQ_BASE_80211G (2407)
102#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700103#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530104#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800106 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
108#define HDD2GHZCHAN(freq, chan, flag) { \
109 .band = IEEE80211_BAND_2GHZ, \
110 .center_freq = (freq), \
111 .hw_value = (chan),\
112 .flags = (flag), \
113 .max_antenna_gain = 0 ,\
114 .max_power = 30, \
115}
116
117#define HDD5GHZCHAN(freq, chan, flag) { \
118 .band = IEEE80211_BAND_5GHZ, \
119 .center_freq = (freq), \
120 .hw_value = (chan),\
121 .flags = (flag), \
122 .max_antenna_gain = 0 ,\
123 .max_power = 30, \
124}
125
126#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
127{\
128 .bitrate = rate, \
129 .hw_value = rate_id, \
130 .flags = flag, \
131}
132
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530133#ifdef WLAN_FEATURE_VOWIFI_11R
134#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
135#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
136#endif
137
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530138#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530139#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530140
Sunil Duttc69bccb2014-05-26 21:30:20 +0530141#ifdef WLAN_FEATURE_LINK_LAYER_STATS
142/*
143 * Used to allocate the size of 4096 for the link layer stats.
144 * The size of 4096 is considered assuming that all data per
145 * respective event fit with in the limit.Please take a call
146 * on the limit based on the data requirements on link layer
147 * statistics.
148 */
149#define LL_STATS_EVENT_BUF_SIZE 4096
150#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530151#ifdef WLAN_FEATURE_EXTSCAN
152/*
153 * Used to allocate the size of 4096 for the EXTScan NL data.
154 * The size of 4096 is considered assuming that all data per
155 * respective event fit with in the limit.Please take a call
156 * on the limit based on the data requirements.
157 */
158
159#define EXTSCAN_EVENT_BUF_SIZE 4096
160#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
161#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530162
Atul Mittal115287b2014-07-08 13:26:33 +0530163/*EXT TDLS*/
164/*
165 * Used to allocate the size of 4096 for the TDLS.
166 * The size of 4096 is considered assuming that all data per
167 * respective event fit with in the limit.Please take a call
168 * on the limit based on the data requirements on link layer
169 * statistics.
170 */
171#define EXTTDLS_EVENT_BUF_SIZE 4096
172
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530173static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700174{
175 WLAN_CIPHER_SUITE_WEP40,
176 WLAN_CIPHER_SUITE_WEP104,
177 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800178#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700179#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
180 WLAN_CIPHER_SUITE_KRK,
181 WLAN_CIPHER_SUITE_CCMP,
182#else
183 WLAN_CIPHER_SUITE_CCMP,
184#endif
185#ifdef FEATURE_WLAN_WAPI
186 WLAN_CIPHER_SUITE_SMS4,
187#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700188#ifdef WLAN_FEATURE_11W
189 WLAN_CIPHER_SUITE_AES_CMAC,
190#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700191};
192
193static inline int is_broadcast_ether_addr(const u8 *addr)
194{
195 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
196 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
197}
198
199static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530200{
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 HDD2GHZCHAN(2412, 1, 0) ,
202 HDD2GHZCHAN(2417, 2, 0) ,
203 HDD2GHZCHAN(2422, 3, 0) ,
204 HDD2GHZCHAN(2427, 4, 0) ,
205 HDD2GHZCHAN(2432, 5, 0) ,
206 HDD2GHZCHAN(2437, 6, 0) ,
207 HDD2GHZCHAN(2442, 7, 0) ,
208 HDD2GHZCHAN(2447, 8, 0) ,
209 HDD2GHZCHAN(2452, 9, 0) ,
210 HDD2GHZCHAN(2457, 10, 0) ,
211 HDD2GHZCHAN(2462, 11, 0) ,
212 HDD2GHZCHAN(2467, 12, 0) ,
213 HDD2GHZCHAN(2472, 13, 0) ,
214 HDD2GHZCHAN(2484, 14, 0) ,
215};
216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
218{
219 HDD2GHZCHAN(2412, 1, 0) ,
220 HDD2GHZCHAN(2437, 6, 0) ,
221 HDD2GHZCHAN(2462, 11, 0) ,
222};
Jeff Johnson295189b2012-06-20 16:38:30 -0700223
224static struct ieee80211_channel hdd_channels_5_GHZ[] =
225{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700226 HDD5GHZCHAN(4920, 240, 0) ,
227 HDD5GHZCHAN(4940, 244, 0) ,
228 HDD5GHZCHAN(4960, 248, 0) ,
229 HDD5GHZCHAN(4980, 252, 0) ,
230 HDD5GHZCHAN(5040, 208, 0) ,
231 HDD5GHZCHAN(5060, 212, 0) ,
232 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 HDD5GHZCHAN(5180, 36, 0) ,
234 HDD5GHZCHAN(5200, 40, 0) ,
235 HDD5GHZCHAN(5220, 44, 0) ,
236 HDD5GHZCHAN(5240, 48, 0) ,
237 HDD5GHZCHAN(5260, 52, 0) ,
238 HDD5GHZCHAN(5280, 56, 0) ,
239 HDD5GHZCHAN(5300, 60, 0) ,
240 HDD5GHZCHAN(5320, 64, 0) ,
241 HDD5GHZCHAN(5500,100, 0) ,
242 HDD5GHZCHAN(5520,104, 0) ,
243 HDD5GHZCHAN(5540,108, 0) ,
244 HDD5GHZCHAN(5560,112, 0) ,
245 HDD5GHZCHAN(5580,116, 0) ,
246 HDD5GHZCHAN(5600,120, 0) ,
247 HDD5GHZCHAN(5620,124, 0) ,
248 HDD5GHZCHAN(5640,128, 0) ,
249 HDD5GHZCHAN(5660,132, 0) ,
250 HDD5GHZCHAN(5680,136, 0) ,
251 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800252#ifdef FEATURE_WLAN_CH144
253 HDD5GHZCHAN(5720,144, 0) ,
254#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 HDD5GHZCHAN(5745,149, 0) ,
256 HDD5GHZCHAN(5765,153, 0) ,
257 HDD5GHZCHAN(5785,157, 0) ,
258 HDD5GHZCHAN(5805,161, 0) ,
259 HDD5GHZCHAN(5825,165, 0) ,
260};
261
262static struct ieee80211_rate g_mode_rates[] =
263{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530264 HDD_G_MODE_RATETAB(10, 0x1, 0),
265 HDD_G_MODE_RATETAB(20, 0x2, 0),
266 HDD_G_MODE_RATETAB(55, 0x4, 0),
267 HDD_G_MODE_RATETAB(110, 0x8, 0),
268 HDD_G_MODE_RATETAB(60, 0x10, 0),
269 HDD_G_MODE_RATETAB(90, 0x20, 0),
270 HDD_G_MODE_RATETAB(120, 0x40, 0),
271 HDD_G_MODE_RATETAB(180, 0x80, 0),
272 HDD_G_MODE_RATETAB(240, 0x100, 0),
273 HDD_G_MODE_RATETAB(360, 0x200, 0),
274 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530276};
Jeff Johnson295189b2012-06-20 16:38:30 -0700277
278static struct ieee80211_rate a_mode_rates[] =
279{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530280 HDD_G_MODE_RATETAB(60, 0x10, 0),
281 HDD_G_MODE_RATETAB(90, 0x20, 0),
282 HDD_G_MODE_RATETAB(120, 0x40, 0),
283 HDD_G_MODE_RATETAB(180, 0x80, 0),
284 HDD_G_MODE_RATETAB(240, 0x100, 0),
285 HDD_G_MODE_RATETAB(360, 0x200, 0),
286 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 HDD_G_MODE_RATETAB(540, 0x800, 0),
288};
289
290static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
291{
292 .channels = hdd_channels_2_4_GHZ,
293 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
294 .band = IEEE80211_BAND_2GHZ,
295 .bitrates = g_mode_rates,
296 .n_bitrates = g_mode_rates_size,
297 .ht_cap.ht_supported = 1,
298 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
299 | IEEE80211_HT_CAP_GRN_FLD
300 | IEEE80211_HT_CAP_DSSSCCK40
301 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
302 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
303 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
304 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
305 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
306 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
307};
308
Jeff Johnson295189b2012-06-20 16:38:30 -0700309static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
310{
311 .channels = hdd_social_channels_2_4_GHZ,
312 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
313 .band = IEEE80211_BAND_2GHZ,
314 .bitrates = g_mode_rates,
315 .n_bitrates = g_mode_rates_size,
316 .ht_cap.ht_supported = 1,
317 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
318 | IEEE80211_HT_CAP_GRN_FLD
319 | IEEE80211_HT_CAP_DSSSCCK40
320 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
321 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
322 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
323 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
324 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
325 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
326};
Jeff Johnson295189b2012-06-20 16:38:30 -0700327
328static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
329{
330 .channels = hdd_channels_5_GHZ,
331 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
332 .band = IEEE80211_BAND_5GHZ,
333 .bitrates = a_mode_rates,
334 .n_bitrates = a_mode_rates_size,
335 .ht_cap.ht_supported = 1,
336 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
337 | IEEE80211_HT_CAP_GRN_FLD
338 | IEEE80211_HT_CAP_DSSSCCK40
339 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
340 | IEEE80211_HT_CAP_SGI_40
341 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
342 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
343 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
344 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
345 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
346 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
347};
348
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530349/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700350 TX/RX direction for each kind of interface */
351static const struct ieee80211_txrx_stypes
352wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
353 [NL80211_IFTYPE_STATION] = {
354 .tx = 0xffff,
355 .rx = BIT(SIR_MAC_MGMT_ACTION) |
356 BIT(SIR_MAC_MGMT_PROBE_REQ),
357 },
358 [NL80211_IFTYPE_AP] = {
359 .tx = 0xffff,
360 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
361 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
362 BIT(SIR_MAC_MGMT_PROBE_REQ) |
363 BIT(SIR_MAC_MGMT_DISASSOC) |
364 BIT(SIR_MAC_MGMT_AUTH) |
365 BIT(SIR_MAC_MGMT_DEAUTH) |
366 BIT(SIR_MAC_MGMT_ACTION),
367 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700368 [NL80211_IFTYPE_ADHOC] = {
369 .tx = 0xffff,
370 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
371 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
372 BIT(SIR_MAC_MGMT_PROBE_REQ) |
373 BIT(SIR_MAC_MGMT_DISASSOC) |
374 BIT(SIR_MAC_MGMT_AUTH) |
375 BIT(SIR_MAC_MGMT_DEAUTH) |
376 BIT(SIR_MAC_MGMT_ACTION),
377 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 [NL80211_IFTYPE_P2P_CLIENT] = {
379 .tx = 0xffff,
380 .rx = BIT(SIR_MAC_MGMT_ACTION) |
381 BIT(SIR_MAC_MGMT_PROBE_REQ),
382 },
383 [NL80211_IFTYPE_P2P_GO] = {
384 /* This is also same as for SoftAP */
385 .tx = 0xffff,
386 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
387 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
388 BIT(SIR_MAC_MGMT_PROBE_REQ) |
389 BIT(SIR_MAC_MGMT_DISASSOC) |
390 BIT(SIR_MAC_MGMT_AUTH) |
391 BIT(SIR_MAC_MGMT_DEAUTH) |
392 BIT(SIR_MAC_MGMT_ACTION),
393 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700394};
395
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800396#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800397static const struct ieee80211_iface_limit
398wlan_hdd_iface_limit[] = {
399 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800400 /* max = 3 ; Our driver create two interfaces during driver init
401 * wlan0 and p2p0 interfaces. p2p0 is considered as station
402 * interface until a group is formed. In JB architecture, once the
403 * group is formed, interface type of p2p0 is changed to P2P GO or
404 * Client.
405 * When supplicant remove the group, it first issue a set interface
406 * cmd to change the mode back to Station. In JB this works fine as
407 * we advertize two station type interface during driver init.
408 * Some vendors create separate interface for P2P GO/Client,
409 * after group formation(Third one). But while group remove
410 * supplicant first tries to change the mode(3rd interface) to STATION
411 * But as we advertized only two sta type interfaces nl80211 was
412 * returning error for the third one which was leading to failure in
413 * delete interface. Ideally while removing the group, supplicant
414 * should not try to change the 3rd interface mode to Station type.
415 * Till we get a fix in wpa_supplicant, we advertize max STA
416 * interface type to 3
417 */
418 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800419 .types = BIT(NL80211_IFTYPE_STATION),
420 },
421 {
422 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700423 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800424 },
425 {
426 .max = 1,
427 .types = BIT(NL80211_IFTYPE_P2P_GO) |
428 BIT(NL80211_IFTYPE_P2P_CLIENT),
429 },
430};
431
432/* By default, only single channel concurrency is allowed */
433static struct ieee80211_iface_combination
434wlan_hdd_iface_combination = {
435 .limits = wlan_hdd_iface_limit,
436 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800437 /*
438 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
439 * and p2p0 interfaces during driver init
440 * Some vendors create separate interface for P2P operations.
441 * wlan0: STA interface
442 * p2p0: P2P Device interface, action frames goes
443 * through this interface.
444 * p2p-xx: P2P interface, After GO negotiation this interface is
445 * created for p2p operations(GO/CLIENT interface).
446 */
447 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800448 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
449 .beacon_int_infra_match = false,
450};
451#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800452
Jeff Johnson295189b2012-06-20 16:38:30 -0700453static struct cfg80211_ops wlan_hdd_cfg80211_ops;
454
455/* Data rate 100KBPS based on IE Index */
456struct index_data_rate_type
457{
458 v_U8_t beacon_rate_index;
459 v_U16_t supported_rate[4];
460};
461
462/* 11B, 11G Rate table include Basic rate and Extended rate
463 The IDX field is the rate index
464 The HI field is the rate when RSSI is strong or being ignored
465 (in this case we report actual rate)
466 The MID field is the rate when RSSI is moderate
467 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
468 The LO field is the rate when RSSI is low
469 (in this case we don't report rates, actual current rate used)
470 */
471static const struct
472{
473 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700474 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700475} supported_data_rate[] =
476{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700477/* IDX HI HM LM LO (RSSI-based index */
478 {2, { 10, 10, 10, 0}},
479 {4, { 20, 20, 10, 0}},
480 {11, { 55, 20, 10, 0}},
481 {12, { 60, 55, 20, 0}},
482 {18, { 90, 55, 20, 0}},
483 {22, {110, 55, 20, 0}},
484 {24, {120, 90, 60, 0}},
485 {36, {180, 120, 60, 0}},
486 {44, {220, 180, 60, 0}},
487 {48, {240, 180, 90, 0}},
488 {66, {330, 180, 90, 0}},
489 {72, {360, 240, 90, 0}},
490 {96, {480, 240, 120, 0}},
491 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700492};
493
494/* MCS Based rate table */
495static struct index_data_rate_type supported_mcs_rate[] =
496{
497/* MCS L20 L40 S20 S40 */
498 {0, {65, 135, 72, 150}},
499 {1, {130, 270, 144, 300}},
500 {2, {195, 405, 217, 450}},
501 {3, {260, 540, 289, 600}},
502 {4, {390, 810, 433, 900}},
503 {5, {520, 1080, 578, 1200}},
504 {6, {585, 1215, 650, 1350}},
505 {7, {650, 1350, 722, 1500}}
506};
507
Leo Chang6f8870f2013-03-26 18:11:36 -0700508#ifdef WLAN_FEATURE_11AC
509
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530510#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700511
512struct index_vht_data_rate_type
513{
514 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530515 v_U16_t supported_VHT80_rate[2];
516 v_U16_t supported_VHT40_rate[2];
517 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700518};
519
520typedef enum
521{
522 DATA_RATE_11AC_MAX_MCS_7,
523 DATA_RATE_11AC_MAX_MCS_8,
524 DATA_RATE_11AC_MAX_MCS_9,
525 DATA_RATE_11AC_MAX_MCS_NA
526} eDataRate11ACMaxMcs;
527
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530528/* SSID broadcast type */
529typedef enum eSSIDBcastType
530{
531 eBCAST_UNKNOWN = 0,
532 eBCAST_NORMAL = 1,
533 eBCAST_HIDDEN = 2,
534} tSSIDBcastType;
535
Leo Chang6f8870f2013-03-26 18:11:36 -0700536/* MCS Based VHT rate table */
537static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
538{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530539/* MCS L80 S80 L40 S40 L20 S40*/
540 {0, {293, 325}, {135, 150}, {65, 72}},
541 {1, {585, 650}, {270, 300}, {130, 144}},
542 {2, {878, 975}, {405, 450}, {195, 217}},
543 {3, {1170, 1300}, {540, 600}, {260, 289}},
544 {4, {1755, 1950}, {810, 900}, {390, 433}},
545 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
546 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
547 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
548 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
549 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700550};
551#endif /* WLAN_FEATURE_11AC */
552
c_hpothu79aab322014-07-14 21:11:01 +0530553/*array index points to MCS and array value points respective rssi*/
554static int rssiMcsTbl[][10] =
555{
556/*MCS 0 1 2 3 4 5 6 7 8 9*/
557 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
558 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
559 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
560};
561
Jeff Johnson295189b2012-06-20 16:38:30 -0700562extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530563#ifdef FEATURE_WLAN_SCAN_PNO
564static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
565#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700566
Leo Chang9056f462013-08-01 19:21:11 -0700567#ifdef WLAN_NL80211_TESTMODE
568enum wlan_hdd_tm_attr
569{
570 WLAN_HDD_TM_ATTR_INVALID = 0,
571 WLAN_HDD_TM_ATTR_CMD = 1,
572 WLAN_HDD_TM_ATTR_DATA = 2,
573 WLAN_HDD_TM_ATTR_TYPE = 3,
574 /* keep last */
575 WLAN_HDD_TM_ATTR_AFTER_LAST,
576 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
577};
578
579enum wlan_hdd_tm_cmd
580{
581 WLAN_HDD_TM_CMD_WLAN_HB = 1,
582};
583
584#define WLAN_HDD_TM_DATA_MAX_LEN 5000
585
586static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
587{
588 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
589 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
590 .len = WLAN_HDD_TM_DATA_MAX_LEN },
591};
592#endif /* WLAN_NL80211_TESTMODE */
593
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800594#ifdef FEATURE_WLAN_CH_AVOID
595/*
596 * FUNCTION: wlan_hdd_send_avoid_freq_event
597 * This is called when wlan driver needs to send vendor specific
598 * avoid frequency range event to userspace
599 */
600int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
601 tHddAvoidFreqList *pAvoidFreqList)
602{
603 struct sk_buff *vendor_event;
604
605 ENTER();
606
607 if (!pHddCtx)
608 {
609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
610 "%s: HDD context is null", __func__);
611 return -1;
612 }
613
614 if (!pAvoidFreqList)
615 {
616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
617 "%s: pAvoidFreqList is null", __func__);
618 return -1;
619 }
620
621 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530622#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
623 NULL,
624#endif
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800625 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530626 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800627 GFP_KERNEL);
628 if (!vendor_event)
629 {
630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
631 "%s: cfg80211_vendor_event_alloc failed", __func__);
632 return -1;
633 }
634
635 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
636 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
637
638 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
639
640 EXIT();
641 return 0;
642}
643#endif /* FEATURE_WLAN_CH_AVOID */
644
Srinivas Dasari030bad32015-02-18 23:23:54 +0530645/*
646 * FUNCTION: __wlan_hdd_cfg80211_nan_request
647 * This is called when wlan driver needs to send vendor specific
648 * nan request event.
649 */
650static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
651 struct wireless_dev *wdev,
652 const void *data, int data_len)
653{
654 tNanRequestReq nan_req;
655 VOS_STATUS status;
656 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530657 struct net_device *dev = wdev->netdev;
658 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
659 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530660 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
661
662 if (0 == data_len)
663 {
664 hddLog(VOS_TRACE_LEVEL_ERROR,
665 FL("NAN - Invalid Request, length = 0"));
666 return ret_val;
667 }
668
669 if (NULL == data)
670 {
671 hddLog(VOS_TRACE_LEVEL_ERROR,
672 FL("NAN - Invalid Request, data is NULL"));
673 return ret_val;
674 }
675
676 status = wlan_hdd_validate_context(pHddCtx);
677 if (0 != status)
678 {
679 hddLog(VOS_TRACE_LEVEL_ERROR,
680 FL("HDD context is not valid"));
681 return -EINVAL;
682 }
683
684 hddLog(LOG1, FL("Received NAN command"));
685 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
686 (tANI_U8 *)data, data_len);
687
688 /* check the NAN Capability */
689 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
690 {
691 hddLog(VOS_TRACE_LEVEL_ERROR,
692 FL("NAN is not supported by Firmware"));
693 return -EINVAL;
694 }
695
696 nan_req.request_data_len = data_len;
697 nan_req.request_data = data;
698
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530699 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530700 if (VOS_STATUS_SUCCESS == status)
701 {
702 ret_val = 0;
703 }
704 return ret_val;
705}
706
707/*
708 * FUNCTION: wlan_hdd_cfg80211_nan_request
709 * Wrapper to protect the nan vendor command from ssr
710 */
711static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
712 struct wireless_dev *wdev,
713 const void *data, int data_len)
714{
715 int ret;
716
717 vos_ssr_protect(__func__);
718 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
719 vos_ssr_unprotect(__func__);
720
721 return ret;
722}
723
724/*
725 * FUNCTION: wlan_hdd_cfg80211_nan_callback
726 * This is a callback function and it gets called
727 * when we need to report nan response event to
728 * upper layers.
729 */
730static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
731{
732 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
733 struct sk_buff *vendor_event;
734 int status;
735 tSirNanEvent *data;
736
737 ENTER();
738 if (NULL == msg)
739 {
740 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
741 FL(" msg received here is null"));
742 return;
743 }
744 data = msg;
745
746 status = wlan_hdd_validate_context(pHddCtx);
747
748 if (0 != status)
749 {
750 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
751 FL("HDD context is not valid"));
752 return;
753 }
754
755 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +0530756#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
757 NULL,
758#endif
Srinivas Dasari030bad32015-02-18 23:23:54 +0530759 data->event_data_len +
760 NLMSG_HDRLEN,
761 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
762 GFP_KERNEL);
763
764 if (!vendor_event)
765 {
766 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
767 FL("cfg80211_vendor_event_alloc failed"));
768 return;
769 }
770 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
771 data->event_data_len, data->event_data))
772 {
773 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
774 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
775 kfree_skb(vendor_event);
776 return;
777 }
778 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
779 EXIT();
780}
781
782/*
783 * FUNCTION: wlan_hdd_cfg80211_nan_init
784 * This function is called to register the callback to sme layer
785 */
786inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
787{
788 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
789}
790
791
Sunil Duttc69bccb2014-05-26 21:30:20 +0530792#ifdef WLAN_FEATURE_LINK_LAYER_STATS
793
794static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
795 struct sk_buff *vendor_event)
796{
797 if (nla_put_u8(vendor_event,
798 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
799 stats->rate.preamble) ||
800 nla_put_u8(vendor_event,
801 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
802 stats->rate.nss) ||
803 nla_put_u8(vendor_event,
804 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
805 stats->rate.bw) ||
806 nla_put_u8(vendor_event,
807 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
808 stats->rate.rateMcsIdx) ||
809 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
810 stats->rate.bitrate ) ||
811 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
812 stats->txMpdu ) ||
813 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
814 stats->rxMpdu ) ||
815 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
816 stats->mpduLost ) ||
817 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
818 stats->retries) ||
819 nla_put_u32(vendor_event,
820 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
821 stats->retriesShort ) ||
822 nla_put_u32(vendor_event,
823 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
824 stats->retriesLong))
825 {
826 hddLog(VOS_TRACE_LEVEL_ERROR,
827 FL("QCA_WLAN_VENDOR_ATTR put fail"));
828 return FALSE;
829 }
830 return TRUE;
831}
832
833static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
834 struct sk_buff *vendor_event)
835{
836 u32 i = 0;
837 struct nlattr *rateInfo;
838 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
839 stats->type) ||
840 nla_put(vendor_event,
841 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
842 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
843 nla_put_u32(vendor_event,
844 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
845 stats->capabilities) ||
846 nla_put_u32(vendor_event,
847 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
848 stats->numRate))
849 {
850 hddLog(VOS_TRACE_LEVEL_ERROR,
851 FL("QCA_WLAN_VENDOR_ATTR put fail"));
852 goto error;
853 }
854
855 rateInfo = nla_nest_start(vendor_event,
856 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530857 if(!rateInfo)
858 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530859 for (i = 0; i < stats->numRate; i++)
860 {
861 struct nlattr *rates;
862 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
863 stats->rateStats +
864 (i * sizeof(tSirWifiRateStat)));
865 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530866 if(!rates)
867 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530868
869 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
870 {
871 hddLog(VOS_TRACE_LEVEL_ERROR,
872 FL("QCA_WLAN_VENDOR_ATTR put fail"));
873 return FALSE;
874 }
875 nla_nest_end(vendor_event, rates);
876 }
877 nla_nest_end(vendor_event, rateInfo);
878
879 return TRUE;
880error:
881 return FALSE;
882}
883
884static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
885 struct sk_buff *vendor_event)
886{
887 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
888 stats->ac ) ||
889 nla_put_u32(vendor_event,
890 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
891 stats->txMpdu ) ||
892 nla_put_u32(vendor_event,
893 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
894 stats->rxMpdu ) ||
895 nla_put_u32(vendor_event,
896 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
897 stats->txMcast ) ||
898 nla_put_u32(vendor_event,
899 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
900 stats->rxMcast ) ||
901 nla_put_u32(vendor_event,
902 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
903 stats->rxAmpdu ) ||
904 nla_put_u32(vendor_event,
905 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
906 stats->txAmpdu ) ||
907 nla_put_u32(vendor_event,
908 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
909 stats->mpduLost )||
910 nla_put_u32(vendor_event,
911 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
912 stats->retries ) ||
913 nla_put_u32(vendor_event,
914 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
915 stats->retriesShort ) ||
916 nla_put_u32(vendor_event,
917 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
918 stats->retriesLong ) ||
919 nla_put_u32(vendor_event,
920 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
921 stats->contentionTimeMin ) ||
922 nla_put_u32(vendor_event,
923 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
924 stats->contentionTimeMax ) ||
925 nla_put_u32(vendor_event,
926 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
927 stats->contentionTimeAvg ) ||
928 nla_put_u32(vendor_event,
929 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
930 stats->contentionNumSamples ))
931 {
932 hddLog(VOS_TRACE_LEVEL_ERROR,
933 FL("QCA_WLAN_VENDOR_ATTR put fail") );
934 return FALSE;
935 }
936 return TRUE;
937}
938
939static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
940 struct sk_buff *vendor_event)
941{
Dino Myclec8f3f332014-07-21 16:48:27 +0530942 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530943 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
944 nla_put(vendor_event,
945 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
946 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
947 nla_put_u32(vendor_event,
948 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
949 stats->state ) ||
950 nla_put_u32(vendor_event,
951 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
952 stats->roaming ) ||
953 nla_put_u32(vendor_event,
954 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
955 stats->capabilities ) ||
956 nla_put(vendor_event,
957 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
958 strlen(stats->ssid), stats->ssid) ||
959 nla_put(vendor_event,
960 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
961 WNI_CFG_BSSID_LEN, stats->bssid) ||
962 nla_put(vendor_event,
963 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
964 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
965 nla_put(vendor_event,
966 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
967 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
968 )
969 {
970 hddLog(VOS_TRACE_LEVEL_ERROR,
971 FL("QCA_WLAN_VENDOR_ATTR put fail") );
972 return FALSE;
973 }
974 return TRUE;
975}
976
Dino Mycle3b9536d2014-07-09 22:05:24 +0530977static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
978 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530979 struct sk_buff *vendor_event)
980{
981 int i = 0;
982 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530983 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
984 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530985 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530986
Sunil Duttc69bccb2014-05-26 21:30:20 +0530987 if (FALSE == put_wifi_interface_info(
988 &pWifiIfaceStat->info,
989 vendor_event))
990 {
991 hddLog(VOS_TRACE_LEVEL_ERROR,
992 FL("QCA_WLAN_VENDOR_ATTR put fail") );
993 return FALSE;
994
995 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530996 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
997 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
998 if (NULL == pWifiIfaceStatTL)
999 {
1000 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
1001 return FALSE;
1002 }
1003
Srinivas Dasaria8a304f2014-11-15 16:13:37 +05301004 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
1005 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
1006 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
1007 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1008
1009 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1010 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1011 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1012 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301013
1014 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1015 {
1016 if (VOS_STATUS_SUCCESS ==
1017 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1018 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1019 {
1020 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1021 * obtained from TL structure
1022 */
1023
1024 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1025 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301026 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1027
Srinivas Dasari98947432014-11-07 19:41:24 +05301028 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1029 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1030 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1031 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1032 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1033 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1034 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1035 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301036
Srinivas Dasari98947432014-11-07 19:41:24 +05301037 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1038 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1039 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1040 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1041 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1042 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1043 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1044 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301045
Srinivas Dasari98947432014-11-07 19:41:24 +05301046 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1047 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1048 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1049 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1050 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1051 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1052 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1053 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301054 }
1055 else
1056 {
1057 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1058 }
1059
Dino Mycle3b9536d2014-07-09 22:05:24 +05301060 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1061 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1062 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1063 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1064 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1065 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1066 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1067 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1068 }
1069 else
1070 {
1071 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1072 }
1073
1074
Sunil Duttc69bccb2014-05-26 21:30:20 +05301075
1076 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301077 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1078 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_IFACE) ||
1079 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301080 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1081 pWifiIfaceStat->beaconRx) ||
1082 nla_put_u32(vendor_event,
1083 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1084 pWifiIfaceStat->mgmtRx) ||
1085 nla_put_u32(vendor_event,
1086 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1087 pWifiIfaceStat->mgmtActionRx) ||
1088 nla_put_u32(vendor_event,
1089 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1090 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301091 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301092 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1093 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301094 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301095 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1096 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301097 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301098 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1099 pWifiIfaceStat->rssiAck))
1100 {
1101 hddLog(VOS_TRACE_LEVEL_ERROR,
1102 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301103 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301104 return FALSE;
1105 }
1106
1107 wmmInfo = nla_nest_start(vendor_event,
1108 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301109 if(!wmmInfo)
1110 {
1111 vos_mem_free(pWifiIfaceStatTL);
1112 return FALSE;
1113 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301114 for (i = 0; i < WIFI_AC_MAX; i++)
1115 {
1116 struct nlattr *wmmStats;
1117 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301118 if(!wmmStats)
1119 {
1120 vos_mem_free(pWifiIfaceStatTL);
1121 return FALSE;
1122 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301123 if (FALSE == put_wifi_wmm_ac_stat(
1124 &pWifiIfaceStat->AccessclassStats[i],
1125 vendor_event))
1126 {
1127 hddLog(VOS_TRACE_LEVEL_ERROR,
1128 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301129 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301130 return FALSE;
1131 }
1132
1133 nla_nest_end(vendor_event, wmmStats);
1134 }
1135 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301136 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301137 return TRUE;
1138}
1139
1140static tSirWifiInterfaceMode
1141 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1142{
1143 switch (deviceMode)
1144 {
1145 case WLAN_HDD_INFRA_STATION:
1146 return WIFI_INTERFACE_STA;
1147 case WLAN_HDD_SOFTAP:
1148 return WIFI_INTERFACE_SOFTAP;
1149 case WLAN_HDD_P2P_CLIENT:
1150 return WIFI_INTERFACE_P2P_CLIENT;
1151 case WLAN_HDD_P2P_GO:
1152 return WIFI_INTERFACE_P2P_GO;
1153 case WLAN_HDD_IBSS:
1154 return WIFI_INTERFACE_IBSS;
1155 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301156 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301157 }
1158}
1159
1160static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1161 tpSirWifiInterfaceInfo pInfo)
1162{
1163 v_U8_t *staMac = NULL;
1164 hdd_station_ctx_t *pHddStaCtx;
1165 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1166 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1167
1168 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1169
1170 vos_mem_copy(pInfo->macAddr,
1171 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1172
1173 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1174 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1175 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1176 {
1177 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1178 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1179 {
1180 pInfo->state = WIFI_DISCONNECTED;
1181 }
1182 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1183 {
1184 hddLog(VOS_TRACE_LEVEL_ERROR,
1185 "%s: Session ID %d, Connection is in progress", __func__,
1186 pAdapter->sessionId);
1187 pInfo->state = WIFI_ASSOCIATING;
1188 }
1189 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1190 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1191 {
1192 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1193 hddLog(VOS_TRACE_LEVEL_ERROR,
1194 "%s: client " MAC_ADDRESS_STR
1195 " is in the middle of WPS/EAPOL exchange.", __func__,
1196 MAC_ADDR_ARRAY(staMac));
1197 pInfo->state = WIFI_AUTHENTICATING;
1198 }
1199 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1200 {
1201 pInfo->state = WIFI_ASSOCIATED;
1202 vos_mem_copy(pInfo->bssid,
1203 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1204 vos_mem_copy(pInfo->ssid,
1205 pHddStaCtx->conn_info.SSID.SSID.ssId,
1206 pHddStaCtx->conn_info.SSID.SSID.length);
1207 //NULL Terminate the string.
1208 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1209 }
1210 }
1211 vos_mem_copy(pInfo->countryStr,
1212 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1213
1214 vos_mem_copy(pInfo->apCountryStr,
1215 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1216
1217 return TRUE;
1218}
1219
1220/*
1221 * hdd_link_layer_process_peer_stats () - This function is called after
1222 * receiving Link Layer Peer statistics from FW.This function converts
1223 * the firmware data to the NL data and sends the same to the kernel/upper
1224 * layers.
1225 */
1226static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1227 v_VOID_t *pData)
1228{
1229 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1230 tpSirWifiRateStat pWifiRateStat;
1231 tpSirWifiPeerStat pWifiPeerStat;
1232 tpSirWifiPeerInfo pWifiPeerInfo;
1233 struct nlattr *peerInfo;
1234 struct sk_buff *vendor_event;
1235 int status, i;
1236
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301237 ENTER();
1238
Sunil Duttc69bccb2014-05-26 21:30:20 +05301239 status = wlan_hdd_validate_context(pHddCtx);
1240 if (0 != status)
1241 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301242 return;
1243 }
1244
1245 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1246
1247 hddLog(VOS_TRACE_LEVEL_INFO,
1248 "LL_STATS_PEER_ALL : numPeers %u",
1249 pWifiPeerStat->numPeers);
1250 {
1251 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1252 {
1253 pWifiPeerInfo = (tpSirWifiPeerInfo)
1254 ((uint8 *)pWifiPeerStat->peerInfo +
1255 ( i * sizeof(tSirWifiPeerInfo)));
1256
Dasari Srinivas1be0c4e2014-10-19 13:03:41 +05301257 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) {
1258 pWifiPeerInfo->type = WIFI_PEER_AP;
1259 }
1260 if (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) {
1261 pWifiPeerInfo->type = WIFI_PEER_P2P_GO;
1262 }
1263
Sunil Duttc69bccb2014-05-26 21:30:20 +05301264 hddLog(VOS_TRACE_LEVEL_INFO,
1265 " %d) LL_STATS Channel Stats "
1266 " Peer Type %u "
1267 " peerMacAddress %pM "
1268 " capabilities 0x%x "
1269 " numRate %u ",
1270 i,
1271 pWifiPeerInfo->type,
1272 pWifiPeerInfo->peerMacAddress,
1273 pWifiPeerInfo->capabilities,
1274 pWifiPeerInfo->numRate);
1275 {
1276 int j;
1277 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1278 {
1279 pWifiRateStat = (tpSirWifiRateStat)
1280 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1281 ( j * sizeof(tSirWifiRateStat)));
1282
1283 hddLog(VOS_TRACE_LEVEL_INFO,
1284 " peer Rate Stats "
1285 " preamble %u "
1286 " nss %u "
1287 " bw %u "
1288 " rateMcsIdx %u "
1289 " reserved %u "
1290 " bitrate %u "
1291 " txMpdu %u "
1292 " rxMpdu %u "
1293 " mpduLost %u "
1294 " retries %u "
1295 " retriesShort %u "
1296 " retriesLong %u",
1297 pWifiRateStat->rate.preamble,
1298 pWifiRateStat->rate.nss,
1299 pWifiRateStat->rate.bw,
1300 pWifiRateStat->rate.rateMcsIdx,
1301 pWifiRateStat->rate.reserved,
1302 pWifiRateStat->rate.bitrate,
1303 pWifiRateStat->txMpdu,
1304 pWifiRateStat->rxMpdu,
1305 pWifiRateStat->mpduLost,
1306 pWifiRateStat->retries,
1307 pWifiRateStat->retriesShort,
1308 pWifiRateStat->retriesLong);
1309 }
1310 }
1311 }
1312 }
1313
1314 /*
1315 * Allocate a size of 4096 for the peer stats comprising
1316 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1317 * sizeof (tSirWifiRateStat).Each field is put with an
1318 * NL attribute.The size of 4096 is considered assuming
1319 * that number of rates shall not exceed beyond 50 with
1320 * the sizeof (tSirWifiRateStat) being 32.
1321 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301322 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1323 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301324 if (!vendor_event)
1325 {
1326 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301327 "%s: cfg80211_vendor_cmd_alloc_reply_skb failed",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301328 __func__);
1329 return;
1330 }
1331 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301332 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1333 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_PEER) ||
1334 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301335 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1336 pWifiPeerStat->numPeers))
1337 {
1338 hddLog(VOS_TRACE_LEVEL_ERROR,
1339 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1340 kfree_skb(vendor_event);
1341 return;
1342 }
1343
1344 peerInfo = nla_nest_start(vendor_event,
1345 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301346 if(!peerInfo)
1347 {
1348 hddLog(VOS_TRACE_LEVEL_ERROR,
1349 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1350 __func__);
1351 kfree_skb(vendor_event);
1352 return;
1353 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301354
1355 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1356 pWifiPeerStat->peerInfo);
1357
1358 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1359 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301360 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301361 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301362
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301363 if(!peers)
1364 {
1365 hddLog(VOS_TRACE_LEVEL_ERROR,
1366 "%s: peer stats put fail",
1367 __func__);
1368 kfree_skb(vendor_event);
1369 return;
1370 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301371 if (FALSE == put_wifi_peer_info(
1372 pWifiPeerInfo, vendor_event))
1373 {
1374 hddLog(VOS_TRACE_LEVEL_ERROR,
1375 "%s: put_wifi_peer_info put fail", __func__);
1376 kfree_skb(vendor_event);
1377 return;
1378 }
1379
1380 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1381 pWifiPeerStat->peerInfo +
1382 (i * sizeof(tSirWifiPeerInfo)) +
1383 (numRate * sizeof (tSirWifiRateStat)));
1384 nla_nest_end(vendor_event, peers);
1385 }
1386 nla_nest_end(vendor_event, peerInfo);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301387 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301388 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301389}
1390
1391/*
1392 * hdd_link_layer_process_iface_stats () - This function is called after
1393 * receiving Link Layer Interface statistics from FW.This function converts
1394 * the firmware data to the NL data and sends the same to the kernel/upper
1395 * layers.
1396 */
1397static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1398 v_VOID_t *pData)
1399{
1400 tpSirWifiIfaceStat pWifiIfaceStat;
1401 struct sk_buff *vendor_event;
1402 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1403 int status;
1404
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301405 ENTER();
1406
Sunil Duttc69bccb2014-05-26 21:30:20 +05301407 status = wlan_hdd_validate_context(pHddCtx);
1408 if (0 != status)
1409 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301410 return;
1411 }
1412 /*
1413 * Allocate a size of 4096 for the interface stats comprising
1414 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1415 * assuming that all these fit with in the limit.Please take
1416 * a call on the limit based on the data requirements on
1417 * interface statistics.
1418 */
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301419 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1420 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301421 if (!vendor_event)
1422 {
1423 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301424 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301425 return;
1426 }
1427
1428 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1429
Dino Mycle3b9536d2014-07-09 22:05:24 +05301430
1431 if (FALSE == hdd_get_interface_info( pAdapter,
1432 &pWifiIfaceStat->info))
1433 {
1434 hddLog(VOS_TRACE_LEVEL_ERROR,
1435 FL("hdd_get_interface_info get fail") );
1436 kfree_skb(vendor_event);
1437 return;
1438 }
1439
1440 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1441 vendor_event))
1442 {
1443 hddLog(VOS_TRACE_LEVEL_ERROR,
1444 FL("put_wifi_iface_stats fail") );
1445 kfree_skb(vendor_event);
1446 return;
1447 }
1448
Sunil Duttc69bccb2014-05-26 21:30:20 +05301449 hddLog(VOS_TRACE_LEVEL_INFO,
1450 "WMI_LINK_STATS_IFACE Data");
1451
1452 hddLog(VOS_TRACE_LEVEL_INFO,
1453 "LL_STATS_IFACE: "
1454 " Mode %u "
1455 " MAC %pM "
1456 " State %u "
1457 " Roaming %u "
1458 " capabilities 0x%x "
1459 " SSID %s "
1460 " BSSID %pM",
1461 pWifiIfaceStat->info.mode,
1462 pWifiIfaceStat->info.macAddr,
1463 pWifiIfaceStat->info.state,
1464 pWifiIfaceStat->info.roaming,
1465 pWifiIfaceStat->info.capabilities,
1466 pWifiIfaceStat->info.ssid,
1467 pWifiIfaceStat->info.bssid);
1468
1469 hddLog(VOS_TRACE_LEVEL_INFO,
1470 " AP country str: %c%c%c",
1471 pWifiIfaceStat->info.apCountryStr[0],
1472 pWifiIfaceStat->info.apCountryStr[1],
1473 pWifiIfaceStat->info.apCountryStr[2]);
1474
1475
1476 hddLog(VOS_TRACE_LEVEL_INFO,
1477 " Country Str Association: %c%c%c",
1478 pWifiIfaceStat->info.countryStr[0],
1479 pWifiIfaceStat->info.countryStr[1],
1480 pWifiIfaceStat->info.countryStr[2]);
1481
1482 hddLog(VOS_TRACE_LEVEL_INFO,
1483 " beaconRx %u "
1484 " mgmtRx %u "
1485 " mgmtActionRx %u "
1486 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301487 " rssiMgmt %d "
1488 " rssiData %d "
1489 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301490 pWifiIfaceStat->beaconRx,
1491 pWifiIfaceStat->mgmtRx,
1492 pWifiIfaceStat->mgmtActionRx,
1493 pWifiIfaceStat->mgmtActionTx,
1494 pWifiIfaceStat->rssiMgmt,
1495 pWifiIfaceStat->rssiData,
1496 pWifiIfaceStat->rssiAck );
1497
1498
1499 {
1500 int i;
1501 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1502 {
1503 hddLog(VOS_TRACE_LEVEL_INFO,
1504
1505 " %d) LL_STATS IFACE: "
1506 " ac: %u txMpdu: %u "
1507 " rxMpdu: %u txMcast: %u "
1508 " rxMcast: %u rxAmpdu: %u "
1509 " txAmpdu: %u mpduLost: %u "
1510 " retries: %u retriesShort: %u "
1511 " retriesLong: %u contentionTimeMin: %u "
1512 " contentionTimeMax: %u contentionTimeAvg: %u "
1513 " contentionNumSamples: %u",
1514 i,
1515 pWifiIfaceStat->AccessclassStats[i].ac,
1516 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1517 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1518 pWifiIfaceStat->AccessclassStats[i].txMcast,
1519 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1520 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1521 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1522 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1523 pWifiIfaceStat->AccessclassStats[i].retries,
1524 pWifiIfaceStat->
1525 AccessclassStats[i].retriesShort,
1526 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1527 pWifiIfaceStat->
1528 AccessclassStats[i].contentionTimeMin,
1529 pWifiIfaceStat->
1530 AccessclassStats[i].contentionTimeMax,
1531 pWifiIfaceStat->
1532 AccessclassStats[i].contentionTimeAvg,
1533 pWifiIfaceStat->
1534 AccessclassStats[i].contentionNumSamples);
1535
1536 }
1537 }
1538
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301539 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301540
1541 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301542}
1543
1544/*
1545 * hdd_link_layer_process_radio_stats () - This function is called after
1546 * receiving Link Layer Radio statistics from FW.This function converts
1547 * the firmware data to the NL data and sends the same to the kernel/upper
1548 * layers.
1549 */
1550static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1551 v_VOID_t *pData)
1552{
1553 int status, i;
1554 tpSirWifiRadioStat pWifiRadioStat;
1555 tpSirWifiChannelStats pWifiChannelStats;
1556 struct sk_buff *vendor_event;
1557 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1558 struct nlattr *chList;
1559
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301560 ENTER();
1561
Sunil Duttc69bccb2014-05-26 21:30:20 +05301562 status = wlan_hdd_validate_context(pHddCtx);
1563 if (0 != status)
1564 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301565 return;
1566 }
1567 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1568
1569 hddLog(VOS_TRACE_LEVEL_INFO,
1570 "LL_STATS_RADIO"
1571 " radio is %d onTime is %u "
1572 " txTime is %u rxTime is %u "
1573 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301574 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301575 " onTimePnoScan is %u onTimeHs20 is %u "
1576 " numChannels is %u",
1577 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1578 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1579 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301580 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301581 pWifiRadioStat->onTimeRoamScan,
1582 pWifiRadioStat->onTimePnoScan,
1583 pWifiRadioStat->onTimeHs20,
1584 pWifiRadioStat->numChannels);
1585 /*
1586 * Allocate a size of 4096 for the Radio stats comprising
1587 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1588 * (tSirWifiChannelStats).Each channel data is put with an
1589 * NL attribute.The size of 4096 is considered assuming that
1590 * number of channels shall not exceed beyond 60 with the
1591 * sizeof (tSirWifiChannelStats) being 24 bytes.
1592 */
1593
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301594 vendor_event = cfg80211_vendor_cmd_alloc_reply_skb(pHddCtx->wiphy,
1595 LL_STATS_EVENT_BUF_SIZE);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301596 if (!vendor_event)
1597 {
1598 hddLog(VOS_TRACE_LEVEL_ERROR,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301599 FL("cfg80211_vendor_cmd_alloc_reply_skb failed") );
Sunil Duttc69bccb2014-05-26 21:30:20 +05301600 return;
1601 }
1602
1603 if (nla_put_u32(vendor_event,
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301604 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE,
1605 QCA_WLAN_VENDOR_ATTR_LL_STATS_TYPE_RADIO) ||
1606 nla_put_u32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301607 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1608 pWifiRadioStat->radio) ||
1609 nla_put_u32(vendor_event,
1610 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1611 pWifiRadioStat->onTime) ||
1612 nla_put_u32(vendor_event,
1613 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1614 pWifiRadioStat->txTime) ||
1615 nla_put_u32(vendor_event,
1616 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1617 pWifiRadioStat->rxTime) ||
1618 nla_put_u32(vendor_event,
1619 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1620 pWifiRadioStat->onTimeScan) ||
1621 nla_put_u32(vendor_event,
1622 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1623 pWifiRadioStat->onTimeNbd) ||
1624 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301625 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1626 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301627 nla_put_u32(vendor_event,
1628 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1629 pWifiRadioStat->onTimeRoamScan) ||
1630 nla_put_u32(vendor_event,
1631 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1632 pWifiRadioStat->onTimePnoScan) ||
1633 nla_put_u32(vendor_event,
1634 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1635 pWifiRadioStat->onTimeHs20) ||
1636 nla_put_u32(vendor_event,
1637 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1638 pWifiRadioStat->numChannels))
1639 {
1640 hddLog(VOS_TRACE_LEVEL_ERROR,
1641 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1642 kfree_skb(vendor_event);
1643 return ;
1644 }
1645
1646 chList = nla_nest_start(vendor_event,
1647 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301648 if(!chList)
1649 {
1650 hddLog(VOS_TRACE_LEVEL_ERROR,
1651 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1652 __func__);
1653 kfree_skb(vendor_event);
1654 return;
1655 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301656 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1657 {
1658 struct nlattr *chInfo;
1659
1660 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1661 pWifiRadioStat->channels +
1662 (i * sizeof(tSirWifiChannelStats)));
1663
1664 hddLog(VOS_TRACE_LEVEL_INFO,
1665 " %d) Channel Info"
1666 " width is %u "
1667 " CenterFreq %u "
1668 " CenterFreq0 %u "
1669 " CenterFreq1 %u "
1670 " onTime %u "
1671 " ccaBusyTime %u",
1672 i,
1673 pWifiChannelStats->channel.width,
1674 pWifiChannelStats->channel.centerFreq,
1675 pWifiChannelStats->channel.centerFreq0,
1676 pWifiChannelStats->channel.centerFreq1,
1677 pWifiChannelStats->onTime,
1678 pWifiChannelStats->ccaBusyTime);
1679
1680
1681 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301682 if(!chInfo)
1683 {
1684 hddLog(VOS_TRACE_LEVEL_ERROR,
1685 "%s: failed to put chInfo",
1686 __func__);
1687 kfree_skb(vendor_event);
1688 return;
1689 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301690
1691 if (nla_put_u32(vendor_event,
1692 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1693 pWifiChannelStats->channel.width) ||
1694 nla_put_u32(vendor_event,
1695 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1696 pWifiChannelStats->channel.centerFreq) ||
1697 nla_put_u32(vendor_event,
1698 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1699 pWifiChannelStats->channel.centerFreq0) ||
1700 nla_put_u32(vendor_event,
1701 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1702 pWifiChannelStats->channel.centerFreq1) ||
1703 nla_put_u32(vendor_event,
1704 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1705 pWifiChannelStats->onTime) ||
1706 nla_put_u32(vendor_event,
1707 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1708 pWifiChannelStats->ccaBusyTime))
1709 {
1710 hddLog(VOS_TRACE_LEVEL_ERROR,
1711 FL("cfg80211_vendor_event_alloc failed") );
1712 kfree_skb(vendor_event);
1713 return ;
1714 }
1715 nla_nest_end(vendor_event, chInfo);
1716 }
1717 nla_nest_end(vendor_event, chList);
1718
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301719 cfg80211_vendor_cmd_reply(vendor_event);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301720
1721 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301722 return;
1723}
1724
1725/*
1726 * hdd_link_layer_stats_ind_callback () - This function is called after
1727 * receiving Link Layer indications from FW.This callback converts the firmware
1728 * data to the NL data and send the same to the kernel/upper layers.
1729 */
1730static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1731 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301732 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301733{
Dino Mycled3d50022014-07-07 12:58:25 +05301734 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1735 hdd_adapter_t *pAdapter = NULL;
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301736 struct hdd_ll_stats_context *context;
Dino Mycled3d50022014-07-07 12:58:25 +05301737 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301738 int status;
1739
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301740 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301741
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301742 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301743 if (0 != status)
1744 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301745 return;
1746 }
1747
Dino Mycled3d50022014-07-07 12:58:25 +05301748 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1749 if (NULL == pAdapter)
1750 {
1751 hddLog(VOS_TRACE_LEVEL_ERROR,
1752 FL(" MAC address %pM does not exist with host"),
1753 macAddr);
1754 return;
1755 }
1756
Sunil Duttc69bccb2014-05-26 21:30:20 +05301757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301758 "%s: Interface: %s LLStats indType: %d", __func__,
1759 pAdapter->dev->name, indType);
1760
Sunil Duttc69bccb2014-05-26 21:30:20 +05301761 switch (indType)
1762 {
1763 case SIR_HAL_LL_STATS_RESULTS_RSP:
1764 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301765 hddLog(VOS_TRACE_LEVEL_INFO,
1766 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1767 hddLog(VOS_TRACE_LEVEL_INFO,
1768 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1769 linkLayerStatsResults->paramId);
1770 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301771 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1772 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301773 hddLog(VOS_TRACE_LEVEL_INFO,
1774 "LL_STATS RESULTS RESPONSE respId = %u",
1775 linkLayerStatsResults->respId);
1776 hddLog(VOS_TRACE_LEVEL_INFO,
1777 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1778 linkLayerStatsResults->moreResultToFollow);
1779 hddLog(VOS_TRACE_LEVEL_INFO,
1780 "LL_STATS RESULTS RESPONSE result = %p",
1781 linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301782 spin_lock(&hdd_context_lock);
1783 context = &pHddCtx->ll_stats_context;
1784 /* validate response received from target */
1785 if ((context->request_id != linkLayerStatsResults->respId) ||
1786 !(context->request_bitmap & linkLayerStatsResults->paramId))
1787 {
1788 spin_unlock(&hdd_context_lock);
1789 hddLog(LOGE,
1790 FL("Error : Request id %d response id %d request bitmap 0x%x"
1791 "response bitmap 0x%x"),
1792 context->request_id, linkLayerStatsResults->respId,
1793 context->request_bitmap, linkLayerStatsResults->paramId);
1794 return;
1795 }
1796 spin_unlock(&hdd_context_lock);
1797
Sunil Duttc69bccb2014-05-26 21:30:20 +05301798 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1799 {
1800 hdd_link_layer_process_radio_stats(pAdapter,
1801 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301802 spin_lock(&hdd_context_lock);
1803 context->request_bitmap &= ~(WMI_LINK_STATS_RADIO);
1804 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301805 }
1806 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1807 {
1808 hdd_link_layer_process_iface_stats(pAdapter,
1809 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301810 spin_lock(&hdd_context_lock);
1811 context->request_bitmap &= ~(WMI_LINK_STATS_IFACE);
1812 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301813 }
1814 else if ( linkLayerStatsResults->paramId &
1815 WMI_LINK_STATS_ALL_PEER )
1816 {
1817 hdd_link_layer_process_peer_stats(pAdapter,
1818 (v_VOID_t *)linkLayerStatsResults->result);
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301819 spin_lock(&hdd_context_lock);
1820 context->request_bitmap &= ~(WMI_LINK_STATS_ALL_PEER);
1821 spin_unlock(&hdd_context_lock);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301822 } /* WMI_LINK_STATS_ALL_PEER */
1823 else
1824 {
1825 hddLog(VOS_TRACE_LEVEL_ERROR,
1826 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1827 }
1828
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301829 spin_lock(&hdd_context_lock);
1830 /* complete response event if all requests are completed */
1831 if (0 == context->request_bitmap)
1832 complete(&context->response_event);
1833 spin_unlock(&hdd_context_lock);
1834
Sunil Duttc69bccb2014-05-26 21:30:20 +05301835 break;
1836 }
1837 default:
1838 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1839 break;
1840 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301841
1842 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301843 return;
1844}
1845
1846const struct
1847nla_policy
1848qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1849{
1850 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1851 { .type = NLA_U32 },
1852 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1853 { .type = NLA_U32 },
1854};
1855
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301856static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1857 struct wireless_dev *wdev,
1858 const void *data,
1859 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301860{
1861 int status;
1862 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301863 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301864 struct net_device *dev = wdev->netdev;
1865 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1866 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1867
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301868 ENTER();
1869
Sunil Duttc69bccb2014-05-26 21:30:20 +05301870 status = wlan_hdd_validate_context(pHddCtx);
1871 if (0 != status)
1872 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301873 return -EINVAL;
1874 }
1875
1876 if (NULL == pAdapter)
1877 {
1878 hddLog(VOS_TRACE_LEVEL_ERROR,
1879 FL("HDD adapter is Null"));
1880 return -ENODEV;
1881 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301882 /* check the LLStats Capability */
1883 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1884 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1885 {
1886 hddLog(VOS_TRACE_LEVEL_ERROR,
1887 FL("Link Layer Statistics not supported by Firmware"));
1888 return -EINVAL;
1889 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301890
1891 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1892 (struct nlattr *)data,
1893 data_len, qca_wlan_vendor_ll_set_policy))
1894 {
1895 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1896 return -EINVAL;
1897 }
1898 if (!tb_vendor
1899 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1900 {
1901 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1902 return -EINVAL;
1903 }
1904 if (!tb_vendor[
1905 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1906 {
1907 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1908 return -EINVAL;
1909 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301910 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301911 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301912
Dino Mycledf0a5d92014-07-04 09:41:55 +05301913 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301914 nla_get_u32(
1915 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1916
Dino Mycledf0a5d92014-07-04 09:41:55 +05301917 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301918 nla_get_u32(
1919 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1920
Dino Mycled3d50022014-07-07 12:58:25 +05301921 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1922 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301923
1924
1925 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301926 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301927 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301928 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301929 hddLog(VOS_TRACE_LEVEL_INFO,
1930 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301931 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301932 hddLog(VOS_TRACE_LEVEL_INFO,
1933 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301934 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301935
1936 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1937 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301938 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301939 {
1940 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1941 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301942 return -EINVAL;
1943
1944 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301945
Sunil Duttc69bccb2014-05-26 21:30:20 +05301946 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301947 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301948 {
1949 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1950 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301951 return -EINVAL;
1952 }
1953
1954 pAdapter->isLinkLayerStatsSet = 1;
1955
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301956 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301957 return 0;
1958}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301959static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1960 struct wireless_dev *wdev,
1961 const void *data,
1962 int data_len)
1963{
1964 int ret = 0;
1965
1966 vos_ssr_protect(__func__);
1967 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1968 vos_ssr_unprotect(__func__);
1969
1970 return ret;
1971}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301972
1973const struct
1974nla_policy
1975qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1976{
1977 /* Unsigned 32bit value provided by the caller issuing the GET stats
1978 * command. When reporting
1979 * the stats results, the driver uses the same value to indicate
1980 * which GET request the results
1981 * correspond to.
1982 */
1983 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1984
1985 /* Unsigned 32bit value . bit mask to identify what statistics are
1986 requested for retrieval */
1987 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1988};
1989
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301990static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1991 struct wireless_dev *wdev,
1992 const void *data,
1993 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301994{
mukul sharma4bd8d2e2015-08-13 20:33:25 +05301995 unsigned long rc;
1996 struct hdd_ll_stats_context *context;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301997 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1998 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301999 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302000 struct net_device *dev = wdev->netdev;
2001 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Mukul Sharma10313ba2015-07-29 19:14:39 +05302002 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302003 int status;
2004
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302005 ENTER();
2006
Sunil Duttc69bccb2014-05-26 21:30:20 +05302007 status = wlan_hdd_validate_context(pHddCtx);
2008 if (0 != status)
2009 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302010 return -EINVAL ;
2011 }
2012
2013 if (NULL == pAdapter)
2014 {
2015 hddLog(VOS_TRACE_LEVEL_FATAL,
2016 "%s: HDD adapter is Null", __func__);
2017 return -ENODEV;
2018 }
Mukul Sharma10313ba2015-07-29 19:14:39 +05302019
2020 if (pHddStaCtx == NULL)
2021 {
2022 hddLog(VOS_TRACE_LEVEL_FATAL,
2023 "%s: HddStaCtx is Null", __func__);
2024 return -ENODEV;
2025 }
2026
Dino Mycledf0a5d92014-07-04 09:41:55 +05302027 /* check the LLStats Capability */
2028 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2029 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2030 {
2031 hddLog(VOS_TRACE_LEVEL_ERROR,
2032 FL("Link Layer Statistics not supported by Firmware"));
2033 return -EINVAL;
2034 }
2035
Sunil Duttc69bccb2014-05-26 21:30:20 +05302036
2037 if (!pAdapter->isLinkLayerStatsSet)
2038 {
2039 hddLog(VOS_TRACE_LEVEL_FATAL,
2040 "%s: isLinkLayerStatsSet : %d",
2041 __func__, pAdapter->isLinkLayerStatsSet);
2042 return -EINVAL;
2043 }
2044
Mukul Sharma10313ba2015-07-29 19:14:39 +05302045 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
2046 {
2047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2048 "%s: Roaming in progress, so unable to proceed this request", __func__);
2049 return -EBUSY;
2050 }
2051
Sunil Duttc69bccb2014-05-26 21:30:20 +05302052 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2053 (struct nlattr *)data,
2054 data_len, qca_wlan_vendor_ll_get_policy))
2055 {
2056 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2057 return -EINVAL;
2058 }
2059
2060 if (!tb_vendor
2061 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2062 {
2063 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2064 return -EINVAL;
2065 }
2066
2067 if (!tb_vendor
2068 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2069 {
2070 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
2071 return -EINVAL;
2072 }
2073
Sunil Duttc69bccb2014-05-26 21:30:20 +05302074
Dino Mycledf0a5d92014-07-04 09:41:55 +05302075 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302076 nla_get_u32( tb_vendor[
2077 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05302078 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302079 nla_get_u32( tb_vendor[
2080 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
2081
Dino Mycled3d50022014-07-07 12:58:25 +05302082 vos_mem_copy(linkLayerStatsGetReq.macAddr,
2083 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302084
2085 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302086 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302087 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302088 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302089 hddLog(VOS_TRACE_LEVEL_INFO,
2090 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302091 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302092
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302093 spin_lock(&hdd_context_lock);
2094 context = &pHddCtx->ll_stats_context;
2095 context->request_id = linkLayerStatsGetReq.reqId;
2096 context->request_bitmap = linkLayerStatsGetReq.paramIdMask;
2097 INIT_COMPLETION(context->response_event);
2098 spin_unlock(&hdd_context_lock);
2099
Sunil Duttc69bccb2014-05-26 21:30:20 +05302100 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302101 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302102 {
2103 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2104 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302105 return -EINVAL;
2106 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302107
mukul sharma4bd8d2e2015-08-13 20:33:25 +05302108 rc = wait_for_completion_timeout(&context->response_event,
2109 msecs_to_jiffies(WLAN_WAIT_TIME_LL_STATS));
2110 if (!rc)
2111 {
2112 hddLog(LOGE,
2113 FL("Target response timed out request id %d request bitmap 0x%x"),
2114 context->request_id, context->request_bitmap);
2115 return -ETIMEDOUT;
2116 }
2117
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302118 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302119 return 0;
2120}
2121
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302122static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2123 struct wireless_dev *wdev,
2124 const void *data,
2125 int data_len)
2126{
2127 int ret = 0;
2128
2129 vos_ssr_protect(__func__);
2130 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
2131 vos_ssr_unprotect(__func__);
2132
2133 return ret;
2134}
2135
Sunil Duttc69bccb2014-05-26 21:30:20 +05302136const struct
2137nla_policy
2138qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
2139{
2140 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
2141 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
2142 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
2143 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
2144};
2145
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302146static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2147 struct wireless_dev *wdev,
2148 const void *data,
2149 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302150{
2151 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2152 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302153 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302154 struct net_device *dev = wdev->netdev;
2155 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2156 u32 statsClearReqMask;
2157 u8 stopReq;
2158 int status;
2159
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302160 ENTER();
2161
Sunil Duttc69bccb2014-05-26 21:30:20 +05302162 status = wlan_hdd_validate_context(pHddCtx);
2163 if (0 != status)
2164 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302165 return -EINVAL;
2166 }
2167
2168 if (NULL == pAdapter)
2169 {
2170 hddLog(VOS_TRACE_LEVEL_FATAL,
2171 "%s: HDD adapter is Null", __func__);
2172 return -ENODEV;
2173 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302174 /* check the LLStats Capability */
2175 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2176 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2177 {
2178 hddLog(VOS_TRACE_LEVEL_ERROR,
2179 FL("Enable LLStats Capability"));
2180 return -EINVAL;
2181 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302182
2183 if (!pAdapter->isLinkLayerStatsSet)
2184 {
2185 hddLog(VOS_TRACE_LEVEL_FATAL,
2186 "%s: isLinkLayerStatsSet : %d",
2187 __func__, pAdapter->isLinkLayerStatsSet);
2188 return -EINVAL;
2189 }
2190
2191 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2192 (struct nlattr *)data,
2193 data_len, qca_wlan_vendor_ll_clr_policy))
2194 {
2195 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2196 return -EINVAL;
2197 }
2198
2199 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2200
2201 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2202 {
2203 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2204 return -EINVAL;
2205
2206 }
2207
Sunil Duttc69bccb2014-05-26 21:30:20 +05302208
Dino Mycledf0a5d92014-07-04 09:41:55 +05302209 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302210 nla_get_u32(
2211 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2212
Dino Mycledf0a5d92014-07-04 09:41:55 +05302213 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302214 nla_get_u8(
2215 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2216
2217 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302218 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302219
Dino Mycled3d50022014-07-07 12:58:25 +05302220 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2221 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302222
2223 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302224 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302225 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302226 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302227 hddLog(VOS_TRACE_LEVEL_INFO,
2228 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302229 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302230 hddLog(VOS_TRACE_LEVEL_INFO,
2231 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302232 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302233
2234 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302235 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302236 {
2237 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302238 hdd_station_ctx_t *pHddStaCtx;
2239
2240 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2241 if (VOS_STATUS_SUCCESS !=
2242 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2243 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2244 {
2245 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2246 "WLANTL_ClearInterfaceStats Failed", __func__);
2247 return -EINVAL;
2248 }
2249 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2250 (statsClearReqMask & WIFI_STATS_IFACE)) {
2251 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2252 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2253 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2254 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2255 }
2256
Sunil Duttc69bccb2014-05-26 21:30:20 +05302257 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2258 2 * sizeof(u32) +
2259 NLMSG_HDRLEN);
2260
2261 if (temp_skbuff != NULL)
2262 {
2263
2264 if (nla_put_u32(temp_skbuff,
2265 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2266 statsClearReqMask) ||
2267 nla_put_u32(temp_skbuff,
2268 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2269 stopReq))
2270 {
2271 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2272 kfree_skb(temp_skbuff);
2273 return -EINVAL;
2274 }
2275 /* If the ask is to stop the stats collection as part of clear
2276 * (stopReq = 1) , ensure that no further requests of get
2277 * go to the firmware by having isLinkLayerStatsSet set to 0.
2278 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302279 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302280 * case the firmware is just asked to clear the statistics.
2281 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302282 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302283 pAdapter->isLinkLayerStatsSet = 0;
2284 return cfg80211_vendor_cmd_reply(temp_skbuff);
2285 }
2286 return -ENOMEM;
2287 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302288
2289 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302290 return -EINVAL;
2291}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302292static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2293 struct wireless_dev *wdev,
2294 const void *data,
2295 int data_len)
2296{
2297 int ret = 0;
2298
2299 vos_ssr_protect(__func__);
2300 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2301 vos_ssr_unprotect(__func__);
2302
2303 return ret;
2304
2305
2306}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302307#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2308
Dino Mycle6fb96c12014-06-10 11:52:40 +05302309#ifdef WLAN_FEATURE_EXTSCAN
2310static const struct nla_policy
2311wlan_hdd_extscan_config_policy
2312 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2313{
2314 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2315 { .type = NLA_U32 },
2316 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2317 { .type = NLA_U32 },
2318 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2319 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2320 { .type = NLA_U32 },
2321 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2322 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2323
2324 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2325 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2326 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2327 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2328 { .type = NLA_U8 },
2329 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2330 { .type = NLA_U32 },
2331 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2332 { .type = NLA_U32 },
2333 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2334 { .type = NLA_U32 },
2335 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] =
2336 { .type = NLA_U8 },
2337 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2338 { .type = NLA_U8 },
2339 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2340 { .type = NLA_U8 },
2341
2342 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2343 { .type = NLA_U32 },
2344 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2345 { .type = NLA_UNSPEC },
2346 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2347 { .type = NLA_S32 },
2348 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2349 { .type = NLA_S32 },
2350 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2351 { .type = NLA_U32 },
2352 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2353 { .type = NLA_U32 },
2354 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] =
2355 { .type = NLA_U32 },
2356 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]
2357 = { .type = NLA_U32 },
2358 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] =
2359 { .type = NLA_U32 },
2360 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type =
2361 NLA_U32 },
2362};
2363
2364static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg)
2365{
2366 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2367 struct sk_buff *skb = NULL;
2368 tpSirEXTScanCapabilitiesEvent pData =
2369 (tpSirEXTScanCapabilitiesEvent) pMsg;
2370
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302371 ENTER();
2372
2373 if (wlan_hdd_validate_context(pHddCtx))
2374 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302375 return;
2376 }
2377
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302378 if (!pMsg)
2379 {
2380 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2381 return;
2382 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302383 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302384#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2385 NULL,
2386#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302387 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2388 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
2389 GFP_KERNEL);
2390
2391 if (!skb) {
2392 hddLog(VOS_TRACE_LEVEL_ERROR,
2393 FL("cfg80211_vendor_event_alloc failed"));
2394 return;
2395 }
2396
2397 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2398 hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize);
2399 hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets);
2400 hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan);
2401 hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)",
2402 pData->maxRssiSampleSize);
2403 hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)",
2404 pData->maxScanReportingThreshold);
2405 hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs);
2406 hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)",
2407 pData->maxSignificantWifiChangeAPs);
2408 hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)",
2409 pData->maxBsidHistoryEntries);
2410
2411 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2412 pData->requestId) ||
2413 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) ||
2414 nla_put_u32(skb,
2415 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
2416 pData->scanCacheSize) ||
2417 nla_put_u32(skb,
2418 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
2419 pData->scanBuckets) ||
2420 nla_put_u32(skb,
2421 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
2422 pData->maxApPerScan) ||
2423 nla_put_u32(skb,
2424 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
2425 pData->maxRssiSampleSize) ||
2426 nla_put_u32(skb,
2427 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
2428 pData->maxScanReportingThreshold) ||
2429 nla_put_u32(skb,
2430 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS,
2431 pData->maxHotlistAPs) ||
2432 nla_put_u32(skb,
2433 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
2434 pData->maxSignificantWifiChangeAPs) ||
2435 nla_put_u32(skb,
2436 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
2437 pData->maxBsidHistoryEntries)) {
2438 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2439 goto nla_put_failure;
2440 }
2441
2442 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302443 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302444 return;
2445
2446nla_put_failure:
2447 kfree_skb(skb);
2448 return;
2449}
2450
2451
2452static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2453{
2454 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2455 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2456 struct sk_buff *skb = NULL;
2457 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
2458
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302459 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302460
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302461 if (wlan_hdd_validate_context(pHddCtx)){
2462 return;
2463 }
2464 if (!pMsg)
2465 {
2466 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302467 return;
2468 }
2469
2470 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302471#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2472 NULL,
2473#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302474 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2475 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
2476 GFP_KERNEL);
2477
2478 if (!skb) {
2479 hddLog(VOS_TRACE_LEVEL_ERROR,
2480 FL("cfg80211_vendor_event_alloc failed"));
2481 return;
2482 }
2483 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2484 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2485 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2486
2487 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2488 pData->requestId) ||
2489 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2490 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2491 goto nla_put_failure;
2492 }
2493
2494 /*
2495 * Store the Request ID for comparing with the requestID obtained
2496 * in other requests.HDD shall return a failure is the extscan_stop
2497 * request is issued with a different requestId as that of the
2498 * extscan_start request. Also, This requestId shall be used while
2499 * indicating the full scan results to the upper layers.
2500 * The requestId is stored with the assumption that the firmware
2501 * shall return the ext scan start request's requestId in ext scan
2502 * start response.
2503 */
2504 if (pData->status == 0)
2505 pMac->sme.extScanStartReqId = pData->requestId;
2506
2507
2508 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302509 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302510 return;
2511
2512nla_put_failure:
2513 kfree_skb(skb);
2514 return;
2515}
2516
2517
2518static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2519{
2520 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2521 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2522 struct sk_buff *skb = NULL;
2523
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302524 ENTER();
2525
2526 if (wlan_hdd_validate_context(pHddCtx)){
2527 return;
2528 }
2529 if (!pMsg)
2530 {
2531 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302532 return;
2533 }
2534
2535 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302536#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2537 NULL,
2538#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302539 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2540 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2541 GFP_KERNEL);
2542
2543 if (!skb) {
2544 hddLog(VOS_TRACE_LEVEL_ERROR,
2545 FL("cfg80211_vendor_event_alloc failed"));
2546 return;
2547 }
2548 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2549 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2550
2551 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2552 pData->requestId) ||
2553 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2554 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2555 goto nla_put_failure;
2556 }
2557
2558 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302559 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302560 return;
2561
2562nla_put_failure:
2563 kfree_skb(skb);
2564 return;
2565}
2566
2567
2568static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2569 void *pMsg)
2570{
2571 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2572 struct sk_buff *skb = NULL;
2573 tpSirEXTScanSetBssidHotListRspParams pData =
2574 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2575
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302576 ENTER();
2577
2578 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302579 return;
2580 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302581 if (!pMsg)
2582 {
2583 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2584 return;
2585 }
2586
Dino Mycle6fb96c12014-06-10 11:52:40 +05302587 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302588#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2589 NULL,
2590#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302591 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2592 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2593 GFP_KERNEL);
2594
2595 if (!skb) {
2596 hddLog(VOS_TRACE_LEVEL_ERROR,
2597 FL("cfg80211_vendor_event_alloc failed"));
2598 return;
2599 }
2600 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2601 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2602 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2603
2604 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2605 pData->requestId) ||
2606 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2607 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2608 goto nla_put_failure;
2609 }
2610
2611 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302612 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302613 return;
2614
2615nla_put_failure:
2616 kfree_skb(skb);
2617 return;
2618}
2619
2620static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2621 void *pMsg)
2622{
2623 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2624 struct sk_buff *skb = NULL;
2625 tpSirEXTScanResetBssidHotlistRspParams pData =
2626 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2627
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302628 ENTER();
2629
2630 if (wlan_hdd_validate_context(pHddCtx)) {
2631 return;
2632 }
2633 if (!pMsg)
2634 {
2635 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302636 return;
2637 }
2638
2639 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302640#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2641 NULL,
2642#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302643 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2644 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2645 GFP_KERNEL);
2646
2647 if (!skb) {
2648 hddLog(VOS_TRACE_LEVEL_ERROR,
2649 FL("cfg80211_vendor_event_alloc failed"));
2650 return;
2651 }
2652 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2653 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2654
2655 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2656 pData->requestId) ||
2657 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2658 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2659 goto nla_put_failure;
2660 }
2661
2662 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302663 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302664 return;
2665
2666nla_put_failure:
2667 kfree_skb(skb);
2668 return;
2669}
2670
2671
2672static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2673 void *pMsg)
2674{
2675 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2676 struct sk_buff *skb = NULL;
2677 tpSirEXTScanSetSignificantChangeRspParams pData =
2678 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2679
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302680 ENTER();
2681
2682 if (wlan_hdd_validate_context(pHddCtx)) {
2683 return;
2684 }
2685 if (!pMsg)
2686 {
2687 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302688 return;
2689 }
2690
2691 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302692#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2693 NULL,
2694#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302695 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2696 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2697 GFP_KERNEL);
2698
2699 if (!skb) {
2700 hddLog(VOS_TRACE_LEVEL_ERROR,
2701 FL("cfg80211_vendor_event_alloc failed"));
2702 return;
2703 }
2704 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2705 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2706 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2707
2708 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2709 pData->requestId) ||
2710 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2711 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2712 goto nla_put_failure;
2713 }
2714
2715 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302716 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302717 return;
2718
2719nla_put_failure:
2720 kfree_skb(skb);
2721 return;
2722}
2723
2724
2725static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2726 void *pMsg)
2727{
2728 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2729 struct sk_buff *skb = NULL;
2730 tpSirEXTScanResetSignificantChangeRspParams pData =
2731 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2732
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302733 ENTER();
2734
2735 if (wlan_hdd_validate_context(pHddCtx)) {
2736 return;
2737 }
2738 if (!pMsg)
2739 {
2740 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302741 return;
2742 }
2743
2744 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302745#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2746 NULL,
2747#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302748 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2749 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2750 GFP_KERNEL);
2751
2752 if (!skb) {
2753 hddLog(VOS_TRACE_LEVEL_ERROR,
2754 FL("cfg80211_vendor_event_alloc failed"));
2755 return;
2756 }
2757 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2758 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2759 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2760
2761 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2762 pData->requestId) ||
2763 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2764 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2765 goto nla_put_failure;
2766 }
2767
2768 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302769 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302770 return;
2771
2772nla_put_failure:
2773 kfree_skb(skb);
2774 return;
2775}
2776
2777static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2778 void *pMsg)
2779{
2780 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2781 struct sk_buff *skb = NULL;
2782 tANI_U32 i = 0, j, resultsPerEvent;
2783 tANI_S32 totalResults;
2784 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2785 tpSirWifiScanResult pSirWifiScanResult;
2786
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302787 ENTER();
2788
2789 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302790 return;
2791 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302792 if (!pMsg)
2793 {
2794 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2795 return;
2796 }
2797
Dino Mycle6fb96c12014-06-10 11:52:40 +05302798 totalResults = pData->numOfAps;
2799 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2800 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2801 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2802
2803 do{
2804 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2805 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2806 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2807
2808 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302809#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2810 NULL,
2811#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302812 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2813 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2814 GFP_KERNEL);
2815
2816 if (!skb) {
2817 hddLog(VOS_TRACE_LEVEL_ERROR,
2818 FL("cfg80211_vendor_event_alloc failed"));
2819 return;
2820 }
2821
2822 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2823
2824 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2825 pData->requestId) ||
2826 nla_put_u32(skb,
2827 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2828 resultsPerEvent)) {
2829 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2830 goto fail;
2831 }
2832 if (nla_put_u8(skb,
2833 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2834 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2835 {
2836 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2837 goto fail;
2838 }
2839
2840 if (resultsPerEvent) {
2841 struct nlattr *aps;
2842
2843 aps = nla_nest_start(skb,
2844 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2845 if (!aps)
2846 {
2847 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2848 goto fail;
2849 }
2850
2851 for (j = 0; j < resultsPerEvent; j++, i++) {
2852 struct nlattr *ap;
2853 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2854 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2855
2856 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2857 "Ssid (%s)"
2858 "Bssid: %pM "
2859 "Channel (%u)"
2860 "Rssi (%d)"
2861 "RTT (%u)"
2862 "RTT_SD (%u)",
2863 i,
2864 pSirWifiScanResult->ts,
2865 pSirWifiScanResult->ssid,
2866 pSirWifiScanResult->bssid,
2867 pSirWifiScanResult->channel,
2868 pSirWifiScanResult->rssi,
2869 pSirWifiScanResult->rtt,
2870 pSirWifiScanResult->rtt_sd);
2871
2872 ap = nla_nest_start(skb, j + 1);
2873 if (!ap)
2874 {
2875 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2876 goto fail;
2877 }
2878
2879 if (nla_put_u64(skb,
2880 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2881 pSirWifiScanResult->ts) )
2882 {
2883 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2884 goto fail;
2885 }
2886 if (nla_put(skb,
2887 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2888 sizeof(pSirWifiScanResult->ssid),
2889 pSirWifiScanResult->ssid) )
2890 {
2891 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2892 goto fail;
2893 }
2894 if (nla_put(skb,
2895 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2896 sizeof(pSirWifiScanResult->bssid),
2897 pSirWifiScanResult->bssid) )
2898 {
2899 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2900 goto fail;
2901 }
2902 if (nla_put_u32(skb,
2903 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2904 pSirWifiScanResult->channel) )
2905 {
2906 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2907 goto fail;
2908 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302909 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302910 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2911 pSirWifiScanResult->rssi) )
2912 {
2913 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2914 goto fail;
2915 }
2916 if (nla_put_u32(skb,
2917 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2918 pSirWifiScanResult->rtt) )
2919 {
2920 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2921 goto fail;
2922 }
2923 if (nla_put_u32(skb,
2924 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2925 pSirWifiScanResult->rtt_sd))
2926 {
2927 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2928 goto fail;
2929 }
2930
2931 nla_nest_end(skb, ap);
2932 }
2933 nla_nest_end(skb, aps);
2934
2935 }
2936 cfg80211_vendor_event(skb, GFP_KERNEL);
2937 } while (totalResults > 0);
2938
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302939 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302940 return;
2941fail:
2942 kfree_skb(skb);
2943 return;
2944}
2945
2946static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2947 void *pMsg)
2948{
2949 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2950 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2951 struct sk_buff *skb = NULL;
2952 tANI_U32 i;
2953
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302954 ENTER();
2955
2956 if (wlan_hdd_validate_context(pHddCtx)) {
2957 return;
2958 }
2959 if (!pMsg)
2960 {
2961 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302962 return;
2963 }
2964
2965 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05302966#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
2967 NULL,
2968#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05302969 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2970 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
2971 GFP_KERNEL);
2972
2973 if (!skb) {
2974 hddLog(VOS_TRACE_LEVEL_ERROR,
2975 FL("cfg80211_vendor_event_alloc failed"));
2976 return;
2977 }
2978 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2979 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2980 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2981 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2982
2983 for (i = 0; i < pData->numOfAps; i++) {
2984 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2985 "Ssid (%s) "
2986 "Bssid (" MAC_ADDRESS_STR ") "
2987 "Channel (%u) "
2988 "Rssi (%d) "
2989 "RTT (%u) "
2990 "RTT_SD (%u) ",
2991 i,
2992 pData->ap[i].ts,
2993 pData->ap[i].ssid,
2994 MAC_ADDR_ARRAY(pData->ap[i].bssid),
2995 pData->ap[i].channel,
2996 pData->ap[i].rssi,
2997 pData->ap[i].rtt,
2998 pData->ap[i].rtt_sd);
2999 }
3000
3001 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3002 pData->requestId) ||
3003 nla_put_u32(skb,
3004 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3005 pData->numOfAps)) {
3006 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3007 goto fail;
3008 }
3009 if (pData->numOfAps) {
3010 struct nlattr *aps;
3011
3012 aps = nla_nest_start(skb,
3013 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3014 if (!aps)
3015 goto fail;
3016
3017 for (i = 0; i < pData->numOfAps; i++) {
3018 struct nlattr *ap;
3019
3020 ap = nla_nest_start(skb, i + 1);
3021 if (!ap)
3022 goto fail;
3023
3024 if (nla_put_u64(skb,
3025 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3026 pData->ap[i].ts) ||
3027 nla_put(skb,
3028 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3029 sizeof(pData->ap[i].ssid),
3030 pData->ap[i].ssid) ||
3031 nla_put(skb,
3032 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3033 sizeof(pData->ap[i].bssid),
3034 pData->ap[i].bssid) ||
3035 nla_put_u32(skb,
3036 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3037 pData->ap[i].channel) ||
3038 nla_put_s32(skb,
3039 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
3040 pData->ap[i].rssi) ||
3041 nla_put_u32(skb,
3042 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3043 pData->ap[i].rtt) ||
3044 nla_put_u32(skb,
3045 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3046 pData->ap[i].rtt_sd))
3047 goto fail;
3048
3049 nla_nest_end(skb, ap);
3050 }
3051 nla_nest_end(skb, aps);
3052
3053 if (nla_put_u8(skb,
3054 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3055 pData->moreData))
3056 goto fail;
3057 }
3058
3059 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303060 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303061 return;
3062
3063fail:
3064 kfree_skb(skb);
3065 return;
3066
3067}
3068static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
3069 void *pMsg)
3070{
3071 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3072 struct sk_buff *skb = NULL;
3073 tANI_U32 i, j;
3074 tpSirWifiSignificantChangeEvent pData =
3075 (tpSirWifiSignificantChangeEvent) pMsg;
3076
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303077 ENTER();
3078
3079 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303080 return;
3081 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303082 if (!pMsg)
3083 {
3084 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3085 return;
3086 }
3087
Dino Mycle6fb96c12014-06-10 11:52:40 +05303088 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303089#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3090 NULL,
3091#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303092 EXTSCAN_EVENT_BUF_SIZE,
3093 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
3094 GFP_KERNEL);
3095
3096 if (!skb) {
3097 hddLog(VOS_TRACE_LEVEL_ERROR,
3098 FL("cfg80211_vendor_event_alloc failed"));
3099 return;
3100 }
3101 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3102 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3103 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
3104 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
3105 pData->numSigRssiBss);
3106 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
3107
3108 for (i = 0; i < pData->numSigRssiBss; i++) {
3109 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
3110 " num RSSI %u ",
3111 i, pData->sigRssiResult[i].bssid,
3112 pData->sigRssiResult[i].channel,
3113 pData->sigRssiResult[i].numRssi);
3114
3115 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
3116
3117 hddLog(VOS_TRACE_LEVEL_INFO,
3118 " [%d]",
Dino Myclec8f3f332014-07-21 16:48:27 +05303119 pData->sigRssiResult[i].rssi[j]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303120
3121 }
3122 }
3123
3124
3125 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3126 pData->requestId) ||
3127 nla_put_u32(skb,
3128 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3129 pData->numSigRssiBss)) {
3130 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3131 goto fail;
3132 }
3133
3134 if (pData->numSigRssiBss) {
3135 struct nlattr *aps;
3136 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3137 if (!aps)
3138 goto fail;
3139 for (i = 0; i < pData->numSigRssiBss; i++) {
3140 struct nlattr *ap;
3141
3142 ap = nla_nest_start(skb, i);
3143 if (!ap)
3144 goto fail;
3145 if (nla_put(skb,
3146 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
3147 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
3148 nla_put_u32(skb,
3149 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
3150 pData->sigRssiResult[i].channel) ||
3151 nla_put_u32(skb,
3152 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
3153 pData->sigRssiResult[i].numRssi) ||
3154 nla_put(skb,
3155 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
3156 sizeof(s32) * pData->sigRssiResult[i].numRssi,
3157 pData->sigRssiResult[i].rssi))
3158 goto fail;
3159 nla_nest_end(skb, ap);
3160 }
3161 nla_nest_end(skb, aps);
3162 if (nla_put_u8(skb,
3163 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3164 pData->moreData))
3165 goto fail;
3166 }
3167 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303168 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303169 return;
3170fail:
3171 kfree_skb(skb);
3172 return;
3173}
3174
3175static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3176 void *pMsg)
3177{
3178 struct sk_buff *skb;
3179 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3180 tpSirWifiFullScanResultEvent pData =
3181 (tpSirWifiFullScanResultEvent) (pMsg);
3182
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303183 ENTER();
3184
3185 if (wlan_hdd_validate_context(pHddCtx)) {
3186 return;
3187 }
3188 if (!pMsg)
3189 {
3190 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303191 return;
3192 }
3193
3194 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303195#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3196 NULL,
3197#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303198 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3199 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3200 GFP_KERNEL);
3201
3202 if (!skb) {
3203 hddLog(VOS_TRACE_LEVEL_ERROR,
3204 FL("cfg80211_vendor_event_alloc failed"));
3205 return;
3206 }
3207
3208 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3209 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3210 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3211 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3212 "Ssid (%s)"
3213 "Bssid (" MAC_ADDRESS_STR ")"
3214 "Channel (%u)"
3215 "Rssi (%d)"
3216 "RTT (%u)"
3217 "RTT_SD (%u)"),
3218 pData->ap.ts,
3219 pData->ap.ssid,
3220 MAC_ADDR_ARRAY(pData->ap.bssid),
3221 pData->ap.channel,
3222 pData->ap.rssi,
3223 pData->ap.rtt,
3224 pData->ap.rtt_sd);
3225 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3226 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3227 pData->requestId) ||
3228 nla_put_u64(skb,
3229 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3230 pData->ap.ts) ||
3231 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3232 sizeof(pData->ap.ssid),
3233 pData->ap.ssid) ||
3234 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3235 WNI_CFG_BSSID_LEN,
3236 pData->ap.bssid) ||
3237 nla_put_u32(skb,
3238 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3239 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303240 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303241 pData->ap.rssi) ||
3242 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3243 pData->ap.rtt) ||
3244 nla_put_u32(skb,
3245 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3246 pData->ap.rtt_sd) ||
3247 nla_put_u16(skb,
3248 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3249 pData->ap.beaconPeriod) ||
3250 nla_put_u16(skb,
3251 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3252 pData->ap.capability) ||
3253 nla_put_u32(skb,
3254 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3255 pData->ieLength))
3256 {
3257 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3258 goto nla_put_failure;
3259 }
3260 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3261 pData->ieLength,
3262 pData->ie))
3263 {
3264 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3265 goto nla_put_failure;
3266 }
3267
3268 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303269 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303270 return;
3271
3272nla_put_failure:
3273 kfree_skb(skb);
3274 return;
3275}
3276
3277static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3278 void *pMsg)
3279{
3280 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3281 struct sk_buff *skb = NULL;
3282 tpSirEXTScanResultsAvailableIndParams pData =
3283 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3284
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303285 ENTER();
3286
3287 if (wlan_hdd_validate_context(pHddCtx)){
3288 return;
3289 }
3290 if (!pMsg)
3291 {
3292 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303293 return;
3294 }
3295
3296 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303297#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3298 NULL,
3299#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303300 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3301 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3302 GFP_KERNEL);
3303
3304 if (!skb) {
3305 hddLog(VOS_TRACE_LEVEL_ERROR,
3306 FL("cfg80211_vendor_event_alloc failed"));
3307 return;
3308 }
3309
3310 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3311 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3312 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3313 pData->numResultsAvailable);
3314 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3315 pData->requestId) ||
3316 nla_put_u32(skb,
3317 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3318 pData->numResultsAvailable)) {
3319 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3320 goto nla_put_failure;
3321 }
3322
3323 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303324 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303325 return;
3326
3327nla_put_failure:
3328 kfree_skb(skb);
3329 return;
3330}
3331
3332static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3333{
3334 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3335 struct sk_buff *skb = NULL;
3336 tpSirEXTScanProgressIndParams pData =
3337 (tpSirEXTScanProgressIndParams) pMsg;
3338
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303339 ENTER();
3340
3341 if (wlan_hdd_validate_context(pHddCtx)){
3342 return;
3343 }
3344 if (!pMsg)
3345 {
3346 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303347 return;
3348 }
3349
3350 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05303351#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
3352 NULL,
3353#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +05303354 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3355 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3356 GFP_KERNEL);
3357
3358 if (!skb) {
3359 hddLog(VOS_TRACE_LEVEL_ERROR,
3360 FL("cfg80211_vendor_event_alloc failed"));
3361 return;
3362 }
3363 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3364 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3365 pData->extScanEventType);
3366 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3367 pData->status);
3368
3369 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3370 pData->extScanEventType) ||
3371 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303372 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3373 pData->requestId) ||
3374 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303375 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3376 pData->status)) {
3377 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3378 goto nla_put_failure;
3379 }
3380
3381 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303382 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303383 return;
3384
3385nla_put_failure:
3386 kfree_skb(skb);
3387 return;
3388}
3389
3390void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3391 void *pMsg)
3392{
3393 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3394
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303395 ENTER();
3396
Dino Mycle6fb96c12014-06-10 11:52:40 +05303397 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303398 return;
3399 }
3400
3401 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3402
3403
3404 switch(evType) {
3405 case SIR_HAL_EXTSCAN_START_RSP:
3406 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3407 break;
3408
3409 case SIR_HAL_EXTSCAN_STOP_RSP:
3410 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3411 break;
3412 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3413 /* There is no need to send this response to upper layer
3414 Just log the message */
3415 hddLog(VOS_TRACE_LEVEL_INFO,
3416 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3417 break;
3418 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3419 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3420 break;
3421
3422 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3423 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3424 break;
3425
3426 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
3427 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
3428 break;
3429
3430 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
3431 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
3432 break;
3433 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
3434 wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg);
3435 break;
3436 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3437 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3438 break;
3439 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3440 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3441 break;
3442 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3443 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3444 break;
3445 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3446 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3447 break;
3448 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
3449 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
3450 break;
3451 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3452 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3453 break;
3454 default:
3455 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3456 break;
3457 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303458 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303459}
3460
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303461static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3462 struct wireless_dev *wdev,
3463 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303464{
Dino Myclee8843b32014-07-04 14:21:45 +05303465 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303466 struct net_device *dev = wdev->netdev;
3467 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3468 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3469 struct nlattr
3470 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3471 eHalStatus status;
3472
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303473 ENTER();
3474
Dino Mycle6fb96c12014-06-10 11:52:40 +05303475 status = wlan_hdd_validate_context(pHddCtx);
3476 if (0 != status)
3477 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303478 return -EINVAL;
3479 }
Dino Myclee8843b32014-07-04 14:21:45 +05303480 /* check the EXTScan Capability */
3481 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3482 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3483 {
3484 hddLog(VOS_TRACE_LEVEL_ERROR,
3485 FL("EXTScan not enabled/supported by Firmware"));
3486 return -EINVAL;
3487 }
3488
Dino Mycle6fb96c12014-06-10 11:52:40 +05303489 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3490 data, dataLen,
3491 wlan_hdd_extscan_config_policy)) {
3492 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3493 return -EINVAL;
3494 }
3495
3496 /* Parse and fetch request Id */
3497 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3498 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3499 return -EINVAL;
3500 }
3501
Dino Mycle6fb96c12014-06-10 11:52:40 +05303502
Dino Myclee8843b32014-07-04 14:21:45 +05303503 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303504 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303505 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303506
Dino Myclee8843b32014-07-04 14:21:45 +05303507 reqMsg.sessionId = pAdapter->sessionId;
3508 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303509
Dino Myclee8843b32014-07-04 14:21:45 +05303510 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303511 if (!HAL_STATUS_SUCCESS(status)) {
3512 hddLog(VOS_TRACE_LEVEL_ERROR,
3513 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303514 return -EINVAL;
3515 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303516 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303517 return 0;
3518}
3519
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303520static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3521 struct wireless_dev *wdev,
3522 const void *data, int dataLen)
3523{
3524 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303525
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303526 vos_ssr_protect(__func__);
3527 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3528 vos_ssr_unprotect(__func__);
3529
3530 return ret;
3531}
3532
3533static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3534 struct wireless_dev *wdev,
3535 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303536{
Dino Myclee8843b32014-07-04 14:21:45 +05303537 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303538 struct net_device *dev = wdev->netdev;
3539 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3540 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3541 struct nlattr
3542 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3543 eHalStatus status;
3544
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303545 ENTER();
3546
Dino Mycle6fb96c12014-06-10 11:52:40 +05303547 status = wlan_hdd_validate_context(pHddCtx);
3548 if (0 != status)
3549 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303550 return -EINVAL;
3551 }
Dino Myclee8843b32014-07-04 14:21:45 +05303552 /* check the EXTScan Capability */
3553 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3554 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3555 {
3556 hddLog(VOS_TRACE_LEVEL_ERROR,
3557 FL("EXTScan not enabled/supported by Firmware"));
3558 return -EINVAL;
3559 }
3560
Dino Mycle6fb96c12014-06-10 11:52:40 +05303561 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3562 data, dataLen,
3563 wlan_hdd_extscan_config_policy)) {
3564 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3565 return -EINVAL;
3566 }
3567 /* Parse and fetch request Id */
3568 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3569 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3570 return -EINVAL;
3571 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303572
Dino Myclee8843b32014-07-04 14:21:45 +05303573 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303574 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3575
Dino Myclee8843b32014-07-04 14:21:45 +05303576 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303577
Dino Myclee8843b32014-07-04 14:21:45 +05303578 reqMsg.sessionId = pAdapter->sessionId;
3579 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303580
3581 /* Parse and fetch flush parameter */
3582 if (!tb
3583 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3584 {
3585 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3586 goto failed;
3587 }
Dino Myclee8843b32014-07-04 14:21:45 +05303588 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303589 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3590
Dino Myclee8843b32014-07-04 14:21:45 +05303591 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303592
Dino Myclee8843b32014-07-04 14:21:45 +05303593 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303594 if (!HAL_STATUS_SUCCESS(status)) {
3595 hddLog(VOS_TRACE_LEVEL_ERROR,
3596 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303597 return -EINVAL;
3598 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303599 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303600 return 0;
3601
3602failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303603 return -EINVAL;
3604}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303605static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3606 struct wireless_dev *wdev,
3607 const void *data, int dataLen)
3608{
3609 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303610
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303611 vos_ssr_protect(__func__);
3612 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3613 vos_ssr_unprotect(__func__);
3614
3615 return ret;
3616}
3617
3618static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303619 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303620 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303621{
3622 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3623 struct net_device *dev = wdev->netdev;
3624 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3625 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3626 struct nlattr
3627 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3628 struct nlattr
3629 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3630 struct nlattr *apTh;
3631 eHalStatus status;
3632 tANI_U8 i = 0;
3633 int rem;
3634
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303635 ENTER();
3636
Dino Mycle6fb96c12014-06-10 11:52:40 +05303637 status = wlan_hdd_validate_context(pHddCtx);
3638 if (0 != status)
3639 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303640 return -EINVAL;
3641 }
Dino Myclee8843b32014-07-04 14:21:45 +05303642 /* check the EXTScan Capability */
3643 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3644 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3645 {
3646 hddLog(VOS_TRACE_LEVEL_ERROR,
3647 FL("EXTScan not enabled/supported by Firmware"));
3648 return -EINVAL;
3649 }
3650
Dino Mycle6fb96c12014-06-10 11:52:40 +05303651 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3652 data, dataLen,
3653 wlan_hdd_extscan_config_policy)) {
3654 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3655 return -EINVAL;
3656 }
3657
3658 /* Parse and fetch request Id */
3659 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3660 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3661 return -EINVAL;
3662 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303663 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3664 vos_mem_malloc(sizeof(*pReqMsg));
3665 if (!pReqMsg) {
3666 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3667 return -ENOMEM;
3668 }
3669
Dino Myclee8843b32014-07-04 14:21:45 +05303670
Dino Mycle6fb96c12014-06-10 11:52:40 +05303671 pReqMsg->requestId = nla_get_u32(
3672 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3673 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3674
3675 /* Parse and fetch number of APs */
3676 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3677 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3678 goto fail;
3679 }
3680
3681 pReqMsg->sessionId = pAdapter->sessionId;
3682 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3683
3684 pReqMsg->numAp = nla_get_u32(
3685 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3686 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3687
3688 nla_for_each_nested(apTh,
3689 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3690 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3691 nla_data(apTh), nla_len(apTh),
3692 NULL)) {
3693 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3694 goto fail;
3695 }
3696
3697 /* Parse and fetch MAC address */
3698 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3699 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3700 goto fail;
3701 }
3702 memcpy(pReqMsg->ap[i].bssid, nla_data(
3703 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3704 sizeof(tSirMacAddr));
3705 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3706
3707 /* Parse and fetch low RSSI */
3708 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3709 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3710 goto fail;
3711 }
3712 pReqMsg->ap[i].low = nla_get_s32(
3713 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3714 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3715
3716 /* Parse and fetch high RSSI */
3717 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3718 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3719 goto fail;
3720 }
3721 pReqMsg->ap[i].high = nla_get_s32(
3722 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3723 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3724 pReqMsg->ap[i].high);
3725
3726 /* Parse and fetch channel */
3727 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3728 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3729 goto fail;
3730 }
3731 pReqMsg->ap[i].channel = nla_get_u32(
3732 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3733 hddLog(VOS_TRACE_LEVEL_INFO,
3734 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3735 i++;
3736 }
3737 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3738 if (!HAL_STATUS_SUCCESS(status)) {
3739 hddLog(VOS_TRACE_LEVEL_ERROR,
3740 FL("sme_SetBssHotlist failed(err=%d)"), status);
3741 vos_mem_free(pReqMsg);
3742 return -EINVAL;
3743 }
3744
Dino Myclee8843b32014-07-04 14:21:45 +05303745 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303746 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303747 return 0;
3748
3749fail:
3750 vos_mem_free(pReqMsg);
3751 return -EINVAL;
3752}
3753
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303754static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3755 struct wireless_dev *wdev,
3756 const void *data, int dataLen)
3757{
3758 int ret = 0;
3759
3760 vos_ssr_protect(__func__);
3761 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3762 dataLen);
3763 vos_ssr_unprotect(__func__);
3764
3765 return ret;
3766}
3767
3768static int __wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303769 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303770 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303771{
3772 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3773 struct net_device *dev = wdev->netdev;
3774 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3775 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3776 struct nlattr
3777 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3778 struct nlattr
3779 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3780 struct nlattr *apTh;
3781 eHalStatus status;
3782 int i = 0;
3783 int rem;
3784
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303785 ENTER();
3786
Dino Mycle6fb96c12014-06-10 11:52:40 +05303787 status = wlan_hdd_validate_context(pHddCtx);
3788 if (0 != status)
3789 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303790 return -EINVAL;
3791 }
Dino Myclee8843b32014-07-04 14:21:45 +05303792 /* check the EXTScan Capability */
3793 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3794 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3795 {
3796 hddLog(VOS_TRACE_LEVEL_ERROR,
3797 FL("EXTScan not enabled/supported by Firmware"));
3798 return -EINVAL;
3799 }
3800
Dino Mycle6fb96c12014-06-10 11:52:40 +05303801 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3802 data, dataLen,
3803 wlan_hdd_extscan_config_policy)) {
3804 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3805 return -EINVAL;
3806 }
3807
3808 /* Parse and fetch request Id */
3809 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3810 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3811 return -EINVAL;
3812 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303813 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303814 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303815 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303816 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3817 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303818 }
3819
Dino Myclee8843b32014-07-04 14:21:45 +05303820
3821
Dino Mycle6fb96c12014-06-10 11:52:40 +05303822 pReqMsg->requestId = nla_get_u32(
3823 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3824 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3825
3826 /* Parse and fetch RSSI sample size */
3827 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3828 {
3829 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3830 goto fail;
3831 }
3832 pReqMsg->rssiSampleSize = nla_get_u32(
3833 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3834 hddLog(VOS_TRACE_LEVEL_INFO,
3835 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3836
3837 /* Parse and fetch lost AP sample size */
3838 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3839 {
3840 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3841 goto fail;
3842 }
3843 pReqMsg->lostApSampleSize = nla_get_u32(
3844 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3845 hddLog(VOS_TRACE_LEVEL_INFO,
3846 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3847 /* Parse and fetch minimum Breaching */
3848 if (!tb
3849 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3850 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3851 goto fail;
3852 }
3853 pReqMsg->minBreaching = nla_get_u32(
3854 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3855 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3856
3857 /* Parse and fetch number of APs */
3858 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3859 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3860 goto fail;
3861 }
3862 pReqMsg->numAp = nla_get_u32(
3863 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3864 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3865
3866 pReqMsg->sessionId = pAdapter->sessionId;
3867 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3868
3869 nla_for_each_nested(apTh,
3870 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3871 if(nla_parse(tb2,
3872 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3873 nla_data(apTh), nla_len(apTh),
3874 NULL)) {
3875 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3876 goto fail;
3877 }
3878
3879 /* Parse and fetch MAC address */
3880 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3881 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3882 goto fail;
3883 }
3884 memcpy(pReqMsg->ap[i].bssid, nla_data(
3885 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3886 sizeof(tSirMacAddr));
3887
3888 /* Parse and fetch low RSSI */
3889 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3890 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3891 goto fail;
3892 }
3893 pReqMsg->ap[i].low = nla_get_s32(
3894 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3895 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3896
3897 /* Parse and fetch high RSSI */
3898 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3899 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3900 goto fail;
3901 }
3902 pReqMsg->ap[i].high = nla_get_s32(
3903 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3904 hddLog(VOS_TRACE_LEVEL_INFO,
3905 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
3906
3907 /* Parse and fetch channel */
3908 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3909 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3910 goto fail;
3911 }
3912 pReqMsg->ap[i].channel = nla_get_u32(
3913 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3914 hddLog(VOS_TRACE_LEVEL_INFO,
3915 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3916 i++;
3917 }
3918
3919 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
3920 if (!HAL_STATUS_SUCCESS(status)) {
3921 hddLog(VOS_TRACE_LEVEL_ERROR,
3922 FL("sme_SetSignificantChange failed(err=%d)"), status);
3923 vos_mem_free(pReqMsg);
3924 return -EINVAL;
3925 }
Dino Myclee8843b32014-07-04 14:21:45 +05303926 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303927 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303928 return 0;
3929
3930fail:
3931 vos_mem_free(pReqMsg);
3932 return -EINVAL;
3933}
3934
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303935static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
3936 struct wireless_dev *wdev,
3937 const void *data, int dataLen)
3938{
3939 int ret = 0;
3940
3941 vos_ssr_protect(__func__);
3942 ret = __wlan_hdd_cfg80211_extscan_set_significant_change(wiphy, wdev, data,
3943 dataLen);
3944 vos_ssr_unprotect(__func__);
3945
3946 return ret;
3947}
3948
3949static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303950 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303951 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303952{
3953 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3954 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3955 tANI_U8 numChannels = 0;
3956 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3957 tANI_U32 requestId;
3958 tWifiBand wifiBand;
3959 eHalStatus status;
3960 struct sk_buff *replySkb;
3961 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303962 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303963
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303964 ENTER();
3965
Dino Mycle6fb96c12014-06-10 11:52:40 +05303966 status = wlan_hdd_validate_context(pHddCtx);
3967 if (0 != status)
3968 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303969 return -EINVAL;
3970 }
Dino Myclee8843b32014-07-04 14:21:45 +05303971
Dino Mycle6fb96c12014-06-10 11:52:40 +05303972 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3973 data, dataLen,
3974 wlan_hdd_extscan_config_policy)) {
3975 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3976 return -EINVAL;
3977 }
3978
3979 /* Parse and fetch request Id */
3980 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3981 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3982 return -EINVAL;
3983 }
3984 requestId = nla_get_u32(
3985 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3986 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3987
3988 /* Parse and fetch wifi band */
3989 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3990 {
3991 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3992 return -EINVAL;
3993 }
3994 wifiBand = nla_get_u32(
3995 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3996 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3997
3998 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
3999 wifiBand, ChannelList,
4000 &numChannels);
4001 if (eHAL_STATUS_SUCCESS != status) {
4002 hddLog(VOS_TRACE_LEVEL_ERROR,
4003 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
4004 return -EINVAL;
4005 }
4006 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
4007 for (i = 0; i < numChannels; i++)
4008 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
4009
4010 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
4011 sizeof(u32) * numChannels +
4012 NLMSG_HDRLEN);
4013
4014 if (!replySkb) {
4015 hddLog(VOS_TRACE_LEVEL_ERROR,
4016 FL("valid channels: buffer alloc fail"));
4017 return -EINVAL;
4018 }
4019 if (nla_put_u32(replySkb,
4020 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
4021 numChannels) ||
4022 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
4023 sizeof(u32) * numChannels, ChannelList)) {
4024
4025 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4026 kfree_skb(replySkb);
4027 return -EINVAL;
4028 }
4029
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304030 ret = cfg80211_vendor_cmd_reply(replySkb);
4031
4032 EXIT();
4033 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304034}
4035
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304036static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
4037 struct wireless_dev *wdev,
4038 const void *data, int dataLen)
4039{
4040 int ret = 0;
4041
4042 vos_ssr_protect(__func__);
4043 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
4044 dataLen);
4045 vos_ssr_unprotect(__func__);
4046
4047 return ret;
4048}
4049
4050static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304051 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304052 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304053{
Dino Myclee8843b32014-07-04 14:21:45 +05304054 tpSirEXTScanStartReqParams pReqMsg = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304055 struct net_device *dev = wdev->netdev;
4056 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4057 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4058 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4059 struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4060 struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4061 struct nlattr *buckets;
4062 struct nlattr *channels;
4063 int rem1;
4064 int rem2;
4065 eHalStatus status;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304066 tANI_U32 j = 0, index = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304067
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304068 ENTER();
4069
Dino Mycle6fb96c12014-06-10 11:52:40 +05304070 status = wlan_hdd_validate_context(pHddCtx);
4071 if (0 != status)
4072 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304073 return -EINVAL;
4074 }
Dino Myclee8843b32014-07-04 14:21:45 +05304075 /* check the EXTScan Capability */
4076 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4077 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4078 {
4079 hddLog(VOS_TRACE_LEVEL_ERROR,
4080 FL("EXTScan not enabled/supported by Firmware"));
4081 return -EINVAL;
4082 }
4083
Dino Mycle6fb96c12014-06-10 11:52:40 +05304084 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4085 data, dataLen,
4086 wlan_hdd_extscan_config_policy)) {
4087 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4088 return -EINVAL;
4089 }
4090
4091 /* Parse and fetch request Id */
4092 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4093 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4094 return -EINVAL;
4095 }
4096
Dino Myclee8843b32014-07-04 14:21:45 +05304097 pReqMsg = (tpSirEXTScanStartReqParams)
4098 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304099 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304100 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4101 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304102 }
4103
4104 pReqMsg->requestId = nla_get_u32(
4105 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4106 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4107
4108 pReqMsg->sessionId = pAdapter->sessionId;
4109 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4110
4111 /* Parse and fetch base period */
4112 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) {
4113 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4114 goto fail;
4115 }
4116 pReqMsg->basePeriod = nla_get_u32(
4117 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]);
4118 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4119 pReqMsg->basePeriod);
4120
4121 /* Parse and fetch max AP per scan */
4122 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) {
4123 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4124 goto fail;
4125 }
4126 pReqMsg->maxAPperScan = nla_get_u32(
4127 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]);
4128 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4129 pReqMsg->maxAPperScan);
4130
4131 /* Parse and fetch report threshold */
4132 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) {
4133 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4134 goto fail;
4135 }
4136 pReqMsg->reportThreshold = nla_get_u8(
4137 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]);
4138 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
4139 pReqMsg->reportThreshold);
4140
4141 /* Parse and fetch number of buckets */
4142 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) {
4143 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4144 goto fail;
4145 }
4146 pReqMsg->numBuckets = nla_get_u8(
4147 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]);
4148 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4149 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4150 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4151 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4152 }
4153 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4154 pReqMsg->numBuckets);
4155 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4156 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4157 goto fail;
4158 }
4159
4160 nla_for_each_nested(buckets,
4161 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4162 if(nla_parse(bucket,
4163 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4164 nla_data(buckets), nla_len(buckets), NULL)) { //policy
4165 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4166 goto fail;
4167 }
4168
4169 /* Parse and fetch bucket spec */
4170 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4171 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed"));
4172 goto fail;
4173 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304174
4175 pReqMsg->buckets[index].bucket = nla_get_u8(
4176 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4177
4178 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"),
4179 pReqMsg->buckets[index].bucket);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304180
4181 /* Parse and fetch wifi band */
4182 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4183 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4184 goto fail;
4185 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304186 pReqMsg->buckets[index].band = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304187 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4188 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304189 pReqMsg->buckets[index].band);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304190
4191 /* Parse and fetch period */
4192 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4193 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed"));
4194 goto fail;
4195 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304196 pReqMsg->buckets[index].period = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304197 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4198 hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304199 pReqMsg->buckets[index].period);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304200
4201 /* Parse and fetch report events */
4202 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4203 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed"));
4204 goto fail;
4205 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304206 pReqMsg->buckets[index].reportEvents = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304207 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4208 hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304209 pReqMsg->buckets[index].reportEvents);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304210
4211 /* Parse and fetch number of channels */
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304212 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS])
4213 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304214 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed"));
4215 goto fail;
4216 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304217 pReqMsg->buckets[index].numChannels = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304218 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4219 hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304220 pReqMsg->buckets[index].numChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304221
4222 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4223 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed"));
4224 goto fail;
4225 }
4226
4227 j = 0;
4228 nla_for_each_nested(channels,
4229 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4230 if(nla_parse(channel,
4231 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4232 nla_data(channels), nla_len(channels),
4233 NULL)) { //wlan_hdd_extscan_config_policy here
4234 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4235 goto fail;
4236 }
4237
4238 /* Parse and fetch channel */
4239 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4240 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4241 goto fail;
4242 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304243 pReqMsg->buckets[index].channels[j].channel = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304244 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4245 hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304246 pReqMsg->buckets[index].channels[j].channel);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304247
4248 /* Parse and fetch dwell time */
4249 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4250 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed"));
4251 goto fail;
4252 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304253 pReqMsg->buckets[index].channels[j].dwellTimeMs = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304254 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4255 hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304256 pReqMsg->buckets[index].channels[j].dwellTimeMs);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304257
4258 /* Parse and fetch channel spec passive */
4259 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4260 hddLog(VOS_TRACE_LEVEL_ERROR,
4261 FL("attr channel spec passive failed"));
4262 goto fail;
4263 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304264 pReqMsg->buckets[index].channels[j].passive = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304265 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4266 hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304267 pReqMsg->buckets[index].channels[j].passive);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304268 j++;
4269 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304270 index++;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304271 }
4272 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4273 if (!HAL_STATUS_SUCCESS(status)) {
4274 hddLog(VOS_TRACE_LEVEL_ERROR,
4275 FL("sme_EXTScanStart failed(err=%d)"), status);
4276 vos_mem_free(pReqMsg);
4277 return -EINVAL;
4278 }
4279
Dino Myclee8843b32014-07-04 14:21:45 +05304280 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304281 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304282 return 0;
4283
4284fail:
4285 vos_mem_free(pReqMsg);
4286 return -EINVAL;
4287}
4288
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304289static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4290 struct wireless_dev *wdev,
4291 const void *data, int dataLen)
4292{
4293 int ret = 0;
4294
4295 vos_ssr_protect(__func__);
4296 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4297 vos_ssr_unprotect(__func__);
4298
4299 return ret;
4300}
4301
4302static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304303 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304304 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304305{
Dino Myclee8843b32014-07-04 14:21:45 +05304306 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304307 struct net_device *dev = wdev->netdev;
4308 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4309 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4310 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4311 eHalStatus status;
4312
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304313 ENTER();
4314
Dino Mycle6fb96c12014-06-10 11:52:40 +05304315 status = wlan_hdd_validate_context(pHddCtx);
4316 if (0 != status)
4317 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304318 return -EINVAL;
4319 }
Dino Myclee8843b32014-07-04 14:21:45 +05304320 /* check the EXTScan Capability */
4321 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4322 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4323 {
4324 hddLog(VOS_TRACE_LEVEL_ERROR,
4325 FL("EXTScan not enabled/supported by Firmware"));
4326 return -EINVAL;
4327 }
4328
Dino Mycle6fb96c12014-06-10 11:52:40 +05304329 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4330 data, dataLen,
4331 wlan_hdd_extscan_config_policy)) {
4332 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4333 return -EINVAL;
4334 }
4335
4336 /* Parse and fetch request Id */
4337 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4338 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4339 return -EINVAL;
4340 }
4341
Dino Myclee8843b32014-07-04 14:21:45 +05304342 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304343 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304344 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304345
Dino Myclee8843b32014-07-04 14:21:45 +05304346 reqMsg.sessionId = pAdapter->sessionId;
4347 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304348
Dino Myclee8843b32014-07-04 14:21:45 +05304349 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304350 if (!HAL_STATUS_SUCCESS(status)) {
4351 hddLog(VOS_TRACE_LEVEL_ERROR,
4352 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304353 return -EINVAL;
4354 }
4355
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304356 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304357 return 0;
4358}
4359
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304360static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4361 struct wireless_dev *wdev,
4362 const void *data, int dataLen)
4363{
4364 int ret = 0;
4365
4366 vos_ssr_protect(__func__);
4367 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4368 vos_ssr_unprotect(__func__);
4369
4370 return ret;
4371}
4372
4373static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304374 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304375 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304376{
Dino Myclee8843b32014-07-04 14:21:45 +05304377 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304378 struct net_device *dev = wdev->netdev;
4379 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4380 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4381 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4382 eHalStatus status;
4383
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304384 ENTER();
4385
Dino Mycle6fb96c12014-06-10 11:52:40 +05304386 status = wlan_hdd_validate_context(pHddCtx);
4387 if (0 != status)
4388 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304389 return -EINVAL;
4390 }
Dino Myclee8843b32014-07-04 14:21:45 +05304391 /* check the EXTScan Capability */
4392 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4393 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4394 {
4395 hddLog(VOS_TRACE_LEVEL_ERROR,
4396 FL("EXTScan not enabled/supported by Firmware"));
4397 return -EINVAL;
4398 }
4399
Dino Mycle6fb96c12014-06-10 11:52:40 +05304400 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4401 data, dataLen,
4402 wlan_hdd_extscan_config_policy)) {
4403 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4404 return -EINVAL;
4405 }
4406
4407 /* Parse and fetch request Id */
4408 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4409 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4410 return -EINVAL;
4411 }
4412
Dino Myclee8843b32014-07-04 14:21:45 +05304413 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304414 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304415 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304416
Dino Myclee8843b32014-07-04 14:21:45 +05304417 reqMsg.sessionId = pAdapter->sessionId;
4418 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304419
Dino Myclee8843b32014-07-04 14:21:45 +05304420 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304421 if (!HAL_STATUS_SUCCESS(status)) {
4422 hddLog(VOS_TRACE_LEVEL_ERROR,
4423 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304424 return -EINVAL;
4425 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304426 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304427 return 0;
4428}
4429
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304430static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4431 struct wireless_dev *wdev,
4432 const void *data, int dataLen)
4433{
4434 int ret = 0;
4435
4436 vos_ssr_protect(__func__);
4437 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4438 vos_ssr_unprotect(__func__);
4439
4440 return ret;
4441}
4442
4443static int __wlan_hdd_cfg80211_extscan_reset_significant_change(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304444 struct wiphy *wiphy,
4445 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304446 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304447{
Dino Myclee8843b32014-07-04 14:21:45 +05304448 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304449 struct net_device *dev = wdev->netdev;
4450 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4451 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4452 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4453 eHalStatus status;
4454
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304455 ENTER();
4456
Dino Mycle6fb96c12014-06-10 11:52:40 +05304457 status = wlan_hdd_validate_context(pHddCtx);
4458 if (0 != status)
4459 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304460 return -EINVAL;
4461 }
Dino Myclee8843b32014-07-04 14:21:45 +05304462 /* check the EXTScan Capability */
4463 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4464 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4465 {
4466 hddLog(VOS_TRACE_LEVEL_ERROR,
4467 FL("EXTScan not enabled/supported by Firmware"));
4468 return -EINVAL;
4469 }
4470
Dino Mycle6fb96c12014-06-10 11:52:40 +05304471 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4472 data, dataLen,
4473 wlan_hdd_extscan_config_policy)) {
4474 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4475 return -EINVAL;
4476 }
4477
4478 /* Parse and fetch request Id */
4479 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4480 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4481 return -EINVAL;
4482 }
4483
Dino Mycle6fb96c12014-06-10 11:52:40 +05304484
Dino Myclee8843b32014-07-04 14:21:45 +05304485 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304486 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304487 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304488
Dino Myclee8843b32014-07-04 14:21:45 +05304489 reqMsg.sessionId = pAdapter->sessionId;
4490 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304491
Dino Myclee8843b32014-07-04 14:21:45 +05304492 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304493 if (!HAL_STATUS_SUCCESS(status)) {
4494 hddLog(VOS_TRACE_LEVEL_ERROR,
4495 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304496 return -EINVAL;
4497 }
4498
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304499 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304500 return 0;
4501}
4502
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304503static int wlan_hdd_cfg80211_extscan_reset_significant_change(
4504 struct wiphy *wiphy,
4505 struct wireless_dev *wdev,
4506 const void *data, int dataLen)
4507{
4508 int ret = 0;
4509
4510 vos_ssr_protect(__func__);
4511 ret = __wlan_hdd_cfg80211_extscan_reset_significant_change(wiphy,
4512 wdev, data,
4513 dataLen);
4514 vos_ssr_unprotect(__func__);
4515
4516 return ret;
4517}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304518#endif /* WLAN_FEATURE_EXTSCAN */
4519
Atul Mittal115287b2014-07-08 13:26:33 +05304520/*EXT TDLS*/
4521static const struct nla_policy
4522wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4523{
4524 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4525 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4526 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4527 {.type = NLA_S32 },
4528 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4529 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4530
4531};
4532
4533static const struct nla_policy
4534wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4535{
4536 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4537
4538};
4539
4540static const struct nla_policy
4541wlan_hdd_tdls_config_state_change_policy[
4542 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4543{
4544 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4545 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4546 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304547 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4548 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4549 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304550
4551};
4552
4553static const struct nla_policy
4554wlan_hdd_tdls_config_get_status_policy[
4555 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4556{
4557 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4558 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4559 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304560 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4561 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4562 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304563
4564};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304565
4566static const struct nla_policy
4567wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4568{
4569 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4570};
4571
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304572static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304573 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304574 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304575 int data_len)
4576{
4577
4578 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4579 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4580
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304581 ENTER();
4582
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304583 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304584 return -EINVAL;
4585 }
4586 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
Ratheesh S P36dbc932015-08-07 14:28:57 +05304587 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN disabled in ini"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304588 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304589 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304590 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
Ratheesh S P36dbc932015-08-07 14:28:57 +05304591 hddLog(VOS_TRACE_LEVEL_INFO, FL("MAC_SPOOFED_SCAN not supported by FW"));
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304592 return -ENOTSUPP;
4593 }
4594
4595 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4596 data, data_len, wlan_hdd_mac_config)) {
4597 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4598 return -EINVAL;
4599 }
4600
4601 /* Parse and fetch mac address */
4602 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4603 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4604 return -EINVAL;
4605 }
4606
4607 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4608 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4609 VOS_MAC_ADDR_LAST_3_BYTES);
4610
Siddharth Bhal76972212014-10-15 16:22:51 +05304611 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4612
4613 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304614 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4615 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304616 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4617 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4618 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4619 {
4620 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4621 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4622 VOS_MAC_ADDRESS_LEN);
4623 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304624 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304625
Siddharth Bhal76972212014-10-15 16:22:51 +05304626 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
4627 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304628 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4629 }
4630
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304631 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304632 return 0;
4633}
4634
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304635static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4636 struct wireless_dev *wdev,
4637 const void *data,
4638 int data_len)
4639{
4640 int ret = 0;
4641
4642 vos_ssr_protect(__func__);
4643 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
4644 vos_ssr_unprotect(__func__);
4645
4646 return ret;
4647}
4648
4649static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304650 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304651 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304652 int data_len)
4653{
4654 u8 peer[6] = {0};
4655 struct net_device *dev = wdev->netdev;
4656 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4657 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4658 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4659 eHalStatus ret;
4660 tANI_S32 state;
4661 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304662 tANI_S32 global_operating_class = 0;
4663 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304664 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304665 int retVal;
4666
4667 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304668
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304669 if (!pAdapter) {
4670 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4671 return -EINVAL;
4672 }
4673
Atul Mittal115287b2014-07-08 13:26:33 +05304674 ret = wlan_hdd_validate_context(pHddCtx);
4675 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304676 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304677 return -EINVAL;
4678 }
4679 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304680 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304681 return -ENOTSUPP;
4682 }
4683 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4684 data, data_len,
4685 wlan_hdd_tdls_config_get_status_policy)) {
4686 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4687 return -EINVAL;
4688 }
4689
4690 /* Parse and fetch mac address */
4691 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4692 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4693 return -EINVAL;
4694 }
4695
4696 memcpy(peer, nla_data(
4697 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4698 sizeof(peer));
4699 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4700
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05304701 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05304702
Atul Mittal115287b2014-07-08 13:26:33 +05304703 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304704 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304705 NLMSG_HDRLEN);
4706
4707 if (!skb) {
4708 hddLog(VOS_TRACE_LEVEL_ERROR,
4709 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4710 return -EINVAL;
4711 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304712 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reason (%d) Status (%d) class (%d) channel (%d) peer" MAC_ADDRESS_STR),
Atul Mittal115287b2014-07-08 13:26:33 +05304713 reason,
4714 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304715 global_operating_class,
4716 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304717 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304718 if (nla_put_s32(skb,
4719 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4720 state) ||
4721 nla_put_s32(skb,
4722 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4723 reason) ||
4724 nla_put_s32(skb,
4725 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4726 global_operating_class) ||
4727 nla_put_s32(skb,
4728 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4729 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304730
4731 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4732 goto nla_put_failure;
4733 }
4734
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304735 retVal = cfg80211_vendor_cmd_reply(skb);
4736 EXIT();
4737 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05304738
4739nla_put_failure:
4740 kfree_skb(skb);
4741 return -EINVAL;
4742}
4743
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304744static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4745 struct wireless_dev *wdev,
4746 const void *data,
4747 int data_len)
4748{
4749 int ret = 0;
4750
4751 vos_ssr_protect(__func__);
4752 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
4753 vos_ssr_unprotect(__func__);
4754
4755 return ret;
4756}
4757
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05304758static int wlan_hdd_cfg80211_exttdls_callback(
4759#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
4760 const tANI_U8* mac,
4761#else
4762 tANI_U8* mac,
4763#endif
Atul Mittal115287b2014-07-08 13:26:33 +05304764 tANI_S32 state,
4765 tANI_S32 reason,
4766 void *ctx)
4767{
4768 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05304769 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304770 tANI_S32 global_operating_class = 0;
4771 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304772 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05304773
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304774 ENTER();
4775
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304776 if (!pAdapter) {
4777 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4778 return -EINVAL;
4779 }
4780
4781 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05304782 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304783 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304784 return -EINVAL;
4785 }
4786
4787 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304788 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304789 return -ENOTSUPP;
4790 }
Anand N Sunkad26ca6cc2015-07-29 09:54:52 +05304791 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
4792#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
4793 NULL,
4794#endif
Atul Mittal115287b2014-07-08 13:26:33 +05304795 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4796 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4797 GFP_KERNEL);
4798
4799 if (!skb) {
4800 hddLog(VOS_TRACE_LEVEL_ERROR,
4801 FL("cfg80211_vendor_event_alloc failed"));
4802 return -EINVAL;
4803 }
4804 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304805 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4806 reason,
4807 state,
4808 global_operating_class,
4809 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304810 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4811 MAC_ADDR_ARRAY(mac));
4812
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304813 if (nla_put(skb,
4814 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4815 VOS_MAC_ADDR_SIZE, mac) ||
4816 nla_put_s32(skb,
4817 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4818 state) ||
4819 nla_put_s32(skb,
4820 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4821 reason) ||
4822 nla_put_s32(skb,
4823 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4824 channel) ||
4825 nla_put_s32(skb,
4826 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4827 global_operating_class)
4828 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304829 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4830 goto nla_put_failure;
4831 }
4832
4833 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304834 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05304835 return (0);
4836
4837nla_put_failure:
4838 kfree_skb(skb);
4839 return -EINVAL;
4840}
4841
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304842static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304843 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304844 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304845 int data_len)
4846{
4847 u8 peer[6] = {0};
4848 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304849 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4850 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4851 eHalStatus status;
4852 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304853 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304854 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304855
4856 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304857
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304858 if (!dev) {
4859 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4860 return -EINVAL;
4861 }
4862
4863 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4864 if (!pAdapter) {
4865 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4866 return -EINVAL;
4867 }
4868
Atul Mittal115287b2014-07-08 13:26:33 +05304869 status = wlan_hdd_validate_context(pHddCtx);
4870 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304871 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304872 return -EINVAL;
4873 }
4874 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304875 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304876 return -ENOTSUPP;
4877 }
4878 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4879 data, data_len,
4880 wlan_hdd_tdls_config_enable_policy)) {
4881 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4882 return -EINVAL;
4883 }
4884
4885 /* Parse and fetch mac address */
4886 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4887 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4888 return -EINVAL;
4889 }
4890
4891 memcpy(peer, nla_data(
4892 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4893 sizeof(peer));
4894 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4895
4896 /* Parse and fetch channel */
4897 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4898 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4899 return -EINVAL;
4900 }
4901 pReqMsg.channel = nla_get_s32(
4902 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4903 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4904
4905 /* Parse and fetch global operating class */
4906 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4907 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4908 return -EINVAL;
4909 }
4910 pReqMsg.global_operating_class = nla_get_s32(
4911 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4912 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4913 pReqMsg.global_operating_class);
4914
4915 /* Parse and fetch latency ms */
4916 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4917 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4918 return -EINVAL;
4919 }
4920 pReqMsg.max_latency_ms = nla_get_s32(
4921 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4922 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4923 pReqMsg.max_latency_ms);
4924
4925 /* Parse and fetch required bandwidth kbps */
4926 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4927 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4928 return -EINVAL;
4929 }
4930
4931 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4932 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4933 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4934 pReqMsg.min_bandwidth_kbps);
4935
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304936 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05304937 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05304938 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304939 wlan_hdd_cfg80211_exttdls_callback);
4940
4941 EXIT();
4942 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304943}
4944
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304945static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4946 struct wireless_dev *wdev,
4947 const void *data,
4948 int data_len)
4949{
4950 int ret = 0;
4951
4952 vos_ssr_protect(__func__);
4953 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
4954 vos_ssr_unprotect(__func__);
4955
4956 return ret;
4957}
4958
4959static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304960 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304961 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304962 int data_len)
4963{
4964 u8 peer[6] = {0};
4965 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304966 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4967 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4968 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304969 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304970 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304971
4972 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304973
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304974 if (!dev) {
4975 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4976 return -EINVAL;
4977 }
4978
4979 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4980 if (!pAdapter) {
4981 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
4982 return -EINVAL;
4983 }
4984
Atul Mittal115287b2014-07-08 13:26:33 +05304985 status = wlan_hdd_validate_context(pHddCtx);
4986 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304987 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304988 return -EINVAL;
4989 }
4990 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304991 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304992 return -ENOTSUPP;
4993 }
4994 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4995 data, data_len,
4996 wlan_hdd_tdls_config_disable_policy)) {
4997 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4998 return -EINVAL;
4999 }
5000 /* Parse and fetch mac address */
5001 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
5002 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
5003 return -EINVAL;
5004 }
5005
5006 memcpy(peer, nla_data(
5007 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
5008 sizeof(peer));
5009 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
5010
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305011 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
5012
5013 EXIT();
5014 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05305015}
5016
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305017static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
5018 struct wireless_dev *wdev,
5019 const void *data,
5020 int data_len)
5021{
5022 int ret = 0;
5023
5024 vos_ssr_protect(__func__);
5025 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
5026 vos_ssr_unprotect(__func__);
5027
5028 return ret;
5029}
5030
Dasari Srinivas7875a302014-09-26 17:50:57 +05305031static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305032__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05305033 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305034 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05305035{
5036 struct net_device *dev = wdev->netdev;
5037 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5038 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5039 struct sk_buff *skb = NULL;
5040 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305041 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305042
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305043 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305044
5045 ret = wlan_hdd_validate_context(pHddCtx);
5046 if (0 != ret)
5047 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305048 return ret;
5049 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305050 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
5051 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
5052 fset |= WIFI_FEATURE_INFRA;
5053 }
5054
5055 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
5056 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
5057 fset |= WIFI_FEATURE_INFRA_5G;
5058 }
5059
5060#ifdef WLAN_FEATURE_P2P
5061 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
5062 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
5063 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
5064 fset |= WIFI_FEATURE_P2P;
5065 }
5066#endif
5067
5068 /* Soft-AP is supported currently by default */
5069 fset |= WIFI_FEATURE_SOFT_AP;
5070
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05305071 /* HOTSPOT is a supplicant feature, enable it by default */
5072 fset |= WIFI_FEATURE_HOTSPOT;
5073
Dasari Srinivas7875a302014-09-26 17:50:57 +05305074#ifdef WLAN_FEATURE_EXTSCAN
5075 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
5076 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
5077 hddLog(LOG1, FL("EXTScan is supported by firmware"));
5078 fset |= WIFI_FEATURE_EXTSCAN;
5079 }
5080#endif
5081
Dasari Srinivas7875a302014-09-26 17:50:57 +05305082 if (sme_IsFeatureSupportedByFW(NAN)) {
5083 hddLog(LOG1, FL("NAN is supported by firmware"));
5084 fset |= WIFI_FEATURE_NAN;
5085 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05305086
5087 /* D2D RTT is not supported currently by default */
5088 if (sme_IsFeatureSupportedByFW(RTT)) {
5089 hddLog(LOG1, FL("RTT is supported by firmware"));
5090 fset |= WIFI_FEATURE_D2AP_RTT;
5091 }
5092
5093#ifdef FEATURE_WLAN_BATCH_SCAN
5094 if (fset & WIFI_FEATURE_EXTSCAN) {
5095 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5096 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5097 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5098 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5099 fset |= WIFI_FEATURE_BATCH_SCAN;
5100 }
5101#endif
5102
5103#ifdef FEATURE_WLAN_SCAN_PNO
5104 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5105 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5106 hddLog(LOG1, FL("PNO is supported by firmware"));
5107 fset |= WIFI_FEATURE_PNO;
5108 }
5109#endif
5110
5111 /* STA+STA is supported currently by default */
5112 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5113
5114#ifdef FEATURE_WLAN_TDLS
5115 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5116 sme_IsFeatureSupportedByFW(TDLS)) {
5117 hddLog(LOG1, FL("TDLS is supported by firmware"));
5118 fset |= WIFI_FEATURE_TDLS;
5119 }
5120
5121 /* TDLS_OFFCHANNEL is not supported currently by default */
5122#endif
5123
5124#ifdef WLAN_AP_STA_CONCURRENCY
5125 /* AP+STA concurrency is supported currently by default */
5126 fset |= WIFI_FEATURE_AP_STA;
5127#endif
5128
Mukul Sharma5add0532015-08-17 15:57:47 +05305129#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5130 fset |= WIFI_FEATURE_LINK_LAYER_STATS;
5131 hddLog(LOG1, FL("Link layer stats is supported by driver"));
5132#endif
5133
Dasari Srinivas7875a302014-09-26 17:50:57 +05305134 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5135 NLMSG_HDRLEN);
5136
5137 if (!skb) {
5138 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5139 return -EINVAL;
5140 }
5141 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5142
5143 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5144 hddLog(LOGE, FL("nla put fail"));
5145 goto nla_put_failure;
5146 }
5147
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305148 ret = cfg80211_vendor_cmd_reply(skb);
5149 EXIT();
5150 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305151
5152nla_put_failure:
5153 kfree_skb(skb);
5154 return -EINVAL;
5155}
5156
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305157static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305158wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5159 struct wireless_dev *wdev,
5160 const void *data, int data_len)
5161{
5162 int ret = 0;
5163
5164 vos_ssr_protect(__func__);
5165 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5166 vos_ssr_unprotect(__func__);
5167
5168 return ret;
5169}
5170
5171static int
5172__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305173 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305174 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305175{
5176 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5177 uint8_t i, feature_sets, max_feature_sets;
5178 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5179 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305180 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5181 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305182
5183 ENTER();
5184
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305185 ret = wlan_hdd_validate_context(pHddCtx);
5186 if (0 != ret)
5187 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305188 return ret;
5189 }
5190
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305191 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5192 data, data_len, NULL)) {
5193 hddLog(LOGE, FL("Invalid ATTR"));
5194 return -EINVAL;
5195 }
5196
5197 /* Parse and fetch max feature set */
5198 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5199 hddLog(LOGE, FL("Attr max feature set size failed"));
5200 return -EINVAL;
5201 }
5202 max_feature_sets = nla_get_u32(
5203 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5204 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5205
5206 /* Fill feature combination matrix */
5207 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305208 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5209 WIFI_FEATURE_P2P;
5210
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305211 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5212 WIFI_FEATURE_SOFT_AP;
5213
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305214 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5215 WIFI_FEATURE_SOFT_AP;
5216
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305217 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5218 WIFI_FEATURE_SOFT_AP |
5219 WIFI_FEATURE_P2P;
5220
5221 /* Add more feature combinations here */
5222
5223 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5224 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5225 hddLog(LOG1, "Feature set matrix");
5226 for (i = 0; i < feature_sets; i++)
5227 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5228
5229 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5230 sizeof(u32) * feature_sets +
5231 NLMSG_HDRLEN);
5232
5233 if (reply_skb) {
5234 if (nla_put_u32(reply_skb,
5235 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5236 feature_sets) ||
5237 nla_put(reply_skb,
5238 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5239 sizeof(u32) * feature_sets, feature_set_matrix)) {
5240 hddLog(LOGE, FL("nla put fail"));
5241 kfree_skb(reply_skb);
5242 return -EINVAL;
5243 }
5244
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305245 ret = cfg80211_vendor_cmd_reply(reply_skb);
5246 EXIT();
5247 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305248 }
5249 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5250 return -ENOMEM;
5251
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305252}
5253
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305254static int
5255wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5256 struct wireless_dev *wdev,
5257 const void *data, int data_len)
5258{
5259 int ret = 0;
5260
5261 vos_ssr_protect(__func__);
5262 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5263 data_len);
5264 vos_ssr_unprotect(__func__);
5265
5266 return ret;
5267}
5268
Agarwal Ashish738843c2014-09-25 12:27:56 +05305269static const struct nla_policy
5270wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5271 +1] =
5272{
5273 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5274};
5275
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305276static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305277 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305278 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305279 int data_len)
5280{
5281 struct net_device *dev = wdev->netdev;
5282 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5283 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5284 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5285 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5286 eHalStatus status;
5287 u32 dfsFlag = 0;
5288
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305289 ENTER();
5290
Agarwal Ashish738843c2014-09-25 12:27:56 +05305291 status = wlan_hdd_validate_context(pHddCtx);
5292 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305293 return -EINVAL;
5294 }
5295 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5296 data, data_len,
5297 wlan_hdd_set_no_dfs_flag_config_policy)) {
5298 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5299 return -EINVAL;
5300 }
5301
5302 /* Parse and fetch required bandwidth kbps */
5303 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5304 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5305 return -EINVAL;
5306 }
5307
5308 dfsFlag = nla_get_u32(
5309 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5310 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
5311 dfsFlag);
5312
5313 pHddCtx->disable_dfs_flag = dfsFlag;
5314
5315 sme_disable_dfs_channel(hHal, dfsFlag);
5316 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305317
5318 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05305319 return 0;
5320}
Atul Mittal115287b2014-07-08 13:26:33 +05305321
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305322static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
5323 struct wireless_dev *wdev,
5324 const void *data,
5325 int data_len)
5326{
5327 int ret = 0;
5328
5329 vos_ssr_protect(__func__);
5330 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
5331 vos_ssr_unprotect(__func__);
5332
5333 return ret;
5334
5335}
5336
Mukul Sharma2a271632014-10-13 14:59:01 +05305337const struct
5338nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
5339{
5340 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
5341 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
5342};
5343
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305344static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05305345 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05305346{
5347
5348 u8 bssid[6] = {0};
5349 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5350 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5351 eHalStatus status = eHAL_STATUS_SUCCESS;
5352 v_U32_t isFwrRoamEnabled = FALSE;
5353 int ret;
5354
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305355 ENTER();
5356
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305357 ret = wlan_hdd_validate_context(pHddCtx);
5358 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305359 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05305360 }
5361
5362 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
5363 data, data_len,
5364 qca_wlan_vendor_attr);
5365 if (ret){
5366 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5367 return -EINVAL;
5368 }
5369
5370 /* Parse and fetch Enable flag */
5371 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
5372 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
5373 return -EINVAL;
5374 }
5375
5376 isFwrRoamEnabled = nla_get_u32(
5377 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
5378
5379 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
5380
5381 /* Parse and fetch bssid */
5382 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
5383 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
5384 return -EINVAL;
5385 }
5386
5387 memcpy(bssid, nla_data(
5388 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
5389 sizeof(bssid));
5390 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
5391
5392 //Update roaming
5393 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305394 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05305395 return status;
5396}
5397
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305398static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
5399 struct wireless_dev *wdev, const void *data, int data_len)
5400{
5401 int ret = 0;
5402
5403 vos_ssr_protect(__func__);
5404 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
5405 vos_ssr_unprotect(__func__);
5406
5407 return ret;
5408}
5409
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305410/**
5411 * __wlan_hdd_cfg80211_setband() - set band
5412 * @wiphy: Pointer to wireless phy
5413 * @wdev: Pointer to wireless device
5414 * @data: Pointer to data
5415 * @data_len: Data length
5416 *
5417 * Return: 0 on success, negative errno on failure
5418 */
5419static int
5420__wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5421 struct wireless_dev *wdev,
5422 const void *data,
5423 int data_len)
5424{
5425 struct net_device *dev = wdev->netdev;
5426 hdd_context_t *hdd_ctx = wiphy_priv(wiphy);
5427 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5428 int ret;
5429 static const struct nla_policy policy[QCA_WLAN_VENDOR_ATTR_MAX + 1]
5430 = {[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE] = { .type = NLA_U32 }};
5431
5432 ENTER();
5433
5434 ret = wlan_hdd_validate_context(hdd_ctx);
5435 if (0 != ret) {
5436 hddLog(LOGE, FL("HDD context is not valid"));
5437 return ret;
5438 }
5439
5440 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX, data, data_len,
5441 policy)) {
5442 hddLog(LOGE, FL("Invalid ATTR"));
5443 return -EINVAL;
5444 }
5445
5446 if (!tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]) {
5447 hddLog(LOGE, FL("attr QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE failed"));
5448 return -EINVAL;
5449 }
5450
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05305451 hdd_ctx->isSetBandByNL = TRUE;
5452 ret = hdd_setBand(dev,
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305453 nla_get_u32(tb[QCA_WLAN_VENDOR_ATTR_SETBAND_VALUE]));
Hanumantha Reddy Pothula1347e432015-08-05 09:53:44 +05305454 hdd_ctx->isSetBandByNL = FALSE;
5455
5456 EXIT();
5457 return ret;
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305458}
5459
5460/**
5461 * wlan_hdd_cfg80211_setband() - Wrapper to offload packets
5462 * @wiphy: wiphy structure pointer
5463 * @wdev: Wireless device structure pointer
5464 * @data: Pointer to the data received
5465 * @data_len: Length of @data
5466 *
5467 * Return: 0 on success; errno on failure
5468 */
5469static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
5470 struct wireless_dev *wdev,
5471 const void *data,
5472 int data_len)
5473{
5474 int ret = 0;
5475
5476 vos_ssr_protect(__func__);
5477 ret = __wlan_hdd_cfg80211_setband(wiphy,
5478 wdev, data, data_len);
5479 vos_ssr_unprotect(__func__);
5480
5481 return ret;
5482}
5483
Sunil Duttc69bccb2014-05-26 21:30:20 +05305484const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
5485{
Mukul Sharma2a271632014-10-13 14:59:01 +05305486 {
5487 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5488 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
5489 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5490 WIPHY_VENDOR_CMD_NEED_NETDEV |
5491 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305492 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05305493 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305494
5495 {
5496 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5497 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
5498 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5499 WIPHY_VENDOR_CMD_NEED_NETDEV |
5500 WIPHY_VENDOR_CMD_NEED_RUNNING,
5501 .doit = wlan_hdd_cfg80211_nan_request
5502 },
5503
Sunil Duttc69bccb2014-05-26 21:30:20 +05305504#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5505 {
5506 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5507 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
5508 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5509 WIPHY_VENDOR_CMD_NEED_NETDEV |
5510 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305511 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05305512 },
5513
5514 {
5515 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5516 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
5517 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5518 WIPHY_VENDOR_CMD_NEED_NETDEV |
5519 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305520 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05305521 },
5522
5523 {
5524 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5525 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
5526 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5527 WIPHY_VENDOR_CMD_NEED_NETDEV |
5528 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305529 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05305530 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305531#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305532#ifdef WLAN_FEATURE_EXTSCAN
5533 {
5534 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5535 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
5536 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5537 WIPHY_VENDOR_CMD_NEED_NETDEV |
5538 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305539 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05305540 },
5541 {
5542 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5543 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
5544 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5545 WIPHY_VENDOR_CMD_NEED_NETDEV |
5546 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305547 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05305548 },
5549 {
5550 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5551 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
5552 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5553 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305554 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05305555 },
5556 {
5557 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5558 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
5559 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5560 WIPHY_VENDOR_CMD_NEED_NETDEV |
5561 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305562 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05305563 },
5564 {
5565 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5566 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
5567 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5568 WIPHY_VENDOR_CMD_NEED_NETDEV |
5569 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305570 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05305571 },
5572 {
5573 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5574 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
5575 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5576 WIPHY_VENDOR_CMD_NEED_NETDEV |
5577 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305578 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305579 },
5580 {
5581 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5582 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
5583 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5584 WIPHY_VENDOR_CMD_NEED_NETDEV |
5585 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305586 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305587 },
5588 {
5589 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5590 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
5591 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5592 WIPHY_VENDOR_CMD_NEED_NETDEV |
5593 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305594 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305595 },
5596 {
5597 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5598 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
5599 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5600 WIPHY_VENDOR_CMD_NEED_NETDEV |
5601 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305602 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305603 },
5604#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305605/*EXT TDLS*/
5606 {
5607 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5608 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
5609 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5610 WIPHY_VENDOR_CMD_NEED_NETDEV |
5611 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305612 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05305613 },
5614 {
5615 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5616 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
5617 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5618 WIPHY_VENDOR_CMD_NEED_NETDEV |
5619 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305620 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05305621 },
5622 {
5623 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5624 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
5625 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5626 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305627 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05305628 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05305629 {
5630 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5631 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
5632 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5633 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305634 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05305635 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05305636 {
5637 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5638 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
5639 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5640 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305641 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05305642 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305643 {
5644 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5645 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
5646 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5647 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305648 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305649 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305650 {
5651 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5652 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
5653 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5654 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305655 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305656 },
Srinivas Dasari41d97c92015-07-29 13:09:39 +05305657 {
5658 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5659 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SETBAND,
5660 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5661 WIPHY_VENDOR_CMD_NEED_NETDEV |
5662 WIPHY_VENDOR_CMD_NEED_RUNNING,
5663 .doit = wlan_hdd_cfg80211_setband
5664 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05305665};
5666
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005667/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05305668static const
5669struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005670{
5671#ifdef FEATURE_WLAN_CH_AVOID
5672 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05305673 .vendor_id = QCA_NL80211_VENDOR_ID,
5674 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005675 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305676#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
5677#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5678 {
5679 /* Index = 1*/
5680 .vendor_id = QCA_NL80211_VENDOR_ID,
5681 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
5682 },
5683 {
5684 /* Index = 2*/
5685 .vendor_id = QCA_NL80211_VENDOR_ID,
5686 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
5687 },
5688 {
5689 /* Index = 3*/
5690 .vendor_id = QCA_NL80211_VENDOR_ID,
5691 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
5692 },
5693 {
5694 /* Index = 4*/
5695 .vendor_id = QCA_NL80211_VENDOR_ID,
5696 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
5697 },
5698 {
5699 /* Index = 5*/
5700 .vendor_id = QCA_NL80211_VENDOR_ID,
5701 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
5702 },
5703 {
5704 /* Index = 6*/
5705 .vendor_id = QCA_NL80211_VENDOR_ID,
5706 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
5707 },
5708#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305709#ifdef WLAN_FEATURE_EXTSCAN
5710 {
5711 .vendor_id = QCA_NL80211_VENDOR_ID,
5712 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
5713 },
5714 {
5715 .vendor_id = QCA_NL80211_VENDOR_ID,
5716 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
5717 },
5718 {
5719 .vendor_id = QCA_NL80211_VENDOR_ID,
5720 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
5721 },
5722 {
5723 .vendor_id = QCA_NL80211_VENDOR_ID,
5724 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
5725 },
5726 {
5727 .vendor_id = QCA_NL80211_VENDOR_ID,
5728 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
5729 },
5730 {
5731 .vendor_id = QCA_NL80211_VENDOR_ID,
5732 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
5733 },
5734 {
5735 .vendor_id = QCA_NL80211_VENDOR_ID,
5736 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
5737 },
5738 {
5739 .vendor_id = QCA_NL80211_VENDOR_ID,
5740 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
5741 },
5742 {
5743 .vendor_id = QCA_NL80211_VENDOR_ID,
5744 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
5745 },
5746 {
5747 .vendor_id = QCA_NL80211_VENDOR_ID,
5748 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
5749 },
5750 {
5751 .vendor_id = QCA_NL80211_VENDOR_ID,
5752 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
5753 },
5754 {
5755 .vendor_id = QCA_NL80211_VENDOR_ID,
5756 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
5757 },
5758 {
5759 .vendor_id = QCA_NL80211_VENDOR_ID,
5760 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
5761 },
5762#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305763/*EXT TDLS*/
5764 {
5765 .vendor_id = QCA_NL80211_VENDOR_ID,
5766 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
5767 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305768
5769 {
5770 .vendor_id = QCA_NL80211_VENDOR_ID,
5771 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
5772 },
5773
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005774};
5775
Jeff Johnson295189b2012-06-20 16:38:30 -07005776/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305777 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305778 * This function is called by hdd_wlan_startup()
5779 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305780 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07005781 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305782struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07005783{
5784 struct wiphy *wiphy;
5785 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305786 /*
5787 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 */
5789 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
5790
5791 if (!wiphy)
5792 {
5793 /* Print error and jump into err label and free the memory */
5794 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
5795 return NULL;
5796 }
5797
Sunil Duttc69bccb2014-05-26 21:30:20 +05305798
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 return wiphy;
5800}
5801
5802/*
5803 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305804 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 * private ioctl to change the band value
5806 */
5807int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
5808{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305809 int i, j;
5810 eNVChannelEnabledType channelEnabledState;
5811
Jeff Johnsone7245742012-09-05 17:12:55 -07005812 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305813
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305814 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005815 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305816
5817 if (NULL == wiphy->bands[i])
5818 {
5819 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5820 __func__, i);
5821 continue;
5822 }
5823
5824 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5825 {
5826 struct ieee80211_supported_band *band = wiphy->bands[i];
5827
5828 channelEnabledState = vos_nv_getChannelEnabledState(
5829 band->channels[j].hw_value);
5830
5831 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
5832 {
Abhishek Singh678227a2014-11-04 10:52:38 +05305833 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305834 continue;
5835 }
5836 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
5837 {
5838 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5839 continue;
5840 }
5841
5842 if (NV_CHANNEL_DISABLE == channelEnabledState ||
5843 NV_CHANNEL_INVALID == channelEnabledState)
5844 {
5845 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5846 }
5847 else if (NV_CHANNEL_DFS == channelEnabledState)
5848 {
5849 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5850 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
5851 }
5852 else
5853 {
5854 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
5855 |IEEE80211_CHAN_RADAR);
5856 }
5857 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005858 }
5859 return 0;
5860}
5861/*
5862 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305863 * This function is called by hdd_wlan_startup()
5864 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 * This function is used to initialize and register wiphy structure.
5866 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305867int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005868 struct wiphy *wiphy,
5869 hdd_config_t *pCfg
5870 )
5871{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305872 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305873 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5874
Jeff Johnsone7245742012-09-05 17:12:55 -07005875 ENTER();
5876
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 /* Now bind the underlying wlan device with wiphy */
5878 set_wiphy_dev(wiphy, dev);
5879
5880 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005881
Kiet Lam6c583332013-10-14 05:37:09 +05305882#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07005883 /* the flag for the other case would be initialzed in
5884 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07005885 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05305886#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005887
Amar Singhalfddc28c2013-09-05 13:03:40 -07005888 /* This will disable updating of NL channels from passive to
5889 * active if a beacon is received on passive channel. */
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305890#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
5891 wiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;
5892#else
Amar Singhalfddc28c2013-09-05 13:03:40 -07005893 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305894#endif
Amar Singhalfddc28c2013-09-05 13:03:40 -07005895
Amar Singhala49cbc52013-10-08 18:37:44 -07005896
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005897#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07005898 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
5899 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
5900 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07005901 | WIPHY_FLAG_OFFCHAN_TX;
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305902#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
5903 wiphy->regulatory_flags = REGULATORY_COUNTRY_IE_IGNORE;
5904#else
5905 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
5906#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005907#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005908
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005909#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005910 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08005911#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005912 || pCfg->isFastRoamIniFeatureEnabled
5913#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005914#ifdef FEATURE_WLAN_ESE
5915 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005916#endif
5917 )
5918 {
5919 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
5920 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08005921#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005922#ifdef FEATURE_WLAN_TDLS
5923 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
5924 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
5925#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305926#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05305927 if (pCfg->configPNOScanSupport)
5928 {
5929 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
5930 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
5931 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
5932 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
5933 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305934#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005935
Abhishek Singh10d85972015-04-17 10:27:23 +05305936#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5937 wiphy->features |= NL80211_FEATURE_HT_IBSS;
5938#endif
5939
Amar Singhalfddc28c2013-09-05 13:03:40 -07005940#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005941 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
5942 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07005943 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005944 driver need to determine what to do with both
5945 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07005946
5947 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07005948#else
5949 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005950#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005951
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305952 wiphy->max_scan_ssids = MAX_SCAN_SSID;
5953
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05305954 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07005955
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305956 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
5957
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 /* Supports STATION & AD-HOC modes right now */
Bhargav Shah0d2e3e52015-07-24 16:51:01 +05305959 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
5960 | BIT(NL80211_IFTYPE_ADHOC)
5961 | BIT(NL80211_IFTYPE_P2P_CLIENT)
5962 | BIT(NL80211_IFTYPE_P2P_GO)
5963 | BIT(NL80211_IFTYPE_AP);
5964
5965 if (VOS_MONITOR_MODE == hdd_get_conparam())
5966 {
5967 wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
5968 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005969
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305970 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005971 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305972#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5973 if( pCfg->enableMCC )
5974 {
5975 /* Currently, supports up to two channels */
5976 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005977
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305978 if( !pCfg->allowMCCGODiffBI )
5979 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005980
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305981 }
5982 wiphy->iface_combinations = &wlan_hdd_iface_combination;
5983 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005984#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305985 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005986
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 /* Before registering we need to update the ht capabilitied based
5988 * on ini values*/
5989 if( !pCfg->ShortGI20MhzEnable )
5990 {
5991 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5992 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5993 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5994 }
5995
5996 if( !pCfg->ShortGI40MhzEnable )
5997 {
5998 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
5999 }
6000
6001 if( !pCfg->nChannelBondingMode5GHz )
6002 {
6003 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
6004 }
6005
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306006 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05306007 if (true == hdd_is_5g_supported(pHddCtx))
6008 {
6009 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
6010 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306011
6012 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
6013 {
6014
6015 if (NULL == wiphy->bands[i])
6016 {
Ratheesh S P36dbc932015-08-07 14:28:57 +05306017 hddLog(VOS_TRACE_LEVEL_INFO,"%s: wiphy->bands[i] is NULL, i = %d",
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05306018 __func__, i);
6019 continue;
6020 }
6021
6022 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
6023 {
6024 struct ieee80211_supported_band *band = wiphy->bands[i];
6025
6026 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
6027 {
6028 // Enable social channels for P2P
6029 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
6030 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
6031 else
6032 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
6033 continue;
6034 }
6035 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
6036 {
6037 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
6038 continue;
6039 }
6040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 }
6042 /*Initialise the supported cipher suite details*/
6043 wiphy->cipher_suites = hdd_cipher_suites;
6044 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
6045
6046 /*signal strength in mBm (100*dBm) */
6047 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
6048
6049#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05306050 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07006051#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006052
Sunil Duttc69bccb2014-05-26 21:30:20 +05306053 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
6054 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08006055 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
6056 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
6057
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306058 EXIT();
6059 return 0;
6060}
6061
6062/* In this function we are registering wiphy. */
6063int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
6064{
6065 ENTER();
6066 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006067 if (0 > wiphy_register(wiphy))
6068 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306069 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07006070 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
6071 return -EIO;
6072 }
6073
6074 EXIT();
6075 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306076}
Jeff Johnson295189b2012-06-20 16:38:30 -07006077
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306078/* In this function we are updating channel list when,
6079 regulatory domain is FCC and country code is US.
6080 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
6081 As per FCC smart phone is not a indoor device.
6082 GO should not opeate on indoor channels */
6083void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
6084{
6085 int j;
6086 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6087 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
6088 //Default counrtycode from NV at the time of wiphy initialization.
6089 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
6090 &defaultCountryCode[0]))
6091 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006092 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306093 }
6094 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
6095 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05306096 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
6097 {
6098 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
6099 return;
6100 }
6101 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
6102 {
6103 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
6104 // Mark UNII -1 band channel as passive
6105 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
6106 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
6107 }
6108 }
6109}
6110
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05306111/* This function registers for all frame which supplicant is interested in */
6112void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07006113{
Jeff Johnson295189b2012-06-20 16:38:30 -07006114 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6115 /* Register for all P2P action, public action etc frames */
6116 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
6117
Jeff Johnsone7245742012-09-05 17:12:55 -07006118 ENTER();
6119
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 /* Right now we are registering these frame when driver is getting
6121 initialized. Once we will move to 2.6.37 kernel, in which we have
6122 frame register ops, we will move this code as a part of that */
6123 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306124 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006125 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6126
6127 /* GAS Initial Response */
6128 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6129 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306130
Jeff Johnson295189b2012-06-20 16:38:30 -07006131 /* GAS Comeback Request */
6132 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6133 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6134
6135 /* GAS Comeback Response */
6136 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6137 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6138
6139 /* P2P Public Action */
6140 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306141 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 P2P_PUBLIC_ACTION_FRAME_SIZE );
6143
6144 /* P2P Action */
6145 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6146 (v_U8_t*)P2P_ACTION_FRAME,
6147 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07006148
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05306149 /* WNM BSS Transition Request frame */
6150 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6151 (v_U8_t*)WNM_BSS_ACTION_FRAME,
6152 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006153
6154 /* WNM-Notification */
6155 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
6156 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6157 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006158}
6159
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05306160void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07006161{
Jeff Johnson295189b2012-06-20 16:38:30 -07006162 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6163 /* Register for all P2P action, public action etc frames */
6164 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
6165
Jeff Johnsone7245742012-09-05 17:12:55 -07006166 ENTER();
6167
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 /* Right now we are registering these frame when driver is getting
6169 initialized. Once we will move to 2.6.37 kernel, in which we have
6170 frame register ops, we will move this code as a part of that */
6171 /* GAS Initial Request */
6172
6173 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6174 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
6175
6176 /* GAS Initial Response */
6177 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6178 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306179
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 /* GAS Comeback Request */
6181 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6182 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6183
6184 /* GAS Comeback Response */
6185 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6186 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6187
6188 /* P2P Public Action */
6189 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306190 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006191 P2P_PUBLIC_ACTION_FRAME_SIZE );
6192
6193 /* P2P Action */
6194 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6195 (v_U8_t*)P2P_ACTION_FRAME,
6196 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006197 /* WNM-Notification */
6198 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6199 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6200 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006201}
6202
6203#ifdef FEATURE_WLAN_WAPI
6204void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05306205 const u8 *mac_addr, const u8 *key , int key_Len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006206{
6207 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6208 tCsrRoamSetKey setKey;
6209 v_BOOL_t isConnected = TRUE;
6210 int status = 0;
6211 v_U32_t roamId= 0xFF;
6212 tANI_U8 *pKeyPtr = NULL;
6213 int n = 0;
6214
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306215 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
6216 __func__, hdd_device_modetoString(pAdapter->device_mode),
6217 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006218
Gopichand Nakkalae7480202013-02-11 15:24:22 +05306219 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 setKey.keyId = key_index; // Store Key ID
6221 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
6222 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
6223 setKey.paeRole = 0 ; // the PAE role
6224 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
6225 {
6226 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
6227 }
6228 else
6229 {
6230 isConnected = hdd_connIsConnected(pHddStaCtx);
6231 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
6232 }
6233 setKey.keyLength = key_Len;
6234 pKeyPtr = setKey.Key;
6235 memcpy( pKeyPtr, key, key_Len);
6236
Arif Hussain6d2a3322013-11-17 19:50:10 -08006237 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 __func__, key_Len);
6239 for (n = 0 ; n < key_Len; n++)
6240 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
6241 __func__,n,setKey.Key[n]);
6242
6243 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6244 if ( isConnected )
6245 {
6246 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
6247 pAdapter->sessionId, &setKey, &roamId );
6248 }
6249 if ( status != 0 )
6250 {
6251 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6252 "[%4d] sme_RoamSetKey returned ERROR status= %d",
6253 __LINE__, status );
6254 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6255 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05306256 /* Need to clear any trace of key value in the memory.
6257 * Thus zero out the memory even though it is local
6258 * variable.
6259 */
6260 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006261}
6262#endif /* FEATURE_WLAN_WAPI*/
6263
6264#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306265int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 beacon_data_t **ppBeacon,
6267 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006268#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306269int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006270 beacon_data_t **ppBeacon,
6271 struct cfg80211_beacon_data *params,
6272 int dtim_period)
6273#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306274{
Jeff Johnson295189b2012-06-20 16:38:30 -07006275 int size;
6276 beacon_data_t *beacon = NULL;
6277 beacon_data_t *old = NULL;
6278 int head_len,tail_len;
6279
Jeff Johnsone7245742012-09-05 17:12:55 -07006280 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006281 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306282 {
6283 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6284 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306286 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006287
6288 old = pAdapter->sessionCtx.ap.beacon;
6289
6290 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306291 {
6292 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6293 FL("session(%d) old and new heads points to NULL"),
6294 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306296 }
6297
6298 if (params->tail && !params->tail_len)
6299 {
6300 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6301 FL("tail_len is zero but tail is not NULL"));
6302 return -EINVAL;
6303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006304
Jeff Johnson295189b2012-06-20 16:38:30 -07006305#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
6306 /* Kernel 3.0 is not updating dtim_period for set beacon */
6307 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306308 {
6309 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6310 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006311 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306312 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006313#endif
6314
6315 if(params->head)
6316 head_len = params->head_len;
6317 else
6318 head_len = old->head_len;
6319
6320 if(params->tail || !old)
6321 tail_len = params->tail_len;
6322 else
6323 tail_len = old->tail_len;
6324
6325 size = sizeof(beacon_data_t) + head_len + tail_len;
6326
6327 beacon = kzalloc(size, GFP_KERNEL);
6328
6329 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306330 {
6331 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6332 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306334 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006335
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006336#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006337 if(params->dtim_period || !old )
6338 beacon->dtim_period = params->dtim_period;
6339 else
6340 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006341#else
6342 if(dtim_period || !old )
6343 beacon->dtim_period = dtim_period;
6344 else
6345 beacon->dtim_period = old->dtim_period;
6346#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306347
Jeff Johnson295189b2012-06-20 16:38:30 -07006348 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
6349 beacon->tail = beacon->head + head_len;
6350 beacon->head_len = head_len;
6351 beacon->tail_len = tail_len;
6352
6353 if(params->head) {
6354 memcpy (beacon->head,params->head,beacon->head_len);
6355 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306356 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07006357 if(old)
6358 memcpy (beacon->head,old->head,beacon->head_len);
6359 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306360
Jeff Johnson295189b2012-06-20 16:38:30 -07006361 if(params->tail) {
6362 memcpy (beacon->tail,params->tail,beacon->tail_len);
6363 }
6364 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306365 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07006366 memcpy (beacon->tail,old->tail,beacon->tail_len);
6367 }
6368
6369 *ppBeacon = beacon;
6370
6371 kfree(old);
6372
6373 return 0;
6374
6375}
Jeff Johnson295189b2012-06-20 16:38:30 -07006376
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05306377v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(
6378#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
6379 const v_U8_t *pIes,
6380#else
6381 v_U8_t *pIes,
6382#endif
6383 int length, v_U8_t eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006384{
6385 int left = length;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05306386 v_U8_t *ptr = (v_U8_t *)pIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07006387 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306388
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306390 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006391 elem_id = ptr[0];
6392 elem_len = ptr[1];
6393 left -= 2;
6394 if(elem_len > left)
6395 {
6396 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006397 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 eid,elem_len,left);
6399 return NULL;
6400 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306401 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006402 {
6403 return ptr;
6404 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306405
Jeff Johnson295189b2012-06-20 16:38:30 -07006406 left -= elem_len;
6407 ptr += (elem_len + 2);
6408 }
6409 return NULL;
6410}
6411
Jeff Johnson295189b2012-06-20 16:38:30 -07006412/* Check if rate is 11g rate or not */
6413static int wlan_hdd_rate_is_11g(u8 rate)
6414{
Sanjay Devnani28322e22013-06-21 16:13:40 -07006415 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006416 u8 i;
6417 for (i = 0; i < 8; i++)
6418 {
6419 if(rate == gRateArray[i])
6420 return TRUE;
6421 }
6422 return FALSE;
6423}
6424
6425/* Check for 11g rate and set proper 11g only mode */
6426static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
6427 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
6428{
6429 u8 i, num_rates = pIe[0];
6430
6431 pIe += 1;
6432 for ( i = 0; i < num_rates; i++)
6433 {
6434 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
6435 {
6436 /* If rate set have 11g rate than change the mode to 11G */
6437 *pSapHw_mode = eSAP_DOT11_MODE_11g;
6438 if (pIe[i] & BASIC_RATE_MASK)
6439 {
6440 /* If we have 11g rate as basic rate, it means mode
6441 is 11g only mode.
6442 */
6443 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
6444 *pCheckRatesfor11g = FALSE;
6445 }
6446 }
6447 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
6448 {
6449 *require_ht = TRUE;
6450 }
6451 }
6452 return;
6453}
6454
6455static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
6456{
6457 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6458 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6459 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6460 u8 checkRatesfor11g = TRUE;
6461 u8 require_ht = FALSE;
6462 u8 *pIe=NULL;
6463
6464 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
6465
6466 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
6467 pBeacon->head_len, WLAN_EID_SUPP_RATES);
6468 if (pIe != NULL)
6469 {
6470 pIe += 1;
6471 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6472 &pConfig->SapHw_mode);
6473 }
6474
6475 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6476 WLAN_EID_EXT_SUPP_RATES);
6477 if (pIe != NULL)
6478 {
6479
6480 pIe += 1;
6481 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6482 &pConfig->SapHw_mode);
6483 }
6484
6485 if( pConfig->channel > 14 )
6486 {
6487 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
6488 }
6489
6490 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6491 WLAN_EID_HT_CAPABILITY);
6492
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306493 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006494 {
6495 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
6496 if(require_ht)
6497 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
6498 }
6499}
6500
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306501static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
6502 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
6503{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006504 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306505 v_U8_t *pIe = NULL;
6506 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6507
6508 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
6509 pBeacon->tail, pBeacon->tail_len);
6510
6511 if (pIe)
6512 {
6513 ielen = pIe[1] + 2;
6514 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6515 {
6516 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
6517 }
6518 else
6519 {
6520 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
6521 return -EINVAL;
6522 }
6523 *total_ielen += ielen;
6524 }
6525 return 0;
6526}
6527
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006528static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
6529 v_U8_t *genie, v_U8_t *total_ielen)
6530{
6531 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6532 int left = pBeacon->tail_len;
6533 v_U8_t *ptr = pBeacon->tail;
6534 v_U8_t elem_id, elem_len;
6535 v_U16_t ielen = 0;
6536
6537 if ( NULL == ptr || 0 == left )
6538 return;
6539
6540 while (left >= 2)
6541 {
6542 elem_id = ptr[0];
6543 elem_len = ptr[1];
6544 left -= 2;
6545 if (elem_len > left)
6546 {
6547 hddLog( VOS_TRACE_LEVEL_ERROR,
6548 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
6549 elem_id, elem_len, left);
6550 return;
6551 }
6552 if (IE_EID_VENDOR == elem_id)
6553 {
6554 /* skipping the VSIE's which we don't want to include or
6555 * it will be included by existing code
6556 */
6557 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
6558#ifdef WLAN_FEATURE_WFD
6559 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
6560#endif
6561 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6562 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6563 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
6564 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6565 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
6566 {
6567 ielen = ptr[1] + 2;
6568 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6569 {
6570 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
6571 *total_ielen += ielen;
6572 }
6573 else
6574 {
6575 hddLog( VOS_TRACE_LEVEL_ERROR,
6576 "IE Length is too big "
6577 "IEs eid=%d elem_len=%d total_ie_lent=%d",
6578 elem_id, elem_len, *total_ielen);
6579 }
6580 }
6581 }
6582
6583 left -= elem_len;
6584 ptr += (elem_len + 2);
6585 }
6586 return;
6587}
6588
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006589#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006590static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6591 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006592#else
6593static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6594 struct cfg80211_beacon_data *params)
6595#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006596{
6597 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306598 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07006600 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006601
6602 genie = vos_mem_malloc(MAX_GENIE_LEN);
6603
6604 if(genie == NULL) {
6605
6606 return -ENOMEM;
6607 }
6608
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306609 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6610 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306612 hddLog(LOGE,
6613 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306614 ret = -EINVAL;
6615 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006616 }
6617
6618#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306619 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6620 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
6621 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306622 hddLog(LOGE,
6623 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306624 ret = -EINVAL;
6625 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006626 }
6627#endif
6628
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306629 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6630 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306632 hddLog(LOGE,
6633 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306634 ret = -EINVAL;
6635 goto done;
6636 }
6637
6638 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
6639 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006640 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006641 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006642
6643 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6644 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
6645 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6646 {
6647 hddLog(LOGE,
6648 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006649 ret = -EINVAL;
6650 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006651 }
6652
6653 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6654 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6655 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6656 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6657 ==eHAL_STATUS_FAILURE)
6658 {
6659 hddLog(LOGE,
6660 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006661 ret = -EINVAL;
6662 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 }
6664
6665 // Added for ProResp IE
6666 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
6667 {
6668 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
6669 u8 probe_rsp_ie_len[3] = {0};
6670 u8 counter = 0;
6671 /* Check Probe Resp Length if it is greater then 255 then Store
6672 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
6673 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
6674 Store More then 255 bytes into One Variable.
6675 */
6676 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6677 {
6678 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6679 {
6680 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6681 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6682 }
6683 else
6684 {
6685 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6686 rem_probe_resp_ie_len = 0;
6687 }
6688 }
6689
6690 rem_probe_resp_ie_len = 0;
6691
6692 if (probe_rsp_ie_len[0] > 0)
6693 {
6694 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6695 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6696 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6697 probe_rsp_ie_len[0], NULL,
6698 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6699 {
6700 hddLog(LOGE,
6701 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006702 ret = -EINVAL;
6703 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 }
6705 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6706 }
6707
6708 if (probe_rsp_ie_len[1] > 0)
6709 {
6710 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6711 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6712 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6713 probe_rsp_ie_len[1], NULL,
6714 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6715 {
6716 hddLog(LOGE,
6717 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006718 ret = -EINVAL;
6719 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006720 }
6721 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6722 }
6723
6724 if (probe_rsp_ie_len[2] > 0)
6725 {
6726 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6727 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6728 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6729 probe_rsp_ie_len[2], NULL,
6730 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6731 {
6732 hddLog(LOGE,
6733 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006734 ret = -EINVAL;
6735 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006736 }
6737 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6738 }
6739
6740 if (probe_rsp_ie_len[1] == 0 )
6741 {
6742 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6743 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
6744 eANI_BOOLEAN_FALSE) )
6745 {
6746 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006747 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 }
6749 }
6750
6751 if (probe_rsp_ie_len[2] == 0 )
6752 {
6753 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6754 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
6755 eANI_BOOLEAN_FALSE) )
6756 {
6757 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006758 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006759 }
6760 }
6761
6762 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6763 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6764 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6765 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6766 == eHAL_STATUS_FAILURE)
6767 {
6768 hddLog(LOGE,
6769 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006770 ret = -EINVAL;
6771 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 }
6773 }
6774 else
6775 {
6776 // Reset WNI_CFG_PROBE_RSP Flags
6777 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
6778
6779 hddLog(VOS_TRACE_LEVEL_INFO,
6780 "%s: No Probe Response IE received in set beacon",
6781 __func__);
6782 }
6783
6784 // Added for AssocResp IE
6785 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
6786 {
6787 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6788 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
6789 params->assocresp_ies_len, NULL,
6790 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6791 {
6792 hddLog(LOGE,
6793 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006794 ret = -EINVAL;
6795 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006796 }
6797
6798 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6799 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
6800 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6801 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6802 == eHAL_STATUS_FAILURE)
6803 {
6804 hddLog(LOGE,
6805 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006806 ret = -EINVAL;
6807 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006808 }
6809 }
6810 else
6811 {
6812 hddLog(VOS_TRACE_LEVEL_INFO,
6813 "%s: No Assoc Response IE received in set beacon",
6814 __func__);
6815
6816 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6817 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6818 eANI_BOOLEAN_FALSE) )
6819 {
6820 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006821 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 }
6823 }
6824
Jeff Johnsone7245742012-09-05 17:12:55 -07006825done:
Jeff Johnson295189b2012-06-20 16:38:30 -07006826 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306827 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006828}
Jeff Johnson295189b2012-06-20 16:38:30 -07006829
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306830/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006831 * FUNCTION: wlan_hdd_validate_operation_channel
6832 * called by wlan_hdd_cfg80211_start_bss() and
6833 * wlan_hdd_cfg80211_set_channel()
6834 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306835 * channel list.
6836 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07006837VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006838{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306839
Jeff Johnson295189b2012-06-20 16:38:30 -07006840 v_U32_t num_ch = 0;
6841 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6842 u32 indx = 0;
6843 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306844 v_U8_t fValidChannel = FALSE, count = 0;
6845 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306846
Jeff Johnson295189b2012-06-20 16:38:30 -07006847 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6848
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306849 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306851 /* Validate the channel */
6852 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006853 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306854 if ( channel == rfChannels[count].channelNum )
6855 {
6856 fValidChannel = TRUE;
6857 break;
6858 }
6859 }
6860 if (fValidChannel != TRUE)
6861 {
6862 hddLog(VOS_TRACE_LEVEL_ERROR,
6863 "%s: Invalid Channel [%d]", __func__, channel);
6864 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006865 }
6866 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306867 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006868 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306869 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6870 valid_ch, &num_ch))
6871 {
6872 hddLog(VOS_TRACE_LEVEL_ERROR,
6873 "%s: failed to get valid channel list", __func__);
6874 return VOS_STATUS_E_FAILURE;
6875 }
6876 for (indx = 0; indx < num_ch; indx++)
6877 {
6878 if (channel == valid_ch[indx])
6879 {
6880 break;
6881 }
6882 }
6883
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306884 if (indx >= num_ch)
6885 {
6886 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6887 {
6888 eCsrBand band;
6889 unsigned int freq;
6890
6891 sme_GetFreqBand(hHal, &band);
6892
6893 if (eCSR_BAND_5G == band)
6894 {
6895#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
6896 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
6897 {
6898 freq = ieee80211_channel_to_frequency(channel,
6899 IEEE80211_BAND_2GHZ);
6900 }
6901 else
6902 {
6903 freq = ieee80211_channel_to_frequency(channel,
6904 IEEE80211_BAND_5GHZ);
6905 }
6906#else
6907 freq = ieee80211_channel_to_frequency(channel);
6908#endif
6909 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
6910 return VOS_STATUS_SUCCESS;
6911 }
6912 }
6913
6914 hddLog(VOS_TRACE_LEVEL_ERROR,
6915 "%s: Invalid Channel [%d]", __func__, channel);
6916 return VOS_STATUS_E_FAILURE;
6917 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006918 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306919
Jeff Johnson295189b2012-06-20 16:38:30 -07006920 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306921
Jeff Johnson295189b2012-06-20 16:38:30 -07006922}
6923
Viral Modi3a32cc52013-02-08 11:14:52 -08006924/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306925 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08006926 * This function is used to set the channel number
6927 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306928static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08006929 struct ieee80211_channel *chan,
6930 enum nl80211_channel_type channel_type
6931 )
6932{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306933 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08006934 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07006935 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08006936 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306937 hdd_context_t *pHddCtx;
6938 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006939
6940 ENTER();
6941
6942 if( NULL == dev )
6943 {
6944 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006945 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006946 return -ENODEV;
6947 }
6948 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306949
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306950 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6951 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
6952 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08006953 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306954 "%s: device_mode = %s (%d) freq = %d", __func__,
6955 hdd_device_modetoString(pAdapter->device_mode),
6956 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306957
6958 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6959 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306960 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08006961 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306962 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006963 }
6964
6965 /*
6966 * Do freq to chan conversion
6967 * TODO: for 11a
6968 */
6969
6970 channel = ieee80211_frequency_to_channel(freq);
6971
6972 /* Check freq range */
6973 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
6974 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
6975 {
6976 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006977 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08006978 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
6979 WNI_CFG_CURRENT_CHANNEL_STAMAX);
6980 return -EINVAL;
6981 }
6982
6983 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6984
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05306985 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
6986 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08006987 {
6988 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
6989 {
6990 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006991 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08006992 return -EINVAL;
6993 }
6994 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6995 "%s: set channel to [%d] for device mode =%d",
6996 __func__, channel,pAdapter->device_mode);
6997 }
6998 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08006999 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08007000 )
7001 {
7002 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7003 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
7004 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7005
7006 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
7007 {
7008 /* Link is up then return cant set channel*/
7009 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007010 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08007011 return -EINVAL;
7012 }
7013
7014 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
7015 pHddStaCtx->conn_info.operationChannel = channel;
7016 pRoamProfile->ChannelInfo.ChannelList =
7017 &pHddStaCtx->conn_info.operationChannel;
7018 }
7019 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08007020 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08007021 )
7022 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307023 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
7024 {
7025 if(VOS_STATUS_SUCCESS !=
7026 wlan_hdd_validate_operation_channel(pAdapter,channel))
7027 {
7028 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007029 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307030 return -EINVAL;
7031 }
7032 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
7033 }
7034 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08007035 {
7036 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
7037
7038 /* If auto channel selection is configured as enable/ 1 then ignore
7039 channel set by supplicant
7040 */
7041 if ( cfg_param->apAutoChannelSelection )
7042 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307043 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
7044 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08007045 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307046 "%s: set channel to auto channel (0) for device mode =%s (%d)",
7047 __func__, hdd_device_modetoString(pAdapter->device_mode),
7048 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08007049 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307050 else
7051 {
7052 if(VOS_STATUS_SUCCESS !=
7053 wlan_hdd_validate_operation_channel(pAdapter,channel))
7054 {
7055 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007056 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05307057 return -EINVAL;
7058 }
7059 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
7060 }
Viral Modi3a32cc52013-02-08 11:14:52 -08007061 }
7062 }
7063 else
7064 {
7065 hddLog(VOS_TRACE_LEVEL_FATAL,
7066 "%s: Invalid device mode failed to set valid channel", __func__);
7067 return -EINVAL;
7068 }
7069 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307070 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08007071}
7072
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05307073static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
7074 struct net_device *dev,
7075 struct ieee80211_channel *chan,
7076 enum nl80211_channel_type channel_type
7077 )
7078{
7079 int ret;
7080
7081 vos_ssr_protect(__func__);
7082 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
7083 vos_ssr_unprotect(__func__);
7084
7085 return ret;
7086}
7087
Jeff Johnson295189b2012-06-20 16:38:30 -07007088#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7089static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
7090 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007091#else
7092static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
7093 struct cfg80211_beacon_data *params,
7094 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307095 enum nl80211_hidden_ssid hidden_ssid,
7096 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007097#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007098{
7099 tsap_Config_t *pConfig;
7100 beacon_data_t *pBeacon = NULL;
7101 struct ieee80211_mgmt *pMgmt_frame;
7102 v_U8_t *pIe=NULL;
7103 v_U16_t capab_info;
7104 eCsrAuthType RSNAuthType;
7105 eCsrEncryptionType RSNEncryptType;
7106 eCsrEncryptionType mcRSNEncryptType;
7107 int status = VOS_STATUS_SUCCESS;
7108 tpWLAN_SAPEventCB pSapEventCallback;
7109 hdd_hostapd_state_t *pHostapdState;
7110 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
7111 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307112 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007113 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307114 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07007115 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08007116 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05307117 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07007118 v_BOOL_t MFPCapable = VOS_FALSE;
7119 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307120 v_BOOL_t sapEnable11AC =
7121 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07007122 ENTER();
7123
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307124 iniConfig = pHddCtx->cfg_ini;
7125
Jeff Johnson295189b2012-06-20 16:38:30 -07007126 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
7127
7128 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
7129
7130 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
7131
7132 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
7133
7134 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
7135
7136 //channel is already set in the set_channel Call back
7137 //pConfig->channel = pCommitConfig->channel;
7138
7139 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307140 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07007141 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
7142
7143 pConfig->dtim_period = pBeacon->dtim_period;
7144
Arif Hussain6d2a3322013-11-17 19:50:10 -08007145 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07007146 pConfig->dtim_period);
7147
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08007148 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07007149 {
7150 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007151 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05307152 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
7153 {
7154 tANI_BOOLEAN restartNeeded;
7155 pConfig->ieee80211d = 1;
7156 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
7157 sme_setRegInfo(hHal, pConfig->countryCode);
7158 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
7159 }
7160 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07007161 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07007162 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007163 pConfig->ieee80211d = 1;
7164 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
7165 sme_setRegInfo(hHal, pConfig->countryCode);
7166 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07007167 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007168 else
7169 {
7170 pConfig->ieee80211d = 0;
7171 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307172 /*
7173 * If auto channel is configured i.e. channel is 0,
7174 * so skip channel validation.
7175 */
7176 if( AUTO_CHANNEL_SELECT != pConfig->channel )
7177 {
7178 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
7179 {
7180 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007181 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05307182 return -EINVAL;
7183 }
7184 }
7185 else
7186 {
7187 if(1 != pHddCtx->is_dynamic_channel_range_set)
7188 {
7189 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
7190 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
7191 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
7192 }
7193 pHddCtx->is_dynamic_channel_range_set = 0;
7194 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007195 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007196 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007197 {
7198 pConfig->ieee80211d = 0;
7199 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307200
7201#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7202 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7203 pConfig->authType = eSAP_OPEN_SYSTEM;
7204 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7205 pConfig->authType = eSAP_SHARED_KEY;
7206 else
7207 pConfig->authType = eSAP_AUTO_SWITCH;
7208#else
7209 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7210 pConfig->authType = eSAP_OPEN_SYSTEM;
7211 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7212 pConfig->authType = eSAP_SHARED_KEY;
7213 else
7214 pConfig->authType = eSAP_AUTO_SWITCH;
7215#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007216
7217 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307218
7219 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07007220 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
7221
7222 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
7223
7224 /*Set wps station to configured*/
7225 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
7226
7227 if(pIe)
7228 {
7229 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
7230 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007231 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07007232 return -EINVAL;
7233 }
7234 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
7235 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007236 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07007237 /* Check 15 bit of WPS IE as it contain information for wps state
7238 * WPS state
7239 */
7240 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
7241 {
7242 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
7243 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
7244 {
7245 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
7246 }
7247 }
7248 }
7249 else
7250 {
7251 pConfig->wps_state = SAP_WPS_DISABLED;
7252 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307253 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07007254
c_hpothufe599e92014-06-16 11:38:55 +05307255 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7256 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7257 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
7258 eCSR_ENCRYPT_TYPE_NONE;
7259
Jeff Johnson295189b2012-06-20 16:38:30 -07007260 pConfig->RSNWPAReqIELength = 0;
7261 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307262 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007263 WLAN_EID_RSN);
7264 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307265 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7267 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7268 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307269 /* The actual processing may eventually be more extensive than
7270 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07007271 * by the app.
7272 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307273 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007274 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7275 &RSNEncryptType,
7276 &mcRSNEncryptType,
7277 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007278 &MFPCapable,
7279 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007280 pConfig->pRSNWPAReqIE[1]+2,
7281 pConfig->pRSNWPAReqIE );
7282
7283 if( VOS_STATUS_SUCCESS == status )
7284 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307285 /* Now copy over all the security attributes you have
7286 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007287 * */
7288 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7289 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7290 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7291 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307292 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007293 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007294 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7295 }
7296 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307297
Jeff Johnson295189b2012-06-20 16:38:30 -07007298 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7299 pBeacon->tail, pBeacon->tail_len);
7300
7301 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
7302 {
7303 if (pConfig->pRSNWPAReqIE)
7304 {
7305 /*Mixed mode WPA/WPA2*/
7306 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
7307 pConfig->RSNWPAReqIELength += pIe[1] + 2;
7308 }
7309 else
7310 {
7311 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7312 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7313 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307314 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007315 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7316 &RSNEncryptType,
7317 &mcRSNEncryptType,
7318 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007319 &MFPCapable,
7320 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007321 pConfig->pRSNWPAReqIE[1]+2,
7322 pConfig->pRSNWPAReqIE );
7323
7324 if( VOS_STATUS_SUCCESS == status )
7325 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307326 /* Now copy over all the security attributes you have
7327 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007328 * */
7329 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7330 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7331 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7332 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307333 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007334 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007335 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7336 }
7337 }
7338 }
7339
Jeff Johnson4416a782013-03-25 14:17:50 -07007340 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
7341 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
7342 return -EINVAL;
7343 }
7344
Jeff Johnson295189b2012-06-20 16:38:30 -07007345 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
7346
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007347#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007348 if (params->ssid != NULL)
7349 {
7350 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
7351 pConfig->SSIDinfo.ssid.length = params->ssid_len;
7352 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7353 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7354 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007355#else
7356 if (ssid != NULL)
7357 {
7358 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
7359 pConfig->SSIDinfo.ssid.length = ssid_len;
7360 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7361 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7362 }
7363#endif
7364
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307365 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07007366 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307367
Jeff Johnson295189b2012-06-20 16:38:30 -07007368 /* default value */
7369 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
7370 pConfig->num_accept_mac = 0;
7371 pConfig->num_deny_mac = 0;
7372
7373 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7374 pBeacon->tail, pBeacon->tail_len);
7375
7376 /* pIe for black list is following form:
7377 type : 1 byte
7378 length : 1 byte
7379 OUI : 4 bytes
7380 acl type : 1 byte
7381 no of mac addr in black list: 1 byte
7382 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307383 */
7384 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007385 {
7386 pConfig->SapMacaddr_acl = pIe[6];
7387 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007388 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007389 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307390 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
7391 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007392 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7393 for (i = 0; i < pConfig->num_deny_mac; i++)
7394 {
7395 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7396 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007398 }
7399 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7400 pBeacon->tail, pBeacon->tail_len);
7401
7402 /* pIe for white list is following form:
7403 type : 1 byte
7404 length : 1 byte
7405 OUI : 4 bytes
7406 acl type : 1 byte
7407 no of mac addr in white list: 1 byte
7408 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307409 */
7410 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007411 {
7412 pConfig->SapMacaddr_acl = pIe[6];
7413 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007414 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007415 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307416 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
7417 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007418 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7419 for (i = 0; i < pConfig->num_accept_mac; i++)
7420 {
7421 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7422 acl_entry++;
7423 }
7424 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307425
Jeff Johnson295189b2012-06-20 16:38:30 -07007426 wlan_hdd_set_sapHwmode(pHostapdAdapter);
7427
Jeff Johnsone7245742012-09-05 17:12:55 -07007428#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007429 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307430 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
7431 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05307432 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
7433 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007434 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
7435 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307436 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
7437 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07007438 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307439 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007440 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307441 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007442
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307443 /* If ACS disable and selected channel <= 14
7444 * OR
7445 * ACS enabled and ACS operating band is choosen as 2.4
7446 * AND
7447 * VHT in 2.4G Disabled
7448 * THEN
7449 * Fallback to 11N mode
7450 */
7451 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
7452 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05307453 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307454 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007455 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307456 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
7457 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007458 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
7459 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007460 }
7461#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307462
Jeff Johnson295189b2012-06-20 16:38:30 -07007463 // ht_capab is not what the name conveys,this is used for protection bitmap
7464 pConfig->ht_capab =
7465 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
7466
7467 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
7468 {
7469 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
7470 return -EINVAL;
7471 }
7472
7473 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307474 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07007475 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
7476 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307477 pConfig->obssProtEnabled =
7478 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07007479
Chet Lanctot8cecea22014-02-11 19:09:36 -08007480#ifdef WLAN_FEATURE_11W
7481 pConfig->mfpCapable = MFPCapable;
7482 pConfig->mfpRequired = MFPRequired;
7483 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
7484 pConfig->mfpCapable, pConfig->mfpRequired);
7485#endif
7486
Arif Hussain6d2a3322013-11-17 19:50:10 -08007487 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07007488 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007489 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
7490 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
7491 (int)pConfig->channel);
7492 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
7493 pConfig->SapHw_mode, pConfig->privacy,
7494 pConfig->authType);
7495 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
7496 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
7497 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
7498 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07007499
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307500 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 {
7502 //Bss already started. just return.
7503 //TODO Probably it should update some beacon params.
7504 hddLog( LOGE, "Bss Already started...Ignore the request");
7505 EXIT();
7506 return 0;
7507 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307508
Agarwal Ashish51325b52014-06-16 16:50:49 +05307509 if (vos_max_concurrent_connections_reached()) {
7510 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7511 return -EINVAL;
7512 }
7513
Jeff Johnson295189b2012-06-20 16:38:30 -07007514 pConfig->persona = pHostapdAdapter->device_mode;
7515
Peng Xu2446a892014-09-05 17:21:18 +05307516 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
7517 if ( NULL != psmeConfig)
7518 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307519 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05307520 sme_GetConfigParam(hHal, psmeConfig);
7521 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307522#ifdef WLAN_FEATURE_AP_HT40_24G
7523 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
7524 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
7525 && pHddCtx->cfg_ini->apHT40_24GEnabled)
7526 {
7527 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
7528 sme_UpdateConfig (hHal, psmeConfig);
7529 }
7530#endif
Peng Xu2446a892014-09-05 17:21:18 +05307531 vos_mem_free(psmeConfig);
7532 }
Peng Xuafc34e32014-09-25 13:23:55 +05307533 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05307534
Jeff Johnson295189b2012-06-20 16:38:30 -07007535 pSapEventCallback = hdd_hostapd_SAPEventCB;
7536 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
7537 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
7538 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007539 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 return -EINVAL;
7541 }
7542
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307543 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07007544 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
7545
7546 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307547
Jeff Johnson295189b2012-06-20 16:38:30 -07007548 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307549 {
7550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007551 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07007552 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007553 VOS_ASSERT(0);
7554 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307555
Jeff Johnson295189b2012-06-20 16:38:30 -07007556 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05307557 /* Initialize WMM configuation */
7558 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307559 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007560
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007561#ifdef WLAN_FEATURE_P2P_DEBUG
7562 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
7563 {
7564 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
7565 {
7566 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7567 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007568 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007569 }
7570 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
7571 {
7572 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7573 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007574 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007575 }
7576 }
7577#endif
7578
Jeff Johnson295189b2012-06-20 16:38:30 -07007579 pHostapdState->bCommit = TRUE;
7580 EXIT();
7581
7582 return 0;
7583}
7584
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007585#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307586static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307587 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007588 struct beacon_parameters *params)
7589{
7590 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307591 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307592 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007593
7594 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307595
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307596 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7597 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
7598 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307599 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
7600 hdd_device_modetoString(pAdapter->device_mode),
7601 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007602
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307603 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7604 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307605 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007606 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307607 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007608 }
7609
Agarwal Ashish51325b52014-06-16 16:50:49 +05307610 if (vos_max_concurrent_connections_reached()) {
7611 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7612 return -EINVAL;
7613 }
7614
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307615 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007616 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007617 )
7618 {
7619 beacon_data_t *old,*new;
7620
7621 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307622
Jeff Johnson295189b2012-06-20 16:38:30 -07007623 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307624 {
7625 hddLog(VOS_TRACE_LEVEL_WARN,
7626 FL("already beacon info added to session(%d)"),
7627 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007628 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007630
7631 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7632
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307633 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07007634 {
7635 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007636 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007637 return -EINVAL;
7638 }
7639
7640 pAdapter->sessionCtx.ap.beacon = new;
7641
7642 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7643 }
7644
7645 EXIT();
7646 return status;
7647}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307648
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307649static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
7650 struct net_device *dev,
7651 struct beacon_parameters *params)
7652{
7653 int ret;
7654
7655 vos_ssr_protect(__func__);
7656 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
7657 vos_ssr_unprotect(__func__);
7658
7659 return ret;
7660}
7661
7662static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007663 struct net_device *dev,
7664 struct beacon_parameters *params)
7665{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307666 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307667 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7668 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307669 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007670
7671 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307672
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307673 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7674 TRACE_CODE_HDD_CFG80211_SET_BEACON,
7675 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
7676 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7677 __func__, hdd_device_modetoString(pAdapter->device_mode),
7678 pAdapter->device_mode);
7679
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307680 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7681 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307682 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007683 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307684 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007685 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307686
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307687 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007688 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307689 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007690 {
7691 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307692
Jeff Johnson295189b2012-06-20 16:38:30 -07007693 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307694
Jeff Johnson295189b2012-06-20 16:38:30 -07007695 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307696 {
7697 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7698 FL("session(%d) old and new heads points to NULL"),
7699 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007700 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007702
7703 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7704
7705 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307706 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007707 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007708 return -EINVAL;
7709 }
7710
7711 pAdapter->sessionCtx.ap.beacon = new;
7712
7713 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7714 }
7715
7716 EXIT();
7717 return status;
7718}
7719
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307720static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
7721 struct net_device *dev,
7722 struct beacon_parameters *params)
7723{
7724 int ret;
7725
7726 vos_ssr_protect(__func__);
7727 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
7728 vos_ssr_unprotect(__func__);
7729
7730 return ret;
7731}
7732
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007733#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7734
7735#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307736static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007737 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007738#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307739static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007740 struct net_device *dev)
7741#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007742{
7743 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07007744 hdd_context_t *pHddCtx = NULL;
7745 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307746 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307747 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007748
7749 ENTER();
7750
7751 if (NULL == pAdapter)
7752 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307753 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007754 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007755 return -ENODEV;
7756 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007757
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307758 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7759 TRACE_CODE_HDD_CFG80211_STOP_AP,
7760 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307761 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7762 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307763 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007764 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307765 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07007766 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007767
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007768 pScanInfo = &pHddCtx->scan_info;
7769
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307770 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7771 __func__, hdd_device_modetoString(pAdapter->device_mode),
7772 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007773
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307774 ret = wlan_hdd_scan_abort(pAdapter);
7775
Girish Gowli4bf7a632014-06-12 13:42:11 +05307776 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07007777 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307778 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7779 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307780
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307781 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07007782 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7784 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08007785
Jeff Johnsone7245742012-09-05 17:12:55 -07007786 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307787 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07007788 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307789 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07007790 }
7791
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05307792 /* Delete all associated STAs before stopping AP/P2P GO */
7793 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05307794 hdd_hostapd_stop(dev);
7795
Jeff Johnson295189b2012-06-20 16:38:30 -07007796 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007797 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007798 )
7799 {
7800 beacon_data_t *old;
7801
7802 old = pAdapter->sessionCtx.ap.beacon;
7803
7804 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307805 {
7806 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7807 FL("session(%d) beacon data points to NULL"),
7808 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007809 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307810 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007811
Jeff Johnson295189b2012-06-20 16:38:30 -07007812 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007813
7814 mutex_lock(&pHddCtx->sap_lock);
7815 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7816 {
Jeff Johnson4416a782013-03-25 14:17:50 -07007817 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007818 {
7819 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7820
7821 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
7822
7823 if (!VOS_IS_STATUS_SUCCESS(status))
7824 {
7825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007826 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007827 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307828 }
7829 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007830 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307831 /* BSS stopped, clear the active sessions for this device mode */
7832 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 }
7834 mutex_unlock(&pHddCtx->sap_lock);
7835
7836 if(status != VOS_STATUS_SUCCESS)
7837 {
7838 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007839 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007840 return -EINVAL;
7841 }
7842
Jeff Johnson4416a782013-03-25 14:17:50 -07007843 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007844 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
7845 ==eHAL_STATUS_FAILURE)
7846 {
7847 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007848 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007849 }
7850
Jeff Johnson4416a782013-03-25 14:17:50 -07007851 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007852 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7853 eANI_BOOLEAN_FALSE) )
7854 {
7855 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007856 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007857 }
7858
7859 // Reset WNI_CFG_PROBE_RSP Flags
7860 wlan_hdd_reset_prob_rspies(pAdapter);
7861
7862 pAdapter->sessionCtx.ap.beacon = NULL;
7863 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007864#ifdef WLAN_FEATURE_P2P_DEBUG
7865 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
7866 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
7867 {
7868 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
7869 "GO got removed");
7870 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
7871 }
7872#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 }
7874 EXIT();
7875 return status;
7876}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007877
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307878#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7879static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
7880 struct net_device *dev)
7881{
7882 int ret;
7883
7884 vos_ssr_protect(__func__);
7885 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
7886 vos_ssr_unprotect(__func__);
7887
7888 return ret;
7889}
7890#else
7891static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
7892 struct net_device *dev)
7893{
7894 int ret;
7895
7896 vos_ssr_protect(__func__);
7897 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
7898 vos_ssr_unprotect(__func__);
7899
7900 return ret;
7901}
7902#endif
7903
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007904#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
7905
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307906static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307907 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007908 struct cfg80211_ap_settings *params)
7909{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307910 hdd_adapter_t *pAdapter;
7911 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307912 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007913
7914 ENTER();
7915
Girish Gowlib143d7a2015-02-18 19:39:55 +05307916 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007917 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307918 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05307919 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307920 return -ENODEV;
7921 }
7922
7923 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7924 if (NULL == pAdapter)
7925 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307926 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307927 "%s: HDD adapter is Null", __func__);
7928 return -ENODEV;
7929 }
7930
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307931 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7932 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
7933 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307934 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
7935 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307936 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307937 "%s: HDD adapter magic is invalid", __func__);
7938 return -ENODEV;
7939 }
7940
7941 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307942 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307943 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307944 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307945 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307946 }
7947
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307948 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
7949 __func__, hdd_device_modetoString(pAdapter->device_mode),
7950 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307951
7952 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007953 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007954 )
7955 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307956 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007957
7958 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307959
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007960 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307961 {
7962 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7963 FL("already beacon info added to session(%d)"),
7964 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007965 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307966 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007967
Girish Gowlib143d7a2015-02-18 19:39:55 +05307968#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7969 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7970 &new,
7971 &params->beacon);
7972#else
7973 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7974 &new,
7975 &params->beacon,
7976 params->dtim_period);
7977#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007978
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307979 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007980 {
7981 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307982 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007983 return -EINVAL;
7984 }
7985 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08007986#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07007987 wlan_hdd_cfg80211_set_channel(wiphy, dev,
7988#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
7989 params->channel, params->channel_type);
7990#else
7991 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
7992#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08007993#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007994 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307995 params->ssid_len, params->hidden_ssid,
7996 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007997 }
7998
7999 EXIT();
8000 return status;
8001}
8002
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308003static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
8004 struct net_device *dev,
8005 struct cfg80211_ap_settings *params)
8006{
8007 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008008
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308009 vos_ssr_protect(__func__);
8010 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
8011 vos_ssr_unprotect(__func__);
8012
8013 return ret;
8014}
8015
8016static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008017 struct net_device *dev,
8018 struct cfg80211_beacon_data *params)
8019{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308020 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308021 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308022 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008023
8024 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308025
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308026 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8027 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
8028 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08008029 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008030 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308031
8032 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8033 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308034 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07008035 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308036 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07008037 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008038
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308039 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008040 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308041 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008042 {
8043 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308044
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008045 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308046
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008047 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308048 {
8049 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8050 FL("session(%d) beacon data points to NULL"),
8051 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008052 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308053 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008054
8055 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
8056
8057 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308058 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008059 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008060 return -EINVAL;
8061 }
8062
8063 pAdapter->sessionCtx.ap.beacon = new;
8064
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05308065 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
8066 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008067 }
8068
8069 EXIT();
8070 return status;
8071}
8072
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308073static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
8074 struct net_device *dev,
8075 struct cfg80211_beacon_data *params)
8076{
8077 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008078
Mukul Sharmab0e0a982014-12-15 18:58:53 +05308079 vos_ssr_protect(__func__);
8080 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
8081 vos_ssr_unprotect(__func__);
8082
8083 return ret;
8084}
8085
8086#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008087
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308088static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008089 struct net_device *dev,
8090 struct bss_parameters *params)
8091{
8092 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308093 hdd_context_t *pHddCtx;
8094 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008095
8096 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308097
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308098 if (NULL == pAdapter)
8099 {
8100 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8101 "%s: HDD adapter is Null", __func__);
8102 return -ENODEV;
8103 }
8104 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308105 ret = wlan_hdd_validate_context(pHddCtx);
8106 if (0 != ret)
8107 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308108 return ret;
8109 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308110 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8111 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
8112 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308113 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8114 __func__, hdd_device_modetoString(pAdapter->device_mode),
8115 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008116
8117 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008118 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308119 )
Jeff Johnson295189b2012-06-20 16:38:30 -07008120 {
8121 /* ap_isolate == -1 means that in change bss, upper layer doesn't
8122 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308123 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07008124 {
8125 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308126 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008127 }
8128
8129 EXIT();
8130 return 0;
8131}
8132
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308133static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
8134 struct net_device *dev,
8135 struct bss_parameters *params)
8136{
8137 int ret;
8138
8139 vos_ssr_protect(__func__);
8140 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
8141 vos_ssr_unprotect(__func__);
8142
8143 return ret;
8144}
Kiet Lam10841362013-11-01 11:36:50 +05308145/* FUNCTION: wlan_hdd_change_country_code_cd
8146* to wait for contry code completion
8147*/
8148void* wlan_hdd_change_country_code_cb(void *pAdapter)
8149{
8150 hdd_adapter_t *call_back_pAdapter = pAdapter;
8151 complete(&call_back_pAdapter->change_country_code);
8152 return NULL;
8153}
8154
Jeff Johnson295189b2012-06-20 16:38:30 -07008155/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308156 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07008157 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
8158 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308159int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008160 struct net_device *ndev,
8161 enum nl80211_iftype type,
8162 u32 *flags,
8163 struct vif_params *params
8164 )
8165{
8166 struct wireless_dev *wdev;
8167 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008168 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07008169 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008170 tCsrRoamProfile *pRoamProfile = NULL;
8171 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308172 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008173 eMib_dot11DesiredBssType connectedBssType;
8174 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308175 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07008176
8177 ENTER();
8178
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308179 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008180 {
8181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8182 "%s: Adapter context is null", __func__);
8183 return VOS_STATUS_E_FAILURE;
8184 }
8185
8186 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8187 if (!pHddCtx)
8188 {
8189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8190 "%s: HDD context is null", __func__);
8191 return VOS_STATUS_E_FAILURE;
8192 }
8193
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308194 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8195 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
8196 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308197 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308198 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07008199 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308200 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 }
8202
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308203 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8204 __func__, hdd_device_modetoString(pAdapter->device_mode),
8205 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008206
Agarwal Ashish51325b52014-06-16 16:50:49 +05308207 if (vos_max_concurrent_connections_reached()) {
8208 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
8209 return -EINVAL;
8210 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308211 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07008212 wdev = ndev->ieee80211_ptr;
8213
8214#ifdef WLAN_BTAMP_FEATURE
8215 if((NL80211_IFTYPE_P2P_CLIENT == type)||
8216 (NL80211_IFTYPE_ADHOC == type)||
8217 (NL80211_IFTYPE_AP == type)||
8218 (NL80211_IFTYPE_P2P_GO == type))
8219 {
8220 pHddCtx->isAmpAllowed = VOS_FALSE;
8221 // stop AMP traffic
8222 status = WLANBAP_StopAmp();
8223 if(VOS_STATUS_SUCCESS != status )
8224 {
8225 pHddCtx->isAmpAllowed = VOS_TRUE;
8226 hddLog(VOS_TRACE_LEVEL_FATAL,
8227 "%s: Failed to stop AMP", __func__);
8228 return -EINVAL;
8229 }
8230 }
8231#endif //WLAN_BTAMP_FEATURE
8232 /* Reset the current device mode bit mask*/
8233 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
8234
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05308235 /* Notify Mode change in case of concurrency.
8236 * Below function invokes TDLS teardown Functionality Since TDLS is
8237 * not Supported in case of concurrency i.e Once P2P session
8238 * is detected disable offchannel and teardown TDLS links
8239 */
8240 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
8241
Jeff Johnson295189b2012-06-20 16:38:30 -07008242 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008243 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07008244 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07008245 )
8246 {
8247 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008248 if (!pWextState)
8249 {
8250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8251 "%s: pWextState is null", __func__);
8252 return VOS_STATUS_E_FAILURE;
8253 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008254 pRoamProfile = &pWextState->roamProfile;
8255 LastBSSType = pRoamProfile->BSSType;
8256
8257 switch (type)
8258 {
8259 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008260 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008261 hddLog(VOS_TRACE_LEVEL_INFO,
8262 "%s: setting interface Type to INFRASTRUCTURE", __func__);
8263 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07008264#ifdef WLAN_FEATURE_11AC
8265 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
8266 {
8267 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
8268 }
8269#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308270 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07008271 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008272 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008273 //Check for sub-string p2p to confirm its a p2p interface
8274 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308275 {
Mahesh A Saptasagarc48ae8a2015-08-09 00:04:35 +05308276#ifdef FEATURE_WLAN_TDLS
8277 mutex_lock(&pHddCtx->tdls_lock);
8278 wlan_hdd_tdls_exit(pAdapter, TRUE);
8279 mutex_unlock(&pHddCtx->tdls_lock);
8280#endif
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008281 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8282 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8283 }
8284 else
8285 {
8286 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008287 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008288 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008289 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05308290
Jeff Johnson295189b2012-06-20 16:38:30 -07008291 case NL80211_IFTYPE_ADHOC:
8292 hddLog(VOS_TRACE_LEVEL_INFO,
8293 "%s: setting interface Type to ADHOC", __func__);
8294 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
8295 pRoamProfile->phyMode =
8296 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07008297 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008298 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +05308299 hdd_set_ibss_ops( pAdapter );
8300 hdd_ibss_init_tx_rx( pAdapter );
Nirav Shah7e3c8132015-06-22 23:51:42 +05308301
8302 status = hdd_sta_id_hash_attach(pAdapter);
8303 if (VOS_STATUS_SUCCESS != status) {
8304 hddLog(VOS_TRACE_LEVEL_ERROR,
8305 FL("Failed to initialize hash for IBSS"));
8306 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008307 break;
8308
8309 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008310 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008311 {
8312 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8313 "%s: setting interface Type to %s", __func__,
8314 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
8315
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008316 //Cancel any remain on channel for GO mode
8317 if (NL80211_IFTYPE_P2P_GO == type)
8318 {
8319 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
8320 }
Mohit Khanna0f232092012-09-11 14:46:08 -07008321 if (NL80211_IFTYPE_AP == type)
8322 {
8323 /* As Loading WLAN Driver one interface being created for p2p device
8324 * address. This will take one HW STA and the max number of clients
8325 * that can connect to softAP will be reduced by one. so while changing
8326 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
8327 * interface as it is not required in SoftAP mode.
8328 */
8329
8330 // Get P2P Adapter
8331 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
8332
8333 if (pP2pAdapter)
8334 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05308335 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +05308336 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07008337 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
8338 }
8339 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05308340 //Disable IMPS & BMPS for SAP/GO
8341 if(VOS_STATUS_E_FAILURE ==
8342 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
8343 {
8344 //Fail to Exit BMPS
8345 VOS_ASSERT(0);
8346 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05308347
8348 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
8349
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308350#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07008351
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308352 /* A Mutex Lock is introduced while changing the mode to
8353 * protect the concurrent access for the Adapters by TDLS
8354 * module.
8355 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308356 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308357#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008358 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +05308359 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008360 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07008361 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8362 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308363#ifdef FEATURE_WLAN_TDLS
8364 mutex_unlock(&pHddCtx->tdls_lock);
8365#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008366 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
8367 (pConfig->apRandomBssidEnabled))
8368 {
8369 /* To meet Android requirements create a randomized
8370 MAC address of the form 02:1A:11:Fx:xx:xx */
8371 get_random_bytes(&ndev->dev_addr[3], 3);
8372 ndev->dev_addr[0] = 0x02;
8373 ndev->dev_addr[1] = 0x1A;
8374 ndev->dev_addr[2] = 0x11;
8375 ndev->dev_addr[3] |= 0xF0;
8376 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
8377 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08008378 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
8379 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008380 }
8381
Jeff Johnson295189b2012-06-20 16:38:30 -07008382 hdd_set_ap_ops( pAdapter->dev );
8383
Kiet Lam10841362013-11-01 11:36:50 +05308384 /* This is for only SAP mode where users can
8385 * control country through ini.
8386 * P2P GO follows station country code
8387 * acquired during the STA scanning. */
8388 if((NL80211_IFTYPE_AP == type) &&
8389 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
8390 {
8391 int status = 0;
8392 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
8393 "%s: setting country code from INI ", __func__);
8394 init_completion(&pAdapter->change_country_code);
8395 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
8396 (void *)(tSmeChangeCountryCallback)
8397 wlan_hdd_change_country_code_cb,
8398 pConfig->apCntryCode, pAdapter,
8399 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05308400 eSIR_FALSE,
8401 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05308402 if (eHAL_STATUS_SUCCESS == status)
8403 {
8404 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308405 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05308406 &pAdapter->change_country_code,
8407 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308408 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05308409 {
8410 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308411 FL("SME Timed out while setting country code %ld"),
8412 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08008413
8414 if (pHddCtx->isLogpInProgress)
8415 {
8416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8417 "%s: LOGP in Progress. Ignore!!!", __func__);
8418 return -EAGAIN;
8419 }
Kiet Lam10841362013-11-01 11:36:50 +05308420 }
8421 }
8422 else
8423 {
8424 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008425 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05308426 return -EINVAL;
8427 }
8428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008429 status = hdd_init_ap_mode(pAdapter);
8430 if(status != VOS_STATUS_SUCCESS)
8431 {
8432 hddLog(VOS_TRACE_LEVEL_FATAL,
8433 "%s: Error initializing the ap mode", __func__);
8434 return -EINVAL;
8435 }
8436 hdd_set_conparam(1);
8437
Nirav Shah7e3c8132015-06-22 23:51:42 +05308438 status = hdd_sta_id_hash_attach(pAdapter);
8439 if (VOS_STATUS_SUCCESS != status)
8440 {
8441 hddLog(VOS_TRACE_LEVEL_ERROR,
8442 FL("Failed to initialize hash for AP"));
8443 return -EINVAL;
8444 }
8445
Jeff Johnson295189b2012-06-20 16:38:30 -07008446 /*interface type changed update in wiphy structure*/
8447 if(wdev)
8448 {
8449 wdev->iftype = type;
8450 pHddCtx->change_iface = type;
8451 }
8452 else
8453 {
8454 hddLog(VOS_TRACE_LEVEL_ERROR,
8455 "%s: ERROR !!!! Wireless dev is NULL", __func__);
8456 return -EINVAL;
8457 }
8458 goto done;
8459 }
8460
8461 default:
8462 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8463 __func__);
8464 return -EOPNOTSUPP;
8465 }
8466 }
8467 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008468 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07008469 )
8470 {
8471 switch(type)
8472 {
8473 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008474 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008475 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05308476
8477 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308478#ifdef FEATURE_WLAN_TDLS
8479
8480 /* A Mutex Lock is introduced while changing the mode to
8481 * protect the concurrent access for the Adapters by TDLS
8482 * module.
8483 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308484 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308485#endif
c_hpothu002231a2015-02-05 14:58:51 +05308486 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008487 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008488 //Check for sub-string p2p to confirm its a p2p interface
8489 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008490 {
8491 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8492 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8493 }
8494 else
8495 {
8496 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008497 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008499 hdd_set_conparam(0);
8500 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008501 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
8502 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308503#ifdef FEATURE_WLAN_TDLS
8504 mutex_unlock(&pHddCtx->tdls_lock);
8505#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05308506 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008507 if( VOS_STATUS_SUCCESS != status )
8508 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07008509 /* In case of JB, for P2P-GO, only change interface will be called,
8510 * This is the right place to enable back bmps_imps()
8511 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308512 if (pHddCtx->hdd_wlan_suspended)
8513 {
8514 hdd_set_pwrparams(pHddCtx);
8515 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008516 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008517 goto done;
8518 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008519 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008520 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008521 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8522 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 goto done;
8524 default:
8525 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8526 __func__);
8527 return -EOPNOTSUPP;
8528
8529 }
8530
8531 }
8532 else
8533 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308534 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
8535 __func__, hdd_device_modetoString(pAdapter->device_mode),
8536 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008537 return -EOPNOTSUPP;
8538 }
8539
8540
8541 if(pRoamProfile)
8542 {
8543 if ( LastBSSType != pRoamProfile->BSSType )
8544 {
8545 /*interface type changed update in wiphy structure*/
8546 wdev->iftype = type;
8547
8548 /*the BSS mode changed, We need to issue disconnect
8549 if connected or in IBSS disconnect state*/
8550 if ( hdd_connGetConnectedBssType(
8551 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
8552 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
8553 {
8554 /*need to issue a disconnect to CSR.*/
8555 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8556 if( eHAL_STATUS_SUCCESS ==
8557 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8558 pAdapter->sessionId,
8559 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
8560 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308561 ret = wait_for_completion_interruptible_timeout(
8562 &pAdapter->disconnect_comp_var,
8563 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8564 if (ret <= 0)
8565 {
8566 hddLog(VOS_TRACE_LEVEL_ERROR,
8567 FL("wait on disconnect_comp_var failed %ld"), ret);
8568 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008569 }
8570 }
8571 }
8572 }
8573
8574done:
8575 /*set bitmask based on updated value*/
8576 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07008577
8578 /* Only STA mode support TM now
8579 * all other mode, TM feature should be disabled */
8580 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
8581 (~VOS_STA & pHddCtx->concurrency_mode) )
8582 {
8583 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
8584 }
8585
Jeff Johnson295189b2012-06-20 16:38:30 -07008586#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308587 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05308588 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07008589 {
8590 //we are ok to do AMP
8591 pHddCtx->isAmpAllowed = VOS_TRUE;
8592 }
8593#endif //WLAN_BTAMP_FEATURE
8594 EXIT();
8595 return 0;
8596}
8597
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308598/*
8599 * FUNCTION: wlan_hdd_cfg80211_change_iface
8600 * wrapper function to protect the actual implementation from SSR.
8601 */
8602int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
8603 struct net_device *ndev,
8604 enum nl80211_iftype type,
8605 u32 *flags,
8606 struct vif_params *params
8607 )
8608{
8609 int ret;
8610
8611 vos_ssr_protect(__func__);
8612 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
8613 vos_ssr_unprotect(__func__);
8614
8615 return ret;
8616}
8617
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008618#ifdef FEATURE_WLAN_TDLS
8619static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308620 struct net_device *dev,
8621#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
8622 const u8 *mac,
8623#else
8624 u8 *mac,
8625#endif
8626 bool update, tCsrStaParams *StaParams)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008627{
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008628 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008629 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308630 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308631 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308632 hdd_adapter_t *pAdapter;
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308633 VOS_STATUS status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008634
8635 ENTER();
8636
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308637 if (!dev) {
8638 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
8639 return -EINVAL;
8640 }
8641
8642 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8643 if (!pAdapter) {
8644 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
8645 return -EINVAL;
8646 }
8647
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308648 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008649 {
8650 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8651 "Invalid arguments");
8652 return -EINVAL;
8653 }
Hoonki Lee27511902013-03-14 18:19:06 -07008654
8655 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
8656 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
8657 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308658 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -07008659 "%s: TDLS mode is disabled OR not enabled in FW."
8660 MAC_ADDRESS_STR " Request declined.",
8661 __func__, MAC_ADDR_ARRAY(mac));
8662 return -ENOTSUPP;
8663 }
8664
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008665 if (pHddCtx->isLogpInProgress)
8666 {
8667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8668 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05308669 wlan_hdd_tdls_set_link_status(pAdapter,
8670 mac,
8671 eTDLS_LINK_IDLE,
8672 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008673 return -EBUSY;
8674 }
8675
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308676 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05308677 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008678
8679 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308680 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008681 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
8682 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308683 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008684 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008685 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308686 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008687
8688 /* in add station, we accept existing valid staId if there is */
8689 if ((0 == update) &&
8690 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
8691 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008692 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308693 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008694 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008695 " link_status %d. staId %d. add station ignored.",
8696 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
8697 return 0;
8698 }
8699 /* in change station, we accept only when staId is valid */
8700 if ((1 == update) &&
8701 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
8702 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
8703 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308704 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008705 "%s: " MAC_ADDRESS_STR
8706 " link status %d. staId %d. change station %s.",
8707 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
8708 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
8709 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008710 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008711
8712 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05308713 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008714 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008715 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8716 "%s: " MAC_ADDRESS_STR
8717 " TDLS setup is ongoing. Request declined.",
8718 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07008719 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008720 }
8721
8722 /* first to check if we reached to maximum supported TDLS peer.
8723 TODO: for now, return -EPERM looks working fine,
8724 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308725 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
8726 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008727 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008728 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8729 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308730 " TDLS Max peer already connected. Request declined."
8731 " Num of peers (%d), Max allowed (%d).",
8732 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
8733 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008734 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008735 }
8736 else
8737 {
8738 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308739 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008740 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008741 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008742 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8743 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
8744 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008745 return -EPERM;
8746 }
8747 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008748 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05308749 wlan_hdd_tdls_set_link_status(pAdapter,
8750 mac,
8751 eTDLS_LINK_CONNECTING,
8752 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008753
Jeff Johnsond75fe012013-04-06 10:53:06 -07008754 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308755 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008756 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308757 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008758 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008759 if(StaParams->htcap_present)
8760 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008762 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008764 "ht_capa->extended_capabilities: %0x",
8765 StaParams->HTCap.extendedHtCapInfo);
8766 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008768 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008770 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008771 if(StaParams->vhtcap_present)
8772 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308773 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008774 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
8775 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
8776 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
8777 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008778 {
8779 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008780 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008781 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008783 "[%d]: %x ", i, StaParams->supported_rates[i]);
8784 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07008785 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308786 else if ((1 == update) && (NULL == StaParams))
8787 {
8788 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8789 "%s : update is true, but staParams is NULL. Error!", __func__);
8790 return -EPERM;
8791 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008792
8793 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
8794
8795 if (!update)
8796 {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308797 /*Before adding sta make sure that device exited from BMPS*/
8798 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8799 {
8800 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8801 "%s: Adding tdls peer sta. Disable BMPS", __func__);
8802 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8803 if (status != VOS_STATUS_SUCCESS) {
8804 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
8805 }
8806 }
8807
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308808 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008809 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308810 if (ret != eHAL_STATUS_SUCCESS) {
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05308811 hddLog(VOS_TRACE_LEVEL_ERROR,
8812 FL("Failed to add TDLS peer STA. Enable Bmps"));
8813 wlan_hdd_tdls_check_bmps(pAdapter);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308814 return -EPERM;
8815 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008816 }
8817 else
8818 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308819 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008820 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308821 if (ret != eHAL_STATUS_SUCCESS) {
8822 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
8823 return -EPERM;
8824 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008825 }
8826
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308827 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008828 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
8829
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308830 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008831 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308833 "%s: timeout waiting for tdls add station indication %ld",
8834 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008835 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008836 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308837
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008838 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
8839 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008841 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008842 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008843 }
8844
8845 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008846
8847error:
Atul Mittal115287b2014-07-08 13:26:33 +05308848 wlan_hdd_tdls_set_link_status(pAdapter,
8849 mac,
8850 eTDLS_LINK_IDLE,
8851 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008852 return -EPERM;
8853
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008854}
8855#endif
8856
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308857static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008858 struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308859#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
8860 const u8 *mac,
8861#else
Jeff Johnson295189b2012-06-20 16:38:30 -07008862 u8 *mac,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05308863#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008864 struct station_parameters *params)
8865{
8866 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308867 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308868 hdd_context_t *pHddCtx;
8869 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008870 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308871 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008872#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008873 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008874 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308875 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008876#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008877
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308878 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308879
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308880 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308881 if ((NULL == pAdapter))
8882 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308884 "invalid adapter ");
8885 return -EINVAL;
8886 }
8887
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308888 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8889 TRACE_CODE_HDD_CHANGE_STATION,
8890 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05308891 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308892
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308893 ret = wlan_hdd_validate_context(pHddCtx);
8894 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +05308895 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308896 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308897 }
8898
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308899 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8900
8901 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008902 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8904 "invalid HDD station context");
8905 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008907 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
8908
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008909 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
8910 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07008911 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008912 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07008913 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308914 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008915 WLANTL_STA_AUTHENTICATED);
8916
Gopichand Nakkala29149562013-05-10 21:43:41 +05308917 if (status != VOS_STATUS_SUCCESS)
8918 {
8919 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8920 "%s: Not able to change TL state to AUTHENTICATED", __func__);
8921 return -EINVAL;
8922 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008923 }
8924 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07008925 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
8926 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308927#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008928 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
8929 StaParams.capability = params->capability;
8930 StaParams.uapsd_queues = params->uapsd_queues;
8931 StaParams.max_sp = params->max_sp;
8932
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308933 /* Convert (first channel , number of channels) tuple to
8934 * the total list of channels. This goes with the assumption
8935 * that if the first channel is < 14, then the next channels
8936 * are an incremental of 1 else an incremental of 4 till the number
8937 * of channels.
8938 */
8939 if (0 != params->supported_channels_len) {
8940 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
8941 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
8942 {
8943 int wifi_chan_index;
8944 StaParams.supported_channels[j] = params->supported_channels[i];
8945 wifi_chan_index =
8946 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
8947 no_of_channels = params->supported_channels[i+1];
8948 for(k=1; k <= no_of_channels; k++)
8949 {
8950 StaParams.supported_channels[j+1] =
8951 StaParams.supported_channels[j] + wifi_chan_index;
8952 j+=1;
8953 }
8954 }
8955 StaParams.supported_channels_len = j;
8956 }
8957 vos_mem_copy(StaParams.supported_oper_classes,
8958 params->supported_oper_classes,
8959 params->supported_oper_classes_len);
8960 StaParams.supported_oper_classes_len =
8961 params->supported_oper_classes_len;
8962
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008963 if (0 != params->ext_capab_len)
8964 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
8965 sizeof(StaParams.extn_capability));
8966
8967 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008968 {
8969 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008970 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008971 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008972
8973 StaParams.supported_rates_len = params->supported_rates_len;
8974
8975 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
8976 * The supported_rates array , for all the structures propogating till Add Sta
8977 * to the firmware has to be modified , if the supplicant (ieee80211) is
8978 * modified to send more rates.
8979 */
8980
8981 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
8982 */
8983 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
8984 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
8985
8986 if (0 != StaParams.supported_rates_len) {
8987 int i = 0;
8988 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
8989 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008990 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008991 "Supported Rates with Length %d", StaParams.supported_rates_len);
8992 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008993 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008994 "[%d]: %0x", i, StaParams.supported_rates[i]);
8995 }
8996
8997 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008998 {
8999 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009000 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07009001 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07009002
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009003 if (0 != params->ext_capab_len ) {
9004 /*Define A Macro : TODO Sunil*/
9005 if ((1<<4) & StaParams.extn_capability[3]) {
9006 isBufSta = 1;
9007 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05309008 /* TDLS Channel Switching Support */
9009 if ((1<<6) & StaParams.extn_capability[3]) {
9010 isOffChannelSupported = 1;
9011 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009012 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05309013 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
9014 &StaParams, isBufSta,
9015 isOffChannelSupported);
9016
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05309017 if (VOS_STATUS_SUCCESS != status) {
9018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9019 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
9020 return -EINVAL;
9021 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009022 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
9023
9024 if (VOS_STATUS_SUCCESS != status) {
9025 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9026 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
9027 return -EINVAL;
9028 }
9029 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07009030#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05309031 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009032 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009033 return status;
9034}
9035
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309036#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
9037static int wlan_hdd_change_station(struct wiphy *wiphy,
9038 struct net_device *dev,
9039 const u8 *mac,
9040 struct station_parameters *params)
9041#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309042static int wlan_hdd_change_station(struct wiphy *wiphy,
9043 struct net_device *dev,
9044 u8 *mac,
9045 struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +05309046#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309047{
9048 int ret;
9049
9050 vos_ssr_protect(__func__);
9051 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
9052 vos_ssr_unprotect(__func__);
9053
9054 return ret;
9055}
9056
Jeff Johnson295189b2012-06-20 16:38:30 -07009057/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309058 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009059 * This function is used to initialize the key information
9060 */
9061#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309062static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009063 struct net_device *ndev,
9064 u8 key_index, bool pairwise,
9065 const u8 *mac_addr,
9066 struct key_params *params
9067 )
9068#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309069static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009070 struct net_device *ndev,
9071 u8 key_index, const u8 *mac_addr,
9072 struct key_params *params
9073 )
9074#endif
9075{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009076 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07009077 tCsrRoamSetKey setKey;
9078 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309079 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009080 v_U32_t roamId= 0xFF;
9081 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009082 hdd_hostapd_state_t *pHostapdState;
9083 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009084 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309085 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009086
9087 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309088
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309089 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9090 TRACE_CODE_HDD_CFG80211_ADD_KEY,
9091 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309092 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9093 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309094 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009095 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309096 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009097 }
9098
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309099 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9100 __func__, hdd_device_modetoString(pAdapter->device_mode),
9101 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009102
9103 if (CSR_MAX_NUM_KEY <= key_index)
9104 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009105 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009106 key_index);
9107
9108 return -EINVAL;
9109 }
9110
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009111 if (CSR_MAX_KEY_LEN < params->key_len)
9112 {
9113 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
9114 params->key_len);
9115
9116 return -EINVAL;
9117 }
9118
9119 hddLog(VOS_TRACE_LEVEL_INFO,
9120 "%s: called with key index = %d & key length %d",
9121 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07009122
9123 /*extract key idx, key len and key*/
9124 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9125 setKey.keyId = key_index;
9126 setKey.keyLength = params->key_len;
9127 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
9128
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009129 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07009130 {
9131 case WLAN_CIPHER_SUITE_WEP40:
9132 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
9133 break;
9134
9135 case WLAN_CIPHER_SUITE_WEP104:
9136 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
9137 break;
9138
9139 case WLAN_CIPHER_SUITE_TKIP:
9140 {
9141 u8 *pKey = &setKey.Key[0];
9142 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
9143
9144 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
9145
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009146 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07009147
9148 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009149 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07009150 |--------------|----------|----------|
9151 <---16bytes---><--8bytes--><--8bytes-->
9152
9153 */
9154 /*Sme expects the 32 bytes key to be in the below order
9155
9156 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009157 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07009158 |--------------|----------|----------|
9159 <---16bytes---><--8bytes--><--8bytes-->
9160 */
9161 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009162 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07009163
9164 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009165 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009166
9167 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009168 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07009169
9170
9171 break;
9172 }
9173
9174 case WLAN_CIPHER_SUITE_CCMP:
9175 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
9176 break;
9177
9178#ifdef FEATURE_WLAN_WAPI
9179 case WLAN_CIPHER_SUITE_SMS4:
9180 {
9181 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9182 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
9183 params->key, params->key_len);
9184 return 0;
9185 }
9186#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009187
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009188#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009189 case WLAN_CIPHER_SUITE_KRK:
9190 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
9191 break;
9192#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07009193
9194#ifdef WLAN_FEATURE_11W
9195 case WLAN_CIPHER_SUITE_AES_CMAC:
9196 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07009197 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07009198#endif
9199
Jeff Johnson295189b2012-06-20 16:38:30 -07009200 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009201 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07009202 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309203 status = -EOPNOTSUPP;
9204 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009205 }
9206
9207 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
9208 __func__, setKey.encType);
9209
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009210 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07009211#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9212 (!pairwise)
9213#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009214 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07009215#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009216 )
9217 {
9218 /* set group key*/
9219 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9220 "%s- %d: setting Broadcast key",
9221 __func__, __LINE__);
9222 setKey.keyDirection = eSIR_RX_ONLY;
9223 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9224 }
9225 else
9226 {
9227 /* set pairwise key*/
9228 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9229 "%s- %d: setting pairwise key",
9230 __func__, __LINE__);
9231 setKey.keyDirection = eSIR_TX_RX;
9232 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9233 }
9234 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
9235 {
9236 setKey.keyDirection = eSIR_TX_RX;
9237 /*Set the group key*/
9238 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9239 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009240
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009241 if ( 0 != status )
9242 {
9243 hddLog(VOS_TRACE_LEVEL_ERROR,
9244 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309245 status = -EINVAL;
9246 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009247 }
9248 /*Save the keys here and call sme_RoamSetKey for setting
9249 the PTK after peer joins the IBSS network*/
9250 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
9251 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309252 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009253 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05309254 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
9255 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
9256 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009257 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009258 if( pHostapdState->bssState == BSS_START )
9259 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009260 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9261 vos_status = wlan_hdd_check_ula_done(pAdapter);
9262
9263 if ( vos_status != VOS_STATUS_SUCCESS )
9264 {
9265 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9266 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9267 __LINE__, vos_status );
9268
9269 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9270
9271 status = -EINVAL;
9272 goto end;
9273 }
9274
Jeff Johnson295189b2012-06-20 16:38:30 -07009275 status = WLANSAP_SetKeySta( pVosContext, &setKey);
9276
9277 if ( status != eHAL_STATUS_SUCCESS )
9278 {
9279 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9280 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9281 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309282 status = -EINVAL;
9283 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009284 }
9285 }
9286
9287 /* Saving WEP keys */
9288 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
9289 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
9290 {
9291 //Save the wep key in ap context. Issue setkey after the BSS is started.
9292 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9293 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
9294 }
9295 else
9296 {
9297 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009298 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009299 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
9300 }
9301 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009302 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9303 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009304 {
9305 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9306 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9307
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309308#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9309 if (!pairwise)
9310#else
9311 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9312#endif
9313 {
9314 /* set group key*/
9315 if (pHddStaCtx->roam_info.deferKeyComplete)
9316 {
9317 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9318 "%s- %d: Perform Set key Complete",
9319 __func__, __LINE__);
9320 hdd_PerformRoamSetKeyComplete(pAdapter);
9321 }
9322 }
9323
Jeff Johnson295189b2012-06-20 16:38:30 -07009324 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
9325
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08009326 pWextState->roamProfile.Keys.defaultIndex = key_index;
9327
9328
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009329 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009330 params->key, params->key_len);
9331
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309332
Jeff Johnson295189b2012-06-20 16:38:30 -07009333 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9334
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309335 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009336 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309337 __func__, setKey.peerMac[0], setKey.peerMac[1],
9338 setKey.peerMac[2], setKey.peerMac[3],
9339 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009340 setKey.keyDirection);
9341
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009342 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +05309343
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009344 if ( vos_status != VOS_STATUS_SUCCESS )
9345 {
9346 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009347 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9348 __LINE__, vos_status );
9349
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009350 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009351
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009352 status = -EINVAL;
9353 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009354
9355 }
9356
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009357#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309358 /* The supplicant may attempt to set the PTK once pre-authentication
9359 is done. Save the key in the UMAC and include it in the ADD BSS
9360 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009361 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309362 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009363 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309364 hddLog(VOS_TRACE_LEVEL_INFO_MED,
9365 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309366 status = 0;
9367 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309368 }
9369 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
9370 {
9371 hddLog(VOS_TRACE_LEVEL_ERROR,
9372 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309373 status = -EINVAL;
9374 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009375 }
9376#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07009377
9378 /* issue set key request to SME*/
9379 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9380 pAdapter->sessionId, &setKey, &roamId );
9381
9382 if ( 0 != status )
9383 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309384 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009385 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
9386 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309387 status = -EINVAL;
9388 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009389 }
9390
9391
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309392 /* in case of IBSS as there was no information available about WEP keys during
9393 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07009394 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309395 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
9396 !( ( IW_AUTH_KEY_MGMT_802_1X
9397 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07009398 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
9399 )
9400 &&
9401 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
9402 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
9403 )
9404 )
9405 {
9406 setKey.keyDirection = eSIR_RX_ONLY;
9407 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9408
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309409 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009410 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309411 __func__, setKey.peerMac[0], setKey.peerMac[1],
9412 setKey.peerMac[2], setKey.peerMac[3],
9413 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009414 setKey.keyDirection);
9415
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309416 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009417 pAdapter->sessionId, &setKey, &roamId );
9418
9419 if ( 0 != status )
9420 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309421 hddLog(VOS_TRACE_LEVEL_ERROR,
9422 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009423 __func__, status);
9424 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309425 status = -EINVAL;
9426 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009427 }
9428 }
9429 }
9430
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309431end:
9432 /* Need to clear any trace of key value in the memory.
9433 * Thus zero out the memory even though it is local
9434 * variable.
9435 */
9436 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309437 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309438 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009439}
9440
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309441#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9442static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9443 struct net_device *ndev,
9444 u8 key_index, bool pairwise,
9445 const u8 *mac_addr,
9446 struct key_params *params
9447 )
9448#else
9449static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9450 struct net_device *ndev,
9451 u8 key_index, const u8 *mac_addr,
9452 struct key_params *params
9453 )
9454#endif
9455{
9456 int ret;
9457 vos_ssr_protect(__func__);
9458#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9459 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
9460 mac_addr, params);
9461#else
9462 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
9463 params);
9464#endif
9465 vos_ssr_unprotect(__func__);
9466
9467 return ret;
9468}
9469
Jeff Johnson295189b2012-06-20 16:38:30 -07009470/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309471 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009472 * This function is used to get the key information
9473 */
9474#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309475static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309476 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009477 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309478 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009479 const u8 *mac_addr, void *cookie,
9480 void (*callback)(void *cookie, struct key_params*)
9481 )
9482#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309483static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309484 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 struct net_device *ndev,
9486 u8 key_index, const u8 *mac_addr, void *cookie,
9487 void (*callback)(void *cookie, struct key_params*)
9488 )
9489#endif
9490{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309491 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309492 hdd_wext_state_t *pWextState = NULL;
9493 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009494 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309495 hdd_context_t *pHddCtx;
9496 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009497
9498 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309499
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309500 if (NULL == pAdapter)
9501 {
9502 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9503 "%s: HDD adapter is Null", __func__);
9504 return -ENODEV;
9505 }
9506
9507 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9508 ret = wlan_hdd_validate_context(pHddCtx);
9509 if (0 != ret)
9510 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309511 return ret;
9512 }
9513
9514 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9515 pRoamProfile = &(pWextState->roamProfile);
9516
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309517 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9518 __func__, hdd_device_modetoString(pAdapter->device_mode),
9519 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309520
Jeff Johnson295189b2012-06-20 16:38:30 -07009521 memset(&params, 0, sizeof(params));
9522
9523 if (CSR_MAX_NUM_KEY <= key_index)
9524 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309525 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07009526 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009528
9529 switch(pRoamProfile->EncryptionType.encryptionType[0])
9530 {
9531 case eCSR_ENCRYPT_TYPE_NONE:
9532 params.cipher = IW_AUTH_CIPHER_NONE;
9533 break;
9534
9535 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
9536 case eCSR_ENCRYPT_TYPE_WEP40:
9537 params.cipher = WLAN_CIPHER_SUITE_WEP40;
9538 break;
9539
9540 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
9541 case eCSR_ENCRYPT_TYPE_WEP104:
9542 params.cipher = WLAN_CIPHER_SUITE_WEP104;
9543 break;
9544
9545 case eCSR_ENCRYPT_TYPE_TKIP:
9546 params.cipher = WLAN_CIPHER_SUITE_TKIP;
9547 break;
9548
9549 case eCSR_ENCRYPT_TYPE_AES:
9550 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
9551 break;
9552
9553 default:
9554 params.cipher = IW_AUTH_CIPHER_NONE;
9555 break;
9556 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309557
c_hpothuaaf19692014-05-17 17:01:48 +05309558 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9559 TRACE_CODE_HDD_CFG80211_GET_KEY,
9560 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309561
Jeff Johnson295189b2012-06-20 16:38:30 -07009562 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
9563 params.seq_len = 0;
9564 params.seq = NULL;
9565 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
9566 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309567 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009568 return 0;
9569}
9570
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309571#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9572static int wlan_hdd_cfg80211_get_key(
9573 struct wiphy *wiphy,
9574 struct net_device *ndev,
9575 u8 key_index, bool pairwise,
9576 const u8 *mac_addr, void *cookie,
9577 void (*callback)(void *cookie, struct key_params*)
9578 )
9579#else
9580static int wlan_hdd_cfg80211_get_key(
9581 struct wiphy *wiphy,
9582 struct net_device *ndev,
9583 u8 key_index, const u8 *mac_addr, void *cookie,
9584 void (*callback)(void *cookie, struct key_params*)
9585 )
9586#endif
9587{
9588 int ret;
9589
9590 vos_ssr_protect(__func__);
9591#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9592 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
9593 mac_addr, cookie, callback);
9594#else
9595 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
9596 callback);
9597#endif
9598 vos_ssr_unprotect(__func__);
9599
9600 return ret;
9601}
9602
Jeff Johnson295189b2012-06-20 16:38:30 -07009603/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309604 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009605 * This function is used to delete the key information
9606 */
9607#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309608static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009609 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309610 u8 key_index,
9611 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009612 const u8 *mac_addr
9613 )
9614#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309615static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009616 struct net_device *ndev,
9617 u8 key_index,
9618 const u8 *mac_addr
9619 )
9620#endif
9621{
9622 int status = 0;
9623
9624 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309625 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009626 //it is observed that this is invalidating peer
9627 //key index whenever re-key is done. This is affecting data link.
9628 //It should be ok to ignore del_key.
9629#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309630 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
9631 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009632 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
9633 tCsrRoamSetKey setKey;
9634 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309635
Jeff Johnson295189b2012-06-20 16:38:30 -07009636 ENTER();
9637
9638 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
9639 __func__,pAdapter->device_mode);
9640
9641 if (CSR_MAX_NUM_KEY <= key_index)
9642 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309643 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009644 key_index);
9645
9646 return -EINVAL;
9647 }
9648
9649 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9650 setKey.keyId = key_index;
9651
9652 if (mac_addr)
9653 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9654 else
9655 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
9656
9657 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
9658
9659 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009660 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309661 )
9662 {
9663
9664 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07009665 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9666 if( pHostapdState->bssState == BSS_START)
9667 {
9668 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309669
Jeff Johnson295189b2012-06-20 16:38:30 -07009670 if ( status != eHAL_STATUS_SUCCESS )
9671 {
9672 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9673 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9674 __LINE__, status );
9675 }
9676 }
9677 }
9678 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309679 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07009680 )
9681 {
9682 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9683
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309684 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9685
9686 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309688 __func__, setKey.peerMac[0], setKey.peerMac[1],
9689 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07009690 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309691 if(pAdapter->sessionCtx.station.conn_info.connState ==
9692 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07009693 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309694 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009695 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309696
Jeff Johnson295189b2012-06-20 16:38:30 -07009697 if ( 0 != status )
9698 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309699 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009700 "%s: sme_RoamSetKey failure, returned %d",
9701 __func__, status);
9702 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9703 return -EINVAL;
9704 }
9705 }
9706 }
9707#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07009708 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009709 return status;
9710}
9711
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309712#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9713static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9714 struct net_device *ndev,
9715 u8 key_index,
9716 bool pairwise,
9717 const u8 *mac_addr
9718 )
9719#else
9720static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9721 struct net_device *ndev,
9722 u8 key_index,
9723 const u8 *mac_addr
9724 )
9725#endif
9726{
9727 int ret;
9728
9729 vos_ssr_protect(__func__);
9730#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9731 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
9732 mac_addr);
9733#else
9734 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
9735#endif
9736 vos_ssr_unprotect(__func__);
9737
9738 return ret;
9739}
9740
Jeff Johnson295189b2012-06-20 16:38:30 -07009741/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309742 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009743 * This function is used to set the default tx key index
9744 */
9745#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309746static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009747 struct net_device *ndev,
9748 u8 key_index,
9749 bool unicast, bool multicast)
9750#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309751static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009752 struct net_device *ndev,
9753 u8 key_index)
9754#endif
9755{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309756 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309757 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05309758 hdd_wext_state_t *pWextState;
9759 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309760 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009761
9762 ENTER();
9763
Gopichand Nakkala29149562013-05-10 21:43:41 +05309764 if ((NULL == pAdapter))
9765 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05309767 "invalid adapter");
9768 return -EINVAL;
9769 }
9770
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309771 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9772 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
9773 pAdapter->sessionId, key_index));
9774
Gopichand Nakkala29149562013-05-10 21:43:41 +05309775 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9776 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9777
9778 if ((NULL == pWextState) || (NULL == pHddStaCtx))
9779 {
9780 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9781 "invalid Wext state or HDD context");
9782 return -EINVAL;
9783 }
9784
Arif Hussain6d2a3322013-11-17 19:50:10 -08009785 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309787
Jeff Johnson295189b2012-06-20 16:38:30 -07009788 if (CSR_MAX_NUM_KEY <= key_index)
9789 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309790 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009791 key_index);
9792
9793 return -EINVAL;
9794 }
9795
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309796 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9797 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309798 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009799 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309800 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009801 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309802
Jeff Johnson295189b2012-06-20 16:38:30 -07009803 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07009804 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309805 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009806 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05309807 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08009808 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309809 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08009810 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009811 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309812 {
9813 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07009814 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309815
Jeff Johnson295189b2012-06-20 16:38:30 -07009816 tCsrRoamSetKey setKey;
9817 v_U32_t roamId= 0xFF;
9818 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309819
9820 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009821 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309822
Jeff Johnson295189b2012-06-20 16:38:30 -07009823 Keys->defaultIndex = (u8)key_index;
9824 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9825 setKey.keyId = key_index;
9826 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309827
9828 vos_mem_copy(&setKey.Key[0],
9829 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009830 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309831
Gopichand Nakkala29149562013-05-10 21:43:41 +05309832 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309833
9834 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07009835 &pHddStaCtx->conn_info.bssId[0],
9836 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309837
Gopichand Nakkala29149562013-05-10 21:43:41 +05309838 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
9839 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
9840 eCSR_ENCRYPT_TYPE_WEP104)
9841 {
9842 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
9843 even though ap is configured for WEP-40 encryption. In this canse the key length
9844 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
9845 type(104) and switching encryption type to 40*/
9846 pWextState->roamProfile.EncryptionType.encryptionType[0] =
9847 eCSR_ENCRYPT_TYPE_WEP40;
9848 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
9849 eCSR_ENCRYPT_TYPE_WEP40;
9850 }
9851
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309852 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07009853 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309854
Jeff Johnson295189b2012-06-20 16:38:30 -07009855 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309856 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009857 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309858
Jeff Johnson295189b2012-06-20 16:38:30 -07009859 if ( 0 != status )
9860 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309861 hddLog(VOS_TRACE_LEVEL_ERROR,
9862 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009863 status);
9864 return -EINVAL;
9865 }
9866 }
9867 }
9868
9869 /* In SoftAp mode setting key direction for default mode */
9870 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
9871 {
9872 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
9873 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
9874 (eCSR_ENCRYPT_TYPE_AES !=
9875 pWextState->roamProfile.EncryptionType.encryptionType[0])
9876 )
9877 {
9878 /* Saving key direction for default key index to TX default */
9879 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9880 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
9881 }
9882 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309883 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009884 return status;
9885}
9886
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309887#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9888static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9889 struct net_device *ndev,
9890 u8 key_index,
9891 bool unicast, bool multicast)
9892#else
9893static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9894 struct net_device *ndev,
9895 u8 key_index)
9896#endif
9897{
9898 int ret;
9899 vos_ssr_protect(__func__);
9900#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9901 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
9902 multicast);
9903#else
9904 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
9905#endif
9906 vos_ssr_unprotect(__func__);
9907
9908 return ret;
9909}
9910
Jeff Johnson295189b2012-06-20 16:38:30 -07009911/*
9912 * FUNCTION: wlan_hdd_cfg80211_inform_bss
9913 * This function is used to inform the BSS details to nl80211 interface.
9914 */
9915static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
9916 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
9917{
9918 struct net_device *dev = pAdapter->dev;
9919 struct wireless_dev *wdev = dev->ieee80211_ptr;
9920 struct wiphy *wiphy = wdev->wiphy;
9921 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
9922 int chan_no;
9923 int ie_length;
9924 const char *ie;
9925 unsigned int freq;
9926 struct ieee80211_channel *chan;
9927 int rssi = 0;
9928 struct cfg80211_bss *bss = NULL;
9929
Jeff Johnson295189b2012-06-20 16:38:30 -07009930 if( NULL == pBssDesc )
9931 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009932 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009933 return bss;
9934 }
9935
9936 chan_no = pBssDesc->channelId;
9937 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
9938 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
9939
9940 if( NULL == ie )
9941 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009942 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009943 return bss;
9944 }
9945
9946#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
9947 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
9948 {
9949 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9950 }
9951 else
9952 {
9953 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9954 }
9955#else
9956 freq = ieee80211_channel_to_frequency(chan_no);
9957#endif
9958
9959 chan = __ieee80211_get_channel(wiphy, freq);
9960
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05309961 if (!chan) {
9962 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
9963 return NULL;
9964 }
9965
Abhishek Singhaee43942014-06-16 18:55:47 +05309966 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07009967
Anand N Sunkad9f80b742015-07-30 20:05:51 +05309968 return cfg80211_inform_bss(wiphy, chan,
9969#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
9970 CFG80211_BSS_FTYPE_UNKNOWN,
9971#endif
9972 pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309973 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07009974 pBssDesc->capabilityInfo,
9975 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05309976 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07009977}
9978
9979
9980
9981/*
9982 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
9983 * This function is used to inform the BSS details to nl80211 interface.
9984 */
9985struct cfg80211_bss*
9986wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
9987 tSirBssDescription *bss_desc
9988 )
9989{
9990 /*
9991 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
9992 already exists in bss data base of cfg80211 for that particular BSS ID.
9993 Using cfg80211_inform_bss_frame to update the bss entry instead of
9994 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
9995 now there is no possibility to get the mgmt(probe response) frame from PE,
9996 converting bss_desc to ieee80211_mgmt(probe response) and passing to
9997 cfg80211_inform_bss_frame.
9998 */
9999 struct net_device *dev = pAdapter->dev;
10000 struct wireless_dev *wdev = dev->ieee80211_ptr;
10001 struct wiphy *wiphy = wdev->wiphy;
10002 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080010003#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
10004 qcom_ie_age *qie_age = NULL;
10005 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
10006#else
Jeff Johnson295189b2012-06-20 16:38:30 -070010007 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080010008#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010009 const char *ie =
10010 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
10011 unsigned int freq;
10012 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053010013 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010014 struct cfg80211_bss *bss_status = NULL;
10015 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
10016 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -070010017 hdd_context_t *pHddCtx;
10018 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -070010019#ifdef WLAN_OPEN_SOURCE
10020 struct timespec ts;
10021#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010022
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053010023
Wilson Yangf80a0542013-10-07 13:02:37 -070010024 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10025 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -070010026 if (0 != status)
10027 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070010028 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070010029 }
10030
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053010031 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -070010032 if (!mgmt)
10033 {
10034 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10035 "%s: memory allocation failed ", __func__);
10036 return NULL;
10037 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -070010038
Jeff Johnson295189b2012-06-20 16:38:30 -070010039 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -070010040
10041#ifdef WLAN_OPEN_SOURCE
10042 /* Android does not want the timestamp from the frame.
10043 Instead it wants a monotonic increasing value */
10044 get_monotonic_boottime(&ts);
10045 mgmt->u.probe_resp.timestamp =
10046 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
10047#else
10048 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -070010049 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
10050 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -070010051
10052#endif
10053
Jeff Johnson295189b2012-06-20 16:38:30 -070010054 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
10055 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -080010056
10057#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
10058 /* GPS Requirement: need age ie per entry. Using vendor specific. */
10059 /* Assuming this is the last IE, copy at the end */
10060 ie_length -=sizeof(qcom_ie_age);
10061 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
10062 qie_age->element_id = QCOM_VENDOR_IE_ID;
10063 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
10064 qie_age->oui_1 = QCOM_OUI1;
10065 qie_age->oui_2 = QCOM_OUI2;
10066 qie_age->oui_3 = QCOM_OUI3;
10067 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
10068 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
10069#endif
10070
Jeff Johnson295189b2012-06-20 16:38:30 -070010071 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +053010072 if (bss_desc->fProbeRsp)
10073 {
10074 mgmt->frame_control |=
10075 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
10076 }
10077 else
10078 {
10079 mgmt->frame_control |=
10080 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
10081 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010082
10083#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010084 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070010085 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
10086 {
10087 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
10088 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010089 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -070010090 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
10091
10092 {
10093 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
10094 }
10095 else
10096 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010097 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
10098 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -070010099 kfree(mgmt);
10100 return NULL;
10101 }
10102#else
10103 freq = ieee80211_channel_to_frequency(chan_no);
10104#endif
10105 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080010106 /*when the band is changed on the fly using the GUI, three things are done
10107 * 1. scan abort 2.flush scan results from cache 3.update the band with the new band user specified(refer to the hdd_setBand_helper function)
10108 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
10109 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
10110 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
10111 * and discards the channels correponding to previous band and calls back with zero bss results.
10112 * but if the time between band update and scan done callback is very small then band change will not reflect in SME and SME reports to HDD
10113 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
10114 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
10115 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
10116 * So drop the bss and continue to next bss.
10117 */
10118 if(chan == NULL)
10119 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010120 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -070010121 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -080010122 return NULL;
10123 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +053010124 /*To keep the rssi icon of the connected AP in the scan window
10125 *and the rssi icon of the wireless networks in sync
10126 * */
10127 if (( eConnectionState_Associated ==
10128 pAdapter->sessionCtx.station.conn_info.connState ) &&
10129 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
10130 pAdapter->sessionCtx.station.conn_info.bssId,
10131 WNI_CFG_BSSID_LEN)) &&
10132 (pHddCtx->hdd_wlan_suspended == FALSE))
10133 {
10134 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
10135 rssi = (pAdapter->rssi * 100);
10136 }
10137 else
10138 {
10139 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
10140 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010141
Nirav Shah20ac06f2013-12-12 18:14:06 +053010142 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +053010143 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
10144 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +053010145
Jeff Johnson295189b2012-06-20 16:38:30 -070010146 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
10147 frame_len, rssi, GFP_KERNEL);
10148 kfree(mgmt);
10149 return bss_status;
10150}
10151
10152/*
10153 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
10154 * This function is used to update the BSS data base of CFG8011
10155 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010156struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070010157 tCsrRoamInfo *pRoamInfo
10158 )
10159{
10160 tCsrRoamConnectedProfile roamProfile;
10161 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10162 struct cfg80211_bss *bss = NULL;
10163
10164 ENTER();
10165
10166 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
10167 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
10168
10169 if (NULL != roamProfile.pBssDesc)
10170 {
Girish Gowlif4b68022014-08-28 23:18:57 +053010171 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10172 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010173
10174 if (NULL == bss)
10175 {
10176 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
10177 __func__);
10178 }
10179
10180 sme_RoamFreeConnectProfile(hHal, &roamProfile);
10181 }
10182 else
10183 {
10184 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
10185 __func__);
10186 }
10187 return bss;
10188}
10189
10190/*
10191 * FUNCTION: wlan_hdd_cfg80211_update_bss
10192 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010193static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
10194 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -070010195 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010196{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010197 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010198 tCsrScanResultInfo *pScanResult;
10199 eHalStatus status = 0;
10200 tScanResultHandle pResult;
10201 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -070010202 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010203 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070010204 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010205
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010206 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10207 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
10208 NO_SESSION, pAdapter->sessionId));
10209
Wilson Yangf80a0542013-10-07 13:02:37 -070010210 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10211
10212 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -070010213 {
Wilson Yangf80a0542013-10-07 13:02:37 -070010214 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10215 "%s:LOGP in Progress. Ignore!!!",__func__);
10216 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010217 }
10218
Wilson Yangf80a0542013-10-07 13:02:37 -070010219
10220 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +053010221 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -070010222 {
10223 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10224 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
10225 return VOS_STATUS_E_PERM;
10226 }
10227
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010228 if (pAdapter->request != NULL)
10229 {
10230 if ((pAdapter->request->n_ssids == 1)
10231 && (pAdapter->request->ssids != NULL)
10232 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
10233 is_p2p_scan = true;
10234 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010235 /*
10236 * start getting scan results and populate cgf80211 BSS database
10237 */
10238 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
10239
10240 /* no scan results */
10241 if (NULL == pResult)
10242 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010243 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
10244 __func__, status);
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053010245 wlan_hdd_get_frame_logs(pAdapter,
10246 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Jeff Johnson295189b2012-06-20 16:38:30 -070010247 return status;
10248 }
10249
10250 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
10251
10252 while (pScanResult)
10253 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010254 /*
10255 * cfg80211_inform_bss() is not updating ie field of bss entry, if
10256 * entry already exists in bss data base of cfg80211 for that
10257 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
10258 * bss entry instead of cfg80211_inform_bss, But this call expects
10259 * mgmt packet as input. As of now there is no possibility to get
10260 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070010261 * ieee80211_mgmt(probe response) and passing to c
10262 * fg80211_inform_bss_frame.
10263 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010264 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
10265 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
10266 {
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010267 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10268 continue; //Skip the non p2p bss entries
10269 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010270 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10271 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010272
Jeff Johnson295189b2012-06-20 16:38:30 -070010273
10274 if (NULL == bss_status)
10275 {
10276 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010277 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010278 }
10279 else
10280 {
Yue Maf49ba872013-08-19 12:04:25 -070010281 cfg80211_put_bss(
10282#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10283 wiphy,
10284#endif
10285 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010286 }
10287
10288 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10289 }
10290
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010291 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010292 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010293 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010294}
10295
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010296void
10297hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
10298{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010299 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080010300 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010301} /****** end hddPrintMacAddr() ******/
10302
10303void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010304hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010305{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010306 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010307 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010308 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
10309 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
10310 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010311} /****** end hddPrintPmkId() ******/
10312
10313//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
10314//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
10315
10316//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
10317//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
10318
10319#define dump_bssid(bssid) \
10320 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010321 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
10322 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010323 }
10324
10325#define dump_pmkid(pMac, pmkid) \
10326 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010327 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
10328 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010329 }
10330
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070010331#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010332/*
10333 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
10334 * This function is used to notify the supplicant of a new PMKSA candidate.
10335 */
10336int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010337 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010338 int index, bool preauth )
10339{
Jeff Johnsone7245742012-09-05 17:12:55 -070010340#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010341 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010342 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010343
10344 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070010345 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010346
10347 if( NULL == pRoamInfo )
10348 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010349 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010350 return -EINVAL;
10351 }
10352
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010353 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
10354 {
10355 dump_bssid(pRoamInfo->bssid);
10356 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010357 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010358 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010359#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010360 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010361}
10362#endif //FEATURE_WLAN_LFR
10363
Yue Maef608272013-04-08 23:09:17 -070010364#ifdef FEATURE_WLAN_LFR_METRICS
10365/*
10366 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
10367 * 802.11r/LFR metrics reporting function to report preauth initiation
10368 *
10369 */
10370#define MAX_LFR_METRICS_EVENT_LENGTH 100
10371VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
10372 tCsrRoamInfo *pRoamInfo)
10373{
10374 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10375 union iwreq_data wrqu;
10376
10377 ENTER();
10378
10379 if (NULL == pAdapter)
10380 {
10381 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10382 return VOS_STATUS_E_FAILURE;
10383 }
10384
10385 /* create the event */
10386 memset(&wrqu, 0, sizeof(wrqu));
10387 memset(metrics_notification, 0, sizeof(metrics_notification));
10388
10389 wrqu.data.pointer = metrics_notification;
10390 wrqu.data.length = scnprintf(metrics_notification,
10391 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
10392 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10393
10394 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10395
10396 EXIT();
10397
10398 return VOS_STATUS_SUCCESS;
10399}
10400
10401/*
10402 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
10403 * 802.11r/LFR metrics reporting function to report preauth completion
10404 * or failure
10405 */
10406VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
10407 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
10408{
10409 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10410 union iwreq_data wrqu;
10411
10412 ENTER();
10413
10414 if (NULL == pAdapter)
10415 {
10416 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10417 return VOS_STATUS_E_FAILURE;
10418 }
10419
10420 /* create the event */
10421 memset(&wrqu, 0, sizeof(wrqu));
10422 memset(metrics_notification, 0, sizeof(metrics_notification));
10423
10424 scnprintf(metrics_notification, sizeof(metrics_notification),
10425 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
10426 MAC_ADDR_ARRAY(pRoamInfo->bssid));
10427
10428 if (1 == preauth_status)
10429 strncat(metrics_notification, " TRUE", 5);
10430 else
10431 strncat(metrics_notification, " FALSE", 6);
10432
10433 wrqu.data.pointer = metrics_notification;
10434 wrqu.data.length = strlen(metrics_notification);
10435
10436 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10437
10438 EXIT();
10439
10440 return VOS_STATUS_SUCCESS;
10441}
10442
10443/*
10444 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
10445 * 802.11r/LFR metrics reporting function to report handover initiation
10446 *
10447 */
10448VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
10449 tCsrRoamInfo *pRoamInfo)
10450{
10451 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10452 union iwreq_data wrqu;
10453
10454 ENTER();
10455
10456 if (NULL == pAdapter)
10457 {
10458 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10459 return VOS_STATUS_E_FAILURE;
10460 }
10461
10462 /* create the event */
10463 memset(&wrqu, 0, sizeof(wrqu));
10464 memset(metrics_notification, 0, sizeof(metrics_notification));
10465
10466 wrqu.data.pointer = metrics_notification;
10467 wrqu.data.length = scnprintf(metrics_notification,
10468 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
10469 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10470
10471 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10472
10473 EXIT();
10474
10475 return VOS_STATUS_SUCCESS;
10476}
10477#endif
10478
Jeff Johnson295189b2012-06-20 16:38:30 -070010479/*
10480 * FUNCTION: hdd_cfg80211_scan_done_callback
10481 * scanning callback function, called after finishing scan
10482 *
10483 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010484static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070010485 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
10486{
10487 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010488 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070010489 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010490 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010491 struct cfg80211_scan_request *req = NULL;
10492 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010493 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010494 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010495 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010496 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010497
10498 ENTER();
10499
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010500 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053010501 if (NULL == pHddCtx) {
10502 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010503 goto allow_suspend;
10504 }
10505
10506 pScanInfo = &pHddCtx->scan_info;
10507
Jeff Johnson295189b2012-06-20 16:38:30 -070010508 hddLog(VOS_TRACE_LEVEL_INFO,
10509 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080010510 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010511 __func__, halHandle, pContext, (int) scanId, (int) status);
10512
Kiet Lamac06e2c2013-10-23 16:25:07 +053010513 pScanInfo->mScanPendingCounter = 0;
10514
Jeff Johnson295189b2012-06-20 16:38:30 -070010515 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010516 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070010517 &pScanInfo->scan_req_completion_event,
10518 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010519 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070010520 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010521 hddLog(VOS_TRACE_LEVEL_ERROR,
10522 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070010523 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010524 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010525 }
10526
Yue Maef608272013-04-08 23:09:17 -070010527 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010528 {
10529 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010530 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010531 }
10532
10533 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010534 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070010535 {
10536 hddLog(VOS_TRACE_LEVEL_INFO,
10537 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010538 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070010539 (int) scanId);
10540 }
10541
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010542 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010543 pAdapter);
10544
10545 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010546 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010547
10548
10549 /* If any client wait scan result through WEXT
10550 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010551 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070010552 {
10553 /* The other scan request waiting for current scan finish
10554 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010555 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010556 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010557 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070010558 }
10559 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010560 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010561 {
10562 struct net_device *dev = pAdapter->dev;
10563 union iwreq_data wrqu;
10564 int we_event;
10565 char *msg;
10566
10567 memset(&wrqu, '\0', sizeof(wrqu));
10568 we_event = SIOCGIWSCAN;
10569 msg = NULL;
10570 wireless_send_event(dev, we_event, &wrqu, msg);
10571 }
10572 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010573 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010574
10575 /* Get the Scan Req */
10576 req = pAdapter->request;
10577
10578 if (!req)
10579 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010580 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010581 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010582 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010583 }
10584
Jeff Johnson295189b2012-06-20 16:38:30 -070010585 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070010586 /* Scan is no longer pending */
10587 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010588
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010589 /* last_scan_timestamp is used to decide if new scan
10590 * is needed or not on station interface. If last station
10591 * scan time and new station scan time is less then
10592 * last_scan_timestamp ; driver will return cached scan.
10593 */
10594 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
10595 {
10596 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
10597
10598 if ( req->n_channels )
10599 {
10600 for (i = 0; i < req->n_channels ; i++ )
10601 {
10602 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
10603 }
10604 /* store no of channel scanned */
10605 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
10606 }
10607
10608 }
10609
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070010610 /*
10611 * cfg80211_scan_done informing NL80211 about completion
10612 * of scanning
10613 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010614 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
10615 {
10616 aborted = true;
10617 }
10618 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080010619 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070010620
Siddharth Bhal76972212014-10-15 16:22:51 +053010621 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
10622 /* Generate new random mac addr for next scan */
10623 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
10624 hdd_processSpoofMacAddrRequest(pHddCtx);
10625 }
10626
Jeff Johnsone7245742012-09-05 17:12:55 -070010627allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010628 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010629 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070010630
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010631 /* Acquire wakelock to handle the case where APP's tries to suspend
10632 * immediatly after the driver gets connect request(i.e after scan)
10633 * from supplicant, this result in app's is suspending and not able
10634 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010635 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010636
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010637#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010638 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010639#endif
10640
Jeff Johnson295189b2012-06-20 16:38:30 -070010641 EXIT();
10642 return 0;
10643}
10644
10645/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053010646 * FUNCTION: hdd_isConnectionInProgress
10647 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010648 *
10649 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010650v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010651{
10652 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10653 hdd_station_ctx_t *pHddStaCtx = NULL;
10654 hdd_adapter_t *pAdapter = NULL;
10655 VOS_STATUS status = 0;
10656 v_U8_t staId = 0;
10657 v_U8_t *staMac = NULL;
10658
c_hpothu9b781ba2013-12-30 20:57:45 +053010659 if (TRUE == pHddCtx->btCoexModeSet)
10660 {
10661 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053010662 FL("BTCoex Mode operation in progress"));
10663 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053010664 }
10665
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010666 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10667
10668 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10669 {
10670 pAdapter = pAdapterNode->pAdapter;
10671
10672 if( pAdapter )
10673 {
10674 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010675 "%s: Adapter with device mode %s (%d) exists",
10676 __func__, hdd_device_modetoString(pAdapter->device_mode),
10677 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010678 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053010679 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10680 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
10681 (eConnectionState_Connecting ==
10682 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
10683 {
10684 hddLog(VOS_TRACE_LEVEL_ERROR,
10685 "%s: %p(%d) Connection is in progress", __func__,
10686 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10687 return VOS_TRUE;
10688 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010689 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053010690 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010691 {
10692 hddLog(VOS_TRACE_LEVEL_ERROR,
10693 "%s: %p(%d) Reassociation is in progress", __func__,
10694 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10695 return VOS_TRUE;
10696 }
10697 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010698 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10699 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010700 {
10701 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10702 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010703 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010704 {
10705 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
10706 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010707 "%s: client " MAC_ADDRESS_STR
10708 " is in the middle of WPS/EAPOL exchange.", __func__,
10709 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010710 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010711 }
10712 }
10713 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
10714 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
10715 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010716 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10717 ptSapContext pSapCtx = NULL;
10718 pSapCtx = VOS_GET_SAP_CB(pVosContext);
10719 if(pSapCtx == NULL){
10720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10721 FL("psapCtx is NULL"));
10722 return VOS_FALSE;
10723 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010724 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
10725 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010726 if ((pSapCtx->aStaInfo[staId].isUsed) &&
10727 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010728 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010729 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010730
10731 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010732 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
10733 "middle of WPS/EAPOL exchange.", __func__,
10734 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010735 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010736 }
10737 }
10738 }
10739 }
10740 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10741 pAdapterNode = pNext;
10742 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053010743 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010744}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010745
10746/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010747 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070010748 * this scan respond to scan trigger and update cfg80211 scan database
10749 * later, scan dump command can be used to recieve scan results
10750 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010751int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010752#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10753 struct net_device *dev,
10754#endif
10755 struct cfg80211_scan_request *request)
10756{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010757 hdd_adapter_t *pAdapter = NULL;
10758 hdd_context_t *pHddCtx = NULL;
10759 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010760 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010761 tCsrScanRequest scanRequest;
10762 tANI_U8 *channelList = NULL, i;
10763 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010764 int status;
10765 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010766 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010767 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053010768 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010769 bool is_p2p_scan = false;
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010770 v_S7_t rssi=0;
10771 hdd_station_ctx_t *pHddStaCtx=NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010772
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010773#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
10774 struct net_device *dev = NULL;
10775 if (NULL == request)
10776 {
10777 hddLog(VOS_TRACE_LEVEL_ERROR,
10778 "%s: scan req param null", __func__);
10779 return -EINVAL;
10780 }
10781 dev = request->wdev->netdev;
10782#endif
10783
10784 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
10785 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
10786 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10787
Jeff Johnson295189b2012-06-20 16:38:30 -070010788 ENTER();
10789
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010790 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10791 __func__, hdd_device_modetoString(pAdapter->device_mode),
10792 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010793
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010794 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010795 if (0 != status)
10796 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010797 return status;
10798 }
10799
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010800 if (NULL == pwextBuf)
10801 {
10802 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
10803 __func__);
10804 return -EIO;
10805 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010806 cfg_param = pHddCtx->cfg_ini;
10807 pScanInfo = &pHddCtx->scan_info;
10808
Hanumantha Reddy Pothula2e282d12015-06-19 14:01:26 +053010809 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10810 if ( (pHddStaCtx != NULL) && (TRUE == hdd_connIsConnected(pHddStaCtx)))
10811 {
10812 wlan_hdd_get_roam_rssi(pAdapter, &rssi);
10813 hddLog(VOS_TRACE_LEVEL_INFO, FL("rssi: %d"), rssi);
10814 }
10815
Jeff Johnson295189b2012-06-20 16:38:30 -070010816#ifdef WLAN_BTAMP_FEATURE
10817 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010818 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070010819 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010820 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010821 "%s: No scanning when AMP is on", __func__);
10822 return -EOPNOTSUPP;
10823 }
10824#endif
10825 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010826 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010827 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010828 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010829 "%s: Not scanning on device_mode = %s (%d)",
10830 __func__, hdd_device_modetoString(pAdapter->device_mode),
10831 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010832 return -EOPNOTSUPP;
10833 }
10834
10835 if (TRUE == pScanInfo->mScanPending)
10836 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010837 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
10838 {
10839 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
10840 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010841 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010842 }
10843
Hanumantha Reddy Pothula4b6be062015-08-18 14:06:24 +053010844 // Don't allow scan if PNO scan is going on.
10845 if (pHddCtx->isPnoEnable)
10846 {
10847 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10848 FL("pno scan in progress"));
10849 return -EBUSY;
10850 }
10851
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010852 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070010853 //Channel and action frame is pending
10854 //Otherwise Cancel Remain On Channel and allow Scan
10855 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010856 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070010857 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010858 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010859 return -EBUSY;
10860 }
10861
Jeff Johnson295189b2012-06-20 16:38:30 -070010862 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
10863 {
10864 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080010865 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010866 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010867 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010868 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
10869 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010870 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010871 "%s: MAX TM Level Scan not allowed", __func__);
10872 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010873 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010874 }
10875 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
10876
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010877 /* Check if scan is allowed at this point of time.
10878 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010879 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010880 {
10881 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
10882 return -EBUSY;
10883 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010884
Jeff Johnson295189b2012-06-20 16:38:30 -070010885 vos_mem_zero( &scanRequest, sizeof(scanRequest));
10886
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010887 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
10888 * Becasue of this, driver is assuming that this is not wildcard scan and so
10889 * is not aging out the scan results.
10890 */
10891 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070010892 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010893 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010894 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010895
10896 if ((request->ssids) && (0 < request->n_ssids))
10897 {
10898 tCsrSSIDInfo *SsidInfo;
10899 int j;
10900 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
10901 /* Allocate num_ssid tCsrSSIDInfo structure */
10902 SsidInfo = scanRequest.SSIDs.SSIDList =
10903 ( tCsrSSIDInfo *)vos_mem_malloc(
10904 request->n_ssids*sizeof(tCsrSSIDInfo));
10905
10906 if(NULL == scanRequest.SSIDs.SSIDList)
10907 {
10908 hddLog(VOS_TRACE_LEVEL_ERROR,
10909 "%s: memory alloc failed SSIDInfo buffer", __func__);
10910 return -ENOMEM;
10911 }
10912
10913 /* copy all the ssid's and their length */
10914 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
10915 {
10916 /* get the ssid length */
10917 SsidInfo->SSID.length = request->ssids[j].ssid_len;
10918 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
10919 SsidInfo->SSID.length);
10920 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
10921 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
10922 j, SsidInfo->SSID.ssId);
10923 }
10924 /* set the scan type to active */
10925 scanRequest.scanType = eSIR_ACTIVE_SCAN;
10926 }
10927 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070010928 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010929 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10930 TRACE_CODE_HDD_CFG80211_SCAN,
10931 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070010932 /* set the scan type to active */
10933 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010934 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010935 else
10936 {
10937 /*Set the scan type to default type, in this case it is ACTIVE*/
10938 scanRequest.scanType = pScanInfo->scan_mode;
10939 }
10940 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
10941 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070010942
10943 /* set BSSType to default type */
10944 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
10945
10946 /*TODO: scan the requested channels only*/
10947
10948 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010949 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070010950 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010951 hddLog(VOS_TRACE_LEVEL_WARN,
10952 "No of Scan Channels exceeded limit: %d", request->n_channels);
10953 request->n_channels = MAX_CHANNEL;
10954 }
10955
10956 hddLog(VOS_TRACE_LEVEL_INFO,
10957 "No of Scan Channels: %d", request->n_channels);
10958
10959
10960 if( request->n_channels )
10961 {
10962 char chList [(request->n_channels*5)+1];
10963 int len;
10964 channelList = vos_mem_malloc( request->n_channels );
10965 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053010966 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010967 hddLog(VOS_TRACE_LEVEL_ERROR,
10968 "%s: memory alloc failed channelList", __func__);
10969 status = -ENOMEM;
10970 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053010971 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010972
10973 for( i = 0, len = 0; i < request->n_channels ; i++ )
10974 {
10975 channelList[i] = request->channels[i]->hw_value;
10976 len += snprintf(chList+len, 5, "%d ", channelList[i]);
10977 }
10978
Nirav Shah20ac06f2013-12-12 18:14:06 +053010979 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010980 "Channel-List: %s ", chList);
10981 }
c_hpothu53512302014-04-15 18:49:53 +053010982
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010983 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
10984 scanRequest.ChannelInfo.ChannelList = channelList;
10985
10986 /* set requestType to full scan */
10987 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
10988
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010989 /* if there is back to back scan happening in driver with in
10990 * nDeferScanTimeInterval interval driver should defer new scan request
10991 * and should provide last cached scan results instead of new channel list.
10992 * This rule is not applicable if scan is p2p scan.
10993 * This condition will work only in case when last request no of channels
10994 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053010995 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053010996 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010997 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010998
Sushant Kaushik86592172015-04-27 16:35:03 +053010999 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
11000 /* if wps ie is NULL , then only defer scan */
11001 if ( pWpsIe == NULL &&
11002 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053011003 {
11004 if ( pScanInfo->last_scan_timestamp !=0 &&
11005 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
11006 {
11007 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
11008 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
11009 vos_mem_compare(pScanInfo->last_scan_channelList,
11010 channelList, pScanInfo->last_scan_numChannels))
11011 {
11012 hddLog(VOS_TRACE_LEVEL_WARN,
11013 " New and old station scan time differ is less then %u",
11014 pHddCtx->cfg_ini->nDeferScanTimeInterval);
11015
11016 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011017 pAdapter);
11018
Agarwal Ashish57e84372014-12-05 18:26:53 +053011019 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053011020 "Return old cached scan as all channels and no of channels are same");
11021
Agarwal Ashish57e84372014-12-05 18:26:53 +053011022 if (0 > ret)
11023 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011024
Agarwal Ashish57e84372014-12-05 18:26:53 +053011025 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053011026
11027 status = eHAL_STATUS_SUCCESS;
11028 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053011029 }
11030 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053011031 }
11032
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011033 /* Flush the scan results(only p2p beacons) for STA scan and P2P
11034 * search (Flush on both full scan and social scan but not on single
11035 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
11036 */
11037
11038 /* Supplicant does single channel scan after 8-way handshake
11039 * and in that case driver shoudnt flush scan results. If
11040 * driver flushes the scan results here and unfortunately if
11041 * the AP doesnt respond to our probe req then association
11042 * fails which is not desired
11043 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053011044 if ((request->n_ssids == 1)
11045 && (request->ssids != NULL)
11046 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
11047 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011048
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053011049 if( is_p2p_scan ||
11050 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011051 {
11052 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
11053 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
11054 pAdapter->sessionId );
11055 }
11056
11057 if( request->ie_len )
11058 {
11059 /* save this for future association (join requires this) */
11060 /*TODO: Array needs to be converted to dynamic allocation,
11061 * as multiple ie.s can be sent in cfg80211_scan_request structure
11062 * CR 597966
11063 */
11064 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
11065 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
11066 pScanInfo->scanAddIE.length = request->ie_len;
11067
11068 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11069 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
11070 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070011071 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011072 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070011073 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011074 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
11075 memcpy( pwextBuf->roamProfile.addIEScan,
11076 request->ie, request->ie_len);
11077 }
11078 else
11079 {
11080 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
11081 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070011082 }
11083
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011084 }
11085 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
11086 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
11087
11088 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
11089 request->ie_len);
11090 if (pP2pIe != NULL)
11091 {
11092#ifdef WLAN_FEATURE_P2P_DEBUG
11093 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
11094 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
11095 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053011096 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011097 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
11098 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
11099 "Go nego completed to Connection is started");
11100 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
11101 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053011102 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011103 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
11104 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070011105 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011106 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
11107 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
11108 "Disconnected state to Connection is started");
11109 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
11110 "for 4way Handshake");
11111 }
11112#endif
11113
11114 /* no_cck will be set during p2p find to disable 11b rates */
11115 if(TRUE == request->no_cck)
11116 {
11117 hddLog(VOS_TRACE_LEVEL_INFO,
11118 "%s: This is a P2P Search", __func__);
11119 scanRequest.p2pSearch = 1;
11120
11121 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053011122 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011123 /* set requestType to P2P Discovery */
11124 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
11125 }
11126
11127 /*
11128 Skip Dfs Channel in case of P2P Search
11129 if it is set in ini file
11130 */
11131 if(cfg_param->skipDfsChnlInP2pSearch)
11132 {
11133 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053011134 }
11135 else
11136 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053011137 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053011138 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011139
Agarwal Ashish4f616132013-12-30 23:32:50 +053011140 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011141 }
11142 }
11143
11144 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
11145
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053011146#ifdef FEATURE_WLAN_TDLS
11147 /* if tdls disagree scan right now, return immediately.
11148 tdls will schedule the scan when scan is allowed. (return SUCCESS)
11149 or will reject the scan if any TDLS is in progress. (return -EBUSY)
11150 */
11151 status = wlan_hdd_tdls_scan_callback (pAdapter,
11152 wiphy,
11153#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11154 dev,
11155#endif
11156 request);
11157 if(status <= 0)
11158 {
11159 if(!status)
11160 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
11161 "scan rejected %d", __func__, status);
11162 else
11163 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
11164 __func__, status);
11165
11166 return status;
11167 }
11168#endif
11169
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070011170 /* acquire the wakelock to avoid the apps suspend during the scan. To
11171 * address the following issues.
11172 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
11173 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
11174 * for long time, this result in apps running at full power for long time.
11175 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
11176 * be stuck in full power because of resume BMPS
11177 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011178 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070011179
Nirav Shah20ac06f2013-12-12 18:14:06 +053011180 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
11181 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011182 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
11183 scanRequest.requestType, scanRequest.scanType,
11184 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053011185 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
11186
Siddharth Bhal76972212014-10-15 16:22:51 +053011187 if (pHddCtx->spoofMacAddr.isEnabled)
11188 {
11189 hddLog(VOS_TRACE_LEVEL_INFO,
11190 "%s: MAC Spoofing enabled for current scan", __func__);
11191 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
11192 * to fill TxBds for probe request during current scan
11193 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011194 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053011195 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011196
11197 if(status != VOS_STATUS_SUCCESS)
11198 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011199 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011200 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053011201#ifdef FEATURE_WLAN_TDLS
11202 wlan_hdd_tdls_scan_done_callback(pAdapter);
11203#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053011204 goto free_mem;
11205 }
Siddharth Bhal76972212014-10-15 16:22:51 +053011206 }
Mahesh A Saptasagar51dc36c2015-06-16 12:07:15 +053011207 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
Jeff Johnsone7245742012-09-05 17:12:55 -070011208 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011209 pAdapter->sessionId, &scanRequest, &scanId,
11210 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070011211
Jeff Johnson295189b2012-06-20 16:38:30 -070011212 if (eHAL_STATUS_SUCCESS != status)
11213 {
11214 hddLog(VOS_TRACE_LEVEL_ERROR,
11215 "%s: sme_ScanRequest returned error %d", __func__, status);
11216 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011217 if(eHAL_STATUS_RESOURCES == status)
11218 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053011219 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
11220 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070011221 status = -EBUSY;
11222 } else {
11223 status = -EIO;
11224 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053011225 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053011226
11227#ifdef FEATURE_WLAN_TDLS
11228 wlan_hdd_tdls_scan_done_callback(pAdapter);
11229#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011230 goto free_mem;
11231 }
11232
11233 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053011234 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011235 pAdapter->request = request;
11236 pScanInfo->scanId = scanId;
11237
11238 complete(&pScanInfo->scan_req_completion_event);
11239
11240free_mem:
11241 if( scanRequest.SSIDs.SSIDList )
11242 {
11243 vos_mem_free(scanRequest.SSIDs.SSIDList);
11244 }
11245
11246 if( channelList )
11247 vos_mem_free( channelList );
11248
11249 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011250 return status;
11251}
11252
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053011253int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
11254#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11255 struct net_device *dev,
11256#endif
11257 struct cfg80211_scan_request *request)
11258{
11259 int ret;
11260
11261 vos_ssr_protect(__func__);
11262 ret = __wlan_hdd_cfg80211_scan(wiphy,
11263#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
11264 dev,
11265#endif
11266 request);
11267 vos_ssr_unprotect(__func__);
11268
11269 return ret;
11270}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011271
11272void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
11273{
11274 v_U8_t iniDot11Mode =
11275 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
11276 eHddDot11Mode hddDot11Mode = iniDot11Mode;
11277
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011278 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
11279 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011280 switch ( iniDot11Mode )
11281 {
11282 case eHDD_DOT11_MODE_AUTO:
11283 case eHDD_DOT11_MODE_11ac:
11284 case eHDD_DOT11_MODE_11ac_ONLY:
11285#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053011286 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
11287 sme_IsFeatureSupportedByFW(DOT11AC) )
11288 hddDot11Mode = eHDD_DOT11_MODE_11ac;
11289 else
11290 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011291#else
11292 hddDot11Mode = eHDD_DOT11_MODE_11n;
11293#endif
11294 break;
11295 case eHDD_DOT11_MODE_11n:
11296 case eHDD_DOT11_MODE_11n_ONLY:
11297 hddDot11Mode = eHDD_DOT11_MODE_11n;
11298 break;
11299 default:
11300 hddDot11Mode = iniDot11Mode;
11301 break;
11302 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011303#ifdef WLAN_FEATURE_AP_HT40_24G
11304 if (operationChannel > SIR_11B_CHANNEL_END)
11305#endif
11306 {
11307 /* This call decides required channel bonding mode */
11308 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011309 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
11310 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011311 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011312}
11313
Jeff Johnson295189b2012-06-20 16:38:30 -070011314/*
11315 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011316 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011317 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011318int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011319 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070011320{
11321 int status = 0;
11322 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080011323 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011324 v_U32_t roamId;
11325 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070011326 eCsrAuthType RSNAuthType;
11327
11328 ENTER();
11329
11330 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080011331 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11332
11333 status = wlan_hdd_validate_context(pHddCtx);
11334 if (status)
11335 {
Yue Mae36e3552014-03-05 17:06:20 -080011336 return status;
11337 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011338
Jeff Johnson295189b2012-06-20 16:38:30 -070011339 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
11340 {
11341 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
11342 return -EINVAL;
11343 }
11344
11345 pRoamProfile = &pWextState->roamProfile;
11346
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011347 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070011348 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011349 hdd_station_ctx_t *pHddStaCtx;
11350 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011351
Siddharth Bhalda0d1622015-04-24 15:47:49 +053011352 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
11353
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011354 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070011355 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
11356 {
11357 /*QoS not enabled in cfg file*/
11358 pRoamProfile->uapsd_mask = 0;
11359 }
11360 else
11361 {
11362 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011363 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070011364 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
11365 }
11366
11367 pRoamProfile->SSIDs.numOfSSIDs = 1;
11368 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
11369 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011370 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070011371 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
11372 ssid, ssid_len);
11373
11374 if (bssid)
11375 {
11376 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
11377 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
11378 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011379 /* Save BSSID in seperate variable as well, as RoamProfile
11380 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070011381 case of join failure we should send valid BSSID to supplicant
11382 */
11383 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
11384 WNI_CFG_BSSID_LEN);
11385 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070011386 else
11387 {
11388 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
11389 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011390
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011391 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
11392 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011393 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
11394 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011395 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011396 /*set gen ie*/
11397 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
11398 /*set auth*/
11399 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
11400 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011401#ifdef FEATURE_WLAN_WAPI
11402 if (pAdapter->wapi_info.nWapiMode)
11403 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011404 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011405 switch (pAdapter->wapi_info.wapiAuthMode)
11406 {
11407 case WAPI_AUTH_MODE_PSK:
11408 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011409 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011410 pAdapter->wapi_info.wapiAuthMode);
11411 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
11412 break;
11413 }
11414 case WAPI_AUTH_MODE_CERT:
11415 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011416 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011417 pAdapter->wapi_info.wapiAuthMode);
11418 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
11419 break;
11420 }
11421 } // End of switch
11422 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
11423 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
11424 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011425 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011426 pRoamProfile->AuthType.numEntries = 1;
11427 pRoamProfile->EncryptionType.numEntries = 1;
11428 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11429 pRoamProfile->mcEncryptionType.numEntries = 1;
11430 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11431 }
11432 }
11433#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011434#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011435 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011436 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11437 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
11438 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011439 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
11440 sizeof (tSirGtkOffloadParams));
11441 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011442 }
11443#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011444 pRoamProfile->csrPersona = pAdapter->device_mode;
11445
Jeff Johnson32d95a32012-09-10 13:15:23 -070011446 if( operatingChannel )
11447 {
11448 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
11449 pRoamProfile->ChannelInfo.numOfChannels = 1;
11450 }
Chet Lanctot186b5732013-03-18 10:26:30 -070011451 else
11452 {
11453 pRoamProfile->ChannelInfo.ChannelList = NULL;
11454 pRoamProfile->ChannelInfo.numOfChannels = 0;
11455 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011456 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
11457 {
11458 hdd_select_cbmode(pAdapter,operatingChannel);
11459 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011460
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011461 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
11462 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011463 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011464 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011465 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
11466 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011467 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11468 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053011469 {
11470 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11471 "%s: Set HDD connState to eConnectionState_Connecting",
11472 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011473 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
11474 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053011475 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011476 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011477 pAdapter->sessionId, pRoamProfile, &roamId);
11478
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011479 if ((eHAL_STATUS_SUCCESS != status) &&
11480 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11481 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011482
11483 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011484 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
11485 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
11486 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011487 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011488 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011489 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011490
11491 pRoamProfile->ChannelInfo.ChannelList = NULL;
11492 pRoamProfile->ChannelInfo.numOfChannels = 0;
11493
Jeff Johnson295189b2012-06-20 16:38:30 -070011494 }
11495 else
11496 {
11497 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
11498 return -EINVAL;
11499 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080011500 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011501 return status;
11502}
11503
11504/*
11505 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
11506 * This function is used to set the authentication type (OPEN/SHARED).
11507 *
11508 */
11509static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
11510 enum nl80211_auth_type auth_type)
11511{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011512 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011513 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11514
11515 ENTER();
11516
11517 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011518 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070011519 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011520 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011521 hddLog(VOS_TRACE_LEVEL_INFO,
11522 "%s: set authentication type to AUTOSWITCH", __func__);
11523 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
11524 break;
11525
11526 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011527#ifdef WLAN_FEATURE_VOWIFI_11R
11528 case NL80211_AUTHTYPE_FT:
11529#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011530 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011531 "%s: set authentication type to OPEN", __func__);
11532 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11533 break;
11534
11535 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011536 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011537 "%s: set authentication type to SHARED", __func__);
11538 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
11539 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011540#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011541 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011542 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011543 "%s: set authentication type to CCKM WPA", __func__);
11544 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
11545 break;
11546#endif
11547
11548
11549 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011550 hddLog(VOS_TRACE_LEVEL_ERROR,
11551 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011552 auth_type);
11553 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
11554 return -EINVAL;
11555 }
11556
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011557 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011558 pHddStaCtx->conn_info.authType;
11559 return 0;
11560}
11561
11562/*
11563 * FUNCTION: wlan_hdd_set_akm_suite
11564 * This function is used to set the key mgmt type(PSK/8021x).
11565 *
11566 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011567static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011568 u32 key_mgmt
11569 )
11570{
11571 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11572 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053011573 /* Should be in ieee802_11_defs.h */
11574#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
11575#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070011576 /*set key mgmt type*/
11577 switch(key_mgmt)
11578 {
11579 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053011580 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011581#ifdef WLAN_FEATURE_VOWIFI_11R
11582 case WLAN_AKM_SUITE_FT_PSK:
11583#endif
11584 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070011585 __func__);
11586 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
11587 break;
11588
11589 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053011590 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011591#ifdef WLAN_FEATURE_VOWIFI_11R
11592 case WLAN_AKM_SUITE_FT_8021X:
11593#endif
11594 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011595 __func__);
11596 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11597 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011598#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011599#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
11600#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
11601 case WLAN_AKM_SUITE_CCKM:
11602 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
11603 __func__);
11604 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
11605 break;
11606#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070011607#ifndef WLAN_AKM_SUITE_OSEN
11608#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
11609 case WLAN_AKM_SUITE_OSEN:
11610 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
11611 __func__);
11612 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11613 break;
11614#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011615
11616 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011617 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011618 __func__, key_mgmt);
11619 return -EINVAL;
11620
11621 }
11622 return 0;
11623}
11624
11625/*
11626 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011627 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070011628 * (NONE/WEP40/WEP104/TKIP/CCMP).
11629 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011630static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
11631 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070011632 bool ucast
11633 )
11634{
11635 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011636 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011637 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11638
11639 ENTER();
11640
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011641 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011642 {
Ratheesh S P36dbc932015-08-07 14:28:57 +053011643 hddLog(VOS_TRACE_LEVEL_INFO, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070011644 __func__, cipher);
11645 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11646 }
11647 else
11648 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011649
Jeff Johnson295189b2012-06-20 16:38:30 -070011650 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011651 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011652 {
11653 case IW_AUTH_CIPHER_NONE:
11654 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11655 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011656
Jeff Johnson295189b2012-06-20 16:38:30 -070011657 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011658 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070011659 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011660
Jeff Johnson295189b2012-06-20 16:38:30 -070011661 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011662 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070011663 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011664
Jeff Johnson295189b2012-06-20 16:38:30 -070011665 case WLAN_CIPHER_SUITE_TKIP:
11666 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
11667 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011668
Jeff Johnson295189b2012-06-20 16:38:30 -070011669 case WLAN_CIPHER_SUITE_CCMP:
11670 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11671 break;
11672#ifdef FEATURE_WLAN_WAPI
11673 case WLAN_CIPHER_SUITE_SMS4:
11674 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
11675 break;
11676#endif
11677
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011678#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011679 case WLAN_CIPHER_SUITE_KRK:
11680 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
11681 break;
11682#endif
11683 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011684 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011685 __func__, cipher);
11686 return -EOPNOTSUPP;
11687 }
11688 }
11689
11690 if (ucast)
11691 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011692 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011693 __func__, encryptionType);
11694 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11695 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011696 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011697 encryptionType;
11698 }
11699 else
11700 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011701 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011702 __func__, encryptionType);
11703 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
11704 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
11705 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
11706 }
11707
11708 return 0;
11709}
11710
11711
11712/*
11713 * FUNCTION: wlan_hdd_cfg80211_set_ie
11714 * This function is used to parse WPA/RSN IE's.
11715 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011716int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011717#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11718 const u8 *ie,
11719#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011720 u8 *ie,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011721#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011722 size_t ie_len
11723 )
11724{
11725 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011726#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
11727 const u8 *genie = ie;
11728#else
Jeff Johnson295189b2012-06-20 16:38:30 -070011729 u8 *genie = ie;
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011730#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011731 v_U16_t remLen = ie_len;
11732#ifdef FEATURE_WLAN_WAPI
11733 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
11734 u16 *tmp;
11735 v_U16_t akmsuiteCount;
11736 int *akmlist;
11737#endif
11738 ENTER();
11739
11740 /* clear previous assocAddIE */
11741 pWextState->assocAddIE.length = 0;
11742 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011743 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011744
11745 while (remLen >= 2)
11746 {
11747 v_U16_t eLen = 0;
11748 v_U8_t elementId;
11749 elementId = *genie++;
11750 eLen = *genie++;
11751 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011752
Arif Hussain6d2a3322013-11-17 19:50:10 -080011753 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070011754 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011755
11756 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070011757 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011758 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011759 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 -070011760 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011761 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011762 "%s: Invalid WPA IE", __func__);
11763 return -EINVAL;
11764 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011765 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070011766 {
11767 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011768 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011769 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011770
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011771 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011772 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011773 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
11774 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011775 VOS_ASSERT(0);
11776 return -ENOMEM;
11777 }
11778 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11779 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11780 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011781
Jeff Johnson295189b2012-06-20 16:38:30 -070011782 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
11783 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11784 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11785 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011786 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
11787 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011788 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
11789 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11790 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
11791 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
11792 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
11793 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011794 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053011795 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070011796 {
11797 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011798 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011799 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011800
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011801 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011802 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011803 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11804 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011805 VOS_ASSERT(0);
11806 return -ENOMEM;
11807 }
11808 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11809 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11810 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011811
Jeff Johnson295189b2012-06-20 16:38:30 -070011812 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11813 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11814 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011815#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011816 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
11817 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011818 /*Consider WFD IE, only for P2P Client */
11819 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
11820 {
11821 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011822 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011823 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011824
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011825 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011826 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011827 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11828 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011829 VOS_ASSERT(0);
11830 return -ENOMEM;
11831 }
11832 // WFD IE is saved to Additional IE ; it should be accumulated to handle
11833 // WPS IE + P2P IE + WFD IE
11834 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11835 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011836
Jeff Johnson295189b2012-06-20 16:38:30 -070011837 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11838 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11839 }
11840#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011841 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011842 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011843 HS20_OUI_TYPE_SIZE)) )
11844 {
11845 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011846 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011847 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011848
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011849 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011850 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011851 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11852 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011853 VOS_ASSERT(0);
11854 return -ENOMEM;
11855 }
11856 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11857 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011858
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011859 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11860 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11861 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011862 /* Appending OSEN Information Element in Assiciation Request */
11863 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
11864 OSEN_OUI_TYPE_SIZE)) )
11865 {
11866 v_U16_t curAddIELen = pWextState->assocAddIE.length;
11867 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
11868 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011869
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011870 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011871 {
11872 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11873 "Need bigger buffer space");
11874 VOS_ASSERT(0);
11875 return -ENOMEM;
11876 }
11877 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11878 pWextState->assocAddIE.length += eLen + 2;
11879
11880 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
11881 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11882 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11883 }
11884
Abhishek Singh4322e622015-06-10 15:42:54 +053011885 /* Update only for WPA IE */
11886 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
11887 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011888
11889 /* populating as ADDIE in beacon frames */
11890 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053011891 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, (u8 *)genie - 2, eLen + 2,
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011892 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
11893 {
11894 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11895 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
11896 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11897 {
11898 hddLog(LOGE,
11899 "Coldn't pass "
11900 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
11901 }
11902 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
11903 else
11904 hddLog(LOGE,
11905 "Could not pass on "
11906 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
11907
11908 /* IBSS mode doesn't contain params->proberesp_ies still
11909 beaconIE's need to be populated in probe response frames */
11910 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
11911 {
11912 u16 rem_probe_resp_ie_len = eLen + 2;
11913 u8 probe_rsp_ie_len[3] = {0};
11914 u8 counter = 0;
11915
11916 /* Check Probe Resp Length if it is greater then 255 then
11917 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
11918 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
11919 not able Store More then 255 bytes into One Variable */
11920
11921 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
11922 {
11923 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
11924 {
11925 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
11926 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
11927 }
11928 else
11929 {
11930 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
11931 rem_probe_resp_ie_len = 0;
11932 }
11933 }
11934
11935 rem_probe_resp_ie_len = 0;
11936
11937 if (probe_rsp_ie_len[0] > 0)
11938 {
11939 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11940 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
11941 (tANI_U8*)(genie - 2),
11942 probe_rsp_ie_len[0], NULL,
11943 eANI_BOOLEAN_FALSE)
11944 == eHAL_STATUS_FAILURE)
11945 {
11946 hddLog(LOGE,
11947 "Could not pass"
11948 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
11949 }
11950 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
11951 }
11952
11953 if (probe_rsp_ie_len[1] > 0)
11954 {
11955 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11956 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
11957 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11958 probe_rsp_ie_len[1], NULL,
11959 eANI_BOOLEAN_FALSE)
11960 == eHAL_STATUS_FAILURE)
11961 {
11962 hddLog(LOGE,
11963 "Could not pass"
11964 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
11965 }
11966 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
11967 }
11968
11969 if (probe_rsp_ie_len[2] > 0)
11970 {
11971 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11972 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
11973 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11974 probe_rsp_ie_len[2], NULL,
11975 eANI_BOOLEAN_FALSE)
11976 == eHAL_STATUS_FAILURE)
11977 {
11978 hddLog(LOGE,
11979 "Could not pass"
11980 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
11981 }
11982 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
11983 }
11984
11985 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11986 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
11987 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11988 {
11989 hddLog(LOGE,
11990 "Could not pass"
11991 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
11992 }
11993 }
11994 else
11995 {
11996 // Reset WNI_CFG_PROBE_RSP Flags
11997 wlan_hdd_reset_prob_rspies(pAdapter);
11998
11999 hddLog(VOS_TRACE_LEVEL_INFO,
12000 "%s: No Probe Response IE received in set beacon",
12001 __func__);
12002 }
12003 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070012004 break;
12005 case DOT11F_EID_RSN:
12006 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
12007 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
12008 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
12009 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
12010 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
12011 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053012012
12013 /* Appending Extended Capabilities with Interworking bit set
12014 * in Assoc Req.
12015 *
12016 * In assoc req this EXT Cap will only be taken into account if
12017 * interworkingService bit is set to 1. Currently
12018 * driver is only interested in interworkingService capability
12019 * from supplicant. If in future any other EXT Cap info is
12020 * required from supplicat, it needs to be handled while
12021 * sending Assoc Req in LIM.
12022 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012023 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012024 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012025 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012026 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012027 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012028
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053012029 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012030 {
Jeff Johnson902c9832012-12-10 14:28:09 -080012031 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
12032 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012033 VOS_ASSERT(0);
12034 return -ENOMEM;
12035 }
12036 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
12037 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012038
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012039 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
12040 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
12041 break;
12042 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012043#ifdef FEATURE_WLAN_WAPI
12044 case WLAN_EID_WAPI:
12045 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070012046 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070012047 pAdapter->wapi_info.nWapiMode);
12048 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012049 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070012050 akmsuiteCount = WPA_GET_LE16(tmp);
12051 tmp = tmp + 1;
12052 akmlist = (int *)(tmp);
12053 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
12054 {
12055 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
12056 }
12057 else
12058 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012059 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070012060 VOS_ASSERT(0);
12061 return -EINVAL;
12062 }
12063
12064 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
12065 {
12066 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012067 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012068 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012069 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012070 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012071 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012072 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012073 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012074 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
12075 }
12076 break;
12077#endif
12078 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012079 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012080 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070012081 /* when Unknown IE is received we should break and continue
12082 * to the next IE in the buffer instead we were returning
12083 * so changing this to break */
12084 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012085 }
12086 genie += eLen;
12087 remLen -= eLen;
12088 }
12089 EXIT();
12090 return 0;
12091}
12092
12093/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053012094 * FUNCTION: hdd_isWPAIEPresent
12095 * Parse the received IE to find the WPA IE
12096 *
12097 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012098static bool hdd_isWPAIEPresent(
12099#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
12100 const u8 *ie,
12101#else
12102 u8 *ie,
12103#endif
12104 u8 ie_len)
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053012105{
12106 v_U8_t eLen = 0;
12107 v_U16_t remLen = ie_len;
12108 v_U8_t elementId = 0;
12109
12110 while (remLen >= 2)
12111 {
12112 elementId = *ie++;
12113 eLen = *ie++;
12114 remLen -= 2;
12115 if (eLen > remLen)
12116 {
12117 hddLog(VOS_TRACE_LEVEL_ERROR,
12118 "%s: IE length is wrong %d", __func__, eLen);
12119 return FALSE;
12120 }
12121 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
12122 {
12123 /* OUI - 0x00 0X50 0XF2
12124 WPA Information Element - 0x01
12125 WPA version - 0x01*/
12126 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
12127 return TRUE;
12128 }
12129 ie += eLen;
12130 remLen -= eLen;
12131 }
12132 return FALSE;
12133}
12134
12135/*
Jeff Johnson295189b2012-06-20 16:38:30 -070012136 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012137 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012138 * parameters during connect operation.
12139 */
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012140int wlan_hdd_cfg80211_set_privacy(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012141 struct cfg80211_connect_params *req
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012142 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012143{
12144 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012145 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012146 ENTER();
12147
12148 /*set wpa version*/
12149 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
12150
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012151 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070012152 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053012153 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070012154 {
12155 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12156 }
12157 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
12158 {
12159 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12160 }
12161 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012162
12163 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012164 pWextState->wpaVersion);
12165
12166 /*set authentication type*/
12167 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
12168
12169 if (0 > status)
12170 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012171 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012172 "%s: failed to set authentication type ", __func__);
12173 return status;
12174 }
12175
12176 /*set key mgmt type*/
12177 if (req->crypto.n_akm_suites)
12178 {
12179 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
12180 if (0 > status)
12181 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012182 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070012183 __func__);
12184 return status;
12185 }
12186 }
12187
12188 /*set pairwise cipher type*/
12189 if (req->crypto.n_ciphers_pairwise)
12190 {
12191 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
12192 req->crypto.ciphers_pairwise[0], true);
12193 if (0 > status)
12194 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012195 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012196 "%s: failed to set unicast cipher type", __func__);
12197 return status;
12198 }
12199 }
12200 else
12201 {
12202 /*Reset previous cipher suite to none*/
12203 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
12204 if (0 > status)
12205 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012206 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012207 "%s: failed to set unicast cipher type", __func__);
12208 return status;
12209 }
12210 }
12211
12212 /*set group cipher type*/
12213 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
12214 false);
12215
12216 if (0 > status)
12217 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012218 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070012219 __func__);
12220 return status;
12221 }
12222
Chet Lanctot186b5732013-03-18 10:26:30 -070012223#ifdef WLAN_FEATURE_11W
12224 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
12225#endif
12226
Jeff Johnson295189b2012-06-20 16:38:30 -070012227 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
12228 if (req->ie_len)
12229 {
12230 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
12231 if ( 0 > status)
12232 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012233 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012234 __func__);
12235 return status;
12236 }
12237 }
12238
12239 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012240 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012241 {
12242 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
12243 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
12244 )
12245 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012246 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070012247 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
12248 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012249 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012250 __func__);
12251 return -EOPNOTSUPP;
12252 }
12253 else
12254 {
12255 u8 key_len = req->key_len;
12256 u8 key_idx = req->key_idx;
12257
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012258 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070012259 && (CSR_MAX_NUM_KEY > key_idx)
12260 )
12261 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012262 hddLog(VOS_TRACE_LEVEL_INFO,
12263 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012264 __func__, key_idx, key_len);
12265 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012266 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070012267 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012268 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070012269 (u8)key_len;
12270 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
12271 }
12272 }
12273 }
12274 }
12275
12276 return status;
12277}
12278
12279/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012280 * FUNCTION: wlan_hdd_try_disconnect
12281 * This function is used to disconnect from previous
12282 * connection
12283 */
12284static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
12285{
12286 long ret = 0;
12287 hdd_station_ctx_t *pHddStaCtx;
12288 eMib_dot11DesiredBssType connectedBssType;
12289
12290 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12291
12292 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
12293
12294 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
12295 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
12296 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
12297 {
12298 /* Issue disconnect to CSR */
12299 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12300 if( eHAL_STATUS_SUCCESS ==
12301 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12302 pAdapter->sessionId,
12303 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
12304 {
12305 ret = wait_for_completion_interruptible_timeout(
12306 &pAdapter->disconnect_comp_var,
12307 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12308 if (0 >= ret)
12309 {
12310 hddLog(LOGE, FL("Failed to receive disconnect event"));
12311 return -EALREADY;
12312 }
12313 }
12314 }
12315 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
12316 {
12317 ret = wait_for_completion_interruptible_timeout(
12318 &pAdapter->disconnect_comp_var,
12319 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12320 if (0 >= ret)
12321 {
12322 hddLog(LOGE, FL("Failed to receive disconnect event"));
12323 return -EALREADY;
12324 }
12325 }
12326
12327 return 0;
12328}
12329
12330/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053012331 * FUNCTION: __wlan_hdd_cfg80211_connect
12332 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070012333 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012334static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012335 struct net_device *ndev,
12336 struct cfg80211_connect_params *req
12337 )
12338{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012339 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012340 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012341 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053012342 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012343
12344 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012345
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012346 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12347 TRACE_CODE_HDD_CFG80211_CONNECT,
12348 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012349 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012350 "%s: device_mode = %s (%d)", __func__,
12351 hdd_device_modetoString(pAdapter->device_mode),
12352 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012353
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012354 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012355 if (!pHddCtx)
12356 {
12357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12358 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053012359 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012360 }
12361
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012362 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012363 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012364 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012365 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012366 }
12367
Agarwal Ashish51325b52014-06-16 16:50:49 +053012368 if (vos_max_concurrent_connections_reached()) {
12369 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12370 return -ECONNREFUSED;
12371 }
12372
Jeff Johnson295189b2012-06-20 16:38:30 -070012373#ifdef WLAN_BTAMP_FEATURE
12374 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012375 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070012376 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012377 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012378 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080012379 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012380 }
12381#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012382
12383 //If Device Mode is Station Concurrent Sessions Exit BMps
12384 //P2P Mode will be taken care in Open/close adapter
12385 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012386 (vos_concurrent_open_sessions_running())) {
12387 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
12388 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012389 }
12390
12391 /*Try disconnecting if already in connected state*/
12392 status = wlan_hdd_try_disconnect(pAdapter);
12393 if ( 0 > status)
12394 {
12395 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12396 " connection"));
12397 return -EALREADY;
12398 }
12399
Jeff Johnson295189b2012-06-20 16:38:30 -070012400 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012401 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070012402
12403 if ( 0 > status)
12404 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012405 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070012406 __func__);
12407 return status;
12408 }
Mohit Khanna765234a2012-09-11 15:08:35 -070012409 if ( req->channel )
12410 {
12411 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
12412 req->ssid_len, req->bssid,
12413 req->channel->hw_value);
12414 }
12415 else
12416 {
12417 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012418 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070012419 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012420
Sushant Kaushikd7083982015-03-18 14:33:24 +053012421 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012422 {
12423 //ReEnable BMPS if disabled
12424 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
12425 (NULL != pHddCtx))
12426 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012427 if (pHddCtx->hdd_wlan_suspended)
12428 {
12429 hdd_set_pwrparams(pHddCtx);
12430 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012431 //ReEnable Bmps and Imps back
12432 hdd_enable_bmps_imps(pHddCtx);
12433 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053012434 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012435 return status;
12436 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012437 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012438 EXIT();
12439 return status;
12440}
12441
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012442static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
12443 struct net_device *ndev,
12444 struct cfg80211_connect_params *req)
12445{
12446 int ret;
12447 vos_ssr_protect(__func__);
12448 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
12449 vos_ssr_unprotect(__func__);
12450
12451 return ret;
12452}
Jeff Johnson295189b2012-06-20 16:38:30 -070012453
12454/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012455 * FUNCTION: wlan_hdd_disconnect
12456 * This function is used to issue a disconnect request to SME
12457 */
12458int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
12459{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012460 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012461 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012462 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012463 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012464
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012465 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012466
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012467 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012468 if (0 != status)
12469 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012470 return status;
12471 }
12472
Sushant Kaushikb4834d22015-07-15 15:29:05 +053012473 if (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)
12474 {
12475 sme_abortConnection(WLAN_HDD_GET_HAL_CTX(pAdapter),
12476 pAdapter->sessionId);
12477 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012478 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012479
Agarwal Ashish47d18112014-08-04 19:55:07 +053012480 /* Need to apply spin lock before decreasing active sessions
12481 * as there can be chance for double decrement if context switch
12482 * Calls hdd_DisConnectHandler.
12483 */
12484
12485 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012486 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
12487 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012488 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
12489 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053012490 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
12491 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012492
Abhishek Singhf4669da2014-05-26 15:07:49 +053012493 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053012494 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
12495
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012496 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012497
Mihir Shete182a0b22014-08-18 16:08:48 +053012498 /*
12499 * stop tx queues before deleting STA/BSS context from the firmware.
12500 * tx has to be disabled because the firmware can get busy dropping
12501 * the tx frames after BSS/STA has been deleted and will not send
12502 * back a response resulting in WDI timeout
12503 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053012504 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053012505 netif_tx_disable(pAdapter->dev);
12506 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012507
Mihir Shete182a0b22014-08-18 16:08:48 +053012508 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012509 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12510 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012511 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
12512 {
12513 hddLog(VOS_TRACE_LEVEL_INFO,
12514 FL("status = %d, already disconnected"),
12515 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012516
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012517 }
12518 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012519 {
12520 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012521 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012522 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012523 result = -EINVAL;
12524 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012525 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012526 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012527 &pAdapter->disconnect_comp_var,
12528 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012529 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012530 {
12531 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012532 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012533 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012534 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012535 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012536 {
12537 hddLog(VOS_TRACE_LEVEL_ERROR,
12538 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012539 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012540 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012541disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012542 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12543 FL("Set HDD connState to eConnectionState_NotConnected"));
12544 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
12545
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012546 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012547 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012548}
12549
12550
12551/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012552 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070012553 * This function is used to issue a disconnect request to SME
12554 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012555static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012556 struct net_device *dev,
12557 u16 reason
12558 )
12559{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012560 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012561 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012562 tCsrRoamProfile *pRoamProfile;
12563 hdd_station_ctx_t *pHddStaCtx;
12564 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012565#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012566 tANI_U8 staIdx;
12567#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012568
Jeff Johnson295189b2012-06-20 16:38:30 -070012569 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012570
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012571 if (!pAdapter) {
12572 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
12573 return -EINVAL;
12574 }
12575
12576 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12577 if (!pHddStaCtx) {
12578 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
12579 return -EINVAL;
12580 }
12581
12582 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12583 status = wlan_hdd_validate_context(pHddCtx);
12584 if (0 != status)
12585 {
12586 return status;
12587 }
12588
12589 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
12590
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012591 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12592 TRACE_CODE_HDD_CFG80211_DISCONNECT,
12593 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012594 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
12595 __func__, hdd_device_modetoString(pAdapter->device_mode),
12596 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012597
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012598 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
12599 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070012600
Jeff Johnson295189b2012-06-20 16:38:30 -070012601 if (NULL != pRoamProfile)
12602 {
12603 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012604 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
12605 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070012606 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012607 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070012608 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012609 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012610 switch(reason)
12611 {
12612 case WLAN_REASON_MIC_FAILURE:
12613 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
12614 break;
12615
12616 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
12617 case WLAN_REASON_DISASSOC_AP_BUSY:
12618 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
12619 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
12620 break;
12621
12622 case WLAN_REASON_PREV_AUTH_NOT_VALID:
12623 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053012624 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
12626 break;
12627
Jeff Johnson295189b2012-06-20 16:38:30 -070012628 default:
12629 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
12630 break;
12631 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012632 pScanInfo = &pHddCtx->scan_info;
12633 if (pScanInfo->mScanPending)
12634 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012635 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012636 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053012637 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012638 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012639 }
Agarwal Ashishc089cec2015-08-10 13:10:04 +053012640 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012641#ifdef FEATURE_WLAN_TDLS
12642 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012643 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012644 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012645 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
12646 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012647 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012648 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012649 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012651 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012652 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012653 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012654 status = sme_DeleteTdlsPeerSta(
12655 WLAN_HDD_GET_HAL_CTX(pAdapter),
12656 pAdapter->sessionId,
12657 mac);
12658 if (status != eHAL_STATUS_SUCCESS) {
12659 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
12660 return -EPERM;
12661 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012662 }
12663 }
12664#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012665 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012666 status = wlan_hdd_disconnect(pAdapter, reasonCode);
12667 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070012668 {
12669 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012670 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012671 __func__, (int)status );
12672 return -EINVAL;
12673 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012674 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012675 else
12676 {
12677 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
12678 "called while in %d state", __func__,
12679 pHddStaCtx->conn_info.connState);
12680 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012681 }
12682 else
12683 {
12684 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
12685 }
12686
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012687 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012688 return status;
12689}
12690
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012691static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
12692 struct net_device *dev,
12693 u16 reason
12694 )
12695{
12696 int ret;
12697 vos_ssr_protect(__func__);
12698 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
12699 vos_ssr_unprotect(__func__);
12700
12701 return ret;
12702}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012703
Jeff Johnson295189b2012-06-20 16:38:30 -070012704/*
12705 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012706 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012707 * settings in IBSS mode.
12708 */
12709static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012710 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012711 struct cfg80211_ibss_params *params
12712 )
12713{
12714 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012715 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012716 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
12717 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012718
Jeff Johnson295189b2012-06-20 16:38:30 -070012719 ENTER();
12720
12721 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070012722 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070012723
12724 if (params->ie_len && ( NULL != params->ie) )
12725 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012726 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12727 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012728 {
12729 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12730 encryptionType = eCSR_ENCRYPT_TYPE_AES;
12731 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012732 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012733 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012734 tDot11fIEWPA dot11WPAIE;
12735 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012736 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012737
Wilson Yang00256342013-10-10 23:13:38 -070012738 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012739 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12740 params->ie_len, DOT11F_EID_WPA);
12741 if ( NULL != ie )
12742 {
12743 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12744 // Unpack the WPA IE
12745 //Skip past the EID byte and length byte - and four byte WiFi OUI
12746 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
12747 &ie[2+4],
12748 ie[1] - 4,
12749 &dot11WPAIE);
12750 /*Extract the multicast cipher, the encType for unicast
12751 cipher for wpa-none is none*/
12752 encryptionType =
12753 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
12754 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012755 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012756
Jeff Johnson295189b2012-06-20 16:38:30 -070012757 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
12758
12759 if (0 > status)
12760 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012761 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012762 __func__);
12763 return status;
12764 }
12765 }
12766
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012767 pWextState->roamProfile.AuthType.authType[0] =
12768 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012769 eCSR_AUTH_TYPE_OPEN_SYSTEM;
12770
12771 if (params->privacy)
12772 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012773 /* Security enabled IBSS, At this time there is no information available
12774 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070012775 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012776 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070012777 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012778 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070012779 *enable privacy bit in beacons */
12780
12781 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
12782 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012783 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
12784 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012785 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
12786 pWextState->roamProfile.EncryptionType.numEntries = 1;
12787 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012788 return status;
12789}
12790
12791/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012792 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012793 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012794 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012795static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012796 struct net_device *dev,
12797 struct cfg80211_ibss_params *params
12798 )
12799{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012800 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012801 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12802 tCsrRoamProfile *pRoamProfile;
12803 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012804 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12805 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012806 tSirMacAddr bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -070012807
12808 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012809
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012810 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12811 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
12812 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012813 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012814 "%s: device_mode = %s (%d)", __func__,
12815 hdd_device_modetoString(pAdapter->device_mode),
12816 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012817
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012818 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012819 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012820 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012821 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012822 }
12823
12824 if (NULL == pWextState)
12825 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012826 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012827 __func__);
12828 return -EIO;
12829 }
12830
Agarwal Ashish51325b52014-06-16 16:50:49 +053012831 if (vos_max_concurrent_connections_reached()) {
12832 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12833 return -ECONNREFUSED;
12834 }
12835
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012836 /*Try disconnecting if already in connected state*/
12837 status = wlan_hdd_try_disconnect(pAdapter);
12838 if ( 0 > status)
12839 {
12840 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12841 " IBSS connection"));
12842 return -EALREADY;
12843 }
12844
Jeff Johnson295189b2012-06-20 16:38:30 -070012845 pRoamProfile = &pWextState->roamProfile;
12846
12847 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
12848 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012849 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012850 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012851 return -EINVAL;
12852 }
12853
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012854 /* BSSID is provided by upper layers hence no need to AUTO generate */
12855 if (NULL != params->bssid) {
12856 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12857 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
12858 hddLog (VOS_TRACE_LEVEL_ERROR,
12859 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12860 return -EIO;
12861 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012862 vos_mem_copy((v_U8_t *)bssid, (v_U8_t *)params->bssid, sizeof(bssid));
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012863 }
krunal sonie9002db2013-11-25 14:24:17 -080012864 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
12865 {
12866 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12867 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
12868 {
12869 hddLog (VOS_TRACE_LEVEL_ERROR,
12870 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12871 return -EIO;
12872 }
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012873
12874 vos_mem_copy((v_U8_t *)bssid,
krunal sonie9002db2013-11-25 14:24:17 -080012875 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012876 sizeof(bssid));
krunal sonie9002db2013-11-25 14:24:17 -080012877 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012878
Jeff Johnson295189b2012-06-20 16:38:30 -070012879 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070012880 if (NULL !=
12881#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12882 params->chandef.chan)
12883#else
12884 params->channel)
12885#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012886 {
12887 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012888 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12889 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
12890 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12891 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012892
12893 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012894 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070012895 ieee80211_frequency_to_channel(
12896#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12897 params->chandef.chan->center_freq);
12898#else
12899 params->channel->center_freq);
12900#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012901
12902 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
12903 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070012904 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012905 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
12906 __func__);
12907 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070012908 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012909
12910 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012911 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012912 if (channelNum == validChan[indx])
12913 {
12914 break;
12915 }
12916 }
12917 if (indx >= numChans)
12918 {
12919 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012920 __func__, channelNum);
12921 return -EINVAL;
12922 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012923 /* Set the Operational Channel */
12924 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
12925 channelNum);
12926 pRoamProfile->ChannelInfo.numOfChannels = 1;
12927 pHddStaCtx->conn_info.operationChannel = channelNum;
12928 pRoamProfile->ChannelInfo.ChannelList =
12929 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070012930 }
12931
12932 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012933 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070012934 if (status < 0)
12935 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012936 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070012937 __func__);
12938 return status;
12939 }
12940
12941 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012942 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012943 params->ssid_len, params->bssid,
12944 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070012945
12946 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012947 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012948
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012949 EXIT();
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012950 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012951}
12952
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012953static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
12954 struct net_device *dev,
12955 struct cfg80211_ibss_params *params
12956 )
12957{
12958 int ret = 0;
12959
12960 vos_ssr_protect(__func__);
12961 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
12962 vos_ssr_unprotect(__func__);
12963
12964 return ret;
12965}
12966
Jeff Johnson295189b2012-06-20 16:38:30 -070012967/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012968 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012969 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012970 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012971static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012972 struct net_device *dev
12973 )
12974{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012975 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012976 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12977 tCsrRoamProfile *pRoamProfile;
12978 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012979 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012980
12981 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012982
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012983 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12984 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
12985 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012986 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012987 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012988 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012989 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012990 }
12991
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012992 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
12993 hdd_device_modetoString(pAdapter->device_mode),
12994 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012995 if (NULL == pWextState)
12996 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012997 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012998 __func__);
12999 return -EIO;
13000 }
13001
13002 pRoamProfile = &pWextState->roamProfile;
13003
13004 /* Issue disconnect only if interface type is set to IBSS */
13005 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
13006 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013007 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070013008 __func__);
13009 return -EINVAL;
13010 }
13011
13012 /* Issue Disconnect request */
13013 INIT_COMPLETION(pAdapter->disconnect_comp_var);
13014 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
13015 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
13016
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013017 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013018 return 0;
13019}
13020
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013021static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
13022 struct net_device *dev
13023 )
13024{
13025 int ret = 0;
13026
13027 vos_ssr_protect(__func__);
13028 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
13029 vos_ssr_unprotect(__func__);
13030
13031 return ret;
13032}
13033
Jeff Johnson295189b2012-06-20 16:38:30 -070013034/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013035 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070013036 * This function is used to set the phy parameters
13037 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
13038 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013039static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070013040 u32 changed)
13041{
13042 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
13043 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013044 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013045
13046 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013047
13048 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013049 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
13050 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013051
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013052 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013053 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013054 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013055 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013056 }
13057
Jeff Johnson295189b2012-06-20 16:38:30 -070013058 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
13059 {
13060 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
13061 WNI_CFG_RTS_THRESHOLD_STAMAX :
13062 wiphy->rts_threshold;
13063
13064 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013065 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070013066 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013067 hddLog(VOS_TRACE_LEVEL_ERROR,
13068 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013069 __func__, rts_threshold);
13070 return -EINVAL;
13071 }
13072
13073 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
13074 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013075 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013076 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013077 hddLog(VOS_TRACE_LEVEL_ERROR,
13078 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013079 __func__, rts_threshold);
13080 return -EIO;
13081 }
13082
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013083 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013084 rts_threshold);
13085 }
13086
13087 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
13088 {
13089 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
13090 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
13091 wiphy->frag_threshold;
13092
13093 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013094 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013095 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013096 hddLog(VOS_TRACE_LEVEL_ERROR,
13097 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070013098 frag_threshold);
13099 return -EINVAL;
13100 }
13101
13102 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
13103 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013104 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013105 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013106 hddLog(VOS_TRACE_LEVEL_ERROR,
13107 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013108 __func__, frag_threshold);
13109 return -EIO;
13110 }
13111
13112 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
13113 frag_threshold);
13114 }
13115
13116 if ((changed & WIPHY_PARAM_RETRY_SHORT)
13117 || (changed & WIPHY_PARAM_RETRY_LONG))
13118 {
13119 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
13120 wiphy->retry_short :
13121 wiphy->retry_long;
13122
13123 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
13124 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
13125 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013126 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013127 __func__, retry_value);
13128 return -EINVAL;
13129 }
13130
13131 if (changed & WIPHY_PARAM_RETRY_SHORT)
13132 {
13133 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
13134 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013135 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013136 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013137 hddLog(VOS_TRACE_LEVEL_ERROR,
13138 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013139 __func__, retry_value);
13140 return -EIO;
13141 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013142 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013143 __func__, retry_value);
13144 }
13145 else if (changed & WIPHY_PARAM_RETRY_SHORT)
13146 {
13147 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
13148 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013149 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013150 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013151 hddLog(VOS_TRACE_LEVEL_ERROR,
13152 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013153 __func__, retry_value);
13154 return -EIO;
13155 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013156 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070013157 __func__, retry_value);
13158 }
13159 }
13160
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013161 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013162 return 0;
13163}
13164
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013165static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
13166 u32 changed)
13167{
13168 int ret;
13169
13170 vos_ssr_protect(__func__);
13171 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
13172 vos_ssr_unprotect(__func__);
13173
13174 return ret;
13175}
13176
Jeff Johnson295189b2012-06-20 16:38:30 -070013177/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013178 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013179 * This function is used to set the txpower
13180 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013181static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013182#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13183 struct wireless_dev *wdev,
13184#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013185#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013186 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013187#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013188 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070013189#endif
13190 int dbm)
13191{
13192 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013193 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013194 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
13195 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013196 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013197
13198 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013199
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013200 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13201 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
13202 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013203 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013204 if (0 != status)
13205 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013206 return status;
13207 }
13208
13209 hHal = pHddCtx->hHal;
13210
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013211 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
13212 dbm, ccmCfgSetCallback,
13213 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070013214 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013215 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
13217 return -EIO;
13218 }
13219
13220 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
13221 dbm);
13222
13223 switch(type)
13224 {
13225 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
13226 /* Fall through */
13227 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
13228 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
13229 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013230 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
13231 __func__);
13232 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070013233 }
13234 break;
13235 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013236 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 __func__);
13238 return -EOPNOTSUPP;
13239 break;
13240 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013241 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
13242 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070013243 return -EIO;
13244 }
13245
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013246 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013247 return 0;
13248}
13249
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053013250static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
13251#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13252 struct wireless_dev *wdev,
13253#endif
13254#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13255 enum tx_power_setting type,
13256#else
13257 enum nl80211_tx_power_setting type,
13258#endif
13259 int dbm)
13260{
13261 int ret;
13262 vos_ssr_protect(__func__);
13263 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
13264#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13265 wdev,
13266#endif
13267#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
13268 type,
13269#else
13270 type,
13271#endif
13272 dbm);
13273 vos_ssr_unprotect(__func__);
13274
13275 return ret;
13276}
13277
Jeff Johnson295189b2012-06-20 16:38:30 -070013278/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013279 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013280 * This function is used to read the txpower
13281 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013282static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013283#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13284 struct wireless_dev *wdev,
13285#endif
13286 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070013287{
13288
13289 hdd_adapter_t *pAdapter;
13290 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013291 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013292
Jeff Johnsone7245742012-09-05 17:12:55 -070013293 ENTER();
13294
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013295 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013296 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013297 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013298 *dbm = 0;
13299 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013300 }
13301
Jeff Johnson295189b2012-06-20 16:38:30 -070013302 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
13303 if (NULL == pAdapter)
13304 {
13305 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
13306 return -ENOENT;
13307 }
13308
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053013309 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13310 TRACE_CODE_HDD_CFG80211_GET_TXPOWER,
13311 pAdapter->sessionId, pAdapter->device_mode));
Jeff Johnson295189b2012-06-20 16:38:30 -070013312 wlan_hdd_get_classAstats(pAdapter);
13313 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
13314
Jeff Johnsone7245742012-09-05 17:12:55 -070013315 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013316 return 0;
13317}
13318
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013319static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
13320#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13321 struct wireless_dev *wdev,
13322#endif
13323 int *dbm)
13324{
13325 int ret;
13326
13327 vos_ssr_protect(__func__);
13328 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
13329#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13330 wdev,
13331#endif
13332 dbm);
13333 vos_ssr_unprotect(__func__);
13334
13335 return ret;
13336}
13337
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013338static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013339#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
13340 const u8* mac,
13341#else
13342 u8* mac,
13343#endif
13344 struct station_info *sinfo)
Jeff Johnson295189b2012-06-20 16:38:30 -070013345{
13346 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13347 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13348 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053013349 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013350
13351 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
13352 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070013353
13354 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
13355 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
13356 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
13357 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
13358 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
13359 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
13360 tANI_U16 maxRate = 0;
13361 tANI_U16 myRate;
13362 tANI_U16 currentRate = 0;
13363 tANI_U8 maxSpeedMCS = 0;
13364 tANI_U8 maxMCSIdx = 0;
13365 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053013366 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013367 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013368 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013369
Leo Chang6f8870f2013-03-26 18:11:36 -070013370#ifdef WLAN_FEATURE_11AC
13371 tANI_U32 vht_mcs_map;
13372 eDataRate11ACMaxMcs vhtMaxMcs;
13373#endif /* WLAN_FEATURE_11AC */
13374
Jeff Johnsone7245742012-09-05 17:12:55 -070013375 ENTER();
13376
Jeff Johnson295189b2012-06-20 16:38:30 -070013377 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
13378 (0 == ssidlen))
13379 {
13380 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
13381 " Invalid ssidlen, %d", __func__, ssidlen);
13382 /*To keep GUI happy*/
13383 return 0;
13384 }
13385
Mukul Sharma811205f2014-07-09 21:07:30 +053013386 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
13387 {
13388 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13389 "%s: Roaming in progress, so unable to proceed this request", __func__);
13390 return 0;
13391 }
13392
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013393 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013394 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013395 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013396 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013397 }
13398
Jeff Johnson295189b2012-06-20 16:38:30 -070013399
Kiet Lam3b17fc82013-09-27 05:24:08 +053013400 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
13401 sinfo->filled |= STATION_INFO_SIGNAL;
13402
c_hpothu09f19542014-05-30 21:53:31 +053013403 wlan_hdd_get_station_stats(pAdapter);
13404 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
13405
13406 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053013407 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
13408 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053013409 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053013410 {
13411 rate_flags = pAdapter->maxRateFlags;
13412 }
c_hpothu44ff4e02014-05-08 00:13:57 +053013413
Jeff Johnson295189b2012-06-20 16:38:30 -070013414 //convert to the UI units of 100kbps
13415 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
13416
13417#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070013418 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 -070013419 sinfo->signal,
13420 pCfg->reportMaxLinkSpeed,
13421 myRate,
13422 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013423 (int) pCfg->linkSpeedRssiMid,
13424 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070013425 (int) rate_flags,
13426 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013427#endif //LINKSPEED_DEBUG_ENABLED
13428
13429 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
13430 {
13431 // we do not want to necessarily report the current speed
13432 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
13433 {
13434 // report the max possible speed
13435 rssidx = 0;
13436 }
13437 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
13438 {
13439 // report the max possible speed with RSSI scaling
13440 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
13441 {
13442 // report the max possible speed
13443 rssidx = 0;
13444 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013445 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070013446 {
13447 // report middle speed
13448 rssidx = 1;
13449 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013450 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
13451 {
13452 // report middle speed
13453 rssidx = 2;
13454 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013455 else
13456 {
13457 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013458 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070013459 }
13460 }
13461 else
13462 {
13463 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
13464 hddLog(VOS_TRACE_LEVEL_ERROR,
13465 "%s: Invalid value for reportMaxLinkSpeed: %u",
13466 __func__, pCfg->reportMaxLinkSpeed);
13467 rssidx = 0;
13468 }
13469
13470 maxRate = 0;
13471
13472 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013473 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
13474 OperationalRates, &ORLeng))
13475 {
13476 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13477 /*To keep GUI happy*/
13478 return 0;
13479 }
13480
Jeff Johnson295189b2012-06-20 16:38:30 -070013481 for (i = 0; i < ORLeng; i++)
13482 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013483 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013484 {
13485 /* Validate Rate Set */
13486 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
13487 {
13488 currentRate = supported_data_rate[j].supported_rate[rssidx];
13489 break;
13490 }
13491 }
13492 /* Update MAX rate */
13493 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13494 }
13495
13496 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013497 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
13498 ExtendedRates, &ERLeng))
13499 {
13500 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13501 /*To keep GUI happy*/
13502 return 0;
13503 }
13504
Jeff Johnson295189b2012-06-20 16:38:30 -070013505 for (i = 0; i < ERLeng; i++)
13506 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013507 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013508 {
13509 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
13510 {
13511 currentRate = supported_data_rate[j].supported_rate[rssidx];
13512 break;
13513 }
13514 }
13515 /* Update MAX rate */
13516 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13517 }
c_hpothu79aab322014-07-14 21:11:01 +053013518
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013519 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053013520 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013521 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053013522 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070013523 {
c_hpothu79aab322014-07-14 21:11:01 +053013524 if (rate_flags & eHAL_TX_RATE_VHT80)
13525 mode = 2;
13526 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
13527 mode = 1;
13528 else
13529 mode = 0;
13530
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013531 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
13532 MCSRates, &MCSLeng))
13533 {
13534 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13535 /*To keep GUI happy*/
13536 return 0;
13537 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070013539#ifdef WLAN_FEATURE_11AC
13540 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013541 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070013542 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013543 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013544 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070013545 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013547 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013548 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013549 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070013550 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013551 maxMCSIdx = 7;
13552 }
13553 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
13554 {
13555 maxMCSIdx = 8;
13556 }
13557 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
13558 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013559 //VHT20 is supporting 0~8
13560 if (rate_flags & eHAL_TX_RATE_VHT20)
13561 maxMCSIdx = 8;
13562 else
13563 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070013564 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013565
c_hpothu79aab322014-07-14 21:11:01 +053013566 if (0 != rssidx)/*check for scaled */
13567 {
13568 //get middle rate MCS index if rssi=1/2
13569 for (i=0; i <= maxMCSIdx; i++)
13570 {
13571 if (sinfo->signal <= rssiMcsTbl[mode][i])
13572 {
13573 maxMCSIdx = i;
13574 break;
13575 }
13576 }
13577 }
13578
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013579 if (rate_flags & eHAL_TX_RATE_VHT80)
13580 {
13581 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
13582 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
13583 }
13584 else if (rate_flags & eHAL_TX_RATE_VHT40)
13585 {
13586 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
13587 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
13588 }
13589 else if (rate_flags & eHAL_TX_RATE_VHT20)
13590 {
13591 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
13592 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
13593 }
13594
Leo Chang6f8870f2013-03-26 18:11:36 -070013595 maxSpeedMCS = 1;
13596 if (currentRate > maxRate)
13597 {
13598 maxRate = currentRate;
13599 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013600
Leo Chang6f8870f2013-03-26 18:11:36 -070013601 }
13602 else
13603#endif /* WLAN_FEATURE_11AC */
13604 {
13605 if (rate_flags & eHAL_TX_RATE_HT40)
13606 {
13607 rateFlag |= 1;
13608 }
13609 if (rate_flags & eHAL_TX_RATE_SGI)
13610 {
13611 rateFlag |= 2;
13612 }
13613
Girish Gowli01abcee2014-07-31 20:18:55 +053013614 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053013615 if (rssidx == 1 || rssidx == 2)
13616 {
13617 //get middle rate MCS index if rssi=1/2
13618 for (i=0; i <= 7; i++)
13619 {
13620 if (sinfo->signal <= rssiMcsTbl[mode][i])
13621 {
13622 temp = i+1;
13623 break;
13624 }
13625 }
13626 }
c_hpothu79aab322014-07-14 21:11:01 +053013627
13628 for (i = 0; i < MCSLeng; i++)
13629 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013630 for (j = 0; j < temp; j++)
13631 {
13632 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
13633 {
13634 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013635 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013636 break;
13637 }
13638 }
13639 if ((j < temp) && (currentRate > maxRate))
13640 {
13641 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070013642 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013643 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013644 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013645 }
13646 }
13647
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013648 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
13649 {
13650 maxRate = myRate;
13651 maxSpeedMCS = 1;
13652 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13653 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013654 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053013655 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070013656 {
13657 maxRate = myRate;
13658 if (rate_flags & eHAL_TX_RATE_LEGACY)
13659 {
13660 maxSpeedMCS = 0;
13661 }
13662 else
13663 {
13664 maxSpeedMCS = 1;
13665 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13666 }
13667 }
13668
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013669 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070013670 {
13671 sinfo->txrate.legacy = maxRate;
13672#ifdef LINKSPEED_DEBUG_ENABLED
13673 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
13674#endif //LINKSPEED_DEBUG_ENABLED
13675 }
13676 else
13677 {
13678 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070013679#ifdef WLAN_FEATURE_11AC
13680 sinfo->txrate.nss = 1;
13681 if (rate_flags & eHAL_TX_RATE_VHT80)
13682 {
13683 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013684 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070013685 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013686 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070013687 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013688 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13689 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13690 }
13691 else if (rate_flags & eHAL_TX_RATE_VHT20)
13692 {
13693 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13694 }
13695#endif /* WLAN_FEATURE_11AC */
13696 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
13697 {
13698 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13699 if (rate_flags & eHAL_TX_RATE_HT40)
13700 {
13701 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13702 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013703 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013704 if (rate_flags & eHAL_TX_RATE_SGI)
13705 {
13706 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13707 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013708
Jeff Johnson295189b2012-06-20 16:38:30 -070013709#ifdef LINKSPEED_DEBUG_ENABLED
13710 pr_info("Reporting MCS rate %d flags %x\n",
13711 sinfo->txrate.mcs,
13712 sinfo->txrate.flags );
13713#endif //LINKSPEED_DEBUG_ENABLED
13714 }
13715 }
13716 else
13717 {
13718 // report current rate instead of max rate
13719
13720 if (rate_flags & eHAL_TX_RATE_LEGACY)
13721 {
13722 //provide to the UI in units of 100kbps
13723 sinfo->txrate.legacy = myRate;
13724#ifdef LINKSPEED_DEBUG_ENABLED
13725 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
13726#endif //LINKSPEED_DEBUG_ENABLED
13727 }
13728 else
13729 {
13730 //must be MCS
13731 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013732#ifdef WLAN_FEATURE_11AC
13733 sinfo->txrate.nss = 1;
13734 if (rate_flags & eHAL_TX_RATE_VHT80)
13735 {
13736 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13737 }
13738 else
13739#endif /* WLAN_FEATURE_11AC */
13740 {
13741 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13742 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013743 if (rate_flags & eHAL_TX_RATE_SGI)
13744 {
13745 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13746 }
13747 if (rate_flags & eHAL_TX_RATE_HT40)
13748 {
13749 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13750 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013751#ifdef WLAN_FEATURE_11AC
13752 else if (rate_flags & eHAL_TX_RATE_VHT80)
13753 {
13754 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
13755 }
13756#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070013757#ifdef LINKSPEED_DEBUG_ENABLED
13758 pr_info("Reporting actual MCS rate %d flags %x\n",
13759 sinfo->txrate.mcs,
13760 sinfo->txrate.flags );
13761#endif //LINKSPEED_DEBUG_ENABLED
13762 }
13763 }
13764 sinfo->filled |= STATION_INFO_TX_BITRATE;
13765
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013766 sinfo->tx_packets =
13767 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
13768 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
13769 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
13770 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
13771
13772 sinfo->tx_retries =
13773 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
13774 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
13775 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
13776 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
13777
13778 sinfo->tx_failed =
13779 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
13780 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
13781 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
13782 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
13783
13784 sinfo->filled |=
13785 STATION_INFO_TX_PACKETS |
13786 STATION_INFO_TX_RETRIES |
13787 STATION_INFO_TX_FAILED;
13788
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013789 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13790 TRACE_CODE_HDD_CFG80211_GET_STA,
13791 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013792 EXIT();
13793 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013794}
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013795#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
13796static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13797 const u8* mac, struct station_info *sinfo)
13798#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013799static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13800 u8* mac, struct station_info *sinfo)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053013801#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013802{
13803 int ret;
13804
13805 vos_ssr_protect(__func__);
13806 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
13807 vos_ssr_unprotect(__func__);
13808
13809 return ret;
13810}
13811
13812static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070013813 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070013814{
13815 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013816 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013817 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013818 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013819
Jeff Johnsone7245742012-09-05 17:12:55 -070013820 ENTER();
13821
Jeff Johnson295189b2012-06-20 16:38:30 -070013822 if (NULL == pAdapter)
13823 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013824 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013825 return -ENODEV;
13826 }
13827
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013828 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13829 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
13830 pAdapter->sessionId, timeout));
13831
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013832 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013833 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013834 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013835 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013836 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013837 }
13838
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013839 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
13840 (TRUE == pHddCtx->hdd_wlan_suspended) &&
13841 (pHddCtx->cfg_ini->fhostArpOffload) &&
13842 (eConnectionState_Associated ==
13843 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13844 {
Amar Singhald53568e2013-09-26 11:03:45 -070013845
13846 hddLog(VOS_TRACE_LEVEL_INFO,
13847 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053013848 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013849 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13850 {
13851 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013852 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013853 __func__, vos_status);
13854 }
13855 }
13856
Jeff Johnson295189b2012-06-20 16:38:30 -070013857 /**The get power cmd from the supplicant gets updated by the nl only
13858 *on successful execution of the function call
13859 *we are oppositely mapped w.r.t mode in the driver
13860 **/
13861 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
13862
13863 if (VOS_STATUS_E_FAILURE == vos_status)
13864 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013865 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13866 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013867 return -EINVAL;
13868 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013869 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013870 return 0;
13871}
13872
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013873static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
13874 struct net_device *dev, bool mode, int timeout)
13875{
13876 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013877
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013878 vos_ssr_protect(__func__);
13879 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
13880 vos_ssr_unprotect(__func__);
13881
13882 return ret;
13883}
Jeff Johnson295189b2012-06-20 16:38:30 -070013884#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013885static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
13886 struct net_device *netdev,
13887 u8 key_index)
13888{
13889 ENTER();
13890 return 0;
13891}
13892
Jeff Johnson295189b2012-06-20 16:38:30 -070013893static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013894 struct net_device *netdev,
13895 u8 key_index)
13896{
13897 int ret;
13898 vos_ssr_protect(__func__);
13899 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
13900 vos_ssr_unprotect(__func__);
13901 return ret;
13902}
13903#endif //LINUX_VERSION_CODE
13904
13905#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13906static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13907 struct net_device *dev,
13908 struct ieee80211_txq_params *params)
13909{
13910 ENTER();
13911 return 0;
13912}
13913#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13914static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13915 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013916{
Jeff Johnsone7245742012-09-05 17:12:55 -070013917 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 return 0;
13919}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013920#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070013921
13922#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13923static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013924 struct net_device *dev,
13925 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013926{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013927 int ret;
13928
13929 vos_ssr_protect(__func__);
13930 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
13931 vos_ssr_unprotect(__func__);
13932 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013933}
13934#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13935static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
13936 struct ieee80211_txq_params *params)
13937{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013938 int ret;
13939
13940 vos_ssr_protect(__func__);
13941 ret = __wlan_hdd_set_txq_params(wiphy, params);
13942 vos_ssr_unprotect(__func__);
13943 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013944}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013945#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013946
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013947static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013948 struct net_device *dev,
13949 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070013950{
13951 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013952 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013953 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013954 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013955 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013956 v_CONTEXT_t pVosContext = NULL;
13957 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013958
Jeff Johnsone7245742012-09-05 17:12:55 -070013959 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013960
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013961 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070013962 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013963 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013964 return -EINVAL;
13965 }
13966
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013967 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13968 TRACE_CODE_HDD_CFG80211_DEL_STA,
13969 pAdapter->sessionId, pAdapter->device_mode));
13970
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013971 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13972 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013973 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013974 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013975 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013976 }
13977
Jeff Johnson295189b2012-06-20 16:38:30 -070013978 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013979 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013980 )
13981 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013982 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13983 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13984 if(pSapCtx == NULL){
13985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13986 FL("psapCtx is NULL"));
13987 return -ENOENT;
13988 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013989 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070013990 {
13991 v_U16_t i;
13992 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
13993 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013994 if ((pSapCtx->aStaInfo[i].isUsed) &&
13995 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070013996 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013997 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013998 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013999 ETHER_ADDR_LEN);
14000
Jeff Johnson295189b2012-06-20 16:38:30 -070014001 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080014002 "%s: Delete STA with MAC::"
14003 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014004 __func__,
14005 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
14006 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070014007 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014008 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014009 }
14010 }
14011 }
14012 else
14013 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014014
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014015 vos_status = hdd_softap_GetStaId(pAdapter,
14016 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014017 if (!VOS_IS_STATUS_SUCCESS(vos_status))
14018 {
14019 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080014020 "%s: Skip this DEL STA as this is not used::"
14021 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014022 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014023 return -ENOENT;
14024 }
14025
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014026 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014027 {
14028 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080014029 "%s: Skip this DEL STA as deauth is in progress::"
14030 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014031 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014032 return -ENOENT;
14033 }
14034
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014035 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014036
Jeff Johnson295189b2012-06-20 16:38:30 -070014037 hddLog(VOS_TRACE_LEVEL_INFO,
14038 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080014039 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070014040 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014041 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014042
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014043 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014044 if (!VOS_IS_STATUS_SUCCESS(vos_status))
14045 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053014046 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014047 hddLog(VOS_TRACE_LEVEL_INFO,
14048 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080014049 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014050 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014051 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080014052 return -ENOENT;
14053 }
14054
Jeff Johnson295189b2012-06-20 16:38:30 -070014055 }
14056 }
14057
14058 EXIT();
14059
14060 return 0;
14061}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014062
14063#ifdef CFG80211_DEL_STA_V2
14064static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14065 struct net_device *dev,
14066 struct station_del_parameters *param)
14067#else
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014068#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
14069static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14070 struct net_device *dev, const u8 *mac)
14071#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014072static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
14073 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014074#endif
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014075#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014076{
14077 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014078 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070014079
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014080 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014081
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014082#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014083 if (NULL == param) {
14084 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014085 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014086 return -EINVAL;
14087 }
14088
14089 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
14090 param->subtype, &delStaParams);
14091
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014092#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053014093 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014094 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053014095#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053014096 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
14097
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014098 vos_ssr_unprotect(__func__);
14099
14100 return ret;
14101}
14102
14103static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014104 struct net_device *dev,
14105#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
14106 const u8 *mac,
14107#else
14108 u8 *mac,
14109#endif
14110 struct station_parameters *params)
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014111{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014112 hdd_adapter_t *pAdapter;
14113 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014114 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014115#ifdef FEATURE_WLAN_TDLS
14116 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014117
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014118 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014119
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014120 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14121 if (NULL == pAdapter)
14122 {
14123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14124 "%s: Adapter is NULL",__func__);
14125 return -EINVAL;
14126 }
14127 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14128 status = wlan_hdd_validate_context(pHddCtx);
14129 if (0 != status)
14130 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014131 return status;
14132 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014133
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014134 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14135 TRACE_CODE_HDD_CFG80211_ADD_STA,
14136 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014137 mask = params->sta_flags_mask;
14138
14139 set = params->sta_flags_set;
14140
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014141 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014142 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
14143 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014144
14145 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
14146 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080014147 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014148 }
14149 }
14150#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014151 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014152 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014153}
14154
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014155#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
14156static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
14157 struct net_device *dev, const u8 *mac,
14158 struct station_parameters *params)
14159#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014160static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
14161 struct net_device *dev, u8 *mac, struct station_parameters *params)
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053014162#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014163{
14164 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014165
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014166 vos_ssr_protect(__func__);
14167 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
14168 vos_ssr_unprotect(__func__);
14169
14170 return ret;
14171}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014172#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070014173
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014174static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070014175 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014176{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014177 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14178 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014179 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014180 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014181 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014182 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070014183
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014184 ENTER();
14185
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014186 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014187 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014188 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014189 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014190 return -EINVAL;
14191 }
14192
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014193 if (!pmksa) {
14194 hddLog(LOGE, FL("pmksa is NULL"));
14195 return -EINVAL;
14196 }
14197
14198 if (!pmksa->bssid || !pmksa->pmkid) {
14199 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
14200 pmksa->bssid, pmksa->pmkid);
14201 return -EINVAL;
14202 }
14203
14204 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
14205 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14206
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014207 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14208 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014209 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014210 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053014211 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014212 }
14213
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014214 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014215 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14216
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014217 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
14218 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014219
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014220 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014221 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014222 &pmk_id, 1, FALSE);
14223
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014224 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14225 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
14226 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014227
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014228 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014229 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014230}
14231
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014232static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
14233 struct cfg80211_pmksa *pmksa)
14234{
14235 int ret;
14236
14237 vos_ssr_protect(__func__);
14238 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
14239 vos_ssr_unprotect(__func__);
14240
14241 return ret;
14242}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014243
Wilson Yang6507c4e2013-10-01 20:11:19 -070014244
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014245static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070014246 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014247{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014248 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14249 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014250 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014251 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014252
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014253 ENTER();
14254
Wilson Yang6507c4e2013-10-01 20:11:19 -070014255 /* Validate pAdapter */
14256 if (NULL == pAdapter)
14257 {
14258 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
14259 return -EINVAL;
14260 }
14261
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014262 if (!pmksa) {
14263 hddLog(LOGE, FL("pmksa is NULL"));
14264 return -EINVAL;
14265 }
14266
14267 if (!pmksa->bssid) {
14268 hddLog(LOGE, FL("pmksa->bssid is NULL"));
14269 return -EINVAL;
14270 }
14271
Kiet Lam98c46a12014-10-31 15:34:57 -070014272 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
14273 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
14274
Wilson Yang6507c4e2013-10-01 20:11:19 -070014275 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14276 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014277 if (0 != status)
14278 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014279 return status;
14280 }
14281
14282 /*Retrieve halHandle*/
14283 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14284
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014285 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14286 TRACE_CODE_HDD_CFG80211_DEL_PMKSA,
14287 pAdapter->sessionId, 0));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014288 /* Delete the PMKID CSR cache */
14289 if (eHAL_STATUS_SUCCESS !=
14290 sme_RoamDelPMKIDfromCache(halHandle,
14291 pAdapter->sessionId, pmksa->bssid, FALSE)) {
14292 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
14293 MAC_ADDR_ARRAY(pmksa->bssid));
14294 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014295 }
14296
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014297 EXIT();
14298 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014299}
14300
Wilson Yang6507c4e2013-10-01 20:11:19 -070014301
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014302static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
14303 struct cfg80211_pmksa *pmksa)
14304{
14305 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014306
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014307 vos_ssr_protect(__func__);
14308 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
14309 vos_ssr_unprotect(__func__);
14310
14311 return ret;
14312
14313}
14314
14315static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014316{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014317 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14318 tHalHandle halHandle;
14319 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014320 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014321
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014322 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070014323
14324 /* Validate pAdapter */
14325 if (NULL == pAdapter)
14326 {
14327 hddLog(VOS_TRACE_LEVEL_ERROR,
14328 "%s: Invalid Adapter" ,__func__);
14329 return -EINVAL;
14330 }
14331
14332 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14333 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014334 if (0 != status)
14335 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014336 return status;
14337 }
14338
14339 /*Retrieve halHandle*/
14340 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14341
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014342 /* Flush the PMKID cache in CSR */
14343 if (eHAL_STATUS_SUCCESS !=
14344 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
14345 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
14346 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014347 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014348 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080014349 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014350}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014351
14352static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
14353{
14354 int ret;
14355
14356 vos_ssr_protect(__func__);
14357 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
14358 vos_ssr_unprotect(__func__);
14359
14360 return ret;
14361}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014362#endif
14363
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014364#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014365static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14366 struct net_device *dev,
14367 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014368{
14369 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14370 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014371 hdd_context_t *pHddCtx;
14372 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014373
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014374 ENTER();
14375
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014376 if (NULL == pAdapter)
14377 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014378 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014379 return -ENODEV;
14380 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014381 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14382 ret = wlan_hdd_validate_context(pHddCtx);
14383 if (0 != ret)
14384 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014385 return ret;
14386 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014387 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014388 if (NULL == pHddStaCtx)
14389 {
14390 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
14391 return -EINVAL;
14392 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014393
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014394 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14395 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
14396 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014397 // Added for debug on reception of Re-assoc Req.
14398 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
14399 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014400 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014401 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080014402 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014403 }
14404
14405#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080014406 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014407 ftie->ie_len);
14408#endif
14409
14410 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014411 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14412 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014413 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014414
14415 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014416 return 0;
14417}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014418
14419static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14420 struct net_device *dev,
14421 struct cfg80211_update_ft_ies_params *ftie)
14422{
14423 int ret;
14424
14425 vos_ssr_protect(__func__);
14426 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
14427 vos_ssr_unprotect(__func__);
14428
14429 return ret;
14430}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014431#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014432
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014433#ifdef FEATURE_WLAN_SCAN_PNO
14434
14435void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
14436 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
14437{
14438 int ret;
14439 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
14440 hdd_context_t *pHddCtx;
14441
Nirav Shah80830bf2013-12-31 16:35:12 +053014442 ENTER();
14443
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014444 if (NULL == pAdapter)
14445 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014446 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014447 "%s: HDD adapter is Null", __func__);
14448 return ;
14449 }
14450
14451 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14452 if (NULL == pHddCtx)
14453 {
14454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14455 "%s: HDD context is Null!!!", __func__);
14456 return ;
14457 }
14458
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014459 spin_lock(&pHddCtx->schedScan_lock);
14460 if (TRUE == pHddCtx->isWiphySuspended)
14461 {
14462 pHddCtx->isSchedScanUpdatePending = TRUE;
14463 spin_unlock(&pHddCtx->schedScan_lock);
14464 hddLog(VOS_TRACE_LEVEL_INFO,
14465 "%s: Update cfg80211 scan database after it resume", __func__);
14466 return ;
14467 }
14468 spin_unlock(&pHddCtx->schedScan_lock);
14469
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014470 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
14471
14472 if (0 > ret)
14473 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
14474
14475 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14477 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014478}
14479
14480/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014481 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014482 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014483 */
14484static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
14485{
14486 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
14487 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014488 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014489 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14490 int status = 0;
14491 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
14492
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014493 /* The current firmware design does not allow PNO during any
14494 * active sessions. Hence, determine the active sessions
14495 * and return a failure.
14496 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014497 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
14498 {
14499 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014500 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014501
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014502 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
14503 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
14504 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
14505 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
14506 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053014507 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014508 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014509 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014510 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014511 }
14512 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14513 pAdapterNode = pNext;
14514 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014515 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014516}
14517
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014518void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
14519{
14520 hdd_adapter_t *pAdapter = callbackContext;
14521 hdd_context_t *pHddCtx;
14522
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014523 ENTER();
14524
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014525 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
14526 {
14527 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14528 FL("Invalid adapter or adapter has invalid magic"));
14529 return;
14530 }
14531
14532 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14533 if (0 != wlan_hdd_validate_context(pHddCtx))
14534 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014535 return;
14536 }
14537
c_hpothub53c45d2014-08-18 16:53:14 +053014538 if (VOS_STATUS_SUCCESS != status)
14539 {
14540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014541 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053014542 pHddCtx->isPnoEnable = FALSE;
14543 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014544
14545 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
14546 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014547 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014548}
14549
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014550/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014551 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
14552 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014553 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014554static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014555 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14556{
14557 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014558 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014559 hdd_context_t *pHddCtx;
14560 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014561 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053014562 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
14563 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014564 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14565 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014566 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014567 hdd_config_t *pConfig = NULL;
14568 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014569
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014570 ENTER();
14571
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014572 if (NULL == pAdapter)
14573 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014575 "%s: HDD adapter is Null", __func__);
14576 return -ENODEV;
14577 }
14578
14579 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014580 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014581
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014582 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014583 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014584 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014585 }
14586
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014587 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014588 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14589 if (NULL == hHal)
14590 {
14591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14592 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014593 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014594 }
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014595 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14596 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_START,
14597 pAdapter->sessionId, pAdapter->device_mode));
Sushant Kaushik2fe89932014-09-03 10:58:09 +053014598 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014599 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053014600 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014601 {
14602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14603 "%s: aborting the existing scan is unsuccessfull", __func__);
14604 return -EBUSY;
14605 }
14606
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014607 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014608 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014610 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014611 return -EBUSY;
14612 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014613
c_hpothu37f21312014-04-09 21:49:54 +053014614 if (TRUE == pHddCtx->isPnoEnable)
14615 {
14616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14617 FL("already PNO is enabled"));
14618 return -EBUSY;
14619 }
c_hpothu225aa7c2014-10-22 17:45:13 +053014620
14621 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
14622 {
14623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14624 "%s: abort ROC failed ", __func__);
14625 return -EBUSY;
14626 }
14627
c_hpothu37f21312014-04-09 21:49:54 +053014628 pHddCtx->isPnoEnable = TRUE;
14629
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014630 pnoRequest.enable = 1; /*Enable PNO */
14631 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014632
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014633 if (( !pnoRequest.ucNetworksCount ) ||
14634 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014635 {
14636 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014637 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014638 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014639 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014640 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014641 goto error;
14642 }
14643
14644 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
14645 {
14646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014647 "%s: Incorrect number of channels %d",
14648 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014649 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014650 goto error;
14651 }
14652
14653 /* Framework provides one set of channels(all)
14654 * common for all saved profile */
14655 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14656 channels_allowed, &num_channels_allowed))
14657 {
14658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14659 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014660 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014661 goto error;
14662 }
14663 /* Checking each channel against allowed channel list */
14664 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053014665 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014666 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014667 char chList [(request->n_channels*5)+1];
14668 int len;
14669 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014670 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014671 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014672 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014673 if (request->channels[i]->hw_value == channels_allowed[indx])
14674 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014675 if ((!pConfig->enableDFSPnoChnlScan) &&
14676 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
14677 {
14678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14679 "%s : Dropping DFS channel : %d",
14680 __func__,channels_allowed[indx]);
14681 num_ignore_dfs_ch++;
14682 break;
14683 }
14684
Nirav Shah80830bf2013-12-31 16:35:12 +053014685 valid_ch[num_ch++] = request->channels[i]->hw_value;
14686 len += snprintf(chList+len, 5, "%d ",
14687 request->channels[i]->hw_value);
14688 break ;
14689 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014690 }
14691 }
Nirav Shah80830bf2013-12-31 16:35:12 +053014692 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014693
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014694 /*If all channels are DFS and dropped, then ignore the PNO request*/
14695 if (num_ignore_dfs_ch == request->n_channels)
14696 {
14697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14698 "%s : All requested channels are DFS channels", __func__);
14699 ret = -EINVAL;
14700 goto error;
14701 }
14702 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014703
14704 pnoRequest.aNetworks =
14705 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14706 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014707 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014708 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14709 FL("failed to allocate memory aNetworks %u"),
14710 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14711 goto error;
14712 }
14713 vos_mem_zero(pnoRequest.aNetworks,
14714 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14715
14716 /* Filling per profile params */
14717 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
14718 {
14719 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014720 request->match_sets[i].ssid.ssid_len;
14721
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014722 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
14723 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014724 {
14725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014726 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014727 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014728 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014729 goto error;
14730 }
14731
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014732 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014733 request->match_sets[i].ssid.ssid,
14734 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14736 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014737 i, pnoRequest.aNetworks[i].ssId.ssId);
14738 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
14739 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
14740 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014741
14742 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014743 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
14744 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014745
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014746 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014747 }
14748
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014749 for (i = 0; i < request->n_ssids; i++)
14750 {
14751 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014752 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014753 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014754 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014755 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014756 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014757 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014758 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014759 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014760 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014761 break;
14762 }
14763 j++;
14764 }
14765 }
14766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14767 "Number of hidden networks being Configured = %d",
14768 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014769 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080014770 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014771
14772 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14773 if (pnoRequest.p24GProbeTemplate == NULL)
14774 {
14775 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14776 FL("failed to allocate memory p24GProbeTemplate %u"),
14777 SIR_PNO_MAX_PB_REQ_SIZE);
14778 goto error;
14779 }
14780
14781 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14782 if (pnoRequest.p5GProbeTemplate == NULL)
14783 {
14784 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14785 FL("failed to allocate memory p5GProbeTemplate %u"),
14786 SIR_PNO_MAX_PB_REQ_SIZE);
14787 goto error;
14788 }
14789
14790 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14791 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14792
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053014793 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
14794 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014795 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014796 pnoRequest.us24GProbeTemplateLen = request->ie_len;
14797 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
14798 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014799
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014800 pnoRequest.us5GProbeTemplateLen = request->ie_len;
14801 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
14802 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014803 }
14804
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014805 /* Driver gets only one time interval which is hardcoded in
14806 * supplicant for 10000ms. Taking power consumption into account 6 timers
14807 * will be used, Timervalue is increased exponentially i.e 10,20,40,
14808 * 80,160,320 secs. And number of scan cycle for each timer
14809 * is configurable through INI param gPNOScanTimerRepeatValue.
14810 * If it is set to 0 only one timer will be used and PNO scan cycle
14811 * will be repeated after each interval specified by supplicant
14812 * till PNO is disabled.
14813 */
14814 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014815 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014816 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014817 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014818 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
14819
14820 tempInterval = (request->interval)/1000;
14821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14822 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
14823 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014824 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014825 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014826 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014827 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014828 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014829 tempInterval *= 2;
14830 }
14831 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014832 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014833
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014834 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014835
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014836 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014837 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
14838 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014839 pAdapter->pno_req_status = 0;
14840
Nirav Shah80830bf2013-12-31 16:35:12 +053014841 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14842 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014843 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
14844 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053014845
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014846 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014847 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014848 hdd_cfg80211_sched_scan_done_callback, pAdapter);
14849 if (eHAL_STATUS_SUCCESS != status)
14850 {
14851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014852 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014853 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014854 goto error;
14855 }
14856
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014857 ret = wait_for_completion_timeout(
14858 &pAdapter->pno_comp_var,
14859 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
14860 if (0 >= ret)
14861 {
14862 // Did not receive the response for PNO enable in time.
14863 // Assuming the PNO enable was success.
14864 // Returning error from here, because we timeout, results
14865 // in side effect of Wifi (Wifi Setting) not to work.
14866 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14867 FL("Timed out waiting for PNO to be Enabled"));
14868 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014869 }
14870
14871 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053014872 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014873
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014874error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14876 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053014877 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014878 if (pnoRequest.aNetworks)
14879 vos_mem_free(pnoRequest.aNetworks);
14880 if (pnoRequest.p24GProbeTemplate)
14881 vos_mem_free(pnoRequest.p24GProbeTemplate);
14882 if (pnoRequest.p5GProbeTemplate)
14883 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014884
14885 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014886 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014887}
14888
14889/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014890 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
14891 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014892 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014893static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
14894 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14895{
14896 int ret;
14897
14898 vos_ssr_protect(__func__);
14899 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
14900 vos_ssr_unprotect(__func__);
14901
14902 return ret;
14903}
14904
14905/*
14906 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
14907 * Function to disable PNO
14908 */
14909static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014910 struct net_device *dev)
14911{
14912 eHalStatus status = eHAL_STATUS_FAILURE;
14913 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14914 hdd_context_t *pHddCtx;
14915 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014916 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014917 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014918
14919 ENTER();
14920
14921 if (NULL == pAdapter)
14922 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014924 "%s: HDD adapter is Null", __func__);
14925 return -ENODEV;
14926 }
14927
14928 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014929
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014930 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014931 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014932 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014933 "%s: HDD context is Null", __func__);
14934 return -ENODEV;
14935 }
14936
14937 /* The return 0 is intentional when isLogpInProgress and
14938 * isLoadUnloadInProgress. We did observe a crash due to a return of
14939 * failure in sched_scan_stop , especially for a case where the unload
14940 * of the happens at the same time. The function __cfg80211_stop_sched_scan
14941 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
14942 * success. If it returns a failure , then its next invocation due to the
14943 * clean up of the second interface will have the dev pointer corresponding
14944 * to the first one leading to a crash.
14945 */
14946 if (pHddCtx->isLogpInProgress)
14947 {
14948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14949 "%s: LOGP in Progress. Ignore!!!", __func__);
14950 return ret;
14951 }
14952
Mihir Shete18156292014-03-11 15:38:30 +053014953 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014954 {
14955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14956 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14957 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014958 }
14959
14960 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14961 if (NULL == hHal)
14962 {
14963 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14964 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014965 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014966 }
14967
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014968 pnoRequest.enable = 0; /* Disable PNO */
14969 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014970
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053014971 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14972 TRACE_CODE_HDD_CFG80211_SCHED_SCAN_STOP,
14973 pAdapter->sessionId, pAdapter->device_mode));
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014974 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014975 pAdapter->sessionId,
14976 NULL, pAdapter);
14977 if (eHAL_STATUS_SUCCESS != status)
14978 {
14979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14980 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014981 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014982 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014983 }
c_hpothu37f21312014-04-09 21:49:54 +053014984 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014985
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014986error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014987 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014988 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014989
14990 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014991 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014992}
14993
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014994/*
14995 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
14996 * NL interface to disable PNO
14997 */
14998static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
14999 struct net_device *dev)
15000{
15001 int ret;
15002
15003 vos_ssr_protect(__func__);
15004 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
15005 vos_ssr_unprotect(__func__);
15006
15007 return ret;
15008}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053015009#endif /*FEATURE_WLAN_SCAN_PNO*/
15010
15011
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015012#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015013#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015014static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15015 struct net_device *dev,
15016 u8 *peer, u8 action_code,
15017 u8 dialog_token,
15018 u16 status_code, u32 peer_capability,
15019 const u8 *buf, size_t len)
15020#else /* TDLS_MGMT_VERSION2 */
15021#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
15022static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15023 struct net_device *dev,
15024 const u8 *peer, u8 action_code,
15025 u8 dialog_token, u16 status_code,
15026 u32 peer_capability, bool initiator,
15027 const u8 *buf, size_t len)
15028#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
15029static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15030 struct net_device *dev,
15031 const u8 *peer, u8 action_code,
15032 u8 dialog_token, u16 status_code,
15033 u32 peer_capability, const u8 *buf,
15034 size_t len)
15035#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
15036static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15037 struct net_device *dev,
15038 u8 *peer, u8 action_code,
15039 u8 dialog_token,
15040 u16 status_code, u32 peer_capability,
15041 const u8 *buf, size_t len)
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015042#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015043static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15044 struct net_device *dev,
15045 u8 *peer, u8 action_code,
15046 u8 dialog_token,
15047 u16 status_code, const u8 *buf,
15048 size_t len)
15049#endif
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015050#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015051{
15052
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015053 hdd_adapter_t *pAdapter;
15054 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015055 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070015056 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080015057 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070015058 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015059 int ret;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015060#if !(TDLS_MGMT_VERSION2) && (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015061 u32 peer_capability = 0;
15062#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015063 tANI_U16 numCurrTdlsPeers;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015064
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015065 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15066 if (NULL == pAdapter)
15067 {
15068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15069 "%s: Adapter is NULL",__func__);
15070 return -EINVAL;
15071 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015072 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15073 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
15074 pAdapter->sessionId, action_code));
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015075 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015076 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015077 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053015078 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015079 "Invalid arguments");
15080 return -EINVAL;
15081 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015082 if (pHddCtx->isLogpInProgress)
15083 {
15084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15085 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053015086 wlan_hdd_tdls_set_link_status(pAdapter,
15087 peer,
15088 eTDLS_LINK_IDLE,
15089 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015090 return -EBUSY;
15091 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053015092 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
15093 {
15094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15095 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
15096 return -EAGAIN;
15097 }
Hoonki Lee27511902013-03-14 18:19:06 -070015098 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015099 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015100 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070015101 "%s: TDLS mode is disabled OR not enabled in FW."
15102 MAC_ADDRESS_STR " action %d declined.",
15103 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015104 return -ENOTSUPP;
15105 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015106
Hoonki Lee27511902013-03-14 18:19:06 -070015107 /* other than teardown frame, other mgmt frames are not sent if disabled */
15108 if (SIR_MAC_TDLS_TEARDOWN != action_code)
15109 {
15110 /* if tdls_mode is disabled to respond to peer's request */
15111 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
15112 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015113 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070015114 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015115 " TDLS mode is disabled. action %d declined.",
15116 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070015117
15118 return -ENOTSUPP;
15119 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053015120
15121 if (vos_max_concurrent_connections_reached())
15122 {
15123 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
15124 return -EINVAL;
15125 }
Hoonki Lee27511902013-03-14 18:19:06 -070015126 }
15127
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015128 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
15129 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053015130 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015131 {
15132 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015133 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015134 " TDLS setup is ongoing. action %d declined.",
15135 __func__, MAC_ADDR_ARRAY(peer), action_code);
15136 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015137 }
15138 }
15139
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015140 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
15141 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080015142 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015143 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15144 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080015145 {
15146 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
15147 we return error code at 'add_station()'. Hence we have this
15148 check again in addtion to add_station().
15149 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015150 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080015151 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015152 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15153 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015154 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
15155 __func__, MAC_ADDR_ARRAY(peer), action_code,
15156 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053015157 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080015158 }
15159 else
15160 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015161 /* maximum reached. tweak to send error code to peer and return
15162 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080015163 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015164 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15165 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053015166 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
15167 __func__, MAC_ADDR_ARRAY(peer), status_code,
15168 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070015169 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015170 /* fall through to send setup resp with failure status
15171 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080015172 }
15173 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015174 else
15175 {
15176 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053015177 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015178 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015179 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015180 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070015181 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
15182 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015183 return -EPERM;
15184 }
15185 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015186 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015187
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015188 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053015189 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015190 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
15191 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015192
Hoonki Leea34dd892013-02-05 22:56:02 -080015193 /*Except teardown responder will not be used so just make 0*/
15194 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080015195 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080015196 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015197
15198 hddTdlsPeer_t *pTdlsPeer;
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015199 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015200
15201 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
15202 responder = pTdlsPeer->is_responder;
15203 else
Hoonki Leea34dd892013-02-05 22:56:02 -080015204 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070015205 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053015206 "%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 -070015207 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
15208 dialog_token, status_code, len);
15209 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080015210 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015211 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015212
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015213 /* For explicit trigger of DIS_REQ come out of BMPS for
15214 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070015215 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015216 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
15217 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070015218 {
15219 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
15220 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053015221 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053015222 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015223 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
15224 if (status != VOS_STATUS_SUCCESS) {
15225 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
15226 }
Hoonki Lee14621352013-04-16 17:51:19 -070015227 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015228 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015229 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peer, eTDLS_CAP_SUPPORTED)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015230 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
15231 }
15232 }
Hoonki Lee14621352013-04-16 17:51:19 -070015233 }
15234
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015235 /* make sure doesn't call send_mgmt() while it is pending */
15236 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
15237 {
15238 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080015239 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015240 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015241 ret = -EBUSY;
15242 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015243 }
15244
15245 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015246 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
15247
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015248 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015249 peer, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015250
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015251 if (VOS_STATUS_SUCCESS != status)
15252 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15254 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015255 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015256 ret = -EINVAL;
15257 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015258 }
15259
Hoonki Leed37cbb32013-04-20 00:31:14 -070015260 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
15261 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
15262
15263 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015264 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070015265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070015266 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070015267 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015268 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080015269
15270 if (pHddCtx->isLogpInProgress)
15271 {
15272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15273 "%s: LOGP in Progress. Ignore!!!", __func__);
15274 return -EAGAIN;
15275 }
15276
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015277 ret = -EINVAL;
15278 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015279 }
15280
Gopichand Nakkala05922802013-03-14 12:23:19 -070015281 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070015282 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015283 ret = max_sta_failed;
15284 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070015285 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015286
Hoonki Leea34dd892013-02-05 22:56:02 -080015287 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
15288 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015289 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, TRUE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015290 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15291 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015292 }
15293 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
15294 {
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015295 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peer, FALSE)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015296 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
15297 }
Hoonki Leea34dd892013-02-05 22:56:02 -080015298 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015299
15300 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053015301
15302tx_failed:
15303 /* add_station will be called before sending TDLS_SETUP_REQ and
15304 * TDLS_SETUP_RSP and as part of add_station driver will enable
15305 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
15306 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
15307 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
15308 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
15309 */
15310
15311 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
15312 (SIR_MAC_TDLS_SETUP_RSP == action_code))
15313 wlan_hdd_tdls_check_bmps(pAdapter);
15314 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015315}
15316
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015317#if TDLS_MGMT_VERSION2
15318static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15319 u8 *peer, u8 action_code, u8 dialog_token,
15320 u16 status_code, u32 peer_capability,
15321 const u8 *buf, size_t len)
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015322#else /* TDLS_MGMT_VERSION2 */
15323#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
15324static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15325 struct net_device *dev,
15326 const u8 *peer, u8 action_code,
15327 u8 dialog_token, u16 status_code,
15328 u32 peer_capability, bool initiator,
15329 const u8 *buf, size_t len)
15330#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
15331static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15332 struct net_device *dev,
15333 const u8 *peer, u8 action_code,
15334 u8 dialog_token, u16 status_code,
15335 u32 peer_capability, const u8 *buf,
15336 size_t len)
15337#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
15338static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
15339 struct net_device *dev,
15340 u8 *peer, u8 action_code,
15341 u8 dialog_token,
15342 u16 status_code, u32 peer_capability,
15343 const u8 *buf, size_t len)
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015344#else
15345static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
15346 u8 *peer, u8 action_code, u8 dialog_token,
15347 u16 status_code, const u8 *buf, size_t len)
15348#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015349#endif
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015350{
15351 int ret;
15352
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015353 vos_ssr_protect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015354#if TDLS_MGMT_VERSION2
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015355 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15356 dialog_token, status_code,
15357 peer_capability, buf, len);
15358#else /* TDLS_MGMT_VERSION2 */
15359#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS)
15360 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15361 dialog_token, status_code,
15362 peer_capability, initiator,
15363 buf, len);
15364#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
15365 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15366 dialog_token, status_code,
15367 peer_capability, buf, len);
15368#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
15369 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15370 dialog_token, status_code,
15371 peer_capability, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015372#else
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015373 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code,
15374 dialog_token, status_code, buf, len);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015375#endif
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015376#endif
15377 vos_ssr_unprotect(__func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015378
Anand N Sunkad9f80b742015-07-30 20:05:51 +053015379 return ret;
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015380}
Atul Mittal115287b2014-07-08 13:26:33 +053015381
15382int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015383#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15384 const u8 *peer,
15385#else
Atul Mittal115287b2014-07-08 13:26:33 +053015386 u8 *peer,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015387#endif
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015388 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053015389 cfg80211_exttdls_callback callback)
15390{
15391
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015392 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053015393 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015394 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053015395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15396 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
15397 __func__, MAC_ADDR_ARRAY(peer));
15398
15399 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15400 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15401
15402 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015403 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15404 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15405 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015406 return -ENOTSUPP;
15407 }
15408
15409 /* To cater the requirement of establishing the TDLS link
15410 * irrespective of the data traffic , get an entry of TDLS peer.
15411 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015412 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015413 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
15414 if (pTdlsPeer == NULL) {
15415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15416 "%s: peer " MAC_ADDRESS_STR " not existing",
15417 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015418 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015419 return -EINVAL;
15420 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015421 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015422
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015423 /* check FW TDLS Off Channel capability */
15424 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015425 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015426 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015427 {
15428 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
15429 pTdlsPeer->peerParams.global_operating_class =
15430 tdls_peer_params->global_operating_class;
15431 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
15432 pTdlsPeer->peerParams.min_bandwidth_kbps =
15433 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015434 /* check configured channel is valid, non dfs and
15435 * not current operating channel */
15436 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
15437 tdls_peer_params->channel)) &&
15438 (pHddStaCtx) &&
15439 (tdls_peer_params->channel !=
15440 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015441 {
15442 pTdlsPeer->isOffChannelConfigured = TRUE;
15443 }
15444 else
15445 {
15446 pTdlsPeer->isOffChannelConfigured = FALSE;
15447 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15448 "%s: Configured Tdls Off Channel is not valid", __func__);
15449
15450 }
15451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015452 "%s: tdls_off_channel %d isOffChannelConfigured %d "
15453 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015454 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015455 pTdlsPeer->isOffChannelConfigured,
15456 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015457 }
15458 else
15459 {
15460 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015461 "%s: TDLS off channel FW capability %d, "
15462 "host capab %d or Invalid TDLS Peer Params", __func__,
15463 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
15464 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015465 }
15466
Atul Mittal115287b2014-07-08 13:26:33 +053015467 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
15468
15469 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15470 " %s TDLS Add Force Peer Failed",
15471 __func__);
15472 return -EINVAL;
15473 }
15474 /*EXT TDLS*/
15475
15476 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
15477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15478 " %s TDLS set callback Failed",
15479 __func__);
15480 return -EINVAL;
15481 }
15482
15483 return(0);
15484
15485}
15486
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015487int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter,
15488#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15489 const u8 *peer
15490#else
15491 u8 *peer
15492#endif
15493)
Atul Mittal115287b2014-07-08 13:26:33 +053015494{
15495
15496 hddTdlsPeer_t *pTdlsPeer;
15497 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15499 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
15500 __func__, MAC_ADDR_ARRAY(peer));
15501
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015502 if (0 != wlan_hdd_validate_context(pHddCtx)) {
15503 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
15504 return -EINVAL;
15505 }
15506
Atul Mittal115287b2014-07-08 13:26:33 +053015507 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15508 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15509
15510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015511 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15512 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15513 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015514 return -ENOTSUPP;
15515 }
15516
15517
15518 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15519
15520 if ( NULL == pTdlsPeer ) {
15521 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015522 " peer not existing",
Atul Mittal115287b2014-07-08 13:26:33 +053015523 __func__, MAC_ADDR_ARRAY(peer));
15524 return -EINVAL;
15525 }
15526 else {
15527 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
15528 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015529 /* if channel switch is configured, reset
15530 the channel for this peer */
15531 if (TRUE == pTdlsPeer->isOffChannelConfigured)
15532 {
15533 pTdlsPeer->peerParams.channel = 0;
15534 pTdlsPeer->isOffChannelConfigured = FALSE;
15535 }
Atul Mittal115287b2014-07-08 13:26:33 +053015536 }
15537
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015538 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
15539 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053015540 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015541 }
Atul Mittal115287b2014-07-08 13:26:33 +053015542
15543 /*EXT TDLS*/
15544
15545 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
15546
15547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15548 " %s TDLS set callback Failed",
15549 __func__);
15550 return -EINVAL;
15551 }
15552 return(0);
15553
15554}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015555static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053015556#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
15557 const u8 *peer,
15558#else
15559 u8 *peer,
15560#endif
15561 enum nl80211_tdls_operation oper)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015562{
15563 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15564 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015565 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015566 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015567
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015568 ENTER();
15569
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015570 if (!pAdapter) {
15571 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15572 return -EINVAL;
15573 }
15574
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015575 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15576 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
15577 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015578 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015579 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015580 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070015581 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015582 return -EINVAL;
15583 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015584
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015585 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015586 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015587 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015588 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015589 }
15590
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015591
15592 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015593 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015594 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015595 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015596 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
15597 "Cannot process TDLS commands",
15598 pHddCtx->cfg_ini->fEnableTDLSSupport,
15599 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015600 return -ENOTSUPP;
15601 }
15602
15603 switch (oper) {
15604 case NL80211_TDLS_ENABLE_LINK:
15605 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015606 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015607 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015608 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053015609 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015610 tANI_U16 numCurrTdlsPeers = 0;
15611 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015612 tANI_U8 suppChannelLen = 0;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015613
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015614 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15615 " %s : NL80211_TDLS_ENABLE_LINK for " MAC_ADDRESS_STR,
15616 __func__, MAC_ADDR_ARRAY(peer));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015617 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015618 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015619 if ( NULL == pTdlsPeer ) {
15620 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15621 " (oper %d) not exsting. ignored",
15622 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15623 return -EINVAL;
15624 }
15625
15626 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15627 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15628 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15629 "NL80211_TDLS_ENABLE_LINK");
15630
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070015631 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
15632 {
15633 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
15634 MAC_ADDRESS_STR " failed",
15635 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
15636 return -EINVAL;
15637 }
15638
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015639 /* before starting tdls connection, set tdls
15640 * off channel established status to default value */
15641 pTdlsPeer->isOffChannelEstablished = FALSE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015642 /* TDLS Off Channel, Disable tdls channel switch,
15643 when there are more than one tdls link */
15644 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053015645 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015646 {
15647 /* get connected peer and send disable tdls off chan */
15648 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015649 if ((connPeer) &&
15650 (connPeer->isOffChannelSupported == TRUE) &&
15651 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015652 {
15653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15654 "%s: More then one peer connected, Disable "
15655 "TDLS channel switch", __func__);
15656
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015657 connPeer->isOffChannelEstablished = FALSE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015658 ret = sme_SendTdlsChanSwitchReq(
15659 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015660 pAdapter->sessionId,
15661 connPeer->peerMac,
15662 connPeer->peerParams.channel,
15663 TDLS_OFF_CHANNEL_BW_OFFSET,
15664 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015665 if (ret != VOS_STATUS_SUCCESS) {
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015666 hddLog(VOS_TRACE_LEVEL_ERROR,
15667 FL("Failed to send TDLS switch channel request"));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015668 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015669 }
15670 else
15671 {
15672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15673 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015674 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015675 "isOffChannelConfigured %d",
15676 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015677 (connPeer ? (connPeer->isOffChannelSupported)
15678 : -1),
15679 (connPeer ? (connPeer->isOffChannelConfigured)
15680 : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015681 }
15682 }
15683
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015684 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015685 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015686 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053015687
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015688 if (0 != wlan_hdd_tdls_get_link_establish_params(
15689 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015690 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015691 return -EINVAL;
15692 }
15693 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015694
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015695 ret = sme_SendTdlsLinkEstablishParams(
15696 WLAN_HDD_GET_HAL_CTX(pAdapter),
15697 pAdapter->sessionId, peer,
15698 &tdlsLinkEstablishParams);
15699 if (ret != VOS_STATUS_SUCCESS) {
15700 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
15701 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015702 /* Send TDLS peer UAPSD capabilities to the firmware and
15703 * register with the TL on after the response for this operation
15704 * is received .
15705 */
15706 ret = wait_for_completion_interruptible_timeout(
15707 &pAdapter->tdls_link_establish_req_comp,
15708 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
15709 if (ret <= 0)
15710 {
15711 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015712 FL("Link Establish Request Failed Status %ld"),
15713 ret);
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015714 return -EINVAL;
15715 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015716 }
Atul Mittal115287b2014-07-08 13:26:33 +053015717 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15718 eTDLS_LINK_CONNECTED,
15719 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015720 staDesc.ucSTAId = pTdlsPeer->staId;
15721 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015722 ret = WLANTL_UpdateTdlsSTAClient(
15723 pHddCtx->pvosContext,
15724 &staDesc);
15725 if (ret != VOS_STATUS_SUCCESS) {
15726 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
15727 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053015728
Gopichand Nakkala471708b2013-06-04 20:03:01 +053015729 /* Mark TDLS client Authenticated .*/
15730 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
15731 pTdlsPeer->staId,
15732 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015733 if (VOS_STATUS_SUCCESS == status)
15734 {
Hoonki Lee14621352013-04-16 17:51:19 -070015735 if (pTdlsPeer->is_responder == 0)
15736 {
15737 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
15738
15739 wlan_hdd_tdls_timer_restart(pAdapter,
15740 &pTdlsPeer->initiatorWaitTimeoutTimer,
15741 WAIT_TIME_TDLS_INITIATOR);
15742 /* suspend initiator TX until it receives direct packet from the
15743 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015744 ret = WLANTL_SuspendDataTx(
15745 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15746 &staId, NULL);
15747 if (ret != VOS_STATUS_SUCCESS) {
15748 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
15749 }
Hoonki Lee14621352013-04-16 17:51:19 -070015750 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015751
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015752 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015753 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015754 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015755 suppChannelLen =
15756 tdlsLinkEstablishParams.supportedChannelsLen;
15757
15758 if ((suppChannelLen > 0) &&
15759 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
15760 {
15761 tANI_U8 suppPeerChannel = 0;
15762 int i = 0;
15763 for (i = 0U; i < suppChannelLen; i++)
15764 {
15765 suppPeerChannel =
15766 tdlsLinkEstablishParams.supportedChannels[i];
15767
15768 pTdlsPeer->isOffChannelSupported = FALSE;
15769 if (suppPeerChannel ==
15770 pTdlsPeer->peerParams.channel)
15771 {
15772 pTdlsPeer->isOffChannelSupported = TRUE;
15773 break;
15774 }
15775 }
15776 }
15777 else
15778 {
15779 pTdlsPeer->isOffChannelSupported = FALSE;
15780 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015781 }
15782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15783 "%s: TDLS channel switch request for channel "
15784 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015785 "%d isOffChannelSupported %d", __func__,
15786 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015787 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015788 suppChannelLen,
15789 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015790
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015791 /* TDLS Off Channel, Enable tdls channel switch,
15792 when their is only one tdls link and it supports */
15793 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15794 if ((numCurrTdlsPeers == 1) &&
15795 (TRUE == pTdlsPeer->isOffChannelSupported) &&
15796 (TRUE == pTdlsPeer->isOffChannelConfigured))
15797 {
15798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15799 "%s: Send TDLS channel switch request for channel %d",
15800 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015801
15802 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015803 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
15804 pAdapter->sessionId,
15805 pTdlsPeer->peerMac,
15806 pTdlsPeer->peerParams.channel,
15807 TDLS_OFF_CHANNEL_BW_OFFSET,
15808 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015809 if (ret != VOS_STATUS_SUCCESS) {
15810 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
15811 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015812 }
15813 else
15814 {
15815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15816 "%s: TDLS channel switch request not sent"
15817 " numCurrTdlsPeers %d "
15818 "isOffChannelSupported %d "
15819 "isOffChannelConfigured %d",
15820 __func__, numCurrTdlsPeers,
15821 pTdlsPeer->isOffChannelSupported,
15822 pTdlsPeer->isOffChannelConfigured);
15823 }
15824
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015825 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015826 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015827
15828 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015829 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
15830 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015831 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015832 int ac;
15833 uint8 ucAc[4] = { WLANTL_AC_VO,
15834 WLANTL_AC_VI,
15835 WLANTL_AC_BK,
15836 WLANTL_AC_BE };
15837 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
15838 for(ac=0; ac < 4; ac++)
15839 {
15840 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15841 pTdlsPeer->staId, ucAc[ac],
15842 tlTid[ac], tlTid[ac], 0, 0,
15843 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015844 if (status != VOS_STATUS_SUCCESS) {
15845 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
15846 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015847 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015848 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015849 }
15850
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015851 }
15852 break;
15853 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080015854 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015855 tANI_U16 numCurrTdlsPeers = 0;
15856 hddTdlsPeer_t *connPeer = NULL;
15857
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15859 " %s : NL80211_TDLS_DISABLE_LINK for " MAC_ADDRESS_STR,
15860 __func__, MAC_ADDR_ARRAY(peer));
15861
Sunil Dutt41de4e22013-11-14 18:09:02 +053015862 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15863
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015864
Sunil Dutt41de4e22013-11-14 18:09:02 +053015865 if ( NULL == pTdlsPeer ) {
15866 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15867 " (oper %d) not exsting. ignored",
15868 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15869 return -EINVAL;
15870 }
15871
15872 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15873 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15874 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15875 "NL80211_TDLS_DISABLE_LINK");
15876
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015877 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080015878 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015879 long status;
15880
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015881 /* set tdls off channel status to false for this peer */
15882 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053015883 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15884 eTDLS_LINK_TEARING,
15885 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
15886 eTDLS_LINK_UNSPECIFIED:
15887 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015888 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
15889
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015890 status = sme_DeleteTdlsPeerSta(
15891 WLAN_HDD_GET_HAL_CTX(pAdapter),
15892 pAdapter->sessionId, peer );
15893 if (status != VOS_STATUS_SUCCESS) {
15894 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15895 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015896
15897 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
15898 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053015899 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053015900 eTDLS_LINK_IDLE,
15901 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015902 if (status <= 0)
15903 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15905 "%s: Del station failed status %ld",
15906 __func__, status);
15907 return -EPERM;
15908 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015909
15910 /* TDLS Off Channel, Enable tdls channel switch,
15911 when their is only one tdls link and it supports */
15912 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15913 if (numCurrTdlsPeers == 1)
15914 {
15915 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15916 if ((connPeer) &&
15917 (connPeer->isOffChannelSupported == TRUE) &&
15918 (connPeer->isOffChannelConfigured == TRUE))
15919 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015920 connPeer->isOffChannelEstablished = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015921 status = sme_SendTdlsChanSwitchReq(
15922 WLAN_HDD_GET_HAL_CTX(pAdapter),
15923 pAdapter->sessionId,
15924 connPeer->peerMac,
15925 connPeer->peerParams.channel,
15926 TDLS_OFF_CHANNEL_BW_OFFSET,
15927 TDLS_CHANNEL_SWITCH_ENABLE);
15928 if (status != VOS_STATUS_SUCCESS) {
15929 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
15930 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015931 }
15932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15933 "%s: TDLS channel switch "
15934 "isOffChannelSupported %d "
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015935 "isOffChannelConfigured %d "
15936 "isOffChannelEstablished %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015937 __func__,
15938 (connPeer ? connPeer->isOffChannelSupported : -1),
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015939 (connPeer ? connPeer->isOffChannelConfigured : -1),
15940 (connPeer ? connPeer->isOffChannelEstablished : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015941 }
15942 else
15943 {
15944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15945 "%s: TDLS channel switch request not sent "
15946 "numCurrTdlsPeers %d ",
15947 __func__, numCurrTdlsPeers);
15948 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015949 }
15950 else
15951 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15953 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080015954 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015955 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015956 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015957 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015958 {
Atul Mittal115287b2014-07-08 13:26:33 +053015959 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015960
Atul Mittal115287b2014-07-08 13:26:33 +053015961 if (0 != status)
15962 {
15963 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015964 FL("Error in TDLS Teardown"));
Atul Mittal115287b2014-07-08 13:26:33 +053015965 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015966 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053015967 break;
15968 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015969 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015970 {
Atul Mittal115287b2014-07-08 13:26:33 +053015971 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
15972 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015973 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053015974 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015975
Atul Mittal115287b2014-07-08 13:26:33 +053015976 if (0 != status)
15977 {
15978 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015979 FL("Error in TDLS Setup"));
Atul Mittal115287b2014-07-08 13:26:33 +053015980 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053015981 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053015982 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015983 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015984 case NL80211_TDLS_DISCOVERY_REQ:
15985 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Agarwal Ashisha7ef41d2015-06-25 18:00:26 +053015987 "%s: Driver doesn't support in-driver setup/teardown/discovery "
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015988 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015989 return -ENOTSUPP;
15990 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15992 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015993 return -ENOTSUPP;
15994 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015995
15996 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015997 return 0;
15998}
Chilam NG571c65a2013-01-19 12:27:36 +053015999
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016000static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016001#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
16002 const u8 *peer,
16003#else
16004 u8 *peer,
16005#endif
16006 enum nl80211_tdls_operation oper)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016007{
16008 int ret;
16009
16010 vos_ssr_protect(__func__);
16011 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
16012 vos_ssr_unprotect(__func__);
16013
16014 return ret;
16015}
16016
Chilam NG571c65a2013-01-19 12:27:36 +053016017int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
16018 struct net_device *dev, u8 *peer)
16019{
Arif Hussaina7c8e412013-11-20 11:06:42 -080016020 hddLog(VOS_TRACE_LEVEL_INFO,
16021 "tdls send discover req: "MAC_ADDRESS_STR,
16022 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053016023
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016024#if TDLS_MGMT_VERSION2
16025 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16026 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16027#else
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016028#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
16029 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16030 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 0, NULL, 0);
16031#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
16032 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16033 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16034#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
16035 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16036 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
16037#else
Chilam NG571c65a2013-01-19 12:27:36 +053016038 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
16039 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053016040#endif
Anand N Sunkad9bfc2622015-07-30 15:18:54 +053016041#endif /* KERNEL_VERSION */
Chilam NG571c65a2013-01-19 12:27:36 +053016042}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016043#endif
16044
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016045#ifdef WLAN_FEATURE_GTK_OFFLOAD
16046/*
16047 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
16048 * Callback rountine called upon receiving response for
16049 * get offload info
16050 */
16051void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
16052 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
16053{
16054
16055 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016056 tANI_U8 tempReplayCounter[8];
16057 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016058
16059 ENTER();
16060
16061 if (NULL == pAdapter)
16062 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053016063 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016064 "%s: HDD adapter is Null", __func__);
16065 return ;
16066 }
16067
16068 if (NULL == pGtkOffloadGetInfoRsp)
16069 {
16070 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16071 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
16072 return ;
16073 }
16074
16075 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
16076 {
16077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16078 "%s: wlan Failed to get replay counter value",
16079 __func__);
16080 return ;
16081 }
16082
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016083 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16084 /* Update replay counter */
16085 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
16086 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
16087
16088 {
16089 /* changing from little to big endian since supplicant
16090 * works on big endian format
16091 */
16092 int i;
16093 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
16094
16095 for (i = 0; i < 8; i++)
16096 {
16097 tempReplayCounter[7-i] = (tANI_U8)p[i];
16098 }
16099 }
16100
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016101 /* Update replay counter to NL */
16102 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016103 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016104}
16105
16106/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016107 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016108 * This function is used to offload GTK rekeying job to the firmware.
16109 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016110int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016111 struct cfg80211_gtk_rekey_data *data)
16112{
16113 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16114 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16115 hdd_station_ctx_t *pHddStaCtx;
16116 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016117 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016118 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016119 eHalStatus status = eHAL_STATUS_FAILURE;
16120
16121 ENTER();
16122
16123 if (NULL == pAdapter)
16124 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053016125 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016126 "%s: HDD adapter is Null", __func__);
16127 return -ENODEV;
16128 }
16129
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053016130 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16131 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
16132 pAdapter->sessionId, pAdapter->device_mode));
16133
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016134 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016135 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016136 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053016137 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016138 }
16139
16140 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16141 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
16142 if (NULL == hHal)
16143 {
16144 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16145 "%s: HAL context is Null!!!", __func__);
16146 return -EAGAIN;
16147 }
16148
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016149 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
16150 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
16151 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
16152 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016153 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016154 {
16155 /* changing from big to little endian since driver
16156 * works on little endian format
16157 */
16158 tANI_U8 *p =
16159 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
16160 int i;
16161
16162 for (i = 0; i < 8; i++)
16163 {
16164 p[7-i] = data->replay_ctr[i];
16165 }
16166 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016167
16168 if (TRUE == pHddCtx->hdd_wlan_suspended)
16169 {
16170 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016171 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
16172 sizeof (tSirGtkOffloadParams));
16173 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016174 pAdapter->sessionId);
16175
16176 if (eHAL_STATUS_SUCCESS != status)
16177 {
16178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16179 "%s: sme_SetGTKOffload failed, returned %d",
16180 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053016181
16182 /* Need to clear any trace of key value in the memory.
16183 * Thus zero out the memory even though it is local
16184 * variable.
16185 */
16186 vos_mem_zero(&hddGtkOffloadReqParams,
16187 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016188 return status;
16189 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16191 "%s: sme_SetGTKOffload successfull", __func__);
16192 }
16193 else
16194 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16196 "%s: wlan not suspended GTKOffload request is stored",
16197 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016198 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016199
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053016200 /* Need to clear any trace of key value in the memory.
16201 * Thus zero out the memory even though it is local
16202 * variable.
16203 */
16204 vos_mem_zero(&hddGtkOffloadReqParams,
16205 sizeof(hddGtkOffloadReqParams));
16206
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016207 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053016208 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016209}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016210
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016211int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
16212 struct cfg80211_gtk_rekey_data *data)
16213{
16214 int ret;
16215
16216 vos_ssr_protect(__func__);
16217 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
16218 vos_ssr_unprotect(__func__);
16219
16220 return ret;
16221}
16222#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016223/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016224 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016225 * This function is used to set access control policy
16226 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016227static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16228 struct net_device *dev,
16229 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016230{
16231 int i;
16232 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16233 hdd_hostapd_state_t *pHostapdState;
16234 tsap_Config_t *pConfig;
16235 v_CONTEXT_t pVosContext = NULL;
16236 hdd_context_t *pHddCtx;
16237 int status;
16238
16239 ENTER();
16240
16241 if (NULL == pAdapter)
16242 {
16243 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16244 "%s: HDD adapter is Null", __func__);
16245 return -ENODEV;
16246 }
16247
16248 if (NULL == params)
16249 {
16250 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16251 "%s: params is Null", __func__);
16252 return -EINVAL;
16253 }
16254
16255 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16256 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016257 if (0 != status)
16258 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016259 return status;
16260 }
16261
16262 pVosContext = pHddCtx->pvosContext;
16263 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
16264
16265 if (NULL == pHostapdState)
16266 {
16267 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16268 "%s: pHostapdState is Null", __func__);
16269 return -EINVAL;
16270 }
16271
16272 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
16273 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016274 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16275 TRACE_CODE_HDD_CFG80211_SET_MAC_ACL,
16276 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016277
16278 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
16279 {
16280 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
16281
16282 /* default value */
16283 pConfig->num_accept_mac = 0;
16284 pConfig->num_deny_mac = 0;
16285
16286 /**
16287 * access control policy
16288 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
16289 * listed in hostapd.deny file.
16290 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
16291 * listed in hostapd.accept file.
16292 */
16293 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
16294 {
16295 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
16296 }
16297 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
16298 {
16299 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
16300 }
16301 else
16302 {
16303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16304 "%s:Acl Policy : %d is not supported",
16305 __func__, params->acl_policy);
16306 return -ENOTSUPP;
16307 }
16308
16309 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
16310 {
16311 pConfig->num_accept_mac = params->n_acl_entries;
16312 for (i = 0; i < params->n_acl_entries; i++)
16313 {
16314 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16315 "** Add ACL MAC entry %i in WhiletList :"
16316 MAC_ADDRESS_STR, i,
16317 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16318
16319 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
16320 sizeof(qcmacaddr));
16321 }
16322 }
16323 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
16324 {
16325 pConfig->num_deny_mac = params->n_acl_entries;
16326 for (i = 0; i < params->n_acl_entries; i++)
16327 {
16328 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16329 "** Add ACL MAC entry %i in BlackList :"
16330 MAC_ADDRESS_STR, i,
16331 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
16332
16333 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
16334 sizeof(qcmacaddr));
16335 }
16336 }
16337
16338 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
16339 {
16340 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16341 "%s: SAP Set Mac Acl fail", __func__);
16342 return -EINVAL;
16343 }
16344 }
16345 else
16346 {
16347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053016348 "%s: Invalid device_mode = %s (%d)",
16349 __func__, hdd_device_modetoString(pAdapter->device_mode),
16350 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016351 return -EINVAL;
16352 }
16353
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016354 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016355 return 0;
16356}
16357
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053016358static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
16359 struct net_device *dev,
16360 const struct cfg80211_acl_data *params)
16361{
16362 int ret;
16363 vos_ssr_protect(__func__);
16364 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
16365 vos_ssr_unprotect(__func__);
16366
16367 return ret;
16368}
16369
Leo Chang9056f462013-08-01 19:21:11 -070016370#ifdef WLAN_NL80211_TESTMODE
16371#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070016372void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070016373(
16374 void *pAdapter,
16375 void *indCont
16376)
16377{
Leo Changd9df8aa2013-09-26 13:32:26 -070016378 tSirLPHBInd *lphbInd;
16379 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053016380 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070016381
16382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016383 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070016384
c_hpothu73f35e62014-04-18 13:40:08 +053016385 if (pAdapter == NULL)
16386 {
16387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16388 "%s: pAdapter is NULL\n",__func__);
16389 return;
16390 }
16391
Leo Chang9056f462013-08-01 19:21:11 -070016392 if (NULL == indCont)
16393 {
16394 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070016395 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070016396 return;
16397 }
16398
c_hpothu73f35e62014-04-18 13:40:08 +053016399 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070016400 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070016401 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053016402 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070016403 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070016404 GFP_ATOMIC);
16405 if (!skb)
16406 {
16407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16408 "LPHB timeout, NL buffer alloc fail");
16409 return;
16410 }
16411
Leo Changac3ba772013-10-07 09:47:04 -070016412 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070016413 {
16414 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16415 "WLAN_HDD_TM_ATTR_CMD put fail");
16416 goto nla_put_failure;
16417 }
Leo Changac3ba772013-10-07 09:47:04 -070016418 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070016419 {
16420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16421 "WLAN_HDD_TM_ATTR_TYPE put fail");
16422 goto nla_put_failure;
16423 }
Leo Changac3ba772013-10-07 09:47:04 -070016424 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070016425 sizeof(tSirLPHBInd), lphbInd))
16426 {
16427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16428 "WLAN_HDD_TM_ATTR_DATA put fail");
16429 goto nla_put_failure;
16430 }
Leo Chang9056f462013-08-01 19:21:11 -070016431 cfg80211_testmode_event(skb, GFP_ATOMIC);
16432 return;
16433
16434nla_put_failure:
16435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16436 "NLA Put fail");
16437 kfree_skb(skb);
16438
16439 return;
16440}
16441#endif /* FEATURE_WLAN_LPHB */
16442
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016443static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070016444{
16445 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
16446 int err = 0;
16447#ifdef FEATURE_WLAN_LPHB
16448 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070016449 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016450
16451 ENTER();
16452
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016453 err = wlan_hdd_validate_context(pHddCtx);
16454 if (0 != err)
16455 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016456 return err;
16457 }
Leo Chang9056f462013-08-01 19:21:11 -070016458#endif /* FEATURE_WLAN_LPHB */
16459
16460 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
16461 if (err)
16462 {
16463 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16464 "%s Testmode INV ATTR", __func__);
16465 return err;
16466 }
16467
16468 if (!tb[WLAN_HDD_TM_ATTR_CMD])
16469 {
16470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16471 "%s Testmode INV CMD", __func__);
16472 return -EINVAL;
16473 }
16474
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016475 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16476 TRACE_CODE_HDD_CFG80211_TESTMODE,
16477 NO_SESSION, nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])));
Leo Chang9056f462013-08-01 19:21:11 -070016478 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
16479 {
16480#ifdef FEATURE_WLAN_LPHB
16481 /* Low Power Heartbeat configuration request */
16482 case WLAN_HDD_TM_CMD_WLAN_HB:
16483 {
16484 int buf_len;
16485 void *buf;
16486 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080016487 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070016488
16489 if (!tb[WLAN_HDD_TM_ATTR_DATA])
16490 {
16491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16492 "%s Testmode INV DATA", __func__);
16493 return -EINVAL;
16494 }
16495
16496 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
16497 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080016498
16499 hb_params_temp =(tSirLPHBReq *)buf;
16500 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
16501 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
16502 return -EINVAL;
16503
Leo Chang9056f462013-08-01 19:21:11 -070016504 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
16505 if (NULL == hb_params)
16506 {
16507 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16508 "%s Request Buffer Alloc Fail", __func__);
16509 return -EINVAL;
16510 }
16511
16512 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070016513 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
16514 hb_params,
16515 wlan_hdd_cfg80211_lphb_ind_handler);
16516 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070016517 {
Leo Changd9df8aa2013-09-26 13:32:26 -070016518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16519 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070016520 vos_mem_free(hb_params);
16521 }
Leo Chang9056f462013-08-01 19:21:11 -070016522 return 0;
16523 }
16524#endif /* FEATURE_WLAN_LPHB */
16525 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16527 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070016528 return -EOPNOTSUPP;
16529 }
16530
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016531 EXIT();
16532 return err;
Leo Chang9056f462013-08-01 19:21:11 -070016533}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016534
Anand N Sunkade9adb1b2015-07-29 09:56:45 +053016535static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy,
16536#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
16537 struct wireless_dev *wdev,
16538#endif
16539 void *data, int len)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016540{
16541 int ret;
16542
16543 vos_ssr_protect(__func__);
16544 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
16545 vos_ssr_unprotect(__func__);
16546
16547 return ret;
16548}
Leo Chang9056f462013-08-01 19:21:11 -070016549#endif /* CONFIG_NL80211_TESTMODE */
16550
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016551static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016552 struct net_device *dev,
16553 int idx, struct survey_info *survey)
16554{
16555 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16556 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053016557 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016558 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053016559 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016560 v_S7_t snr,rssi;
16561 int status, i, j, filled = 0;
16562
16563 ENTER();
16564
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016565 if (NULL == pAdapter)
16566 {
16567 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16568 "%s: HDD adapter is Null", __func__);
16569 return -ENODEV;
16570 }
16571
16572 if (NULL == wiphy)
16573 {
16574 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16575 "%s: wiphy is Null", __func__);
16576 return -ENODEV;
16577 }
16578
16579 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16580 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016581 if (0 != status)
16582 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016583 return status;
16584 }
16585
Mihir Sheted9072e02013-08-21 17:02:29 +053016586 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16587
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016588 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053016589 0 != pAdapter->survey_idx ||
16590 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016591 {
16592 /* The survey dump ops when implemented completely is expected to
16593 * return a survey of all channels and the ops is called by the
16594 * kernel with incremental values of the argument 'idx' till it
16595 * returns -ENONET. But we can only support the survey for the
16596 * operating channel for now. survey_idx is used to track
16597 * that the ops is called only once and then return -ENONET for
16598 * the next iteration
16599 */
16600 pAdapter->survey_idx = 0;
16601 return -ENONET;
16602 }
16603
Mukul Sharma9d5233b2015-06-11 20:28:20 +053016604 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
16605 {
16606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16607 "%s: Roaming in progress, hence return ", __func__);
16608 return -ENONET;
16609 }
16610
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016611 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16612
16613 wlan_hdd_get_snr(pAdapter, &snr);
16614 wlan_hdd_get_rssi(pAdapter, &rssi);
16615
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016616 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16617 TRACE_CODE_HDD_CFG80211_DUMP_SURVEY,
16618 pAdapter->sessionId, pAdapter->device_mode));
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016619 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
16620 hdd_wlan_get_freq(channel, &freq);
16621
16622
16623 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
16624 {
16625 if (NULL == wiphy->bands[i])
16626 {
16627 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
16628 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
16629 continue;
16630 }
16631
16632 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
16633 {
16634 struct ieee80211_supported_band *band = wiphy->bands[i];
16635
16636 if (band->channels[j].center_freq == (v_U16_t)freq)
16637 {
16638 survey->channel = &band->channels[j];
16639 /* The Rx BDs contain SNR values in dB for the received frames
16640 * while the supplicant expects noise. So we calculate and
16641 * return the value of noise (dBm)
16642 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
16643 */
16644 survey->noise = rssi - snr;
16645 survey->filled = SURVEY_INFO_NOISE_DBM;
16646 filled = 1;
16647 }
16648 }
16649 }
16650
16651 if (filled)
16652 pAdapter->survey_idx = 1;
16653 else
16654 {
16655 pAdapter->survey_idx = 0;
16656 return -ENONET;
16657 }
16658
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016659 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016660 return 0;
16661}
16662
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016663static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
16664 struct net_device *dev,
16665 int idx, struct survey_info *survey)
16666{
16667 int ret;
16668
16669 vos_ssr_protect(__func__);
16670 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
16671 vos_ssr_unprotect(__func__);
16672
16673 return ret;
16674}
16675
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016676/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016677 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016678 * this is called when cfg80211 driver resume
16679 * driver updates latest sched_scan scan result(if any) to cfg80211 database
16680 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016681int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016682{
16683 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16684 hdd_adapter_t *pAdapter;
16685 hdd_adapter_list_node_t *pAdapterNode, *pNext;
16686 VOS_STATUS status = VOS_STATUS_SUCCESS;
16687
16688 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016689
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016690 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016691 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016692 return 0;
16693 }
16694
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016695 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_CFG80211_RESUME_WLAN,
16696 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016697 spin_lock(&pHddCtx->schedScan_lock);
16698 pHddCtx->isWiphySuspended = FALSE;
16699 if (TRUE != pHddCtx->isSchedScanUpdatePending)
16700 {
16701 spin_unlock(&pHddCtx->schedScan_lock);
16702 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16703 "%s: Return resume is not due to PNO indication", __func__);
16704 return 0;
16705 }
16706 // Reset flag to avoid updatating cfg80211 data old results again
16707 pHddCtx->isSchedScanUpdatePending = FALSE;
16708 spin_unlock(&pHddCtx->schedScan_lock);
16709
16710 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
16711
16712 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
16713 {
16714 pAdapter = pAdapterNode->pAdapter;
16715 if ( (NULL != pAdapter) &&
16716 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
16717 {
16718 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016719 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016720 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16721 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016722 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016723 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016724 {
16725 /* Acquire wakelock to handle the case where APP's tries to
16726 * suspend immediately after updating the scan results. Whis
16727 * results in app's is in suspended state and not able to
16728 * process the connect request to AP
16729 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053016730 hdd_prevent_suspend_timeout(2000,
16731 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016732 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016733 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016734
16735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16736 "%s : cfg80211 scan result database updated", __func__);
16737
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016738 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016739 return 0;
16740
16741 }
16742 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16743 pAdapterNode = pNext;
16744 }
16745
16746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16747 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016748 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016749 return 0;
16750}
16751
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016752int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
16753{
16754 int ret;
16755
16756 vos_ssr_protect(__func__);
16757 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
16758 vos_ssr_unprotect(__func__);
16759
16760 return ret;
16761}
16762
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016763/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016764 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016765 * this is called when cfg80211 driver suspends
16766 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016767int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016768 struct cfg80211_wowlan *wow)
16769{
16770 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016771 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016772
16773 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016774
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016775 ret = wlan_hdd_validate_context(pHddCtx);
16776 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016777 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016778 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016779 }
16780
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016781
Konamki, Sreelakshmi7b464be2015-07-14 12:17:01 +053016782 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
16783 TRACE_CODE_HDD_CFG80211_SUSPEND_WLAN,
16784 NO_SESSION, pHddCtx->isWiphySuspended));
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016785 pHddCtx->isWiphySuspended = TRUE;
16786
16787 EXIT();
16788
16789 return 0;
16790}
16791
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016792int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
16793 struct cfg80211_wowlan *wow)
16794{
16795 int ret;
16796
16797 vos_ssr_protect(__func__);
16798 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
16799 vos_ssr_unprotect(__func__);
16800
16801 return ret;
16802}
Jeff Johnson295189b2012-06-20 16:38:30 -070016803/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016804static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070016805{
16806 .add_virtual_intf = wlan_hdd_add_virtual_intf,
16807 .del_virtual_intf = wlan_hdd_del_virtual_intf,
16808 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
16809 .change_station = wlan_hdd_change_station,
16810#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
16811 .add_beacon = wlan_hdd_cfg80211_add_beacon,
16812 .del_beacon = wlan_hdd_cfg80211_del_beacon,
16813 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016814#else
16815 .start_ap = wlan_hdd_cfg80211_start_ap,
16816 .change_beacon = wlan_hdd_cfg80211_change_beacon,
16817 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070016818#endif
16819 .change_bss = wlan_hdd_cfg80211_change_bss,
16820 .add_key = wlan_hdd_cfg80211_add_key,
16821 .get_key = wlan_hdd_cfg80211_get_key,
16822 .del_key = wlan_hdd_cfg80211_del_key,
16823 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016824#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070016825 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016826#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016827 .scan = wlan_hdd_cfg80211_scan,
16828 .connect = wlan_hdd_cfg80211_connect,
16829 .disconnect = wlan_hdd_cfg80211_disconnect,
16830 .join_ibss = wlan_hdd_cfg80211_join_ibss,
16831 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
16832 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
16833 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
16834 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070016835 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
16836 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053016837 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070016838#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16839 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
16840 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
16841 .set_txq_params = wlan_hdd_set_txq_params,
16842#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016843 .get_station = wlan_hdd_cfg80211_get_station,
16844 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
16845 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016846 .add_station = wlan_hdd_cfg80211_add_station,
16847#ifdef FEATURE_WLAN_LFR
16848 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
16849 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
16850 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
16851#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016852#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
16853 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
16854#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016855#ifdef FEATURE_WLAN_TDLS
16856 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
16857 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
16858#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016859#ifdef WLAN_FEATURE_GTK_OFFLOAD
16860 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
16861#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016862#ifdef FEATURE_WLAN_SCAN_PNO
16863 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
16864 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
16865#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016866 .resume = wlan_hdd_cfg80211_resume_wlan,
16867 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016868 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070016869#ifdef WLAN_NL80211_TESTMODE
16870 .testmode_cmd = wlan_hdd_cfg80211_testmode,
16871#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016872 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070016873};
16874