blob: 15651c44eb25cb06acc9af6d20f9afd997e2dc19 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +053026 *
Kiet Lamaa8e15a2014-02-11 23:30:06 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Kiet Lama7f454d2014-07-24 12:04:06 -070030
31
Jeff Johnson295189b2012-06-20 16:38:30 -070032/**========================================================================
33
34 \file wlan_hdd_cfg80211.c
35
36 \brief WLAN Host Device Driver implementation
37
Jeff Johnson295189b2012-06-20 16:38:30 -070038 ========================================================================*/
39
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070040/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070041
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070042 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070043
44
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070045 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070047
48
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070049 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070050
51
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070052 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070053 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070054 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070055
56 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070057 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070058 ==========================================================================*/
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060
61#include <linux/version.h>
62#include <linux/module.h>
63#include <linux/kernel.h>
64#include <linux/init.h>
65#include <linux/wireless.h>
66#include <wlan_hdd_includes.h>
67#include <net/arp.h>
68#include <net/cfg80211.h>
69#include <linux/wireless.h>
70#include <wlan_hdd_wowl.h>
71#include <aniGlobal.h>
72#include "ccmApi.h"
73#include "sirParams.h"
74#include "dot11f.h"
75#include "wlan_hdd_assoc.h"
76#include "wlan_hdd_wext.h"
77#include "sme_Api.h"
78#include "wlan_hdd_p2p.h"
79#include "wlan_hdd_cfg80211.h"
80#include "wlan_hdd_hostapd.h"
81#include "sapInternal.h"
82#include "wlan_hdd_softap_tx_rx.h"
83#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053084#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053085#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053086#include "wlan_hdd_trace.h"
87#include "vos_types.h"
88#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070089#ifdef WLAN_BTAMP_FEATURE
90#include "bap_hdd_misc.h"
91#endif
92#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080093#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053094#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053095#include "wlan_qct_wda.h"
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053096#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070097#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070098
99#define g_mode_rates_size (12)
100#define a_mode_rates_size (8)
101#define FREQ_BASE_80211G (2407)
102#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700103#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530104#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800106 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
108#define HDD2GHZCHAN(freq, chan, flag) { \
109 .band = IEEE80211_BAND_2GHZ, \
110 .center_freq = (freq), \
111 .hw_value = (chan),\
112 .flags = (flag), \
113 .max_antenna_gain = 0 ,\
114 .max_power = 30, \
115}
116
117#define HDD5GHZCHAN(freq, chan, flag) { \
118 .band = IEEE80211_BAND_5GHZ, \
119 .center_freq = (freq), \
120 .hw_value = (chan),\
121 .flags = (flag), \
122 .max_antenna_gain = 0 ,\
123 .max_power = 30, \
124}
125
126#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
127{\
128 .bitrate = rate, \
129 .hw_value = rate_id, \
130 .flags = flag, \
131}
132
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530133#ifdef WLAN_FEATURE_VOWIFI_11R
134#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
135#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
136#endif
137
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530138#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530139#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530140
Sunil Duttc69bccb2014-05-26 21:30:20 +0530141#ifdef WLAN_FEATURE_LINK_LAYER_STATS
142/*
143 * Used to allocate the size of 4096 for the link layer stats.
144 * The size of 4096 is considered assuming that all data per
145 * respective event fit with in the limit.Please take a call
146 * on the limit based on the data requirements on link layer
147 * statistics.
148 */
149#define LL_STATS_EVENT_BUF_SIZE 4096
150#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530151#ifdef WLAN_FEATURE_EXTSCAN
152/*
153 * Used to allocate the size of 4096 for the EXTScan NL data.
154 * The size of 4096 is considered assuming that all data per
155 * respective event fit with in the limit.Please take a call
156 * on the limit based on the data requirements.
157 */
158
159#define EXTSCAN_EVENT_BUF_SIZE 4096
160#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
161#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530162
Atul Mittal115287b2014-07-08 13:26:33 +0530163/*EXT TDLS*/
164/*
165 * Used to allocate the size of 4096 for the TDLS.
166 * The size of 4096 is considered assuming that all data per
167 * respective event fit with in the limit.Please take a call
168 * on the limit based on the data requirements on link layer
169 * statistics.
170 */
171#define EXTTDLS_EVENT_BUF_SIZE 4096
172
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530173static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700174{
175 WLAN_CIPHER_SUITE_WEP40,
176 WLAN_CIPHER_SUITE_WEP104,
177 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800178#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700179#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
180 WLAN_CIPHER_SUITE_KRK,
181 WLAN_CIPHER_SUITE_CCMP,
182#else
183 WLAN_CIPHER_SUITE_CCMP,
184#endif
185#ifdef FEATURE_WLAN_WAPI
186 WLAN_CIPHER_SUITE_SMS4,
187#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700188#ifdef WLAN_FEATURE_11W
189 WLAN_CIPHER_SUITE_AES_CMAC,
190#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700191};
192
193static inline int is_broadcast_ether_addr(const u8 *addr)
194{
195 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
196 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
197}
198
199static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530200{
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 HDD2GHZCHAN(2412, 1, 0) ,
202 HDD2GHZCHAN(2417, 2, 0) ,
203 HDD2GHZCHAN(2422, 3, 0) ,
204 HDD2GHZCHAN(2427, 4, 0) ,
205 HDD2GHZCHAN(2432, 5, 0) ,
206 HDD2GHZCHAN(2437, 6, 0) ,
207 HDD2GHZCHAN(2442, 7, 0) ,
208 HDD2GHZCHAN(2447, 8, 0) ,
209 HDD2GHZCHAN(2452, 9, 0) ,
210 HDD2GHZCHAN(2457, 10, 0) ,
211 HDD2GHZCHAN(2462, 11, 0) ,
212 HDD2GHZCHAN(2467, 12, 0) ,
213 HDD2GHZCHAN(2472, 13, 0) ,
214 HDD2GHZCHAN(2484, 14, 0) ,
215};
216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
218{
219 HDD2GHZCHAN(2412, 1, 0) ,
220 HDD2GHZCHAN(2437, 6, 0) ,
221 HDD2GHZCHAN(2462, 11, 0) ,
222};
Jeff Johnson295189b2012-06-20 16:38:30 -0700223
224static struct ieee80211_channel hdd_channels_5_GHZ[] =
225{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700226 HDD5GHZCHAN(4920, 240, 0) ,
227 HDD5GHZCHAN(4940, 244, 0) ,
228 HDD5GHZCHAN(4960, 248, 0) ,
229 HDD5GHZCHAN(4980, 252, 0) ,
230 HDD5GHZCHAN(5040, 208, 0) ,
231 HDD5GHZCHAN(5060, 212, 0) ,
232 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 HDD5GHZCHAN(5180, 36, 0) ,
234 HDD5GHZCHAN(5200, 40, 0) ,
235 HDD5GHZCHAN(5220, 44, 0) ,
236 HDD5GHZCHAN(5240, 48, 0) ,
237 HDD5GHZCHAN(5260, 52, 0) ,
238 HDD5GHZCHAN(5280, 56, 0) ,
239 HDD5GHZCHAN(5300, 60, 0) ,
240 HDD5GHZCHAN(5320, 64, 0) ,
241 HDD5GHZCHAN(5500,100, 0) ,
242 HDD5GHZCHAN(5520,104, 0) ,
243 HDD5GHZCHAN(5540,108, 0) ,
244 HDD5GHZCHAN(5560,112, 0) ,
245 HDD5GHZCHAN(5580,116, 0) ,
246 HDD5GHZCHAN(5600,120, 0) ,
247 HDD5GHZCHAN(5620,124, 0) ,
248 HDD5GHZCHAN(5640,128, 0) ,
249 HDD5GHZCHAN(5660,132, 0) ,
250 HDD5GHZCHAN(5680,136, 0) ,
251 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800252#ifdef FEATURE_WLAN_CH144
253 HDD5GHZCHAN(5720,144, 0) ,
254#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 HDD5GHZCHAN(5745,149, 0) ,
256 HDD5GHZCHAN(5765,153, 0) ,
257 HDD5GHZCHAN(5785,157, 0) ,
258 HDD5GHZCHAN(5805,161, 0) ,
259 HDD5GHZCHAN(5825,165, 0) ,
260};
261
262static struct ieee80211_rate g_mode_rates[] =
263{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530264 HDD_G_MODE_RATETAB(10, 0x1, 0),
265 HDD_G_MODE_RATETAB(20, 0x2, 0),
266 HDD_G_MODE_RATETAB(55, 0x4, 0),
267 HDD_G_MODE_RATETAB(110, 0x8, 0),
268 HDD_G_MODE_RATETAB(60, 0x10, 0),
269 HDD_G_MODE_RATETAB(90, 0x20, 0),
270 HDD_G_MODE_RATETAB(120, 0x40, 0),
271 HDD_G_MODE_RATETAB(180, 0x80, 0),
272 HDD_G_MODE_RATETAB(240, 0x100, 0),
273 HDD_G_MODE_RATETAB(360, 0x200, 0),
274 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530276};
Jeff Johnson295189b2012-06-20 16:38:30 -0700277
278static struct ieee80211_rate a_mode_rates[] =
279{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530280 HDD_G_MODE_RATETAB(60, 0x10, 0),
281 HDD_G_MODE_RATETAB(90, 0x20, 0),
282 HDD_G_MODE_RATETAB(120, 0x40, 0),
283 HDD_G_MODE_RATETAB(180, 0x80, 0),
284 HDD_G_MODE_RATETAB(240, 0x100, 0),
285 HDD_G_MODE_RATETAB(360, 0x200, 0),
286 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 HDD_G_MODE_RATETAB(540, 0x800, 0),
288};
289
290static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
291{
292 .channels = hdd_channels_2_4_GHZ,
293 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
294 .band = IEEE80211_BAND_2GHZ,
295 .bitrates = g_mode_rates,
296 .n_bitrates = g_mode_rates_size,
297 .ht_cap.ht_supported = 1,
298 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
299 | IEEE80211_HT_CAP_GRN_FLD
300 | IEEE80211_HT_CAP_DSSSCCK40
301 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
302 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
303 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
304 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
305 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
306 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
307};
308
Jeff Johnson295189b2012-06-20 16:38:30 -0700309static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
310{
311 .channels = hdd_social_channels_2_4_GHZ,
312 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
313 .band = IEEE80211_BAND_2GHZ,
314 .bitrates = g_mode_rates,
315 .n_bitrates = g_mode_rates_size,
316 .ht_cap.ht_supported = 1,
317 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
318 | IEEE80211_HT_CAP_GRN_FLD
319 | IEEE80211_HT_CAP_DSSSCCK40
320 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
321 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
322 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
323 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
324 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
325 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
326};
Jeff Johnson295189b2012-06-20 16:38:30 -0700327
328static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
329{
330 .channels = hdd_channels_5_GHZ,
331 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
332 .band = IEEE80211_BAND_5GHZ,
333 .bitrates = a_mode_rates,
334 .n_bitrates = a_mode_rates_size,
335 .ht_cap.ht_supported = 1,
336 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
337 | IEEE80211_HT_CAP_GRN_FLD
338 | IEEE80211_HT_CAP_DSSSCCK40
339 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
340 | IEEE80211_HT_CAP_SGI_40
341 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
342 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
343 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
344 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
345 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
346 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
347};
348
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530349/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700350 TX/RX direction for each kind of interface */
351static const struct ieee80211_txrx_stypes
352wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
353 [NL80211_IFTYPE_STATION] = {
354 .tx = 0xffff,
355 .rx = BIT(SIR_MAC_MGMT_ACTION) |
356 BIT(SIR_MAC_MGMT_PROBE_REQ),
357 },
358 [NL80211_IFTYPE_AP] = {
359 .tx = 0xffff,
360 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
361 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
362 BIT(SIR_MAC_MGMT_PROBE_REQ) |
363 BIT(SIR_MAC_MGMT_DISASSOC) |
364 BIT(SIR_MAC_MGMT_AUTH) |
365 BIT(SIR_MAC_MGMT_DEAUTH) |
366 BIT(SIR_MAC_MGMT_ACTION),
367 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700368 [NL80211_IFTYPE_ADHOC] = {
369 .tx = 0xffff,
370 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
371 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
372 BIT(SIR_MAC_MGMT_PROBE_REQ) |
373 BIT(SIR_MAC_MGMT_DISASSOC) |
374 BIT(SIR_MAC_MGMT_AUTH) |
375 BIT(SIR_MAC_MGMT_DEAUTH) |
376 BIT(SIR_MAC_MGMT_ACTION),
377 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 [NL80211_IFTYPE_P2P_CLIENT] = {
379 .tx = 0xffff,
380 .rx = BIT(SIR_MAC_MGMT_ACTION) |
381 BIT(SIR_MAC_MGMT_PROBE_REQ),
382 },
383 [NL80211_IFTYPE_P2P_GO] = {
384 /* This is also same as for SoftAP */
385 .tx = 0xffff,
386 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
387 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
388 BIT(SIR_MAC_MGMT_PROBE_REQ) |
389 BIT(SIR_MAC_MGMT_DISASSOC) |
390 BIT(SIR_MAC_MGMT_AUTH) |
391 BIT(SIR_MAC_MGMT_DEAUTH) |
392 BIT(SIR_MAC_MGMT_ACTION),
393 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700394};
395
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800396#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800397static const struct ieee80211_iface_limit
398wlan_hdd_iface_limit[] = {
399 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800400 /* max = 3 ; Our driver create two interfaces during driver init
401 * wlan0 and p2p0 interfaces. p2p0 is considered as station
402 * interface until a group is formed. In JB architecture, once the
403 * group is formed, interface type of p2p0 is changed to P2P GO or
404 * Client.
405 * When supplicant remove the group, it first issue a set interface
406 * cmd to change the mode back to Station. In JB this works fine as
407 * we advertize two station type interface during driver init.
408 * Some vendors create separate interface for P2P GO/Client,
409 * after group formation(Third one). But while group remove
410 * supplicant first tries to change the mode(3rd interface) to STATION
411 * But as we advertized only two sta type interfaces nl80211 was
412 * returning error for the third one which was leading to failure in
413 * delete interface. Ideally while removing the group, supplicant
414 * should not try to change the 3rd interface mode to Station type.
415 * Till we get a fix in wpa_supplicant, we advertize max STA
416 * interface type to 3
417 */
418 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800419 .types = BIT(NL80211_IFTYPE_STATION),
420 },
421 {
422 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700423 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800424 },
425 {
426 .max = 1,
427 .types = BIT(NL80211_IFTYPE_P2P_GO) |
428 BIT(NL80211_IFTYPE_P2P_CLIENT),
429 },
430};
431
432/* By default, only single channel concurrency is allowed */
433static struct ieee80211_iface_combination
434wlan_hdd_iface_combination = {
435 .limits = wlan_hdd_iface_limit,
436 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800437 /*
438 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
439 * and p2p0 interfaces during driver init
440 * Some vendors create separate interface for P2P operations.
441 * wlan0: STA interface
442 * p2p0: P2P Device interface, action frames goes
443 * through this interface.
444 * p2p-xx: P2P interface, After GO negotiation this interface is
445 * created for p2p operations(GO/CLIENT interface).
446 */
447 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800448 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
449 .beacon_int_infra_match = false,
450};
451#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800452
Jeff Johnson295189b2012-06-20 16:38:30 -0700453static struct cfg80211_ops wlan_hdd_cfg80211_ops;
454
455/* Data rate 100KBPS based on IE Index */
456struct index_data_rate_type
457{
458 v_U8_t beacon_rate_index;
459 v_U16_t supported_rate[4];
460};
461
462/* 11B, 11G Rate table include Basic rate and Extended rate
463 The IDX field is the rate index
464 The HI field is the rate when RSSI is strong or being ignored
465 (in this case we report actual rate)
466 The MID field is the rate when RSSI is moderate
467 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
468 The LO field is the rate when RSSI is low
469 (in this case we don't report rates, actual current rate used)
470 */
471static const struct
472{
473 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700474 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700475} supported_data_rate[] =
476{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700477/* IDX HI HM LM LO (RSSI-based index */
478 {2, { 10, 10, 10, 0}},
479 {4, { 20, 20, 10, 0}},
480 {11, { 55, 20, 10, 0}},
481 {12, { 60, 55, 20, 0}},
482 {18, { 90, 55, 20, 0}},
483 {22, {110, 55, 20, 0}},
484 {24, {120, 90, 60, 0}},
485 {36, {180, 120, 60, 0}},
486 {44, {220, 180, 60, 0}},
487 {48, {240, 180, 90, 0}},
488 {66, {330, 180, 90, 0}},
489 {72, {360, 240, 90, 0}},
490 {96, {480, 240, 120, 0}},
491 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700492};
493
494/* MCS Based rate table */
495static struct index_data_rate_type supported_mcs_rate[] =
496{
497/* MCS L20 L40 S20 S40 */
498 {0, {65, 135, 72, 150}},
499 {1, {130, 270, 144, 300}},
500 {2, {195, 405, 217, 450}},
501 {3, {260, 540, 289, 600}},
502 {4, {390, 810, 433, 900}},
503 {5, {520, 1080, 578, 1200}},
504 {6, {585, 1215, 650, 1350}},
505 {7, {650, 1350, 722, 1500}}
506};
507
Leo Chang6f8870f2013-03-26 18:11:36 -0700508#ifdef WLAN_FEATURE_11AC
509
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530510#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700511
512struct index_vht_data_rate_type
513{
514 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530515 v_U16_t supported_VHT80_rate[2];
516 v_U16_t supported_VHT40_rate[2];
517 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700518};
519
520typedef enum
521{
522 DATA_RATE_11AC_MAX_MCS_7,
523 DATA_RATE_11AC_MAX_MCS_8,
524 DATA_RATE_11AC_MAX_MCS_9,
525 DATA_RATE_11AC_MAX_MCS_NA
526} eDataRate11ACMaxMcs;
527
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530528/* SSID broadcast type */
529typedef enum eSSIDBcastType
530{
531 eBCAST_UNKNOWN = 0,
532 eBCAST_NORMAL = 1,
533 eBCAST_HIDDEN = 2,
534} tSSIDBcastType;
535
Leo Chang6f8870f2013-03-26 18:11:36 -0700536/* MCS Based VHT rate table */
537static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
538{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530539/* MCS L80 S80 L40 S40 L20 S40*/
540 {0, {293, 325}, {135, 150}, {65, 72}},
541 {1, {585, 650}, {270, 300}, {130, 144}},
542 {2, {878, 975}, {405, 450}, {195, 217}},
543 {3, {1170, 1300}, {540, 600}, {260, 289}},
544 {4, {1755, 1950}, {810, 900}, {390, 433}},
545 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
546 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
547 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
548 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
549 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700550};
551#endif /* WLAN_FEATURE_11AC */
552
c_hpothu79aab322014-07-14 21:11:01 +0530553/*array index points to MCS and array value points respective rssi*/
554static int rssiMcsTbl[][10] =
555{
556/*MCS 0 1 2 3 4 5 6 7 8 9*/
557 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
558 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
559 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
560};
561
Jeff Johnson295189b2012-06-20 16:38:30 -0700562extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530563#ifdef FEATURE_WLAN_SCAN_PNO
564static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
565#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700566
Leo Chang9056f462013-08-01 19:21:11 -0700567#ifdef WLAN_NL80211_TESTMODE
568enum wlan_hdd_tm_attr
569{
570 WLAN_HDD_TM_ATTR_INVALID = 0,
571 WLAN_HDD_TM_ATTR_CMD = 1,
572 WLAN_HDD_TM_ATTR_DATA = 2,
573 WLAN_HDD_TM_ATTR_TYPE = 3,
574 /* keep last */
575 WLAN_HDD_TM_ATTR_AFTER_LAST,
576 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
577};
578
579enum wlan_hdd_tm_cmd
580{
581 WLAN_HDD_TM_CMD_WLAN_HB = 1,
582};
583
584#define WLAN_HDD_TM_DATA_MAX_LEN 5000
585
586static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
587{
588 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
589 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
590 .len = WLAN_HDD_TM_DATA_MAX_LEN },
591};
592#endif /* WLAN_NL80211_TESTMODE */
593
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800594#ifdef FEATURE_WLAN_CH_AVOID
595/*
596 * FUNCTION: wlan_hdd_send_avoid_freq_event
597 * This is called when wlan driver needs to send vendor specific
598 * avoid frequency range event to userspace
599 */
600int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
601 tHddAvoidFreqList *pAvoidFreqList)
602{
603 struct sk_buff *vendor_event;
604
605 ENTER();
606
607 if (!pHddCtx)
608 {
609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
610 "%s: HDD context is null", __func__);
611 return -1;
612 }
613
614 if (!pAvoidFreqList)
615 {
616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
617 "%s: pAvoidFreqList is null", __func__);
618 return -1;
619 }
620
621 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
622 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530623 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800624 GFP_KERNEL);
625 if (!vendor_event)
626 {
627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
628 "%s: cfg80211_vendor_event_alloc failed", __func__);
629 return -1;
630 }
631
632 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
633 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
634
635 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
636
637 EXIT();
638 return 0;
639}
640#endif /* FEATURE_WLAN_CH_AVOID */
641
Srinivas Dasari030bad32015-02-18 23:23:54 +0530642/*
643 * FUNCTION: __wlan_hdd_cfg80211_nan_request
644 * This is called when wlan driver needs to send vendor specific
645 * nan request event.
646 */
647static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
648 struct wireless_dev *wdev,
649 const void *data, int data_len)
650{
651 tNanRequestReq nan_req;
652 VOS_STATUS status;
653 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530654 struct net_device *dev = wdev->netdev;
655 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
656 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530657 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
658
659 if (0 == data_len)
660 {
661 hddLog(VOS_TRACE_LEVEL_ERROR,
662 FL("NAN - Invalid Request, length = 0"));
663 return ret_val;
664 }
665
666 if (NULL == data)
667 {
668 hddLog(VOS_TRACE_LEVEL_ERROR,
669 FL("NAN - Invalid Request, data is NULL"));
670 return ret_val;
671 }
672
673 status = wlan_hdd_validate_context(pHddCtx);
674 if (0 != status)
675 {
676 hddLog(VOS_TRACE_LEVEL_ERROR,
677 FL("HDD context is not valid"));
678 return -EINVAL;
679 }
680
681 hddLog(LOG1, FL("Received NAN command"));
682 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
683 (tANI_U8 *)data, data_len);
684
685 /* check the NAN Capability */
686 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
687 {
688 hddLog(VOS_TRACE_LEVEL_ERROR,
689 FL("NAN is not supported by Firmware"));
690 return -EINVAL;
691 }
692
693 nan_req.request_data_len = data_len;
694 nan_req.request_data = data;
695
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530696 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530697 if (VOS_STATUS_SUCCESS == status)
698 {
699 ret_val = 0;
700 }
701 return ret_val;
702}
703
704/*
705 * FUNCTION: wlan_hdd_cfg80211_nan_request
706 * Wrapper to protect the nan vendor command from ssr
707 */
708static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
709 struct wireless_dev *wdev,
710 const void *data, int data_len)
711{
712 int ret;
713
714 vos_ssr_protect(__func__);
715 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
716 vos_ssr_unprotect(__func__);
717
718 return ret;
719}
720
721/*
722 * FUNCTION: wlan_hdd_cfg80211_nan_callback
723 * This is a callback function and it gets called
724 * when we need to report nan response event to
725 * upper layers.
726 */
727static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
728{
729 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
730 struct sk_buff *vendor_event;
731 int status;
732 tSirNanEvent *data;
733
734 ENTER();
735 if (NULL == msg)
736 {
737 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
738 FL(" msg received here is null"));
739 return;
740 }
741 data = msg;
742
743 status = wlan_hdd_validate_context(pHddCtx);
744
745 if (0 != status)
746 {
747 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
748 FL("HDD context is not valid"));
749 return;
750 }
751
752 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
753 data->event_data_len +
754 NLMSG_HDRLEN,
755 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
756 GFP_KERNEL);
757
758 if (!vendor_event)
759 {
760 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
761 FL("cfg80211_vendor_event_alloc failed"));
762 return;
763 }
764 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
765 data->event_data_len, data->event_data))
766 {
767 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
768 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
769 kfree_skb(vendor_event);
770 return;
771 }
772 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
773 EXIT();
774}
775
776/*
777 * FUNCTION: wlan_hdd_cfg80211_nan_init
778 * This function is called to register the callback to sme layer
779 */
780inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
781{
782 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
783}
784
785
Sunil Duttc69bccb2014-05-26 21:30:20 +0530786#ifdef WLAN_FEATURE_LINK_LAYER_STATS
787
788static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
789 struct sk_buff *vendor_event)
790{
791 if (nla_put_u8(vendor_event,
792 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
793 stats->rate.preamble) ||
794 nla_put_u8(vendor_event,
795 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
796 stats->rate.nss) ||
797 nla_put_u8(vendor_event,
798 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
799 stats->rate.bw) ||
800 nla_put_u8(vendor_event,
801 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
802 stats->rate.rateMcsIdx) ||
803 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
804 stats->rate.bitrate ) ||
805 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
806 stats->txMpdu ) ||
807 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
808 stats->rxMpdu ) ||
809 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
810 stats->mpduLost ) ||
811 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
812 stats->retries) ||
813 nla_put_u32(vendor_event,
814 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
815 stats->retriesShort ) ||
816 nla_put_u32(vendor_event,
817 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
818 stats->retriesLong))
819 {
820 hddLog(VOS_TRACE_LEVEL_ERROR,
821 FL("QCA_WLAN_VENDOR_ATTR put fail"));
822 return FALSE;
823 }
824 return TRUE;
825}
826
827static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
828 struct sk_buff *vendor_event)
829{
830 u32 i = 0;
831 struct nlattr *rateInfo;
832 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
833 stats->type) ||
834 nla_put(vendor_event,
835 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
836 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
837 nla_put_u32(vendor_event,
838 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
839 stats->capabilities) ||
840 nla_put_u32(vendor_event,
841 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
842 stats->numRate))
843 {
844 hddLog(VOS_TRACE_LEVEL_ERROR,
845 FL("QCA_WLAN_VENDOR_ATTR put fail"));
846 goto error;
847 }
848
849 rateInfo = nla_nest_start(vendor_event,
850 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530851 if(!rateInfo)
852 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530853 for (i = 0; i < stats->numRate; i++)
854 {
855 struct nlattr *rates;
856 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
857 stats->rateStats +
858 (i * sizeof(tSirWifiRateStat)));
859 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530860 if(!rates)
861 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530862
863 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
864 {
865 hddLog(VOS_TRACE_LEVEL_ERROR,
866 FL("QCA_WLAN_VENDOR_ATTR put fail"));
867 return FALSE;
868 }
869 nla_nest_end(vendor_event, rates);
870 }
871 nla_nest_end(vendor_event, rateInfo);
872
873 return TRUE;
874error:
875 return FALSE;
876}
877
878static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
879 struct sk_buff *vendor_event)
880{
881 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
882 stats->ac ) ||
883 nla_put_u32(vendor_event,
884 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
885 stats->txMpdu ) ||
886 nla_put_u32(vendor_event,
887 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
888 stats->rxMpdu ) ||
889 nla_put_u32(vendor_event,
890 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
891 stats->txMcast ) ||
892 nla_put_u32(vendor_event,
893 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
894 stats->rxMcast ) ||
895 nla_put_u32(vendor_event,
896 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
897 stats->rxAmpdu ) ||
898 nla_put_u32(vendor_event,
899 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
900 stats->txAmpdu ) ||
901 nla_put_u32(vendor_event,
902 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
903 stats->mpduLost )||
904 nla_put_u32(vendor_event,
905 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
906 stats->retries ) ||
907 nla_put_u32(vendor_event,
908 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
909 stats->retriesShort ) ||
910 nla_put_u32(vendor_event,
911 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
912 stats->retriesLong ) ||
913 nla_put_u32(vendor_event,
914 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
915 stats->contentionTimeMin ) ||
916 nla_put_u32(vendor_event,
917 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
918 stats->contentionTimeMax ) ||
919 nla_put_u32(vendor_event,
920 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
921 stats->contentionTimeAvg ) ||
922 nla_put_u32(vendor_event,
923 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
924 stats->contentionNumSamples ))
925 {
926 hddLog(VOS_TRACE_LEVEL_ERROR,
927 FL("QCA_WLAN_VENDOR_ATTR put fail") );
928 return FALSE;
929 }
930 return TRUE;
931}
932
933static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
934 struct sk_buff *vendor_event)
935{
Dino Myclec8f3f332014-07-21 16:48:27 +0530936 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530937 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
938 nla_put(vendor_event,
939 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
940 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
941 nla_put_u32(vendor_event,
942 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
943 stats->state ) ||
944 nla_put_u32(vendor_event,
945 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
946 stats->roaming ) ||
947 nla_put_u32(vendor_event,
948 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
949 stats->capabilities ) ||
950 nla_put(vendor_event,
951 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
952 strlen(stats->ssid), stats->ssid) ||
953 nla_put(vendor_event,
954 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
955 WNI_CFG_BSSID_LEN, stats->bssid) ||
956 nla_put(vendor_event,
957 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
958 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
959 nla_put(vendor_event,
960 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
961 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
962 )
963 {
964 hddLog(VOS_TRACE_LEVEL_ERROR,
965 FL("QCA_WLAN_VENDOR_ATTR put fail") );
966 return FALSE;
967 }
968 return TRUE;
969}
970
Dino Mycle3b9536d2014-07-09 22:05:24 +0530971static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
972 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530973 struct sk_buff *vendor_event)
974{
975 int i = 0;
976 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530977 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
978 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530979 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530980
Sunil Duttc69bccb2014-05-26 21:30:20 +0530981 if (FALSE == put_wifi_interface_info(
982 &pWifiIfaceStat->info,
983 vendor_event))
984 {
985 hddLog(VOS_TRACE_LEVEL_ERROR,
986 FL("QCA_WLAN_VENDOR_ATTR put fail") );
987 return FALSE;
988
989 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530990 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
991 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
992 if (NULL == pWifiIfaceStatTL)
993 {
994 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
995 return FALSE;
996 }
997
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530998 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
999 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
1000 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
1001 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1002
1003 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1004 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1005 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1006 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301007
1008 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1009 {
1010 if (VOS_STATUS_SUCCESS ==
1011 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1012 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1013 {
1014 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1015 * obtained from TL structure
1016 */
1017
1018 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1019 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301020 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1021
Srinivas Dasari98947432014-11-07 19:41:24 +05301022 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1023 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1024 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1025 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1026 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1027 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1028 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1029 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301030
Srinivas Dasari98947432014-11-07 19:41:24 +05301031 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1032 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1033 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1034 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1035 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1036 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1037 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1038 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301039
Srinivas Dasari98947432014-11-07 19:41:24 +05301040 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1041 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1042 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1043 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1044 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1045 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1046 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1047 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301048 }
1049 else
1050 {
1051 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1052 }
1053
Dino Mycle3b9536d2014-07-09 22:05:24 +05301054 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1055 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1056 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1057 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1058 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1059 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1060 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1061 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1062 }
1063 else
1064 {
1065 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1066 }
1067
1068
Sunil Duttc69bccb2014-05-26 21:30:20 +05301069
1070 if (nla_put_u32(vendor_event,
1071 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1072 pWifiIfaceStat->beaconRx) ||
1073 nla_put_u32(vendor_event,
1074 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1075 pWifiIfaceStat->mgmtRx) ||
1076 nla_put_u32(vendor_event,
1077 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1078 pWifiIfaceStat->mgmtActionRx) ||
1079 nla_put_u32(vendor_event,
1080 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1081 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301082 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301083 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1084 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301085 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301086 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1087 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301088 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301089 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1090 pWifiIfaceStat->rssiAck))
1091 {
1092 hddLog(VOS_TRACE_LEVEL_ERROR,
1093 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301094 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301095 return FALSE;
1096 }
1097
1098 wmmInfo = nla_nest_start(vendor_event,
1099 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301100 if(!wmmInfo)
1101 {
1102 vos_mem_free(pWifiIfaceStatTL);
1103 return FALSE;
1104 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301105 for (i = 0; i < WIFI_AC_MAX; i++)
1106 {
1107 struct nlattr *wmmStats;
1108 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301109 if(!wmmStats)
1110 {
1111 vos_mem_free(pWifiIfaceStatTL);
1112 return FALSE;
1113 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301114 if (FALSE == put_wifi_wmm_ac_stat(
1115 &pWifiIfaceStat->AccessclassStats[i],
1116 vendor_event))
1117 {
1118 hddLog(VOS_TRACE_LEVEL_ERROR,
1119 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301120 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301121 return FALSE;
1122 }
1123
1124 nla_nest_end(vendor_event, wmmStats);
1125 }
1126 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301127 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301128 return TRUE;
1129}
1130
1131static tSirWifiInterfaceMode
1132 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1133{
1134 switch (deviceMode)
1135 {
1136 case WLAN_HDD_INFRA_STATION:
1137 return WIFI_INTERFACE_STA;
1138 case WLAN_HDD_SOFTAP:
1139 return WIFI_INTERFACE_SOFTAP;
1140 case WLAN_HDD_P2P_CLIENT:
1141 return WIFI_INTERFACE_P2P_CLIENT;
1142 case WLAN_HDD_P2P_GO:
1143 return WIFI_INTERFACE_P2P_GO;
1144 case WLAN_HDD_IBSS:
1145 return WIFI_INTERFACE_IBSS;
1146 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301147 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301148 }
1149}
1150
1151static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1152 tpSirWifiInterfaceInfo pInfo)
1153{
1154 v_U8_t *staMac = NULL;
1155 hdd_station_ctx_t *pHddStaCtx;
1156 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1157 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1158
1159 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1160
1161 vos_mem_copy(pInfo->macAddr,
1162 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1163
1164 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1165 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1166 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1167 {
1168 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1169 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1170 {
1171 pInfo->state = WIFI_DISCONNECTED;
1172 }
1173 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1174 {
1175 hddLog(VOS_TRACE_LEVEL_ERROR,
1176 "%s: Session ID %d, Connection is in progress", __func__,
1177 pAdapter->sessionId);
1178 pInfo->state = WIFI_ASSOCIATING;
1179 }
1180 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1181 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1182 {
1183 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1184 hddLog(VOS_TRACE_LEVEL_ERROR,
1185 "%s: client " MAC_ADDRESS_STR
1186 " is in the middle of WPS/EAPOL exchange.", __func__,
1187 MAC_ADDR_ARRAY(staMac));
1188 pInfo->state = WIFI_AUTHENTICATING;
1189 }
1190 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1191 {
1192 pInfo->state = WIFI_ASSOCIATED;
1193 vos_mem_copy(pInfo->bssid,
1194 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1195 vos_mem_copy(pInfo->ssid,
1196 pHddStaCtx->conn_info.SSID.SSID.ssId,
1197 pHddStaCtx->conn_info.SSID.SSID.length);
1198 //NULL Terminate the string.
1199 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1200 }
1201 }
1202 vos_mem_copy(pInfo->countryStr,
1203 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1204
1205 vos_mem_copy(pInfo->apCountryStr,
1206 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1207
1208 return TRUE;
1209}
1210
1211/*
1212 * hdd_link_layer_process_peer_stats () - This function is called after
1213 * receiving Link Layer Peer statistics from FW.This function converts
1214 * the firmware data to the NL data and sends the same to the kernel/upper
1215 * layers.
1216 */
1217static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1218 v_VOID_t *pData)
1219{
1220 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1221 tpSirWifiRateStat pWifiRateStat;
1222 tpSirWifiPeerStat pWifiPeerStat;
1223 tpSirWifiPeerInfo pWifiPeerInfo;
1224 struct nlattr *peerInfo;
1225 struct sk_buff *vendor_event;
1226 int status, i;
1227
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301228 ENTER();
1229
Sunil Duttc69bccb2014-05-26 21:30:20 +05301230 status = wlan_hdd_validate_context(pHddCtx);
1231 if (0 != status)
1232 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301233 return;
1234 }
1235
1236 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1237
1238 hddLog(VOS_TRACE_LEVEL_INFO,
1239 "LL_STATS_PEER_ALL : numPeers %u",
1240 pWifiPeerStat->numPeers);
1241 {
1242 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1243 {
1244 pWifiPeerInfo = (tpSirWifiPeerInfo)
1245 ((uint8 *)pWifiPeerStat->peerInfo +
1246 ( i * sizeof(tSirWifiPeerInfo)));
1247
Dasari Srinivas1be0c4e2014-10-19 13:03:41 +05301248 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) {
1249 pWifiPeerInfo->type = WIFI_PEER_AP;
1250 }
1251 if (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) {
1252 pWifiPeerInfo->type = WIFI_PEER_P2P_GO;
1253 }
1254
Sunil Duttc69bccb2014-05-26 21:30:20 +05301255 hddLog(VOS_TRACE_LEVEL_INFO,
1256 " %d) LL_STATS Channel Stats "
1257 " Peer Type %u "
1258 " peerMacAddress %pM "
1259 " capabilities 0x%x "
1260 " numRate %u ",
1261 i,
1262 pWifiPeerInfo->type,
1263 pWifiPeerInfo->peerMacAddress,
1264 pWifiPeerInfo->capabilities,
1265 pWifiPeerInfo->numRate);
1266 {
1267 int j;
1268 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1269 {
1270 pWifiRateStat = (tpSirWifiRateStat)
1271 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1272 ( j * sizeof(tSirWifiRateStat)));
1273
1274 hddLog(VOS_TRACE_LEVEL_INFO,
1275 " peer Rate Stats "
1276 " preamble %u "
1277 " nss %u "
1278 " bw %u "
1279 " rateMcsIdx %u "
1280 " reserved %u "
1281 " bitrate %u "
1282 " txMpdu %u "
1283 " rxMpdu %u "
1284 " mpduLost %u "
1285 " retries %u "
1286 " retriesShort %u "
1287 " retriesLong %u",
1288 pWifiRateStat->rate.preamble,
1289 pWifiRateStat->rate.nss,
1290 pWifiRateStat->rate.bw,
1291 pWifiRateStat->rate.rateMcsIdx,
1292 pWifiRateStat->rate.reserved,
1293 pWifiRateStat->rate.bitrate,
1294 pWifiRateStat->txMpdu,
1295 pWifiRateStat->rxMpdu,
1296 pWifiRateStat->mpduLost,
1297 pWifiRateStat->retries,
1298 pWifiRateStat->retriesShort,
1299 pWifiRateStat->retriesLong);
1300 }
1301 }
1302 }
1303 }
1304
1305 /*
1306 * Allocate a size of 4096 for the peer stats comprising
1307 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1308 * sizeof (tSirWifiRateStat).Each field is put with an
1309 * NL attribute.The size of 4096 is considered assuming
1310 * that number of rates shall not exceed beyond 50 with
1311 * the sizeof (tSirWifiRateStat) being 32.
1312 */
1313 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1314 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1315 QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX,
1316 GFP_KERNEL);
1317 if (!vendor_event)
1318 {
1319 hddLog(VOS_TRACE_LEVEL_ERROR,
1320 "%s: cfg80211_vendor_event_alloc failed",
1321 __func__);
1322 return;
1323 }
1324 if (nla_put_u32(vendor_event,
1325 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1326 pWifiPeerStat->numPeers))
1327 {
1328 hddLog(VOS_TRACE_LEVEL_ERROR,
1329 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1330 kfree_skb(vendor_event);
1331 return;
1332 }
1333
1334 peerInfo = nla_nest_start(vendor_event,
1335 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301336 if(!peerInfo)
1337 {
1338 hddLog(VOS_TRACE_LEVEL_ERROR,
1339 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1340 __func__);
1341 kfree_skb(vendor_event);
1342 return;
1343 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301344
1345 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1346 pWifiPeerStat->peerInfo);
1347
1348 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1349 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301350 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301351 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301352
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301353 if(!peers)
1354 {
1355 hddLog(VOS_TRACE_LEVEL_ERROR,
1356 "%s: peer stats put fail",
1357 __func__);
1358 kfree_skb(vendor_event);
1359 return;
1360 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301361 if (FALSE == put_wifi_peer_info(
1362 pWifiPeerInfo, vendor_event))
1363 {
1364 hddLog(VOS_TRACE_LEVEL_ERROR,
1365 "%s: put_wifi_peer_info put fail", __func__);
1366 kfree_skb(vendor_event);
1367 return;
1368 }
1369
1370 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1371 pWifiPeerStat->peerInfo +
1372 (i * sizeof(tSirWifiPeerInfo)) +
1373 (numRate * sizeof (tSirWifiRateStat)));
1374 nla_nest_end(vendor_event, peers);
1375 }
1376 nla_nest_end(vendor_event, peerInfo);
1377 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301378
1379 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301380}
1381
1382/*
1383 * hdd_link_layer_process_iface_stats () - This function is called after
1384 * receiving Link Layer Interface statistics from FW.This function converts
1385 * the firmware data to the NL data and sends the same to the kernel/upper
1386 * layers.
1387 */
1388static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1389 v_VOID_t *pData)
1390{
1391 tpSirWifiIfaceStat pWifiIfaceStat;
1392 struct sk_buff *vendor_event;
1393 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1394 int status;
1395
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301396 ENTER();
1397
Sunil Duttc69bccb2014-05-26 21:30:20 +05301398 status = wlan_hdd_validate_context(pHddCtx);
1399 if (0 != status)
1400 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301401 return;
1402 }
1403 /*
1404 * Allocate a size of 4096 for the interface stats comprising
1405 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1406 * assuming that all these fit with in the limit.Please take
1407 * a call on the limit based on the data requirements on
1408 * interface statistics.
1409 */
1410 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1411 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1412 QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX,
1413 GFP_KERNEL);
1414 if (!vendor_event)
1415 {
1416 hddLog(VOS_TRACE_LEVEL_ERROR,
1417 FL("cfg80211_vendor_event_alloc failed") );
1418 return;
1419 }
1420
1421 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1422
Dino Mycle3b9536d2014-07-09 22:05:24 +05301423
1424 if (FALSE == hdd_get_interface_info( pAdapter,
1425 &pWifiIfaceStat->info))
1426 {
1427 hddLog(VOS_TRACE_LEVEL_ERROR,
1428 FL("hdd_get_interface_info get fail") );
1429 kfree_skb(vendor_event);
1430 return;
1431 }
1432
1433 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1434 vendor_event))
1435 {
1436 hddLog(VOS_TRACE_LEVEL_ERROR,
1437 FL("put_wifi_iface_stats fail") );
1438 kfree_skb(vendor_event);
1439 return;
1440 }
1441
Sunil Duttc69bccb2014-05-26 21:30:20 +05301442 hddLog(VOS_TRACE_LEVEL_INFO,
1443 "WMI_LINK_STATS_IFACE Data");
1444
1445 hddLog(VOS_TRACE_LEVEL_INFO,
1446 "LL_STATS_IFACE: "
1447 " Mode %u "
1448 " MAC %pM "
1449 " State %u "
1450 " Roaming %u "
1451 " capabilities 0x%x "
1452 " SSID %s "
1453 " BSSID %pM",
1454 pWifiIfaceStat->info.mode,
1455 pWifiIfaceStat->info.macAddr,
1456 pWifiIfaceStat->info.state,
1457 pWifiIfaceStat->info.roaming,
1458 pWifiIfaceStat->info.capabilities,
1459 pWifiIfaceStat->info.ssid,
1460 pWifiIfaceStat->info.bssid);
1461
1462 hddLog(VOS_TRACE_LEVEL_INFO,
1463 " AP country str: %c%c%c",
1464 pWifiIfaceStat->info.apCountryStr[0],
1465 pWifiIfaceStat->info.apCountryStr[1],
1466 pWifiIfaceStat->info.apCountryStr[2]);
1467
1468
1469 hddLog(VOS_TRACE_LEVEL_INFO,
1470 " Country Str Association: %c%c%c",
1471 pWifiIfaceStat->info.countryStr[0],
1472 pWifiIfaceStat->info.countryStr[1],
1473 pWifiIfaceStat->info.countryStr[2]);
1474
1475 hddLog(VOS_TRACE_LEVEL_INFO,
1476 " beaconRx %u "
1477 " mgmtRx %u "
1478 " mgmtActionRx %u "
1479 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301480 " rssiMgmt %d "
1481 " rssiData %d "
1482 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301483 pWifiIfaceStat->beaconRx,
1484 pWifiIfaceStat->mgmtRx,
1485 pWifiIfaceStat->mgmtActionRx,
1486 pWifiIfaceStat->mgmtActionTx,
1487 pWifiIfaceStat->rssiMgmt,
1488 pWifiIfaceStat->rssiData,
1489 pWifiIfaceStat->rssiAck );
1490
1491
1492 {
1493 int i;
1494 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1495 {
1496 hddLog(VOS_TRACE_LEVEL_INFO,
1497
1498 " %d) LL_STATS IFACE: "
1499 " ac: %u txMpdu: %u "
1500 " rxMpdu: %u txMcast: %u "
1501 " rxMcast: %u rxAmpdu: %u "
1502 " txAmpdu: %u mpduLost: %u "
1503 " retries: %u retriesShort: %u "
1504 " retriesLong: %u contentionTimeMin: %u "
1505 " contentionTimeMax: %u contentionTimeAvg: %u "
1506 " contentionNumSamples: %u",
1507 i,
1508 pWifiIfaceStat->AccessclassStats[i].ac,
1509 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1510 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1511 pWifiIfaceStat->AccessclassStats[i].txMcast,
1512 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1513 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1514 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1515 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1516 pWifiIfaceStat->AccessclassStats[i].retries,
1517 pWifiIfaceStat->
1518 AccessclassStats[i].retriesShort,
1519 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1520 pWifiIfaceStat->
1521 AccessclassStats[i].contentionTimeMin,
1522 pWifiIfaceStat->
1523 AccessclassStats[i].contentionTimeMax,
1524 pWifiIfaceStat->
1525 AccessclassStats[i].contentionTimeAvg,
1526 pWifiIfaceStat->
1527 AccessclassStats[i].contentionNumSamples);
1528
1529 }
1530 }
1531
Sunil Duttc69bccb2014-05-26 21:30:20 +05301532 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301533
1534 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301535}
1536
1537/*
1538 * hdd_link_layer_process_radio_stats () - This function is called after
1539 * receiving Link Layer Radio statistics from FW.This function converts
1540 * the firmware data to the NL data and sends the same to the kernel/upper
1541 * layers.
1542 */
1543static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1544 v_VOID_t *pData)
1545{
1546 int status, i;
1547 tpSirWifiRadioStat pWifiRadioStat;
1548 tpSirWifiChannelStats pWifiChannelStats;
1549 struct sk_buff *vendor_event;
1550 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1551 struct nlattr *chList;
1552
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301553 ENTER();
1554
Sunil Duttc69bccb2014-05-26 21:30:20 +05301555 status = wlan_hdd_validate_context(pHddCtx);
1556 if (0 != status)
1557 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301558 return;
1559 }
1560 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1561
1562 hddLog(VOS_TRACE_LEVEL_INFO,
1563 "LL_STATS_RADIO"
1564 " radio is %d onTime is %u "
1565 " txTime is %u rxTime is %u "
1566 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301567 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301568 " onTimePnoScan is %u onTimeHs20 is %u "
1569 " numChannels is %u",
1570 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1571 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1572 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301573 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301574 pWifiRadioStat->onTimeRoamScan,
1575 pWifiRadioStat->onTimePnoScan,
1576 pWifiRadioStat->onTimeHs20,
1577 pWifiRadioStat->numChannels);
1578 /*
1579 * Allocate a size of 4096 for the Radio stats comprising
1580 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1581 * (tSirWifiChannelStats).Each channel data is put with an
1582 * NL attribute.The size of 4096 is considered assuming that
1583 * number of channels shall not exceed beyond 60 with the
1584 * sizeof (tSirWifiChannelStats) being 24 bytes.
1585 */
1586
1587 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1588 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN ,
1589 QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX,
1590 GFP_KERNEL);
1591
1592 if (!vendor_event)
1593 {
1594 hddLog(VOS_TRACE_LEVEL_ERROR,
1595 FL("cfg80211_vendor_event_alloc failed") );
1596 return;
1597 }
1598
1599 if (nla_put_u32(vendor_event,
1600 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1601 pWifiRadioStat->radio) ||
1602 nla_put_u32(vendor_event,
1603 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1604 pWifiRadioStat->onTime) ||
1605 nla_put_u32(vendor_event,
1606 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1607 pWifiRadioStat->txTime) ||
1608 nla_put_u32(vendor_event,
1609 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1610 pWifiRadioStat->rxTime) ||
1611 nla_put_u32(vendor_event,
1612 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1613 pWifiRadioStat->onTimeScan) ||
1614 nla_put_u32(vendor_event,
1615 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1616 pWifiRadioStat->onTimeNbd) ||
1617 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301618 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1619 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301620 nla_put_u32(vendor_event,
1621 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1622 pWifiRadioStat->onTimeRoamScan) ||
1623 nla_put_u32(vendor_event,
1624 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1625 pWifiRadioStat->onTimePnoScan) ||
1626 nla_put_u32(vendor_event,
1627 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1628 pWifiRadioStat->onTimeHs20) ||
1629 nla_put_u32(vendor_event,
1630 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1631 pWifiRadioStat->numChannels))
1632 {
1633 hddLog(VOS_TRACE_LEVEL_ERROR,
1634 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1635 kfree_skb(vendor_event);
1636 return ;
1637 }
1638
1639 chList = nla_nest_start(vendor_event,
1640 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301641 if(!chList)
1642 {
1643 hddLog(VOS_TRACE_LEVEL_ERROR,
1644 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1645 __func__);
1646 kfree_skb(vendor_event);
1647 return;
1648 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301649 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1650 {
1651 struct nlattr *chInfo;
1652
1653 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1654 pWifiRadioStat->channels +
1655 (i * sizeof(tSirWifiChannelStats)));
1656
1657 hddLog(VOS_TRACE_LEVEL_INFO,
1658 " %d) Channel Info"
1659 " width is %u "
1660 " CenterFreq %u "
1661 " CenterFreq0 %u "
1662 " CenterFreq1 %u "
1663 " onTime %u "
1664 " ccaBusyTime %u",
1665 i,
1666 pWifiChannelStats->channel.width,
1667 pWifiChannelStats->channel.centerFreq,
1668 pWifiChannelStats->channel.centerFreq0,
1669 pWifiChannelStats->channel.centerFreq1,
1670 pWifiChannelStats->onTime,
1671 pWifiChannelStats->ccaBusyTime);
1672
1673
1674 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301675 if(!chInfo)
1676 {
1677 hddLog(VOS_TRACE_LEVEL_ERROR,
1678 "%s: failed to put chInfo",
1679 __func__);
1680 kfree_skb(vendor_event);
1681 return;
1682 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301683
1684 if (nla_put_u32(vendor_event,
1685 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1686 pWifiChannelStats->channel.width) ||
1687 nla_put_u32(vendor_event,
1688 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1689 pWifiChannelStats->channel.centerFreq) ||
1690 nla_put_u32(vendor_event,
1691 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1692 pWifiChannelStats->channel.centerFreq0) ||
1693 nla_put_u32(vendor_event,
1694 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1695 pWifiChannelStats->channel.centerFreq1) ||
1696 nla_put_u32(vendor_event,
1697 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1698 pWifiChannelStats->onTime) ||
1699 nla_put_u32(vendor_event,
1700 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1701 pWifiChannelStats->ccaBusyTime))
1702 {
1703 hddLog(VOS_TRACE_LEVEL_ERROR,
1704 FL("cfg80211_vendor_event_alloc failed") );
1705 kfree_skb(vendor_event);
1706 return ;
1707 }
1708 nla_nest_end(vendor_event, chInfo);
1709 }
1710 nla_nest_end(vendor_event, chList);
1711
1712 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301713
1714 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301715 return;
1716}
1717
1718/*
1719 * hdd_link_layer_stats_ind_callback () - This function is called after
1720 * receiving Link Layer indications from FW.This callback converts the firmware
1721 * data to the NL data and send the same to the kernel/upper layers.
1722 */
1723static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1724 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301725 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301726{
Dino Mycled3d50022014-07-07 12:58:25 +05301727 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1728 hdd_adapter_t *pAdapter = NULL;
1729 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301730 int status;
1731
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301732 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301733
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301734 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301735 if (0 != status)
1736 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301737 return;
1738 }
1739
Dino Mycled3d50022014-07-07 12:58:25 +05301740 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1741 if (NULL == pAdapter)
1742 {
1743 hddLog(VOS_TRACE_LEVEL_ERROR,
1744 FL(" MAC address %pM does not exist with host"),
1745 macAddr);
1746 return;
1747 }
1748
Sunil Duttc69bccb2014-05-26 21:30:20 +05301749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301750 "%s: Interface: %s LLStats indType: %d", __func__,
1751 pAdapter->dev->name, indType);
1752
Sunil Duttc69bccb2014-05-26 21:30:20 +05301753 switch (indType)
1754 {
1755 case SIR_HAL_LL_STATS_RESULTS_RSP:
1756 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301757 hddLog(VOS_TRACE_LEVEL_INFO,
1758 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1759 hddLog(VOS_TRACE_LEVEL_INFO,
1760 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1761 linkLayerStatsResults->paramId);
1762 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301763 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1764 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301765 hddLog(VOS_TRACE_LEVEL_INFO,
1766 "LL_STATS RESULTS RESPONSE respId = %u",
1767 linkLayerStatsResults->respId);
1768 hddLog(VOS_TRACE_LEVEL_INFO,
1769 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1770 linkLayerStatsResults->moreResultToFollow);
1771 hddLog(VOS_TRACE_LEVEL_INFO,
1772 "LL_STATS RESULTS RESPONSE result = %p",
1773 linkLayerStatsResults->result);
1774 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1775 {
1776 hdd_link_layer_process_radio_stats(pAdapter,
1777 (v_VOID_t *)linkLayerStatsResults->result);
1778 }
1779 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1780 {
1781 hdd_link_layer_process_iface_stats(pAdapter,
1782 (v_VOID_t *)linkLayerStatsResults->result);
1783 }
1784 else if ( linkLayerStatsResults->paramId &
1785 WMI_LINK_STATS_ALL_PEER )
1786 {
1787 hdd_link_layer_process_peer_stats(pAdapter,
1788 (v_VOID_t *)linkLayerStatsResults->result);
1789 } /* WMI_LINK_STATS_ALL_PEER */
1790 else
1791 {
1792 hddLog(VOS_TRACE_LEVEL_ERROR,
1793 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1794 }
1795
1796 break;
1797 }
1798 default:
1799 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1800 break;
1801 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301802
1803 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301804 return;
1805}
1806
1807const struct
1808nla_policy
1809qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1810{
1811 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1812 { .type = NLA_U32 },
1813 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1814 { .type = NLA_U32 },
1815};
1816
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301817static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1818 struct wireless_dev *wdev,
1819 const void *data,
1820 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301821{
1822 int status;
1823 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301824 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301825 struct net_device *dev = wdev->netdev;
1826 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1827 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Srinivas Dasari98947432014-11-07 19:41:24 +05301828 hdd_station_ctx_t *pHddStaCtx;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301829
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301830 ENTER();
1831
Sunil Duttc69bccb2014-05-26 21:30:20 +05301832 status = wlan_hdd_validate_context(pHddCtx);
1833 if (0 != status)
1834 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301835 return -EINVAL;
1836 }
1837
1838 if (NULL == pAdapter)
1839 {
1840 hddLog(VOS_TRACE_LEVEL_ERROR,
1841 FL("HDD adapter is Null"));
1842 return -ENODEV;
1843 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301844 /* check the LLStats Capability */
1845 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1846 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1847 {
1848 hddLog(VOS_TRACE_LEVEL_ERROR,
1849 FL("Link Layer Statistics not supported by Firmware"));
1850 return -EINVAL;
1851 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301852
1853 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1854 (struct nlattr *)data,
1855 data_len, qca_wlan_vendor_ll_set_policy))
1856 {
1857 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1858 return -EINVAL;
1859 }
1860 if (!tb_vendor
1861 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1862 {
1863 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1864 return -EINVAL;
1865 }
1866 if (!tb_vendor[
1867 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1868 {
1869 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1870 return -EINVAL;
1871 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301872 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301873 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301874
Dino Mycledf0a5d92014-07-04 09:41:55 +05301875 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301876 nla_get_u32(
1877 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1878
Dino Mycledf0a5d92014-07-04 09:41:55 +05301879 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301880 nla_get_u32(
1881 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1882
Dino Mycled3d50022014-07-07 12:58:25 +05301883 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1884 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301885
1886
1887 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301888 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301889 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301890 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301891 hddLog(VOS_TRACE_LEVEL_INFO,
1892 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301893 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301894 hddLog(VOS_TRACE_LEVEL_INFO,
1895 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301896 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301897
1898 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1899 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301900 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301901 {
1902 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1903 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301904 return -EINVAL;
1905
1906 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301907
1908 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1909 if (VOS_STATUS_SUCCESS !=
1910 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1911 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE))
1912 {
1913 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1914 "WLANTL_ClearInterfaceStats Failed", __func__);
1915 return -EINVAL;
1916 }
1917
1918 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1919 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1920 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1921 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1922
Sunil Duttc69bccb2014-05-26 21:30:20 +05301923 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301924 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301925 {
1926 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1927 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301928 return -EINVAL;
1929 }
1930
1931 pAdapter->isLinkLayerStatsSet = 1;
1932
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301933 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301934 return 0;
1935}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301936static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1937 struct wireless_dev *wdev,
1938 const void *data,
1939 int data_len)
1940{
1941 int ret = 0;
1942
1943 vos_ssr_protect(__func__);
1944 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1945 vos_ssr_unprotect(__func__);
1946
1947 return ret;
1948}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301949
1950const struct
1951nla_policy
1952qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1953{
1954 /* Unsigned 32bit value provided by the caller issuing the GET stats
1955 * command. When reporting
1956 * the stats results, the driver uses the same value to indicate
1957 * which GET request the results
1958 * correspond to.
1959 */
1960 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1961
1962 /* Unsigned 32bit value . bit mask to identify what statistics are
1963 requested for retrieval */
1964 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1965};
1966
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301967static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1968 struct wireless_dev *wdev,
1969 const void *data,
1970 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301971{
1972 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1973 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301974 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301975 struct net_device *dev = wdev->netdev;
1976 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1977 int status;
1978
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301979 ENTER();
1980
Sunil Duttc69bccb2014-05-26 21:30:20 +05301981 status = wlan_hdd_validate_context(pHddCtx);
1982 if (0 != status)
1983 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301984 return -EINVAL ;
1985 }
1986
1987 if (NULL == pAdapter)
1988 {
1989 hddLog(VOS_TRACE_LEVEL_FATAL,
1990 "%s: HDD adapter is Null", __func__);
1991 return -ENODEV;
1992 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301993 /* check the LLStats Capability */
1994 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1995 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1996 {
1997 hddLog(VOS_TRACE_LEVEL_ERROR,
1998 FL("Link Layer Statistics not supported by Firmware"));
1999 return -EINVAL;
2000 }
2001
Sunil Duttc69bccb2014-05-26 21:30:20 +05302002
2003 if (!pAdapter->isLinkLayerStatsSet)
2004 {
2005 hddLog(VOS_TRACE_LEVEL_FATAL,
2006 "%s: isLinkLayerStatsSet : %d",
2007 __func__, pAdapter->isLinkLayerStatsSet);
2008 return -EINVAL;
2009 }
2010
2011 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2012 (struct nlattr *)data,
2013 data_len, qca_wlan_vendor_ll_get_policy))
2014 {
2015 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2016 return -EINVAL;
2017 }
2018
2019 if (!tb_vendor
2020 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2021 {
2022 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2023 return -EINVAL;
2024 }
2025
2026 if (!tb_vendor
2027 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2028 {
2029 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
2030 return -EINVAL;
2031 }
2032
Sunil Duttc69bccb2014-05-26 21:30:20 +05302033
Dino Mycledf0a5d92014-07-04 09:41:55 +05302034 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302035 nla_get_u32( tb_vendor[
2036 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05302037 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302038 nla_get_u32( tb_vendor[
2039 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
2040
Dino Mycled3d50022014-07-07 12:58:25 +05302041 vos_mem_copy(linkLayerStatsGetReq.macAddr,
2042 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302043
2044 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302045 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302046 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302047 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302048 hddLog(VOS_TRACE_LEVEL_INFO,
2049 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302050 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302051
2052 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302053 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302054 {
2055 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2056 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302057 return -EINVAL;
2058 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302059
2060 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302061 return 0;
2062}
2063
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302064static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2065 struct wireless_dev *wdev,
2066 const void *data,
2067 int data_len)
2068{
2069 int ret = 0;
2070
2071 vos_ssr_protect(__func__);
2072 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
2073 vos_ssr_unprotect(__func__);
2074
2075 return ret;
2076}
2077
Sunil Duttc69bccb2014-05-26 21:30:20 +05302078const struct
2079nla_policy
2080qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
2081{
2082 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
2083 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
2084 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
2085 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
2086};
2087
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302088static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2089 struct wireless_dev *wdev,
2090 const void *data,
2091 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302092{
2093 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2094 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302095 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302096 struct net_device *dev = wdev->netdev;
2097 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2098 u32 statsClearReqMask;
2099 u8 stopReq;
2100 int status;
2101
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302102 ENTER();
2103
Sunil Duttc69bccb2014-05-26 21:30:20 +05302104 status = wlan_hdd_validate_context(pHddCtx);
2105 if (0 != status)
2106 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302107 return -EINVAL;
2108 }
2109
2110 if (NULL == pAdapter)
2111 {
2112 hddLog(VOS_TRACE_LEVEL_FATAL,
2113 "%s: HDD adapter is Null", __func__);
2114 return -ENODEV;
2115 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302116 /* check the LLStats Capability */
2117 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2118 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2119 {
2120 hddLog(VOS_TRACE_LEVEL_ERROR,
2121 FL("Enable LLStats Capability"));
2122 return -EINVAL;
2123 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302124
2125 if (!pAdapter->isLinkLayerStatsSet)
2126 {
2127 hddLog(VOS_TRACE_LEVEL_FATAL,
2128 "%s: isLinkLayerStatsSet : %d",
2129 __func__, pAdapter->isLinkLayerStatsSet);
2130 return -EINVAL;
2131 }
2132
2133 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2134 (struct nlattr *)data,
2135 data_len, qca_wlan_vendor_ll_clr_policy))
2136 {
2137 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2138 return -EINVAL;
2139 }
2140
2141 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2142
2143 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2144 {
2145 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2146 return -EINVAL;
2147
2148 }
2149
Sunil Duttc69bccb2014-05-26 21:30:20 +05302150
Dino Mycledf0a5d92014-07-04 09:41:55 +05302151 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302152 nla_get_u32(
2153 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2154
Dino Mycledf0a5d92014-07-04 09:41:55 +05302155 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302156 nla_get_u8(
2157 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2158
2159 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302160 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302161
Dino Mycled3d50022014-07-07 12:58:25 +05302162 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2163 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302164
2165 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302166 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302167 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302168 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302169 hddLog(VOS_TRACE_LEVEL_INFO,
2170 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302171 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302172 hddLog(VOS_TRACE_LEVEL_INFO,
2173 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302174 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302175
2176 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302177 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302178 {
2179 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302180 hdd_station_ctx_t *pHddStaCtx;
2181
2182 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2183 if (VOS_STATUS_SUCCESS !=
2184 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2185 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2186 {
2187 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2188 "WLANTL_ClearInterfaceStats Failed", __func__);
2189 return -EINVAL;
2190 }
2191 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2192 (statsClearReqMask & WIFI_STATS_IFACE)) {
2193 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2194 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2195 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2196 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2197 }
2198
Sunil Duttc69bccb2014-05-26 21:30:20 +05302199 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2200 2 * sizeof(u32) +
2201 NLMSG_HDRLEN);
2202
2203 if (temp_skbuff != NULL)
2204 {
2205
2206 if (nla_put_u32(temp_skbuff,
2207 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2208 statsClearReqMask) ||
2209 nla_put_u32(temp_skbuff,
2210 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2211 stopReq))
2212 {
2213 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2214 kfree_skb(temp_skbuff);
2215 return -EINVAL;
2216 }
2217 /* If the ask is to stop the stats collection as part of clear
2218 * (stopReq = 1) , ensure that no further requests of get
2219 * go to the firmware by having isLinkLayerStatsSet set to 0.
2220 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302221 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302222 * case the firmware is just asked to clear the statistics.
2223 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302224 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302225 pAdapter->isLinkLayerStatsSet = 0;
2226 return cfg80211_vendor_cmd_reply(temp_skbuff);
2227 }
2228 return -ENOMEM;
2229 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302230
2231 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302232 return -EINVAL;
2233}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302234static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2235 struct wireless_dev *wdev,
2236 const void *data,
2237 int data_len)
2238{
2239 int ret = 0;
2240
2241 vos_ssr_protect(__func__);
2242 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2243 vos_ssr_unprotect(__func__);
2244
2245 return ret;
2246
2247
2248}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302249#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2250
Dino Mycle6fb96c12014-06-10 11:52:40 +05302251#ifdef WLAN_FEATURE_EXTSCAN
2252static const struct nla_policy
2253wlan_hdd_extscan_config_policy
2254 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2255{
2256 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2257 { .type = NLA_U32 },
2258 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2259 { .type = NLA_U32 },
2260 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2261 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2262 { .type = NLA_U32 },
2263 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2264 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2265
2266 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2267 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2268 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2269 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2270 { .type = NLA_U8 },
2271 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2272 { .type = NLA_U32 },
2273 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2274 { .type = NLA_U32 },
2275 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2276 { .type = NLA_U32 },
2277 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] =
2278 { .type = NLA_U8 },
2279 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2280 { .type = NLA_U8 },
2281 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2282 { .type = NLA_U8 },
2283
2284 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2285 { .type = NLA_U32 },
2286 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2287 { .type = NLA_UNSPEC },
2288 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2289 { .type = NLA_S32 },
2290 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2291 { .type = NLA_S32 },
2292 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2293 { .type = NLA_U32 },
2294 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2295 { .type = NLA_U32 },
2296 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] =
2297 { .type = NLA_U32 },
2298 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]
2299 = { .type = NLA_U32 },
2300 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] =
2301 { .type = NLA_U32 },
2302 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type =
2303 NLA_U32 },
2304};
2305
2306static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg)
2307{
2308 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2309 struct sk_buff *skb = NULL;
2310 tpSirEXTScanCapabilitiesEvent pData =
2311 (tpSirEXTScanCapabilitiesEvent) pMsg;
2312
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302313 ENTER();
2314
2315 if (wlan_hdd_validate_context(pHddCtx))
2316 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302317 return;
2318 }
2319
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302320 if (!pMsg)
2321 {
2322 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2323 return;
2324 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302325 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2326 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2327 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
2328 GFP_KERNEL);
2329
2330 if (!skb) {
2331 hddLog(VOS_TRACE_LEVEL_ERROR,
2332 FL("cfg80211_vendor_event_alloc failed"));
2333 return;
2334 }
2335
2336 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2337 hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize);
2338 hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets);
2339 hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan);
2340 hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)",
2341 pData->maxRssiSampleSize);
2342 hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)",
2343 pData->maxScanReportingThreshold);
2344 hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs);
2345 hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)",
2346 pData->maxSignificantWifiChangeAPs);
2347 hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)",
2348 pData->maxBsidHistoryEntries);
2349
2350 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2351 pData->requestId) ||
2352 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) ||
2353 nla_put_u32(skb,
2354 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
2355 pData->scanCacheSize) ||
2356 nla_put_u32(skb,
2357 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
2358 pData->scanBuckets) ||
2359 nla_put_u32(skb,
2360 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
2361 pData->maxApPerScan) ||
2362 nla_put_u32(skb,
2363 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
2364 pData->maxRssiSampleSize) ||
2365 nla_put_u32(skb,
2366 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
2367 pData->maxScanReportingThreshold) ||
2368 nla_put_u32(skb,
2369 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS,
2370 pData->maxHotlistAPs) ||
2371 nla_put_u32(skb,
2372 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
2373 pData->maxSignificantWifiChangeAPs) ||
2374 nla_put_u32(skb,
2375 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
2376 pData->maxBsidHistoryEntries)) {
2377 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2378 goto nla_put_failure;
2379 }
2380
2381 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302382 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302383 return;
2384
2385nla_put_failure:
2386 kfree_skb(skb);
2387 return;
2388}
2389
2390
2391static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2392{
2393 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2394 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2395 struct sk_buff *skb = NULL;
2396 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
2397
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302398 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302399
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302400 if (wlan_hdd_validate_context(pHddCtx)){
2401 return;
2402 }
2403 if (!pMsg)
2404 {
2405 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302406 return;
2407 }
2408
2409 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2410 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2411 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
2412 GFP_KERNEL);
2413
2414 if (!skb) {
2415 hddLog(VOS_TRACE_LEVEL_ERROR,
2416 FL("cfg80211_vendor_event_alloc failed"));
2417 return;
2418 }
2419 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2420 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2421 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2422
2423 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2424 pData->requestId) ||
2425 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2426 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2427 goto nla_put_failure;
2428 }
2429
2430 /*
2431 * Store the Request ID for comparing with the requestID obtained
2432 * in other requests.HDD shall return a failure is the extscan_stop
2433 * request is issued with a different requestId as that of the
2434 * extscan_start request. Also, This requestId shall be used while
2435 * indicating the full scan results to the upper layers.
2436 * The requestId is stored with the assumption that the firmware
2437 * shall return the ext scan start request's requestId in ext scan
2438 * start response.
2439 */
2440 if (pData->status == 0)
2441 pMac->sme.extScanStartReqId = pData->requestId;
2442
2443
2444 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302445 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302446 return;
2447
2448nla_put_failure:
2449 kfree_skb(skb);
2450 return;
2451}
2452
2453
2454static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2455{
2456 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2457 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2458 struct sk_buff *skb = NULL;
2459
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302460 ENTER();
2461
2462 if (wlan_hdd_validate_context(pHddCtx)){
2463 return;
2464 }
2465 if (!pMsg)
2466 {
2467 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302468 return;
2469 }
2470
2471 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2472 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2473 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2474 GFP_KERNEL);
2475
2476 if (!skb) {
2477 hddLog(VOS_TRACE_LEVEL_ERROR,
2478 FL("cfg80211_vendor_event_alloc failed"));
2479 return;
2480 }
2481 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2482 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2483
2484 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2485 pData->requestId) ||
2486 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2487 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2488 goto nla_put_failure;
2489 }
2490
2491 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302492 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302493 return;
2494
2495nla_put_failure:
2496 kfree_skb(skb);
2497 return;
2498}
2499
2500
2501static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2502 void *pMsg)
2503{
2504 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2505 struct sk_buff *skb = NULL;
2506 tpSirEXTScanSetBssidHotListRspParams pData =
2507 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2508
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302509 ENTER();
2510
2511 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302512 return;
2513 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302514 if (!pMsg)
2515 {
2516 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2517 return;
2518 }
2519
Dino Mycle6fb96c12014-06-10 11:52:40 +05302520 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2521 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2522 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2523 GFP_KERNEL);
2524
2525 if (!skb) {
2526 hddLog(VOS_TRACE_LEVEL_ERROR,
2527 FL("cfg80211_vendor_event_alloc failed"));
2528 return;
2529 }
2530 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2531 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2532 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2533
2534 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2535 pData->requestId) ||
2536 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2537 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2538 goto nla_put_failure;
2539 }
2540
2541 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302542 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302543 return;
2544
2545nla_put_failure:
2546 kfree_skb(skb);
2547 return;
2548}
2549
2550static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2551 void *pMsg)
2552{
2553 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2554 struct sk_buff *skb = NULL;
2555 tpSirEXTScanResetBssidHotlistRspParams pData =
2556 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2557
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302558 ENTER();
2559
2560 if (wlan_hdd_validate_context(pHddCtx)) {
2561 return;
2562 }
2563 if (!pMsg)
2564 {
2565 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302566 return;
2567 }
2568
2569 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2570 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2571 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2572 GFP_KERNEL);
2573
2574 if (!skb) {
2575 hddLog(VOS_TRACE_LEVEL_ERROR,
2576 FL("cfg80211_vendor_event_alloc failed"));
2577 return;
2578 }
2579 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2580 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2581
2582 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2583 pData->requestId) ||
2584 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2585 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2586 goto nla_put_failure;
2587 }
2588
2589 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302590 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302591 return;
2592
2593nla_put_failure:
2594 kfree_skb(skb);
2595 return;
2596}
2597
2598
2599static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2600 void *pMsg)
2601{
2602 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2603 struct sk_buff *skb = NULL;
2604 tpSirEXTScanSetSignificantChangeRspParams pData =
2605 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2606
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302607 ENTER();
2608
2609 if (wlan_hdd_validate_context(pHddCtx)) {
2610 return;
2611 }
2612 if (!pMsg)
2613 {
2614 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302615 return;
2616 }
2617
2618 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2619 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2620 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2621 GFP_KERNEL);
2622
2623 if (!skb) {
2624 hddLog(VOS_TRACE_LEVEL_ERROR,
2625 FL("cfg80211_vendor_event_alloc failed"));
2626 return;
2627 }
2628 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2629 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2630 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2631
2632 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2633 pData->requestId) ||
2634 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2635 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2636 goto nla_put_failure;
2637 }
2638
2639 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302640 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302641 return;
2642
2643nla_put_failure:
2644 kfree_skb(skb);
2645 return;
2646}
2647
2648
2649static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2650 void *pMsg)
2651{
2652 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2653 struct sk_buff *skb = NULL;
2654 tpSirEXTScanResetSignificantChangeRspParams pData =
2655 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2656
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302657 ENTER();
2658
2659 if (wlan_hdd_validate_context(pHddCtx)) {
2660 return;
2661 }
2662 if (!pMsg)
2663 {
2664 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302665 return;
2666 }
2667
2668 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2669 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2670 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2671 GFP_KERNEL);
2672
2673 if (!skb) {
2674 hddLog(VOS_TRACE_LEVEL_ERROR,
2675 FL("cfg80211_vendor_event_alloc failed"));
2676 return;
2677 }
2678 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2679 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2680 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2681
2682 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2683 pData->requestId) ||
2684 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2685 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2686 goto nla_put_failure;
2687 }
2688
2689 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302690 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302691 return;
2692
2693nla_put_failure:
2694 kfree_skb(skb);
2695 return;
2696}
2697
2698static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2699 void *pMsg)
2700{
2701 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2702 struct sk_buff *skb = NULL;
2703 tANI_U32 i = 0, j, resultsPerEvent;
2704 tANI_S32 totalResults;
2705 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2706 tpSirWifiScanResult pSirWifiScanResult;
2707
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302708 ENTER();
2709
2710 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302711 return;
2712 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302713 if (!pMsg)
2714 {
2715 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2716 return;
2717 }
2718
Dino Mycle6fb96c12014-06-10 11:52:40 +05302719 totalResults = pData->numOfAps;
2720 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2721 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2722 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2723
2724 do{
2725 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2726 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2727 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2728
2729 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2730 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2731 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2732 GFP_KERNEL);
2733
2734 if (!skb) {
2735 hddLog(VOS_TRACE_LEVEL_ERROR,
2736 FL("cfg80211_vendor_event_alloc failed"));
2737 return;
2738 }
2739
2740 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2741
2742 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2743 pData->requestId) ||
2744 nla_put_u32(skb,
2745 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2746 resultsPerEvent)) {
2747 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2748 goto fail;
2749 }
2750 if (nla_put_u8(skb,
2751 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2752 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2753 {
2754 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2755 goto fail;
2756 }
2757
2758 if (resultsPerEvent) {
2759 struct nlattr *aps;
2760
2761 aps = nla_nest_start(skb,
2762 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2763 if (!aps)
2764 {
2765 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2766 goto fail;
2767 }
2768
2769 for (j = 0; j < resultsPerEvent; j++, i++) {
2770 struct nlattr *ap;
2771 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2772 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2773
2774 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2775 "Ssid (%s)"
2776 "Bssid: %pM "
2777 "Channel (%u)"
2778 "Rssi (%d)"
2779 "RTT (%u)"
2780 "RTT_SD (%u)",
2781 i,
2782 pSirWifiScanResult->ts,
2783 pSirWifiScanResult->ssid,
2784 pSirWifiScanResult->bssid,
2785 pSirWifiScanResult->channel,
2786 pSirWifiScanResult->rssi,
2787 pSirWifiScanResult->rtt,
2788 pSirWifiScanResult->rtt_sd);
2789
2790 ap = nla_nest_start(skb, j + 1);
2791 if (!ap)
2792 {
2793 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2794 goto fail;
2795 }
2796
2797 if (nla_put_u64(skb,
2798 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2799 pSirWifiScanResult->ts) )
2800 {
2801 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2802 goto fail;
2803 }
2804 if (nla_put(skb,
2805 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2806 sizeof(pSirWifiScanResult->ssid),
2807 pSirWifiScanResult->ssid) )
2808 {
2809 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2810 goto fail;
2811 }
2812 if (nla_put(skb,
2813 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2814 sizeof(pSirWifiScanResult->bssid),
2815 pSirWifiScanResult->bssid) )
2816 {
2817 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2818 goto fail;
2819 }
2820 if (nla_put_u32(skb,
2821 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2822 pSirWifiScanResult->channel) )
2823 {
2824 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2825 goto fail;
2826 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302827 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302828 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2829 pSirWifiScanResult->rssi) )
2830 {
2831 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2832 goto fail;
2833 }
2834 if (nla_put_u32(skb,
2835 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2836 pSirWifiScanResult->rtt) )
2837 {
2838 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2839 goto fail;
2840 }
2841 if (nla_put_u32(skb,
2842 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2843 pSirWifiScanResult->rtt_sd))
2844 {
2845 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2846 goto fail;
2847 }
2848
2849 nla_nest_end(skb, ap);
2850 }
2851 nla_nest_end(skb, aps);
2852
2853 }
2854 cfg80211_vendor_event(skb, GFP_KERNEL);
2855 } while (totalResults > 0);
2856
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302857 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302858 return;
2859fail:
2860 kfree_skb(skb);
2861 return;
2862}
2863
2864static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2865 void *pMsg)
2866{
2867 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2868 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2869 struct sk_buff *skb = NULL;
2870 tANI_U32 i;
2871
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302872 ENTER();
2873
2874 if (wlan_hdd_validate_context(pHddCtx)) {
2875 return;
2876 }
2877 if (!pMsg)
2878 {
2879 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302880 return;
2881 }
2882
2883 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2884 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2885 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
2886 GFP_KERNEL);
2887
2888 if (!skb) {
2889 hddLog(VOS_TRACE_LEVEL_ERROR,
2890 FL("cfg80211_vendor_event_alloc failed"));
2891 return;
2892 }
2893 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2894 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2895 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2896 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2897
2898 for (i = 0; i < pData->numOfAps; i++) {
2899 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2900 "Ssid (%s) "
2901 "Bssid (" MAC_ADDRESS_STR ") "
2902 "Channel (%u) "
2903 "Rssi (%d) "
2904 "RTT (%u) "
2905 "RTT_SD (%u) ",
2906 i,
2907 pData->ap[i].ts,
2908 pData->ap[i].ssid,
2909 MAC_ADDR_ARRAY(pData->ap[i].bssid),
2910 pData->ap[i].channel,
2911 pData->ap[i].rssi,
2912 pData->ap[i].rtt,
2913 pData->ap[i].rtt_sd);
2914 }
2915
2916 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2917 pData->requestId) ||
2918 nla_put_u32(skb,
2919 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2920 pData->numOfAps)) {
2921 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2922 goto fail;
2923 }
2924 if (pData->numOfAps) {
2925 struct nlattr *aps;
2926
2927 aps = nla_nest_start(skb,
2928 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2929 if (!aps)
2930 goto fail;
2931
2932 for (i = 0; i < pData->numOfAps; i++) {
2933 struct nlattr *ap;
2934
2935 ap = nla_nest_start(skb, i + 1);
2936 if (!ap)
2937 goto fail;
2938
2939 if (nla_put_u64(skb,
2940 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2941 pData->ap[i].ts) ||
2942 nla_put(skb,
2943 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2944 sizeof(pData->ap[i].ssid),
2945 pData->ap[i].ssid) ||
2946 nla_put(skb,
2947 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2948 sizeof(pData->ap[i].bssid),
2949 pData->ap[i].bssid) ||
2950 nla_put_u32(skb,
2951 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2952 pData->ap[i].channel) ||
2953 nla_put_s32(skb,
2954 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2955 pData->ap[i].rssi) ||
2956 nla_put_u32(skb,
2957 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2958 pData->ap[i].rtt) ||
2959 nla_put_u32(skb,
2960 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2961 pData->ap[i].rtt_sd))
2962 goto fail;
2963
2964 nla_nest_end(skb, ap);
2965 }
2966 nla_nest_end(skb, aps);
2967
2968 if (nla_put_u8(skb,
2969 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2970 pData->moreData))
2971 goto fail;
2972 }
2973
2974 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302975 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302976 return;
2977
2978fail:
2979 kfree_skb(skb);
2980 return;
2981
2982}
2983static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
2984 void *pMsg)
2985{
2986 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2987 struct sk_buff *skb = NULL;
2988 tANI_U32 i, j;
2989 tpSirWifiSignificantChangeEvent pData =
2990 (tpSirWifiSignificantChangeEvent) pMsg;
2991
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302992 ENTER();
2993
2994 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302995 return;
2996 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302997 if (!pMsg)
2998 {
2999 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3000 return;
3001 }
3002
Dino Mycle6fb96c12014-06-10 11:52:40 +05303003 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3004 EXTSCAN_EVENT_BUF_SIZE,
3005 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
3006 GFP_KERNEL);
3007
3008 if (!skb) {
3009 hddLog(VOS_TRACE_LEVEL_ERROR,
3010 FL("cfg80211_vendor_event_alloc failed"));
3011 return;
3012 }
3013 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3014 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3015 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
3016 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
3017 pData->numSigRssiBss);
3018 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
3019
3020 for (i = 0; i < pData->numSigRssiBss; i++) {
3021 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
3022 " num RSSI %u ",
3023 i, pData->sigRssiResult[i].bssid,
3024 pData->sigRssiResult[i].channel,
3025 pData->sigRssiResult[i].numRssi);
3026
3027 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
3028
3029 hddLog(VOS_TRACE_LEVEL_INFO,
3030 " [%d]",
Dino Myclec8f3f332014-07-21 16:48:27 +05303031 pData->sigRssiResult[i].rssi[j]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303032
3033 }
3034 }
3035
3036
3037 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3038 pData->requestId) ||
3039 nla_put_u32(skb,
3040 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3041 pData->numSigRssiBss)) {
3042 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3043 goto fail;
3044 }
3045
3046 if (pData->numSigRssiBss) {
3047 struct nlattr *aps;
3048 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3049 if (!aps)
3050 goto fail;
3051 for (i = 0; i < pData->numSigRssiBss; i++) {
3052 struct nlattr *ap;
3053
3054 ap = nla_nest_start(skb, i);
3055 if (!ap)
3056 goto fail;
3057 if (nla_put(skb,
3058 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
3059 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
3060 nla_put_u32(skb,
3061 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
3062 pData->sigRssiResult[i].channel) ||
3063 nla_put_u32(skb,
3064 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
3065 pData->sigRssiResult[i].numRssi) ||
3066 nla_put(skb,
3067 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
3068 sizeof(s32) * pData->sigRssiResult[i].numRssi,
3069 pData->sigRssiResult[i].rssi))
3070 goto fail;
3071 nla_nest_end(skb, ap);
3072 }
3073 nla_nest_end(skb, aps);
3074 if (nla_put_u8(skb,
3075 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3076 pData->moreData))
3077 goto fail;
3078 }
3079 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303080 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303081 return;
3082fail:
3083 kfree_skb(skb);
3084 return;
3085}
3086
3087static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3088 void *pMsg)
3089{
3090 struct sk_buff *skb;
3091 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3092 tpSirWifiFullScanResultEvent pData =
3093 (tpSirWifiFullScanResultEvent) (pMsg);
3094
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303095 ENTER();
3096
3097 if (wlan_hdd_validate_context(pHddCtx)) {
3098 return;
3099 }
3100 if (!pMsg)
3101 {
3102 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303103 return;
3104 }
3105
3106 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3107 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3108 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3109 GFP_KERNEL);
3110
3111 if (!skb) {
3112 hddLog(VOS_TRACE_LEVEL_ERROR,
3113 FL("cfg80211_vendor_event_alloc failed"));
3114 return;
3115 }
3116
3117 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3118 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3119 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3120 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3121 "Ssid (%s)"
3122 "Bssid (" MAC_ADDRESS_STR ")"
3123 "Channel (%u)"
3124 "Rssi (%d)"
3125 "RTT (%u)"
3126 "RTT_SD (%u)"),
3127 pData->ap.ts,
3128 pData->ap.ssid,
3129 MAC_ADDR_ARRAY(pData->ap.bssid),
3130 pData->ap.channel,
3131 pData->ap.rssi,
3132 pData->ap.rtt,
3133 pData->ap.rtt_sd);
3134 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3135 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3136 pData->requestId) ||
3137 nla_put_u64(skb,
3138 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3139 pData->ap.ts) ||
3140 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3141 sizeof(pData->ap.ssid),
3142 pData->ap.ssid) ||
3143 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3144 WNI_CFG_BSSID_LEN,
3145 pData->ap.bssid) ||
3146 nla_put_u32(skb,
3147 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3148 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303149 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303150 pData->ap.rssi) ||
3151 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3152 pData->ap.rtt) ||
3153 nla_put_u32(skb,
3154 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3155 pData->ap.rtt_sd) ||
3156 nla_put_u16(skb,
3157 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3158 pData->ap.beaconPeriod) ||
3159 nla_put_u16(skb,
3160 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3161 pData->ap.capability) ||
3162 nla_put_u32(skb,
3163 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3164 pData->ieLength))
3165 {
3166 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3167 goto nla_put_failure;
3168 }
3169 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3170 pData->ieLength,
3171 pData->ie))
3172 {
3173 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3174 goto nla_put_failure;
3175 }
3176
3177 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303178 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303179 return;
3180
3181nla_put_failure:
3182 kfree_skb(skb);
3183 return;
3184}
3185
3186static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3187 void *pMsg)
3188{
3189 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3190 struct sk_buff *skb = NULL;
3191 tpSirEXTScanResultsAvailableIndParams pData =
3192 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3193
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303194 ENTER();
3195
3196 if (wlan_hdd_validate_context(pHddCtx)){
3197 return;
3198 }
3199 if (!pMsg)
3200 {
3201 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303202 return;
3203 }
3204
3205 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3206 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3207 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3208 GFP_KERNEL);
3209
3210 if (!skb) {
3211 hddLog(VOS_TRACE_LEVEL_ERROR,
3212 FL("cfg80211_vendor_event_alloc failed"));
3213 return;
3214 }
3215
3216 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3217 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3218 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3219 pData->numResultsAvailable);
3220 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3221 pData->requestId) ||
3222 nla_put_u32(skb,
3223 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3224 pData->numResultsAvailable)) {
3225 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3226 goto nla_put_failure;
3227 }
3228
3229 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303230 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303231 return;
3232
3233nla_put_failure:
3234 kfree_skb(skb);
3235 return;
3236}
3237
3238static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3239{
3240 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3241 struct sk_buff *skb = NULL;
3242 tpSirEXTScanProgressIndParams pData =
3243 (tpSirEXTScanProgressIndParams) pMsg;
3244
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303245 ENTER();
3246
3247 if (wlan_hdd_validate_context(pHddCtx)){
3248 return;
3249 }
3250 if (!pMsg)
3251 {
3252 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303253 return;
3254 }
3255
3256 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3257 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3258 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3259 GFP_KERNEL);
3260
3261 if (!skb) {
3262 hddLog(VOS_TRACE_LEVEL_ERROR,
3263 FL("cfg80211_vendor_event_alloc failed"));
3264 return;
3265 }
3266 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3267 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3268 pData->extScanEventType);
3269 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3270 pData->status);
3271
3272 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3273 pData->extScanEventType) ||
3274 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303275 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3276 pData->requestId) ||
3277 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303278 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3279 pData->status)) {
3280 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3281 goto nla_put_failure;
3282 }
3283
3284 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303285 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303286 return;
3287
3288nla_put_failure:
3289 kfree_skb(skb);
3290 return;
3291}
3292
3293void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3294 void *pMsg)
3295{
3296 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3297
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303298 ENTER();
3299
Dino Mycle6fb96c12014-06-10 11:52:40 +05303300 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303301 return;
3302 }
3303
3304 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3305
3306
3307 switch(evType) {
3308 case SIR_HAL_EXTSCAN_START_RSP:
3309 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3310 break;
3311
3312 case SIR_HAL_EXTSCAN_STOP_RSP:
3313 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3314 break;
3315 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3316 /* There is no need to send this response to upper layer
3317 Just log the message */
3318 hddLog(VOS_TRACE_LEVEL_INFO,
3319 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3320 break;
3321 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3322 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3323 break;
3324
3325 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3326 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3327 break;
3328
3329 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
3330 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
3331 break;
3332
3333 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
3334 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
3335 break;
3336 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
3337 wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg);
3338 break;
3339 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3340 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3341 break;
3342 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3343 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3344 break;
3345 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3346 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3347 break;
3348 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3349 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3350 break;
3351 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
3352 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
3353 break;
3354 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3355 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3356 break;
3357 default:
3358 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3359 break;
3360 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303361 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303362}
3363
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303364static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3365 struct wireless_dev *wdev,
3366 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303367{
Dino Myclee8843b32014-07-04 14:21:45 +05303368 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303369 struct net_device *dev = wdev->netdev;
3370 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3371 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3372 struct nlattr
3373 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3374 eHalStatus status;
3375
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303376 ENTER();
3377
Dino Mycle6fb96c12014-06-10 11:52:40 +05303378 status = wlan_hdd_validate_context(pHddCtx);
3379 if (0 != status)
3380 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303381 return -EINVAL;
3382 }
Dino Myclee8843b32014-07-04 14:21:45 +05303383 /* check the EXTScan Capability */
3384 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3385 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3386 {
3387 hddLog(VOS_TRACE_LEVEL_ERROR,
3388 FL("EXTScan not enabled/supported by Firmware"));
3389 return -EINVAL;
3390 }
3391
Dino Mycle6fb96c12014-06-10 11:52:40 +05303392 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3393 data, dataLen,
3394 wlan_hdd_extscan_config_policy)) {
3395 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3396 return -EINVAL;
3397 }
3398
3399 /* Parse and fetch request Id */
3400 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3401 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3402 return -EINVAL;
3403 }
3404
Dino Mycle6fb96c12014-06-10 11:52:40 +05303405
Dino Myclee8843b32014-07-04 14:21:45 +05303406 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303407 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303408 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303409
Dino Myclee8843b32014-07-04 14:21:45 +05303410 reqMsg.sessionId = pAdapter->sessionId;
3411 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303412
Dino Myclee8843b32014-07-04 14:21:45 +05303413 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303414 if (!HAL_STATUS_SUCCESS(status)) {
3415 hddLog(VOS_TRACE_LEVEL_ERROR,
3416 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303417 return -EINVAL;
3418 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303419 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303420 return 0;
3421}
3422
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303423static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3424 struct wireless_dev *wdev,
3425 const void *data, int dataLen)
3426{
3427 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303428
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303429 vos_ssr_protect(__func__);
3430 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3431 vos_ssr_unprotect(__func__);
3432
3433 return ret;
3434}
3435
3436static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3437 struct wireless_dev *wdev,
3438 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303439{
Dino Myclee8843b32014-07-04 14:21:45 +05303440 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303441 struct net_device *dev = wdev->netdev;
3442 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3443 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3444 struct nlattr
3445 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3446 eHalStatus status;
3447
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303448 ENTER();
3449
Dino Mycle6fb96c12014-06-10 11:52:40 +05303450 status = wlan_hdd_validate_context(pHddCtx);
3451 if (0 != status)
3452 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303453 return -EINVAL;
3454 }
Dino Myclee8843b32014-07-04 14:21:45 +05303455 /* check the EXTScan Capability */
3456 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3457 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3458 {
3459 hddLog(VOS_TRACE_LEVEL_ERROR,
3460 FL("EXTScan not enabled/supported by Firmware"));
3461 return -EINVAL;
3462 }
3463
Dino Mycle6fb96c12014-06-10 11:52:40 +05303464 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3465 data, dataLen,
3466 wlan_hdd_extscan_config_policy)) {
3467 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3468 return -EINVAL;
3469 }
3470 /* Parse and fetch request Id */
3471 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3472 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3473 return -EINVAL;
3474 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303475
Dino Myclee8843b32014-07-04 14:21:45 +05303476 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303477 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3478
Dino Myclee8843b32014-07-04 14:21:45 +05303479 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303480
Dino Myclee8843b32014-07-04 14:21:45 +05303481 reqMsg.sessionId = pAdapter->sessionId;
3482 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303483
3484 /* Parse and fetch flush parameter */
3485 if (!tb
3486 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3487 {
3488 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3489 goto failed;
3490 }
Dino Myclee8843b32014-07-04 14:21:45 +05303491 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303492 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3493
Dino Myclee8843b32014-07-04 14:21:45 +05303494 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303495
Dino Myclee8843b32014-07-04 14:21:45 +05303496 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303497 if (!HAL_STATUS_SUCCESS(status)) {
3498 hddLog(VOS_TRACE_LEVEL_ERROR,
3499 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303500 return -EINVAL;
3501 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303502 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303503 return 0;
3504
3505failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303506 return -EINVAL;
3507}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303508static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3509 struct wireless_dev *wdev,
3510 const void *data, int dataLen)
3511{
3512 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303513
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303514 vos_ssr_protect(__func__);
3515 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3516 vos_ssr_unprotect(__func__);
3517
3518 return ret;
3519}
3520
3521static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303522 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303523 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303524{
3525 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3526 struct net_device *dev = wdev->netdev;
3527 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3528 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3529 struct nlattr
3530 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3531 struct nlattr
3532 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3533 struct nlattr *apTh;
3534 eHalStatus status;
3535 tANI_U8 i = 0;
3536 int rem;
3537
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303538 ENTER();
3539
Dino Mycle6fb96c12014-06-10 11:52:40 +05303540 status = wlan_hdd_validate_context(pHddCtx);
3541 if (0 != status)
3542 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303543 return -EINVAL;
3544 }
Dino Myclee8843b32014-07-04 14:21:45 +05303545 /* check the EXTScan Capability */
3546 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3547 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3548 {
3549 hddLog(VOS_TRACE_LEVEL_ERROR,
3550 FL("EXTScan not enabled/supported by Firmware"));
3551 return -EINVAL;
3552 }
3553
Dino Mycle6fb96c12014-06-10 11:52:40 +05303554 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3555 data, dataLen,
3556 wlan_hdd_extscan_config_policy)) {
3557 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3558 return -EINVAL;
3559 }
3560
3561 /* Parse and fetch request Id */
3562 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3563 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3564 return -EINVAL;
3565 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303566 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3567 vos_mem_malloc(sizeof(*pReqMsg));
3568 if (!pReqMsg) {
3569 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3570 return -ENOMEM;
3571 }
3572
Dino Myclee8843b32014-07-04 14:21:45 +05303573
Dino Mycle6fb96c12014-06-10 11:52:40 +05303574 pReqMsg->requestId = nla_get_u32(
3575 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3576 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3577
3578 /* Parse and fetch number of APs */
3579 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3580 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3581 goto fail;
3582 }
3583
3584 pReqMsg->sessionId = pAdapter->sessionId;
3585 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3586
3587 pReqMsg->numAp = nla_get_u32(
3588 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3589 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3590
3591 nla_for_each_nested(apTh,
3592 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3593 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3594 nla_data(apTh), nla_len(apTh),
3595 NULL)) {
3596 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3597 goto fail;
3598 }
3599
3600 /* Parse and fetch MAC address */
3601 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3602 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3603 goto fail;
3604 }
3605 memcpy(pReqMsg->ap[i].bssid, nla_data(
3606 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3607 sizeof(tSirMacAddr));
3608 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3609
3610 /* Parse and fetch low RSSI */
3611 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3612 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3613 goto fail;
3614 }
3615 pReqMsg->ap[i].low = nla_get_s32(
3616 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3617 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3618
3619 /* Parse and fetch high RSSI */
3620 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3621 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3622 goto fail;
3623 }
3624 pReqMsg->ap[i].high = nla_get_s32(
3625 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3626 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3627 pReqMsg->ap[i].high);
3628
3629 /* Parse and fetch channel */
3630 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3631 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3632 goto fail;
3633 }
3634 pReqMsg->ap[i].channel = nla_get_u32(
3635 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3636 hddLog(VOS_TRACE_LEVEL_INFO,
3637 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3638 i++;
3639 }
3640 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3641 if (!HAL_STATUS_SUCCESS(status)) {
3642 hddLog(VOS_TRACE_LEVEL_ERROR,
3643 FL("sme_SetBssHotlist failed(err=%d)"), status);
3644 vos_mem_free(pReqMsg);
3645 return -EINVAL;
3646 }
3647
Dino Myclee8843b32014-07-04 14:21:45 +05303648 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303649 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303650 return 0;
3651
3652fail:
3653 vos_mem_free(pReqMsg);
3654 return -EINVAL;
3655}
3656
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303657static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3658 struct wireless_dev *wdev,
3659 const void *data, int dataLen)
3660{
3661 int ret = 0;
3662
3663 vos_ssr_protect(__func__);
3664 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3665 dataLen);
3666 vos_ssr_unprotect(__func__);
3667
3668 return ret;
3669}
3670
3671static int __wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303672 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303673 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303674{
3675 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3676 struct net_device *dev = wdev->netdev;
3677 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3678 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3679 struct nlattr
3680 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3681 struct nlattr
3682 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3683 struct nlattr *apTh;
3684 eHalStatus status;
3685 int i = 0;
3686 int rem;
3687
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303688 ENTER();
3689
Dino Mycle6fb96c12014-06-10 11:52:40 +05303690 status = wlan_hdd_validate_context(pHddCtx);
3691 if (0 != status)
3692 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303693 return -EINVAL;
3694 }
Dino Myclee8843b32014-07-04 14:21:45 +05303695 /* check the EXTScan Capability */
3696 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3697 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3698 {
3699 hddLog(VOS_TRACE_LEVEL_ERROR,
3700 FL("EXTScan not enabled/supported by Firmware"));
3701 return -EINVAL;
3702 }
3703
Dino Mycle6fb96c12014-06-10 11:52:40 +05303704 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3705 data, dataLen,
3706 wlan_hdd_extscan_config_policy)) {
3707 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3708 return -EINVAL;
3709 }
3710
3711 /* Parse and fetch request Id */
3712 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3713 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3714 return -EINVAL;
3715 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303716 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303717 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303718 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303719 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3720 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303721 }
3722
Dino Myclee8843b32014-07-04 14:21:45 +05303723
3724
Dino Mycle6fb96c12014-06-10 11:52:40 +05303725 pReqMsg->requestId = nla_get_u32(
3726 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3727 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3728
3729 /* Parse and fetch RSSI sample size */
3730 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3731 {
3732 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3733 goto fail;
3734 }
3735 pReqMsg->rssiSampleSize = nla_get_u32(
3736 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3737 hddLog(VOS_TRACE_LEVEL_INFO,
3738 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3739
3740 /* Parse and fetch lost AP sample size */
3741 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3742 {
3743 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3744 goto fail;
3745 }
3746 pReqMsg->lostApSampleSize = nla_get_u32(
3747 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3748 hddLog(VOS_TRACE_LEVEL_INFO,
3749 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3750 /* Parse and fetch minimum Breaching */
3751 if (!tb
3752 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3753 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3754 goto fail;
3755 }
3756 pReqMsg->minBreaching = nla_get_u32(
3757 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3758 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3759
3760 /* Parse and fetch number of APs */
3761 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3762 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3763 goto fail;
3764 }
3765 pReqMsg->numAp = nla_get_u32(
3766 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3767 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3768
3769 pReqMsg->sessionId = pAdapter->sessionId;
3770 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3771
3772 nla_for_each_nested(apTh,
3773 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3774 if(nla_parse(tb2,
3775 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3776 nla_data(apTh), nla_len(apTh),
3777 NULL)) {
3778 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3779 goto fail;
3780 }
3781
3782 /* Parse and fetch MAC address */
3783 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3784 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3785 goto fail;
3786 }
3787 memcpy(pReqMsg->ap[i].bssid, nla_data(
3788 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3789 sizeof(tSirMacAddr));
3790
3791 /* Parse and fetch low RSSI */
3792 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3793 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3794 goto fail;
3795 }
3796 pReqMsg->ap[i].low = nla_get_s32(
3797 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3798 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3799
3800 /* Parse and fetch high RSSI */
3801 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3802 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3803 goto fail;
3804 }
3805 pReqMsg->ap[i].high = nla_get_s32(
3806 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3807 hddLog(VOS_TRACE_LEVEL_INFO,
3808 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
3809
3810 /* Parse and fetch channel */
3811 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3812 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3813 goto fail;
3814 }
3815 pReqMsg->ap[i].channel = nla_get_u32(
3816 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3817 hddLog(VOS_TRACE_LEVEL_INFO,
3818 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3819 i++;
3820 }
3821
3822 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
3823 if (!HAL_STATUS_SUCCESS(status)) {
3824 hddLog(VOS_TRACE_LEVEL_ERROR,
3825 FL("sme_SetSignificantChange failed(err=%d)"), status);
3826 vos_mem_free(pReqMsg);
3827 return -EINVAL;
3828 }
Dino Myclee8843b32014-07-04 14:21:45 +05303829 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303830 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303831 return 0;
3832
3833fail:
3834 vos_mem_free(pReqMsg);
3835 return -EINVAL;
3836}
3837
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303838static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
3839 struct wireless_dev *wdev,
3840 const void *data, int dataLen)
3841{
3842 int ret = 0;
3843
3844 vos_ssr_protect(__func__);
3845 ret = __wlan_hdd_cfg80211_extscan_set_significant_change(wiphy, wdev, data,
3846 dataLen);
3847 vos_ssr_unprotect(__func__);
3848
3849 return ret;
3850}
3851
3852static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303853 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303854 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303855{
3856 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3857 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3858 tANI_U8 numChannels = 0;
3859 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3860 tANI_U32 requestId;
3861 tWifiBand wifiBand;
3862 eHalStatus status;
3863 struct sk_buff *replySkb;
3864 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303865 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303866
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303867 ENTER();
3868
Dino Mycle6fb96c12014-06-10 11:52:40 +05303869 status = wlan_hdd_validate_context(pHddCtx);
3870 if (0 != status)
3871 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303872 return -EINVAL;
3873 }
Dino Myclee8843b32014-07-04 14:21:45 +05303874 /* check the EXTScan Capability */
3875 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3876 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3877 {
3878 hddLog(VOS_TRACE_LEVEL_ERROR,
3879 FL("EXTScan not enabled/supported by Firmware"));
3880 return -EINVAL;
3881 }
3882
Dino Mycle6fb96c12014-06-10 11:52:40 +05303883 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3884 data, dataLen,
3885 wlan_hdd_extscan_config_policy)) {
3886 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3887 return -EINVAL;
3888 }
3889
3890 /* Parse and fetch request Id */
3891 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3892 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3893 return -EINVAL;
3894 }
3895 requestId = nla_get_u32(
3896 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3897 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3898
3899 /* Parse and fetch wifi band */
3900 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3901 {
3902 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3903 return -EINVAL;
3904 }
3905 wifiBand = nla_get_u32(
3906 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3907 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3908
3909 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
3910 wifiBand, ChannelList,
3911 &numChannels);
3912 if (eHAL_STATUS_SUCCESS != status) {
3913 hddLog(VOS_TRACE_LEVEL_ERROR,
3914 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
3915 return -EINVAL;
3916 }
3917 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
3918 for (i = 0; i < numChannels; i++)
3919 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
3920
3921 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
3922 sizeof(u32) * numChannels +
3923 NLMSG_HDRLEN);
3924
3925 if (!replySkb) {
3926 hddLog(VOS_TRACE_LEVEL_ERROR,
3927 FL("valid channels: buffer alloc fail"));
3928 return -EINVAL;
3929 }
3930 if (nla_put_u32(replySkb,
3931 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
3932 numChannels) ||
3933 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
3934 sizeof(u32) * numChannels, ChannelList)) {
3935
3936 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3937 kfree_skb(replySkb);
3938 return -EINVAL;
3939 }
3940
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303941 ret = cfg80211_vendor_cmd_reply(replySkb);
3942
3943 EXIT();
3944 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303945}
3946
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303947static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
3948 struct wireless_dev *wdev,
3949 const void *data, int dataLen)
3950{
3951 int ret = 0;
3952
3953 vos_ssr_protect(__func__);
3954 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
3955 dataLen);
3956 vos_ssr_unprotect(__func__);
3957
3958 return ret;
3959}
3960
3961static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303962 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303963 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303964{
Dino Myclee8843b32014-07-04 14:21:45 +05303965 tpSirEXTScanStartReqParams pReqMsg = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303966 struct net_device *dev = wdev->netdev;
3967 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3968 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3969 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3970 struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3971 struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3972 struct nlattr *buckets;
3973 struct nlattr *channels;
3974 int rem1;
3975 int rem2;
3976 eHalStatus status;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303977 tANI_U32 j = 0, index = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303978
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303979 ENTER();
3980
Dino Mycle6fb96c12014-06-10 11:52:40 +05303981 status = wlan_hdd_validate_context(pHddCtx);
3982 if (0 != status)
3983 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303984 return -EINVAL;
3985 }
Dino Myclee8843b32014-07-04 14:21:45 +05303986 /* check the EXTScan Capability */
3987 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3988 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3989 {
3990 hddLog(VOS_TRACE_LEVEL_ERROR,
3991 FL("EXTScan not enabled/supported by Firmware"));
3992 return -EINVAL;
3993 }
3994
Dino Mycle6fb96c12014-06-10 11:52:40 +05303995 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3996 data, dataLen,
3997 wlan_hdd_extscan_config_policy)) {
3998 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3999 return -EINVAL;
4000 }
4001
4002 /* Parse and fetch request Id */
4003 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4004 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4005 return -EINVAL;
4006 }
4007
Dino Myclee8843b32014-07-04 14:21:45 +05304008 pReqMsg = (tpSirEXTScanStartReqParams)
4009 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304010 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304011 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4012 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304013 }
4014
4015 pReqMsg->requestId = nla_get_u32(
4016 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4017 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4018
4019 pReqMsg->sessionId = pAdapter->sessionId;
4020 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4021
4022 /* Parse and fetch base period */
4023 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) {
4024 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4025 goto fail;
4026 }
4027 pReqMsg->basePeriod = nla_get_u32(
4028 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]);
4029 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4030 pReqMsg->basePeriod);
4031
4032 /* Parse and fetch max AP per scan */
4033 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) {
4034 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4035 goto fail;
4036 }
4037 pReqMsg->maxAPperScan = nla_get_u32(
4038 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]);
4039 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4040 pReqMsg->maxAPperScan);
4041
4042 /* Parse and fetch report threshold */
4043 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) {
4044 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4045 goto fail;
4046 }
4047 pReqMsg->reportThreshold = nla_get_u8(
4048 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]);
4049 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
4050 pReqMsg->reportThreshold);
4051
4052 /* Parse and fetch number of buckets */
4053 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) {
4054 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4055 goto fail;
4056 }
4057 pReqMsg->numBuckets = nla_get_u8(
4058 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]);
4059 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4060 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4061 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4062 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4063 }
4064 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4065 pReqMsg->numBuckets);
4066 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4067 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4068 goto fail;
4069 }
4070
4071 nla_for_each_nested(buckets,
4072 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4073 if(nla_parse(bucket,
4074 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4075 nla_data(buckets), nla_len(buckets), NULL)) { //policy
4076 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4077 goto fail;
4078 }
4079
4080 /* Parse and fetch bucket spec */
4081 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4082 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed"));
4083 goto fail;
4084 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304085
4086 pReqMsg->buckets[index].bucket = nla_get_u8(
4087 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4088
4089 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"),
4090 pReqMsg->buckets[index].bucket);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304091
4092 /* Parse and fetch wifi band */
4093 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4094 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4095 goto fail;
4096 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304097 pReqMsg->buckets[index].band = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304098 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4099 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304100 pReqMsg->buckets[index].band);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304101
4102 /* Parse and fetch period */
4103 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4104 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed"));
4105 goto fail;
4106 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304107 pReqMsg->buckets[index].period = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304108 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4109 hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304110 pReqMsg->buckets[index].period);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304111
4112 /* Parse and fetch report events */
4113 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4114 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed"));
4115 goto fail;
4116 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304117 pReqMsg->buckets[index].reportEvents = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304118 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4119 hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304120 pReqMsg->buckets[index].reportEvents);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304121
4122 /* Parse and fetch number of channels */
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304123 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS])
4124 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304125 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed"));
4126 goto fail;
4127 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304128 pReqMsg->buckets[index].numChannels = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304129 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4130 hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304131 pReqMsg->buckets[index].numChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304132
4133 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4134 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed"));
4135 goto fail;
4136 }
4137
4138 j = 0;
4139 nla_for_each_nested(channels,
4140 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4141 if(nla_parse(channel,
4142 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4143 nla_data(channels), nla_len(channels),
4144 NULL)) { //wlan_hdd_extscan_config_policy here
4145 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4146 goto fail;
4147 }
4148
4149 /* Parse and fetch channel */
4150 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4151 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4152 goto fail;
4153 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304154 pReqMsg->buckets[index].channels[j].channel = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304155 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4156 hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304157 pReqMsg->buckets[index].channels[j].channel);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304158
4159 /* Parse and fetch dwell time */
4160 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4161 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed"));
4162 goto fail;
4163 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304164 pReqMsg->buckets[index].channels[j].dwellTimeMs = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304165 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4166 hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304167 pReqMsg->buckets[index].channels[j].dwellTimeMs);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304168
4169 /* Parse and fetch channel spec passive */
4170 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4171 hddLog(VOS_TRACE_LEVEL_ERROR,
4172 FL("attr channel spec passive failed"));
4173 goto fail;
4174 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304175 pReqMsg->buckets[index].channels[j].passive = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304176 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4177 hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304178 pReqMsg->buckets[index].channels[j].passive);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304179 j++;
4180 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304181 index++;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304182 }
4183 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4184 if (!HAL_STATUS_SUCCESS(status)) {
4185 hddLog(VOS_TRACE_LEVEL_ERROR,
4186 FL("sme_EXTScanStart failed(err=%d)"), status);
4187 vos_mem_free(pReqMsg);
4188 return -EINVAL;
4189 }
4190
Dino Myclee8843b32014-07-04 14:21:45 +05304191 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304192 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304193 return 0;
4194
4195fail:
4196 vos_mem_free(pReqMsg);
4197 return -EINVAL;
4198}
4199
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304200static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4201 struct wireless_dev *wdev,
4202 const void *data, int dataLen)
4203{
4204 int ret = 0;
4205
4206 vos_ssr_protect(__func__);
4207 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4208 vos_ssr_unprotect(__func__);
4209
4210 return ret;
4211}
4212
4213static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304214 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304215 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304216{
Dino Myclee8843b32014-07-04 14:21:45 +05304217 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304218 struct net_device *dev = wdev->netdev;
4219 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4220 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4221 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4222 eHalStatus status;
4223
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304224 ENTER();
4225
Dino Mycle6fb96c12014-06-10 11:52:40 +05304226 status = wlan_hdd_validate_context(pHddCtx);
4227 if (0 != status)
4228 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304229 return -EINVAL;
4230 }
Dino Myclee8843b32014-07-04 14:21:45 +05304231 /* check the EXTScan Capability */
4232 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4233 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4234 {
4235 hddLog(VOS_TRACE_LEVEL_ERROR,
4236 FL("EXTScan not enabled/supported by Firmware"));
4237 return -EINVAL;
4238 }
4239
Dino Mycle6fb96c12014-06-10 11:52:40 +05304240 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4241 data, dataLen,
4242 wlan_hdd_extscan_config_policy)) {
4243 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4244 return -EINVAL;
4245 }
4246
4247 /* Parse and fetch request Id */
4248 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4249 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4250 return -EINVAL;
4251 }
4252
Dino Myclee8843b32014-07-04 14:21:45 +05304253 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304254 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304255 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304256
Dino Myclee8843b32014-07-04 14:21:45 +05304257 reqMsg.sessionId = pAdapter->sessionId;
4258 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304259
Dino Myclee8843b32014-07-04 14:21:45 +05304260 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304261 if (!HAL_STATUS_SUCCESS(status)) {
4262 hddLog(VOS_TRACE_LEVEL_ERROR,
4263 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304264 return -EINVAL;
4265 }
4266
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304267 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304268 return 0;
4269}
4270
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304271static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4272 struct wireless_dev *wdev,
4273 const void *data, int dataLen)
4274{
4275 int ret = 0;
4276
4277 vos_ssr_protect(__func__);
4278 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4279 vos_ssr_unprotect(__func__);
4280
4281 return ret;
4282}
4283
4284static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304285 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304286 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304287{
Dino Myclee8843b32014-07-04 14:21:45 +05304288 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304289 struct net_device *dev = wdev->netdev;
4290 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4291 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4292 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4293 eHalStatus status;
4294
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304295 ENTER();
4296
Dino Mycle6fb96c12014-06-10 11:52:40 +05304297 status = wlan_hdd_validate_context(pHddCtx);
4298 if (0 != status)
4299 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304300 return -EINVAL;
4301 }
Dino Myclee8843b32014-07-04 14:21:45 +05304302 /* check the EXTScan Capability */
4303 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4304 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4305 {
4306 hddLog(VOS_TRACE_LEVEL_ERROR,
4307 FL("EXTScan not enabled/supported by Firmware"));
4308 return -EINVAL;
4309 }
4310
Dino Mycle6fb96c12014-06-10 11:52:40 +05304311 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4312 data, dataLen,
4313 wlan_hdd_extscan_config_policy)) {
4314 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4315 return -EINVAL;
4316 }
4317
4318 /* Parse and fetch request Id */
4319 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4320 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4321 return -EINVAL;
4322 }
4323
Dino Myclee8843b32014-07-04 14:21:45 +05304324 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304325 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304326 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304327
Dino Myclee8843b32014-07-04 14:21:45 +05304328 reqMsg.sessionId = pAdapter->sessionId;
4329 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304330
Dino Myclee8843b32014-07-04 14:21:45 +05304331 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304332 if (!HAL_STATUS_SUCCESS(status)) {
4333 hddLog(VOS_TRACE_LEVEL_ERROR,
4334 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304335 return -EINVAL;
4336 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304337 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304338 return 0;
4339}
4340
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304341static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4342 struct wireless_dev *wdev,
4343 const void *data, int dataLen)
4344{
4345 int ret = 0;
4346
4347 vos_ssr_protect(__func__);
4348 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4349 vos_ssr_unprotect(__func__);
4350
4351 return ret;
4352}
4353
4354static int __wlan_hdd_cfg80211_extscan_reset_significant_change(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304355 struct wiphy *wiphy,
4356 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304357 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304358{
Dino Myclee8843b32014-07-04 14:21:45 +05304359 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304360 struct net_device *dev = wdev->netdev;
4361 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4362 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4363 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4364 eHalStatus status;
4365
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304366 ENTER();
4367
Dino Mycle6fb96c12014-06-10 11:52:40 +05304368 status = wlan_hdd_validate_context(pHddCtx);
4369 if (0 != status)
4370 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304371 return -EINVAL;
4372 }
Dino Myclee8843b32014-07-04 14:21:45 +05304373 /* check the EXTScan Capability */
4374 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4375 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4376 {
4377 hddLog(VOS_TRACE_LEVEL_ERROR,
4378 FL("EXTScan not enabled/supported by Firmware"));
4379 return -EINVAL;
4380 }
4381
Dino Mycle6fb96c12014-06-10 11:52:40 +05304382 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4383 data, dataLen,
4384 wlan_hdd_extscan_config_policy)) {
4385 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4386 return -EINVAL;
4387 }
4388
4389 /* Parse and fetch request Id */
4390 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4391 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4392 return -EINVAL;
4393 }
4394
Dino Mycle6fb96c12014-06-10 11:52:40 +05304395
Dino Myclee8843b32014-07-04 14:21:45 +05304396 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304397 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304398 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304399
Dino Myclee8843b32014-07-04 14:21:45 +05304400 reqMsg.sessionId = pAdapter->sessionId;
4401 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304402
Dino Myclee8843b32014-07-04 14:21:45 +05304403 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304404 if (!HAL_STATUS_SUCCESS(status)) {
4405 hddLog(VOS_TRACE_LEVEL_ERROR,
4406 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304407 return -EINVAL;
4408 }
4409
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304410 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304411 return 0;
4412}
4413
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304414static int wlan_hdd_cfg80211_extscan_reset_significant_change(
4415 struct wiphy *wiphy,
4416 struct wireless_dev *wdev,
4417 const void *data, int dataLen)
4418{
4419 int ret = 0;
4420
4421 vos_ssr_protect(__func__);
4422 ret = __wlan_hdd_cfg80211_extscan_reset_significant_change(wiphy,
4423 wdev, data,
4424 dataLen);
4425 vos_ssr_unprotect(__func__);
4426
4427 return ret;
4428}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304429#endif /* WLAN_FEATURE_EXTSCAN */
4430
Atul Mittal115287b2014-07-08 13:26:33 +05304431/*EXT TDLS*/
4432static const struct nla_policy
4433wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4434{
4435 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4436 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4437 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4438 {.type = NLA_S32 },
4439 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4440 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4441
4442};
4443
4444static const struct nla_policy
4445wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4446{
4447 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4448
4449};
4450
4451static const struct nla_policy
4452wlan_hdd_tdls_config_state_change_policy[
4453 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4454{
4455 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4456 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4457 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304458 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4459 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4460 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304461
4462};
4463
4464static const struct nla_policy
4465wlan_hdd_tdls_config_get_status_policy[
4466 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4467{
4468 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4469 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4470 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304471 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4472 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4473 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304474
4475};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304476
4477static const struct nla_policy
4478wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4479{
4480 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4481};
4482
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304483static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304484 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304485 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304486 int data_len)
4487{
4488
4489 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4490 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4491
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304492 ENTER();
4493
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304494 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304495 return -EINVAL;
4496 }
4497 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
4498 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN disabled in ini"));
4499 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304500 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304501 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
4502 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN not supported by FW"));
4503 return -ENOTSUPP;
4504 }
4505
4506 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4507 data, data_len, wlan_hdd_mac_config)) {
4508 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4509 return -EINVAL;
4510 }
4511
4512 /* Parse and fetch mac address */
4513 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4514 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4515 return -EINVAL;
4516 }
4517
4518 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4519 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4520 VOS_MAC_ADDR_LAST_3_BYTES);
4521
Siddharth Bhal76972212014-10-15 16:22:51 +05304522 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4523
4524 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304525 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4526 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304527 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4528 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4529 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4530 {
4531 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4532 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4533 VOS_MAC_ADDRESS_LEN);
4534 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304535 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304536
Siddharth Bhal76972212014-10-15 16:22:51 +05304537 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
4538 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304539 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4540 }
4541
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304542 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304543 return 0;
4544}
4545
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304546static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4547 struct wireless_dev *wdev,
4548 const void *data,
4549 int data_len)
4550{
4551 int ret = 0;
4552
4553 vos_ssr_protect(__func__);
4554 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
4555 vos_ssr_unprotect(__func__);
4556
4557 return ret;
4558}
4559
4560static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304561 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304562 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304563 int data_len)
4564{
4565 u8 peer[6] = {0};
4566 struct net_device *dev = wdev->netdev;
4567 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4568 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4569 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4570 eHalStatus ret;
4571 tANI_S32 state;
4572 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304573 tANI_S32 global_operating_class = 0;
4574 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304575 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304576 int retVal;
4577
4578 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304579
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304580 if (!pAdapter) {
4581 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4582 return -EINVAL;
4583 }
4584
Atul Mittal115287b2014-07-08 13:26:33 +05304585 ret = wlan_hdd_validate_context(pHddCtx);
4586 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304587 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304588 return -EINVAL;
4589 }
4590 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304591 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304592 return -ENOTSUPP;
4593 }
4594 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4595 data, data_len,
4596 wlan_hdd_tdls_config_get_status_policy)) {
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_TDLS_GET_STATUS_MAC_ADDR]) {
4603 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4604 return -EINVAL;
4605 }
4606
4607 memcpy(peer, nla_data(
4608 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4609 sizeof(peer));
4610 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4611
Konamki, Sreelakshmiabb59ed2015-06-12 12:13:23 +05304612 wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
Atul Mittal115287b2014-07-08 13:26:33 +05304613
Atul Mittal115287b2014-07-08 13:26:33 +05304614 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304615 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304616 NLMSG_HDRLEN);
4617
4618 if (!skb) {
4619 hddLog(VOS_TRACE_LEVEL_ERROR,
4620 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4621 return -EINVAL;
4622 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304623 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 +05304624 reason,
4625 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304626 global_operating_class,
4627 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304628 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304629 if (nla_put_s32(skb,
4630 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4631 state) ||
4632 nla_put_s32(skb,
4633 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4634 reason) ||
4635 nla_put_s32(skb,
4636 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4637 global_operating_class) ||
4638 nla_put_s32(skb,
4639 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4640 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304641
4642 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4643 goto nla_put_failure;
4644 }
4645
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304646 retVal = cfg80211_vendor_cmd_reply(skb);
4647 EXIT();
4648 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05304649
4650nla_put_failure:
4651 kfree_skb(skb);
4652 return -EINVAL;
4653}
4654
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304655static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4656 struct wireless_dev *wdev,
4657 const void *data,
4658 int data_len)
4659{
4660 int ret = 0;
4661
4662 vos_ssr_protect(__func__);
4663 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
4664 vos_ssr_unprotect(__func__);
4665
4666 return ret;
4667}
4668
Atul Mittal115287b2014-07-08 13:26:33 +05304669static int wlan_hdd_cfg80211_exttdls_callback(tANI_U8* mac,
4670 tANI_S32 state,
4671 tANI_S32 reason,
4672 void *ctx)
4673{
4674 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05304675 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304676 tANI_S32 global_operating_class = 0;
4677 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304678 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05304679
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304680 ENTER();
4681
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304682 if (!pAdapter) {
4683 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4684 return -EINVAL;
4685 }
4686
4687 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05304688 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304689 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304690 return -EINVAL;
4691 }
4692
4693 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304694 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304695 return -ENOTSUPP;
4696 }
4697 skb = cfg80211_vendor_event_alloc(
4698 pHddCtx->wiphy,
4699 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4700 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4701 GFP_KERNEL);
4702
4703 if (!skb) {
4704 hddLog(VOS_TRACE_LEVEL_ERROR,
4705 FL("cfg80211_vendor_event_alloc failed"));
4706 return -EINVAL;
4707 }
4708 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304709 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4710 reason,
4711 state,
4712 global_operating_class,
4713 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304714 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4715 MAC_ADDR_ARRAY(mac));
4716
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304717 if (nla_put(skb,
4718 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4719 VOS_MAC_ADDR_SIZE, mac) ||
4720 nla_put_s32(skb,
4721 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4722 state) ||
4723 nla_put_s32(skb,
4724 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4725 reason) ||
4726 nla_put_s32(skb,
4727 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4728 channel) ||
4729 nla_put_s32(skb,
4730 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4731 global_operating_class)
4732 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304733 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4734 goto nla_put_failure;
4735 }
4736
4737 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304738 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05304739 return (0);
4740
4741nla_put_failure:
4742 kfree_skb(skb);
4743 return -EINVAL;
4744}
4745
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304746static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304747 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304748 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304749 int data_len)
4750{
4751 u8 peer[6] = {0};
4752 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304753 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4754 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4755 eHalStatus status;
4756 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304757 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304758 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304759
4760 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304761
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304762 if (!dev) {
4763 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4764 return -EINVAL;
4765 }
4766
4767 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4768 if (!pAdapter) {
4769 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4770 return -EINVAL;
4771 }
4772
Atul Mittal115287b2014-07-08 13:26:33 +05304773 status = wlan_hdd_validate_context(pHddCtx);
4774 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304775 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304776 return -EINVAL;
4777 }
4778 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304779 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304780 return -ENOTSUPP;
4781 }
4782 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4783 data, data_len,
4784 wlan_hdd_tdls_config_enable_policy)) {
4785 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4786 return -EINVAL;
4787 }
4788
4789 /* Parse and fetch mac address */
4790 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4791 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4792 return -EINVAL;
4793 }
4794
4795 memcpy(peer, nla_data(
4796 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4797 sizeof(peer));
4798 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4799
4800 /* Parse and fetch channel */
4801 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4802 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4803 return -EINVAL;
4804 }
4805 pReqMsg.channel = nla_get_s32(
4806 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4807 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4808
4809 /* Parse and fetch global operating class */
4810 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4811 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4812 return -EINVAL;
4813 }
4814 pReqMsg.global_operating_class = nla_get_s32(
4815 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4816 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4817 pReqMsg.global_operating_class);
4818
4819 /* Parse and fetch latency ms */
4820 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4821 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4822 return -EINVAL;
4823 }
4824 pReqMsg.max_latency_ms = nla_get_s32(
4825 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4826 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4827 pReqMsg.max_latency_ms);
4828
4829 /* Parse and fetch required bandwidth kbps */
4830 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4831 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4832 return -EINVAL;
4833 }
4834
4835 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4836 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4837 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4838 pReqMsg.min_bandwidth_kbps);
4839
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304840 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05304841 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05304842 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304843 wlan_hdd_cfg80211_exttdls_callback);
4844
4845 EXIT();
4846 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304847}
4848
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304849static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4850 struct wireless_dev *wdev,
4851 const void *data,
4852 int data_len)
4853{
4854 int ret = 0;
4855
4856 vos_ssr_protect(__func__);
4857 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
4858 vos_ssr_unprotect(__func__);
4859
4860 return ret;
4861}
4862
4863static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304864 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304865 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304866 int data_len)
4867{
4868 u8 peer[6] = {0};
4869 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304870 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4871 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4872 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304873 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304874 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304875
4876 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304877
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304878 if (!dev) {
4879 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4880 return -EINVAL;
4881 }
4882
4883 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4884 if (!pAdapter) {
4885 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
4886 return -EINVAL;
4887 }
4888
Atul Mittal115287b2014-07-08 13:26:33 +05304889 status = wlan_hdd_validate_context(pHddCtx);
4890 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304891 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304892 return -EINVAL;
4893 }
4894 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304895 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304896 return -ENOTSUPP;
4897 }
4898 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4899 data, data_len,
4900 wlan_hdd_tdls_config_disable_policy)) {
4901 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4902 return -EINVAL;
4903 }
4904 /* Parse and fetch mac address */
4905 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
4906 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4907 return -EINVAL;
4908 }
4909
4910 memcpy(peer, nla_data(
4911 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
4912 sizeof(peer));
4913 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4914
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304915 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
4916
4917 EXIT();
4918 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304919}
4920
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304921static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
4922 struct wireless_dev *wdev,
4923 const void *data,
4924 int data_len)
4925{
4926 int ret = 0;
4927
4928 vos_ssr_protect(__func__);
4929 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
4930 vos_ssr_unprotect(__func__);
4931
4932 return ret;
4933}
4934
Dasari Srinivas7875a302014-09-26 17:50:57 +05304935static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304936__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05304937 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304938 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05304939{
4940 struct net_device *dev = wdev->netdev;
4941 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4942 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4943 struct sk_buff *skb = NULL;
4944 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304945 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05304946
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304947 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304948
4949 ret = wlan_hdd_validate_context(pHddCtx);
4950 if (0 != ret)
4951 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304952 return ret;
4953 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304954 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
4955 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
4956 fset |= WIFI_FEATURE_INFRA;
4957 }
4958
4959 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
4960 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
4961 fset |= WIFI_FEATURE_INFRA_5G;
4962 }
4963
4964#ifdef WLAN_FEATURE_P2P
4965 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
4966 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
4967 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
4968 fset |= WIFI_FEATURE_P2P;
4969 }
4970#endif
4971
4972 /* Soft-AP is supported currently by default */
4973 fset |= WIFI_FEATURE_SOFT_AP;
4974
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05304975 /* HOTSPOT is a supplicant feature, enable it by default */
4976 fset |= WIFI_FEATURE_HOTSPOT;
4977
Dasari Srinivas7875a302014-09-26 17:50:57 +05304978#ifdef WLAN_FEATURE_EXTSCAN
4979 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
4980 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
4981 hddLog(LOG1, FL("EXTScan is supported by firmware"));
4982 fset |= WIFI_FEATURE_EXTSCAN;
4983 }
4984#endif
4985
Dasari Srinivas7875a302014-09-26 17:50:57 +05304986 if (sme_IsFeatureSupportedByFW(NAN)) {
4987 hddLog(LOG1, FL("NAN is supported by firmware"));
4988 fset |= WIFI_FEATURE_NAN;
4989 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304990
4991 /* D2D RTT is not supported currently by default */
4992 if (sme_IsFeatureSupportedByFW(RTT)) {
4993 hddLog(LOG1, FL("RTT is supported by firmware"));
4994 fset |= WIFI_FEATURE_D2AP_RTT;
4995 }
4996
4997#ifdef FEATURE_WLAN_BATCH_SCAN
4998 if (fset & WIFI_FEATURE_EXTSCAN) {
4999 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5000 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5001 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5002 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5003 fset |= WIFI_FEATURE_BATCH_SCAN;
5004 }
5005#endif
5006
5007#ifdef FEATURE_WLAN_SCAN_PNO
5008 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5009 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5010 hddLog(LOG1, FL("PNO is supported by firmware"));
5011 fset |= WIFI_FEATURE_PNO;
5012 }
5013#endif
5014
5015 /* STA+STA is supported currently by default */
5016 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5017
5018#ifdef FEATURE_WLAN_TDLS
5019 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5020 sme_IsFeatureSupportedByFW(TDLS)) {
5021 hddLog(LOG1, FL("TDLS is supported by firmware"));
5022 fset |= WIFI_FEATURE_TDLS;
5023 }
5024
5025 /* TDLS_OFFCHANNEL is not supported currently by default */
5026#endif
5027
5028#ifdef WLAN_AP_STA_CONCURRENCY
5029 /* AP+STA concurrency is supported currently by default */
5030 fset |= WIFI_FEATURE_AP_STA;
5031#endif
5032
5033 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5034 NLMSG_HDRLEN);
5035
5036 if (!skb) {
5037 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5038 return -EINVAL;
5039 }
5040 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5041
5042 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5043 hddLog(LOGE, FL("nla put fail"));
5044 goto nla_put_failure;
5045 }
5046
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305047 ret = cfg80211_vendor_cmd_reply(skb);
5048 EXIT();
5049 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305050
5051nla_put_failure:
5052 kfree_skb(skb);
5053 return -EINVAL;
5054}
5055
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305056static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305057wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5058 struct wireless_dev *wdev,
5059 const void *data, int data_len)
5060{
5061 int ret = 0;
5062
5063 vos_ssr_protect(__func__);
5064 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5065 vos_ssr_unprotect(__func__);
5066
5067 return ret;
5068}
5069
5070static int
5071__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305072 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305073 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305074{
5075 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5076 uint8_t i, feature_sets, max_feature_sets;
5077 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5078 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305079 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5080 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305081
5082 ENTER();
5083
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305084 ret = wlan_hdd_validate_context(pHddCtx);
5085 if (0 != ret)
5086 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305087 return ret;
5088 }
5089
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305090 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5091 data, data_len, NULL)) {
5092 hddLog(LOGE, FL("Invalid ATTR"));
5093 return -EINVAL;
5094 }
5095
5096 /* Parse and fetch max feature set */
5097 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5098 hddLog(LOGE, FL("Attr max feature set size failed"));
5099 return -EINVAL;
5100 }
5101 max_feature_sets = nla_get_u32(
5102 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5103 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5104
5105 /* Fill feature combination matrix */
5106 feature_sets = 0;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305107 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5108 WIFI_FEATURE_P2P;
5109
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305110 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5111 WIFI_FEATURE_SOFT_AP;
5112
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305113 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5114 WIFI_FEATURE_SOFT_AP;
5115
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305116 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5117 WIFI_FEATURE_SOFT_AP |
5118 WIFI_FEATURE_P2P;
5119
5120 /* Add more feature combinations here */
5121
5122 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5123 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5124 hddLog(LOG1, "Feature set matrix");
5125 for (i = 0; i < feature_sets; i++)
5126 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5127
5128 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5129 sizeof(u32) * feature_sets +
5130 NLMSG_HDRLEN);
5131
5132 if (reply_skb) {
5133 if (nla_put_u32(reply_skb,
5134 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5135 feature_sets) ||
5136 nla_put(reply_skb,
5137 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5138 sizeof(u32) * feature_sets, feature_set_matrix)) {
5139 hddLog(LOGE, FL("nla put fail"));
5140 kfree_skb(reply_skb);
5141 return -EINVAL;
5142 }
5143
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305144 ret = cfg80211_vendor_cmd_reply(reply_skb);
5145 EXIT();
5146 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305147 }
5148 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5149 return -ENOMEM;
5150
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305151}
5152
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305153static int
5154wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5155 struct wireless_dev *wdev,
5156 const void *data, int data_len)
5157{
5158 int ret = 0;
5159
5160 vos_ssr_protect(__func__);
5161 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5162 data_len);
5163 vos_ssr_unprotect(__func__);
5164
5165 return ret;
5166}
5167
Agarwal Ashish738843c2014-09-25 12:27:56 +05305168static const struct nla_policy
5169wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5170 +1] =
5171{
5172 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5173};
5174
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305175static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305176 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305177 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305178 int data_len)
5179{
5180 struct net_device *dev = wdev->netdev;
5181 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5182 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5183 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5184 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5185 eHalStatus status;
5186 u32 dfsFlag = 0;
5187
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305188 ENTER();
5189
Agarwal Ashish738843c2014-09-25 12:27:56 +05305190 status = wlan_hdd_validate_context(pHddCtx);
5191 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305192 return -EINVAL;
5193 }
5194 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5195 data, data_len,
5196 wlan_hdd_set_no_dfs_flag_config_policy)) {
5197 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5198 return -EINVAL;
5199 }
5200
5201 /* Parse and fetch required bandwidth kbps */
5202 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5203 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5204 return -EINVAL;
5205 }
5206
5207 dfsFlag = nla_get_u32(
5208 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5209 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
5210 dfsFlag);
5211
5212 pHddCtx->disable_dfs_flag = dfsFlag;
5213
5214 sme_disable_dfs_channel(hHal, dfsFlag);
5215 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305216
5217 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05305218 return 0;
5219}
Atul Mittal115287b2014-07-08 13:26:33 +05305220
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305221static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
5222 struct wireless_dev *wdev,
5223 const void *data,
5224 int data_len)
5225{
5226 int ret = 0;
5227
5228 vos_ssr_protect(__func__);
5229 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
5230 vos_ssr_unprotect(__func__);
5231
5232 return ret;
5233
5234}
5235
Mukul Sharma2a271632014-10-13 14:59:01 +05305236const struct
5237nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
5238{
5239 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
5240 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
5241};
5242
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305243static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05305244 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05305245{
5246
5247 u8 bssid[6] = {0};
5248 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5249 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5250 eHalStatus status = eHAL_STATUS_SUCCESS;
5251 v_U32_t isFwrRoamEnabled = FALSE;
5252 int ret;
5253
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305254 ENTER();
5255
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305256 ret = wlan_hdd_validate_context(pHddCtx);
5257 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305258 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05305259 }
5260
5261 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
5262 data, data_len,
5263 qca_wlan_vendor_attr);
5264 if (ret){
5265 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5266 return -EINVAL;
5267 }
5268
5269 /* Parse and fetch Enable flag */
5270 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
5271 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
5272 return -EINVAL;
5273 }
5274
5275 isFwrRoamEnabled = nla_get_u32(
5276 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
5277
5278 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
5279
5280 /* Parse and fetch bssid */
5281 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
5282 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
5283 return -EINVAL;
5284 }
5285
5286 memcpy(bssid, nla_data(
5287 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
5288 sizeof(bssid));
5289 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
5290
5291 //Update roaming
5292 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305293 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05305294 return status;
5295}
5296
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305297static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
5298 struct wireless_dev *wdev, const void *data, int data_len)
5299{
5300 int ret = 0;
5301
5302 vos_ssr_protect(__func__);
5303 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
5304 vos_ssr_unprotect(__func__);
5305
5306 return ret;
5307}
5308
Sunil Duttc69bccb2014-05-26 21:30:20 +05305309const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
5310{
Mukul Sharma2a271632014-10-13 14:59:01 +05305311 {
5312 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5313 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
5314 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5315 WIPHY_VENDOR_CMD_NEED_NETDEV |
5316 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305317 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05305318 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305319
5320 {
5321 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5322 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
5323 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5324 WIPHY_VENDOR_CMD_NEED_NETDEV |
5325 WIPHY_VENDOR_CMD_NEED_RUNNING,
5326 .doit = wlan_hdd_cfg80211_nan_request
5327 },
5328
Sunil Duttc69bccb2014-05-26 21:30:20 +05305329#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5330 {
5331 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5332 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
5333 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5334 WIPHY_VENDOR_CMD_NEED_NETDEV |
5335 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305336 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05305337 },
5338
5339 {
5340 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5341 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
5342 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5343 WIPHY_VENDOR_CMD_NEED_NETDEV |
5344 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305345 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05305346 },
5347
5348 {
5349 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5350 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
5351 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5352 WIPHY_VENDOR_CMD_NEED_NETDEV |
5353 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305354 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05305355 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305356#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305357#ifdef WLAN_FEATURE_EXTSCAN
5358 {
5359 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5360 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
5361 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5362 WIPHY_VENDOR_CMD_NEED_NETDEV |
5363 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305364 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05305365 },
5366 {
5367 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5368 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
5369 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5370 WIPHY_VENDOR_CMD_NEED_NETDEV |
5371 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305372 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05305373 },
5374 {
5375 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5376 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
5377 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5378 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305379 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05305380 },
5381 {
5382 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5383 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
5384 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5385 WIPHY_VENDOR_CMD_NEED_NETDEV |
5386 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305387 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05305388 },
5389 {
5390 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5391 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
5392 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5393 WIPHY_VENDOR_CMD_NEED_NETDEV |
5394 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305395 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05305396 },
5397 {
5398 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5399 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
5400 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5401 WIPHY_VENDOR_CMD_NEED_NETDEV |
5402 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305403 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305404 },
5405 {
5406 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5407 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
5408 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5409 WIPHY_VENDOR_CMD_NEED_NETDEV |
5410 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305411 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305412 },
5413 {
5414 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5415 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
5416 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5417 WIPHY_VENDOR_CMD_NEED_NETDEV |
5418 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305419 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305420 },
5421 {
5422 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5423 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
5424 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5425 WIPHY_VENDOR_CMD_NEED_NETDEV |
5426 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305427 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305428 },
5429#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305430/*EXT TDLS*/
5431 {
5432 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5433 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
5434 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5435 WIPHY_VENDOR_CMD_NEED_NETDEV |
5436 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305437 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05305438 },
5439 {
5440 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5441 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
5442 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5443 WIPHY_VENDOR_CMD_NEED_NETDEV |
5444 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305445 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05305446 },
5447 {
5448 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5449 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
5450 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5451 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305452 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05305453 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05305454 {
5455 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5456 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
5457 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5458 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305459 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05305460 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05305461 {
5462 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5463 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
5464 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5465 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305466 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05305467 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305468 {
5469 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5470 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
5471 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5472 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305473 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305474 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305475 {
5476 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5477 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
5478 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5479 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305480 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305481 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305482};
5483
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005484/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05305485static const
5486struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005487{
5488#ifdef FEATURE_WLAN_CH_AVOID
5489 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05305490 .vendor_id = QCA_NL80211_VENDOR_ID,
5491 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005492 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305493#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
5494#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5495 {
5496 /* Index = 1*/
5497 .vendor_id = QCA_NL80211_VENDOR_ID,
5498 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
5499 },
5500 {
5501 /* Index = 2*/
5502 .vendor_id = QCA_NL80211_VENDOR_ID,
5503 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
5504 },
5505 {
5506 /* Index = 3*/
5507 .vendor_id = QCA_NL80211_VENDOR_ID,
5508 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
5509 },
5510 {
5511 /* Index = 4*/
5512 .vendor_id = QCA_NL80211_VENDOR_ID,
5513 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
5514 },
5515 {
5516 /* Index = 5*/
5517 .vendor_id = QCA_NL80211_VENDOR_ID,
5518 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
5519 },
5520 {
5521 /* Index = 6*/
5522 .vendor_id = QCA_NL80211_VENDOR_ID,
5523 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
5524 },
5525#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305526#ifdef WLAN_FEATURE_EXTSCAN
5527 {
5528 .vendor_id = QCA_NL80211_VENDOR_ID,
5529 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
5530 },
5531 {
5532 .vendor_id = QCA_NL80211_VENDOR_ID,
5533 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
5534 },
5535 {
5536 .vendor_id = QCA_NL80211_VENDOR_ID,
5537 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
5538 },
5539 {
5540 .vendor_id = QCA_NL80211_VENDOR_ID,
5541 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
5542 },
5543 {
5544 .vendor_id = QCA_NL80211_VENDOR_ID,
5545 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
5546 },
5547 {
5548 .vendor_id = QCA_NL80211_VENDOR_ID,
5549 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
5550 },
5551 {
5552 .vendor_id = QCA_NL80211_VENDOR_ID,
5553 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
5554 },
5555 {
5556 .vendor_id = QCA_NL80211_VENDOR_ID,
5557 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
5558 },
5559 {
5560 .vendor_id = QCA_NL80211_VENDOR_ID,
5561 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
5562 },
5563 {
5564 .vendor_id = QCA_NL80211_VENDOR_ID,
5565 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
5566 },
5567 {
5568 .vendor_id = QCA_NL80211_VENDOR_ID,
5569 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
5570 },
5571 {
5572 .vendor_id = QCA_NL80211_VENDOR_ID,
5573 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
5574 },
5575 {
5576 .vendor_id = QCA_NL80211_VENDOR_ID,
5577 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
5578 },
5579#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305580/*EXT TDLS*/
5581 {
5582 .vendor_id = QCA_NL80211_VENDOR_ID,
5583 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
5584 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305585
5586 {
5587 .vendor_id = QCA_NL80211_VENDOR_ID,
5588 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
5589 },
5590
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005591};
5592
Jeff Johnson295189b2012-06-20 16:38:30 -07005593/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305594 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305595 * This function is called by hdd_wlan_startup()
5596 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305597 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07005598 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305599struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07005600{
5601 struct wiphy *wiphy;
5602 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305603 /*
5604 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07005605 */
5606 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
5607
5608 if (!wiphy)
5609 {
5610 /* Print error and jump into err label and free the memory */
5611 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
5612 return NULL;
5613 }
5614
Sunil Duttc69bccb2014-05-26 21:30:20 +05305615
Jeff Johnson295189b2012-06-20 16:38:30 -07005616 return wiphy;
5617}
5618
5619/*
5620 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305621 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 * private ioctl to change the band value
5623 */
5624int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
5625{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305626 int i, j;
5627 eNVChannelEnabledType channelEnabledState;
5628
Jeff Johnsone7245742012-09-05 17:12:55 -07005629 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305630
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305631 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005632 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305633
5634 if (NULL == wiphy->bands[i])
5635 {
5636 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5637 __func__, i);
5638 continue;
5639 }
5640
5641 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5642 {
5643 struct ieee80211_supported_band *band = wiphy->bands[i];
5644
5645 channelEnabledState = vos_nv_getChannelEnabledState(
5646 band->channels[j].hw_value);
5647
5648 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
5649 {
Abhishek Singh678227a2014-11-04 10:52:38 +05305650 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305651 continue;
5652 }
5653 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
5654 {
5655 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5656 continue;
5657 }
5658
5659 if (NV_CHANNEL_DISABLE == channelEnabledState ||
5660 NV_CHANNEL_INVALID == channelEnabledState)
5661 {
5662 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5663 }
5664 else if (NV_CHANNEL_DFS == channelEnabledState)
5665 {
5666 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5667 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
5668 }
5669 else
5670 {
5671 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
5672 |IEEE80211_CHAN_RADAR);
5673 }
5674 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005675 }
5676 return 0;
5677}
5678/*
5679 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305680 * This function is called by hdd_wlan_startup()
5681 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07005682 * This function is used to initialize and register wiphy structure.
5683 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305684int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005685 struct wiphy *wiphy,
5686 hdd_config_t *pCfg
5687 )
5688{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305689 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305690 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5691
Jeff Johnsone7245742012-09-05 17:12:55 -07005692 ENTER();
5693
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 /* Now bind the underlying wlan device with wiphy */
5695 set_wiphy_dev(wiphy, dev);
5696
5697 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005698
Kiet Lam6c583332013-10-14 05:37:09 +05305699#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07005700 /* the flag for the other case would be initialzed in
5701 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07005702 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05305703#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005704
Amar Singhalfddc28c2013-09-05 13:03:40 -07005705 /* This will disable updating of NL channels from passive to
5706 * active if a beacon is received on passive channel. */
5707 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -07005708
Amar Singhalfddc28c2013-09-05 13:03:40 -07005709
Amar Singhala49cbc52013-10-08 18:37:44 -07005710
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005711#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07005712 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
5713 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
5714 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07005715 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +05305716 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005717#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005718
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005719#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005720 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08005721#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005722 || pCfg->isFastRoamIniFeatureEnabled
5723#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005724#ifdef FEATURE_WLAN_ESE
5725 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005726#endif
5727 )
5728 {
5729 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
5730 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08005731#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005732#ifdef FEATURE_WLAN_TDLS
5733 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
5734 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
5735#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305736#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05305737 if (pCfg->configPNOScanSupport)
5738 {
5739 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
5740 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
5741 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
5742 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
5743 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305744#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005745
Abhishek Singh10d85972015-04-17 10:27:23 +05305746#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5747 wiphy->features |= NL80211_FEATURE_HT_IBSS;
5748#endif
5749
Amar Singhalfddc28c2013-09-05 13:03:40 -07005750#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005751 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
5752 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07005753 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005754 driver need to determine what to do with both
5755 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07005756
5757 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07005758#else
5759 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005760#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005761
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305762 wiphy->max_scan_ssids = MAX_SCAN_SSID;
5763
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05305764 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07005765
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305766 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
5767
Jeff Johnson295189b2012-06-20 16:38:30 -07005768 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305769 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07005770 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 | BIT(NL80211_IFTYPE_P2P_CLIENT)
5772 | BIT(NL80211_IFTYPE_P2P_GO)
Katya Nigame7b69a82015-04-28 15:24:06 +05305773 | BIT(NL80211_IFTYPE_AP)
5774 | BIT(NL80211_IFTYPE_MONITOR);
Jeff Johnson295189b2012-06-20 16:38:30 -07005775
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305776 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005777 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305778#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5779 if( pCfg->enableMCC )
5780 {
5781 /* Currently, supports up to two channels */
5782 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005783
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305784 if( !pCfg->allowMCCGODiffBI )
5785 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005786
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305787 }
5788 wiphy->iface_combinations = &wlan_hdd_iface_combination;
5789 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005790#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305791 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005792
Jeff Johnson295189b2012-06-20 16:38:30 -07005793 /* Before registering we need to update the ht capabilitied based
5794 * on ini values*/
5795 if( !pCfg->ShortGI20MhzEnable )
5796 {
5797 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5798 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5799 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5800 }
5801
5802 if( !pCfg->ShortGI40MhzEnable )
5803 {
5804 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
5805 }
5806
5807 if( !pCfg->nChannelBondingMode5GHz )
5808 {
5809 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5810 }
5811
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305812 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305813 if (true == hdd_is_5g_supported(pHddCtx))
5814 {
5815 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
5816 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305817
5818 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
5819 {
5820
5821 if (NULL == wiphy->bands[i])
5822 {
5823 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5824 __func__, i);
5825 continue;
5826 }
5827
5828 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5829 {
5830 struct ieee80211_supported_band *band = wiphy->bands[i];
5831
5832 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
5833 {
5834 // Enable social channels for P2P
5835 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
5836 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5837 else
5838 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5839 continue;
5840 }
5841 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
5842 {
5843 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5844 continue;
5845 }
5846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 }
5848 /*Initialise the supported cipher suite details*/
5849 wiphy->cipher_suites = hdd_cipher_suites;
5850 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
5851
5852 /*signal strength in mBm (100*dBm) */
5853 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
5854
5855#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05305856 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07005857#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005858
Sunil Duttc69bccb2014-05-26 21:30:20 +05305859 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
5860 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005861 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
5862 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
5863
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305864 EXIT();
5865 return 0;
5866}
5867
5868/* In this function we are registering wiphy. */
5869int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
5870{
5871 ENTER();
5872 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005873 if (0 > wiphy_register(wiphy))
5874 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305875 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
5877 return -EIO;
5878 }
5879
5880 EXIT();
5881 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305882}
Jeff Johnson295189b2012-06-20 16:38:30 -07005883
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305884/* In this function we are updating channel list when,
5885 regulatory domain is FCC and country code is US.
5886 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
5887 As per FCC smart phone is not a indoor device.
5888 GO should not opeate on indoor channels */
5889void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
5890{
5891 int j;
5892 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5893 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
5894 //Default counrtycode from NV at the time of wiphy initialization.
5895 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
5896 &defaultCountryCode[0]))
5897 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005898 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305899 }
5900 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
5901 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305902 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
5903 {
5904 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
5905 return;
5906 }
5907 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
5908 {
5909 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
5910 // Mark UNII -1 band channel as passive
5911 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
5912 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
5913 }
5914 }
5915}
5916
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305917/* This function registers for all frame which supplicant is interested in */
5918void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005919{
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5921 /* Register for all P2P action, public action etc frames */
5922 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5923
Jeff Johnsone7245742012-09-05 17:12:55 -07005924 ENTER();
5925
Jeff Johnson295189b2012-06-20 16:38:30 -07005926 /* Right now we are registering these frame when driver is getting
5927 initialized. Once we will move to 2.6.37 kernel, in which we have
5928 frame register ops, we will move this code as a part of that */
5929 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305930 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07005931 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5932
5933 /* GAS Initial Response */
5934 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5935 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305936
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 /* GAS Comeback Request */
5938 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5939 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
5940
5941 /* GAS Comeback Response */
5942 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5943 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
5944
5945 /* P2P Public Action */
5946 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305947 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 P2P_PUBLIC_ACTION_FRAME_SIZE );
5949
5950 /* P2P Action */
5951 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5952 (v_U8_t*)P2P_ACTION_FRAME,
5953 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07005954
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05305955 /* WNM BSS Transition Request frame */
5956 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5957 (v_U8_t*)WNM_BSS_ACTION_FRAME,
5958 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07005959
5960 /* WNM-Notification */
5961 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5962 (v_U8_t*)WNM_NOTIFICATION_FRAME,
5963 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005964}
5965
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305966void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005967{
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5969 /* Register for all P2P action, public action etc frames */
5970 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5971
Jeff Johnsone7245742012-09-05 17:12:55 -07005972 ENTER();
5973
Jeff Johnson295189b2012-06-20 16:38:30 -07005974 /* Right now we are registering these frame when driver is getting
5975 initialized. Once we will move to 2.6.37 kernel, in which we have
5976 frame register ops, we will move this code as a part of that */
5977 /* GAS Initial Request */
5978
5979 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5980 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5981
5982 /* GAS Initial Response */
5983 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5984 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305985
Jeff Johnson295189b2012-06-20 16:38:30 -07005986 /* GAS Comeback Request */
5987 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5988 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
5989
5990 /* GAS Comeback Response */
5991 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5992 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
5993
5994 /* P2P Public Action */
5995 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305996 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07005997 P2P_PUBLIC_ACTION_FRAME_SIZE );
5998
5999 /* P2P Action */
6000 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6001 (v_U8_t*)P2P_ACTION_FRAME,
6002 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006003 /* WNM-Notification */
6004 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6005 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6006 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006007}
6008
6009#ifdef FEATURE_WLAN_WAPI
6010void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
6011 const u8 *mac_addr, u8 *key , int key_Len)
6012{
6013 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6014 tCsrRoamSetKey setKey;
6015 v_BOOL_t isConnected = TRUE;
6016 int status = 0;
6017 v_U32_t roamId= 0xFF;
6018 tANI_U8 *pKeyPtr = NULL;
6019 int n = 0;
6020
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306021 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
6022 __func__, hdd_device_modetoString(pAdapter->device_mode),
6023 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006024
Gopichand Nakkalae7480202013-02-11 15:24:22 +05306025 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 setKey.keyId = key_index; // Store Key ID
6027 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
6028 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
6029 setKey.paeRole = 0 ; // the PAE role
6030 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
6031 {
6032 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
6033 }
6034 else
6035 {
6036 isConnected = hdd_connIsConnected(pHddStaCtx);
6037 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
6038 }
6039 setKey.keyLength = key_Len;
6040 pKeyPtr = setKey.Key;
6041 memcpy( pKeyPtr, key, key_Len);
6042
Arif Hussain6d2a3322013-11-17 19:50:10 -08006043 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 __func__, key_Len);
6045 for (n = 0 ; n < key_Len; n++)
6046 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
6047 __func__,n,setKey.Key[n]);
6048
6049 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6050 if ( isConnected )
6051 {
6052 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
6053 pAdapter->sessionId, &setKey, &roamId );
6054 }
6055 if ( status != 0 )
6056 {
6057 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6058 "[%4d] sme_RoamSetKey returned ERROR status= %d",
6059 __LINE__, status );
6060 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6061 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05306062 /* Need to clear any trace of key value in the memory.
6063 * Thus zero out the memory even though it is local
6064 * variable.
6065 */
6066 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006067}
6068#endif /* FEATURE_WLAN_WAPI*/
6069
6070#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306071int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006072 beacon_data_t **ppBeacon,
6073 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006074#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306075int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006076 beacon_data_t **ppBeacon,
6077 struct cfg80211_beacon_data *params,
6078 int dtim_period)
6079#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306080{
Jeff Johnson295189b2012-06-20 16:38:30 -07006081 int size;
6082 beacon_data_t *beacon = NULL;
6083 beacon_data_t *old = NULL;
6084 int head_len,tail_len;
6085
Jeff Johnsone7245742012-09-05 17:12:55 -07006086 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006087 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306088 {
6089 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6090 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006093
6094 old = pAdapter->sessionCtx.ap.beacon;
6095
6096 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306097 {
6098 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6099 FL("session(%d) old and new heads points to NULL"),
6100 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006101 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306102 }
6103
6104 if (params->tail && !params->tail_len)
6105 {
6106 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6107 FL("tail_len is zero but tail is not NULL"));
6108 return -EINVAL;
6109 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006110
Jeff Johnson295189b2012-06-20 16:38:30 -07006111#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
6112 /* Kernel 3.0 is not updating dtim_period for set beacon */
6113 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306114 {
6115 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6116 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306118 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006119#endif
6120
6121 if(params->head)
6122 head_len = params->head_len;
6123 else
6124 head_len = old->head_len;
6125
6126 if(params->tail || !old)
6127 tail_len = params->tail_len;
6128 else
6129 tail_len = old->tail_len;
6130
6131 size = sizeof(beacon_data_t) + head_len + tail_len;
6132
6133 beacon = kzalloc(size, GFP_KERNEL);
6134
6135 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306136 {
6137 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6138 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006139 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306140 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006141
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006142#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006143 if(params->dtim_period || !old )
6144 beacon->dtim_period = params->dtim_period;
6145 else
6146 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006147#else
6148 if(dtim_period || !old )
6149 beacon->dtim_period = dtim_period;
6150 else
6151 beacon->dtim_period = old->dtim_period;
6152#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306153
Jeff Johnson295189b2012-06-20 16:38:30 -07006154 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
6155 beacon->tail = beacon->head + head_len;
6156 beacon->head_len = head_len;
6157 beacon->tail_len = tail_len;
6158
6159 if(params->head) {
6160 memcpy (beacon->head,params->head,beacon->head_len);
6161 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306162 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07006163 if(old)
6164 memcpy (beacon->head,old->head,beacon->head_len);
6165 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306166
Jeff Johnson295189b2012-06-20 16:38:30 -07006167 if(params->tail) {
6168 memcpy (beacon->tail,params->tail,beacon->tail_len);
6169 }
6170 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306171 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07006172 memcpy (beacon->tail,old->tail,beacon->tail_len);
6173 }
6174
6175 *ppBeacon = beacon;
6176
6177 kfree(old);
6178
6179 return 0;
6180
6181}
Jeff Johnson295189b2012-06-20 16:38:30 -07006182
6183v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
6184{
6185 int left = length;
6186 v_U8_t *ptr = pIes;
6187 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306188
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306190 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006191 elem_id = ptr[0];
6192 elem_len = ptr[1];
6193 left -= 2;
6194 if(elem_len > left)
6195 {
6196 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006197 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006198 eid,elem_len,left);
6199 return NULL;
6200 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306201 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006202 {
6203 return ptr;
6204 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306205
Jeff Johnson295189b2012-06-20 16:38:30 -07006206 left -= elem_len;
6207 ptr += (elem_len + 2);
6208 }
6209 return NULL;
6210}
6211
Jeff Johnson295189b2012-06-20 16:38:30 -07006212/* Check if rate is 11g rate or not */
6213static int wlan_hdd_rate_is_11g(u8 rate)
6214{
Sanjay Devnani28322e22013-06-21 16:13:40 -07006215 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 u8 i;
6217 for (i = 0; i < 8; i++)
6218 {
6219 if(rate == gRateArray[i])
6220 return TRUE;
6221 }
6222 return FALSE;
6223}
6224
6225/* Check for 11g rate and set proper 11g only mode */
6226static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
6227 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
6228{
6229 u8 i, num_rates = pIe[0];
6230
6231 pIe += 1;
6232 for ( i = 0; i < num_rates; i++)
6233 {
6234 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
6235 {
6236 /* If rate set have 11g rate than change the mode to 11G */
6237 *pSapHw_mode = eSAP_DOT11_MODE_11g;
6238 if (pIe[i] & BASIC_RATE_MASK)
6239 {
6240 /* If we have 11g rate as basic rate, it means mode
6241 is 11g only mode.
6242 */
6243 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
6244 *pCheckRatesfor11g = FALSE;
6245 }
6246 }
6247 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
6248 {
6249 *require_ht = TRUE;
6250 }
6251 }
6252 return;
6253}
6254
6255static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
6256{
6257 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6258 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6259 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6260 u8 checkRatesfor11g = TRUE;
6261 u8 require_ht = FALSE;
6262 u8 *pIe=NULL;
6263
6264 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
6265
6266 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
6267 pBeacon->head_len, WLAN_EID_SUPP_RATES);
6268 if (pIe != NULL)
6269 {
6270 pIe += 1;
6271 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6272 &pConfig->SapHw_mode);
6273 }
6274
6275 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6276 WLAN_EID_EXT_SUPP_RATES);
6277 if (pIe != NULL)
6278 {
6279
6280 pIe += 1;
6281 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6282 &pConfig->SapHw_mode);
6283 }
6284
6285 if( pConfig->channel > 14 )
6286 {
6287 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
6288 }
6289
6290 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6291 WLAN_EID_HT_CAPABILITY);
6292
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306293 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 {
6295 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
6296 if(require_ht)
6297 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
6298 }
6299}
6300
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306301static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
6302 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
6303{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006304 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306305 v_U8_t *pIe = NULL;
6306 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6307
6308 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
6309 pBeacon->tail, pBeacon->tail_len);
6310
6311 if (pIe)
6312 {
6313 ielen = pIe[1] + 2;
6314 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6315 {
6316 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
6317 }
6318 else
6319 {
6320 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
6321 return -EINVAL;
6322 }
6323 *total_ielen += ielen;
6324 }
6325 return 0;
6326}
6327
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006328static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
6329 v_U8_t *genie, v_U8_t *total_ielen)
6330{
6331 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6332 int left = pBeacon->tail_len;
6333 v_U8_t *ptr = pBeacon->tail;
6334 v_U8_t elem_id, elem_len;
6335 v_U16_t ielen = 0;
6336
6337 if ( NULL == ptr || 0 == left )
6338 return;
6339
6340 while (left >= 2)
6341 {
6342 elem_id = ptr[0];
6343 elem_len = ptr[1];
6344 left -= 2;
6345 if (elem_len > left)
6346 {
6347 hddLog( VOS_TRACE_LEVEL_ERROR,
6348 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
6349 elem_id, elem_len, left);
6350 return;
6351 }
6352 if (IE_EID_VENDOR == elem_id)
6353 {
6354 /* skipping the VSIE's which we don't want to include or
6355 * it will be included by existing code
6356 */
6357 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
6358#ifdef WLAN_FEATURE_WFD
6359 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
6360#endif
6361 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6362 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6363 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
6364 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6365 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
6366 {
6367 ielen = ptr[1] + 2;
6368 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6369 {
6370 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
6371 *total_ielen += ielen;
6372 }
6373 else
6374 {
6375 hddLog( VOS_TRACE_LEVEL_ERROR,
6376 "IE Length is too big "
6377 "IEs eid=%d elem_len=%d total_ie_lent=%d",
6378 elem_id, elem_len, *total_ielen);
6379 }
6380 }
6381 }
6382
6383 left -= elem_len;
6384 ptr += (elem_len + 2);
6385 }
6386 return;
6387}
6388
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006389#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006390static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6391 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006392#else
6393static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6394 struct cfg80211_beacon_data *params)
6395#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006396{
6397 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306398 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006399 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07006400 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006401
6402 genie = vos_mem_malloc(MAX_GENIE_LEN);
6403
6404 if(genie == NULL) {
6405
6406 return -ENOMEM;
6407 }
6408
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306409 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6410 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306412 hddLog(LOGE,
6413 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306414 ret = -EINVAL;
6415 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006416 }
6417
6418#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306419 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6420 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
6421 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306422 hddLog(LOGE,
6423 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306424 ret = -EINVAL;
6425 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006426 }
6427#endif
6428
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306429 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6430 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006431 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306432 hddLog(LOGE,
6433 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306434 ret = -EINVAL;
6435 goto done;
6436 }
6437
6438 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
6439 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006440 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006442
6443 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6444 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
6445 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6446 {
6447 hddLog(LOGE,
6448 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006449 ret = -EINVAL;
6450 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006451 }
6452
6453 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6454 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6455 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6456 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6457 ==eHAL_STATUS_FAILURE)
6458 {
6459 hddLog(LOGE,
6460 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006461 ret = -EINVAL;
6462 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006463 }
6464
6465 // Added for ProResp IE
6466 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
6467 {
6468 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
6469 u8 probe_rsp_ie_len[3] = {0};
6470 u8 counter = 0;
6471 /* Check Probe Resp Length if it is greater then 255 then Store
6472 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
6473 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
6474 Store More then 255 bytes into One Variable.
6475 */
6476 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6477 {
6478 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6479 {
6480 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6481 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6482 }
6483 else
6484 {
6485 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6486 rem_probe_resp_ie_len = 0;
6487 }
6488 }
6489
6490 rem_probe_resp_ie_len = 0;
6491
6492 if (probe_rsp_ie_len[0] > 0)
6493 {
6494 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6495 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6496 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6497 probe_rsp_ie_len[0], NULL,
6498 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6499 {
6500 hddLog(LOGE,
6501 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006502 ret = -EINVAL;
6503 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006504 }
6505 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6506 }
6507
6508 if (probe_rsp_ie_len[1] > 0)
6509 {
6510 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6511 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6512 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6513 probe_rsp_ie_len[1], NULL,
6514 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6515 {
6516 hddLog(LOGE,
6517 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006518 ret = -EINVAL;
6519 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 }
6521 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6522 }
6523
6524 if (probe_rsp_ie_len[2] > 0)
6525 {
6526 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6527 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6528 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6529 probe_rsp_ie_len[2], NULL,
6530 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6531 {
6532 hddLog(LOGE,
6533 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006534 ret = -EINVAL;
6535 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006536 }
6537 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6538 }
6539
6540 if (probe_rsp_ie_len[1] == 0 )
6541 {
6542 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6543 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
6544 eANI_BOOLEAN_FALSE) )
6545 {
6546 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006547 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006548 }
6549 }
6550
6551 if (probe_rsp_ie_len[2] == 0 )
6552 {
6553 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6554 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
6555 eANI_BOOLEAN_FALSE) )
6556 {
6557 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006558 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006559 }
6560 }
6561
6562 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6563 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6564 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6565 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6566 == eHAL_STATUS_FAILURE)
6567 {
6568 hddLog(LOGE,
6569 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006570 ret = -EINVAL;
6571 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006572 }
6573 }
6574 else
6575 {
6576 // Reset WNI_CFG_PROBE_RSP Flags
6577 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
6578
6579 hddLog(VOS_TRACE_LEVEL_INFO,
6580 "%s: No Probe Response IE received in set beacon",
6581 __func__);
6582 }
6583
6584 // Added for AssocResp IE
6585 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
6586 {
6587 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6588 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
6589 params->assocresp_ies_len, NULL,
6590 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6591 {
6592 hddLog(LOGE,
6593 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006594 ret = -EINVAL;
6595 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006596 }
6597
6598 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6599 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
6600 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6601 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6602 == eHAL_STATUS_FAILURE)
6603 {
6604 hddLog(LOGE,
6605 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006606 ret = -EINVAL;
6607 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 }
6609 }
6610 else
6611 {
6612 hddLog(VOS_TRACE_LEVEL_INFO,
6613 "%s: No Assoc Response IE received in set beacon",
6614 __func__);
6615
6616 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6617 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6618 eANI_BOOLEAN_FALSE) )
6619 {
6620 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006621 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006622 }
6623 }
6624
Jeff Johnsone7245742012-09-05 17:12:55 -07006625done:
Jeff Johnson295189b2012-06-20 16:38:30 -07006626 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306627 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006628}
Jeff Johnson295189b2012-06-20 16:38:30 -07006629
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306630/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 * FUNCTION: wlan_hdd_validate_operation_channel
6632 * called by wlan_hdd_cfg80211_start_bss() and
6633 * wlan_hdd_cfg80211_set_channel()
6634 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306635 * channel list.
6636 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07006637VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006638{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306639
Jeff Johnson295189b2012-06-20 16:38:30 -07006640 v_U32_t num_ch = 0;
6641 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6642 u32 indx = 0;
6643 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306644 v_U8_t fValidChannel = FALSE, count = 0;
6645 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306646
Jeff Johnson295189b2012-06-20 16:38:30 -07006647 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6648
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306649 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006650 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306651 /* Validate the channel */
6652 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006653 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306654 if ( channel == rfChannels[count].channelNum )
6655 {
6656 fValidChannel = TRUE;
6657 break;
6658 }
6659 }
6660 if (fValidChannel != TRUE)
6661 {
6662 hddLog(VOS_TRACE_LEVEL_ERROR,
6663 "%s: Invalid Channel [%d]", __func__, channel);
6664 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006665 }
6666 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306667 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006668 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306669 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6670 valid_ch, &num_ch))
6671 {
6672 hddLog(VOS_TRACE_LEVEL_ERROR,
6673 "%s: failed to get valid channel list", __func__);
6674 return VOS_STATUS_E_FAILURE;
6675 }
6676 for (indx = 0; indx < num_ch; indx++)
6677 {
6678 if (channel == valid_ch[indx])
6679 {
6680 break;
6681 }
6682 }
6683
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306684 if (indx >= num_ch)
6685 {
6686 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6687 {
6688 eCsrBand band;
6689 unsigned int freq;
6690
6691 sme_GetFreqBand(hHal, &band);
6692
6693 if (eCSR_BAND_5G == band)
6694 {
6695#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
6696 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
6697 {
6698 freq = ieee80211_channel_to_frequency(channel,
6699 IEEE80211_BAND_2GHZ);
6700 }
6701 else
6702 {
6703 freq = ieee80211_channel_to_frequency(channel,
6704 IEEE80211_BAND_5GHZ);
6705 }
6706#else
6707 freq = ieee80211_channel_to_frequency(channel);
6708#endif
6709 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
6710 return VOS_STATUS_SUCCESS;
6711 }
6712 }
6713
6714 hddLog(VOS_TRACE_LEVEL_ERROR,
6715 "%s: Invalid Channel [%d]", __func__, channel);
6716 return VOS_STATUS_E_FAILURE;
6717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306719
Jeff Johnson295189b2012-06-20 16:38:30 -07006720 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306721
Jeff Johnson295189b2012-06-20 16:38:30 -07006722}
6723
Viral Modi3a32cc52013-02-08 11:14:52 -08006724/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306725 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08006726 * This function is used to set the channel number
6727 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306728static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08006729 struct ieee80211_channel *chan,
6730 enum nl80211_channel_type channel_type
6731 )
6732{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306733 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08006734 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07006735 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08006736 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306737 hdd_context_t *pHddCtx;
6738 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006739
6740 ENTER();
6741
6742 if( NULL == dev )
6743 {
6744 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006745 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006746 return -ENODEV;
6747 }
6748 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306749
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306750 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6751 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
6752 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08006753 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306754 "%s: device_mode = %s (%d) freq = %d", __func__,
6755 hdd_device_modetoString(pAdapter->device_mode),
6756 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306757
6758 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6759 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306760 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08006761 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306762 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006763 }
6764
6765 /*
6766 * Do freq to chan conversion
6767 * TODO: for 11a
6768 */
6769
6770 channel = ieee80211_frequency_to_channel(freq);
6771
6772 /* Check freq range */
6773 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
6774 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
6775 {
6776 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006777 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08006778 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
6779 WNI_CFG_CURRENT_CHANNEL_STAMAX);
6780 return -EINVAL;
6781 }
6782
6783 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6784
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05306785 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
6786 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08006787 {
6788 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
6789 {
6790 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006791 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08006792 return -EINVAL;
6793 }
6794 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6795 "%s: set channel to [%d] for device mode =%d",
6796 __func__, channel,pAdapter->device_mode);
6797 }
6798 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08006799 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08006800 )
6801 {
6802 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6803 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
6804 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6805
6806 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
6807 {
6808 /* Link is up then return cant set channel*/
6809 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006810 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006811 return -EINVAL;
6812 }
6813
6814 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
6815 pHddStaCtx->conn_info.operationChannel = channel;
6816 pRoamProfile->ChannelInfo.ChannelList =
6817 &pHddStaCtx->conn_info.operationChannel;
6818 }
6819 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08006820 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08006821 )
6822 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306823 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6824 {
6825 if(VOS_STATUS_SUCCESS !=
6826 wlan_hdd_validate_operation_channel(pAdapter,channel))
6827 {
6828 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006829 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306830 return -EINVAL;
6831 }
6832 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6833 }
6834 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08006835 {
6836 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
6837
6838 /* If auto channel selection is configured as enable/ 1 then ignore
6839 channel set by supplicant
6840 */
6841 if ( cfg_param->apAutoChannelSelection )
6842 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306843 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
6844 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08006845 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306846 "%s: set channel to auto channel (0) for device mode =%s (%d)",
6847 __func__, hdd_device_modetoString(pAdapter->device_mode),
6848 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08006849 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306850 else
6851 {
6852 if(VOS_STATUS_SUCCESS !=
6853 wlan_hdd_validate_operation_channel(pAdapter,channel))
6854 {
6855 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006856 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306857 return -EINVAL;
6858 }
6859 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6860 }
Viral Modi3a32cc52013-02-08 11:14:52 -08006861 }
6862 }
6863 else
6864 {
6865 hddLog(VOS_TRACE_LEVEL_FATAL,
6866 "%s: Invalid device mode failed to set valid channel", __func__);
6867 return -EINVAL;
6868 }
6869 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306870 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006871}
6872
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306873static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
6874 struct net_device *dev,
6875 struct ieee80211_channel *chan,
6876 enum nl80211_channel_type channel_type
6877 )
6878{
6879 int ret;
6880
6881 vos_ssr_protect(__func__);
6882 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
6883 vos_ssr_unprotect(__func__);
6884
6885 return ret;
6886}
6887
Jeff Johnson295189b2012-06-20 16:38:30 -07006888#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
6889static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6890 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006891#else
6892static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6893 struct cfg80211_beacon_data *params,
6894 const u8 *ssid, size_t ssid_len,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05306895 enum nl80211_hidden_ssid hidden_ssid,
6896 v_U8_t auth_type)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006897#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006898{
6899 tsap_Config_t *pConfig;
6900 beacon_data_t *pBeacon = NULL;
6901 struct ieee80211_mgmt *pMgmt_frame;
6902 v_U8_t *pIe=NULL;
6903 v_U16_t capab_info;
6904 eCsrAuthType RSNAuthType;
6905 eCsrEncryptionType RSNEncryptType;
6906 eCsrEncryptionType mcRSNEncryptType;
6907 int status = VOS_STATUS_SUCCESS;
6908 tpWLAN_SAPEventCB pSapEventCallback;
6909 hdd_hostapd_state_t *pHostapdState;
6910 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
6911 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306912 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006913 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306914 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006915 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08006916 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05306917 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07006918 v_BOOL_t MFPCapable = VOS_FALSE;
6919 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05306920 v_BOOL_t sapEnable11AC =
6921 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07006922 ENTER();
6923
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306924 iniConfig = pHddCtx->cfg_ini;
6925
Jeff Johnson295189b2012-06-20 16:38:30 -07006926 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
6927
6928 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6929
6930 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6931
6932 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6933
6934 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
6935
6936 //channel is already set in the set_channel Call back
6937 //pConfig->channel = pCommitConfig->channel;
6938
6939 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306940 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07006941 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
6942
6943 pConfig->dtim_period = pBeacon->dtim_period;
6944
Arif Hussain6d2a3322013-11-17 19:50:10 -08006945 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07006946 pConfig->dtim_period);
6947
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08006948 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07006949 {
6950 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006951 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05306952 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
6953 {
6954 tANI_BOOLEAN restartNeeded;
6955 pConfig->ieee80211d = 1;
6956 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
6957 sme_setRegInfo(hHal, pConfig->countryCode);
6958 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
6959 }
6960 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006961 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07006962 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006963 pConfig->ieee80211d = 1;
6964 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
6965 sme_setRegInfo(hHal, pConfig->countryCode);
6966 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07006967 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07006968 else
6969 {
6970 pConfig->ieee80211d = 0;
6971 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306972 /*
6973 * If auto channel is configured i.e. channel is 0,
6974 * so skip channel validation.
6975 */
6976 if( AUTO_CHANNEL_SELECT != pConfig->channel )
6977 {
6978 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
6979 {
6980 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006981 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306982 return -EINVAL;
6983 }
6984 }
6985 else
6986 {
6987 if(1 != pHddCtx->is_dynamic_channel_range_set)
6988 {
6989 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
6990 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
6991 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
6992 }
6993 pHddCtx->is_dynamic_channel_range_set = 0;
6994 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006995 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07006996 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006997 {
6998 pConfig->ieee80211d = 0;
6999 }
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307000
7001#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7002 if (params->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7003 pConfig->authType = eSAP_OPEN_SYSTEM;
7004 else if (params->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7005 pConfig->authType = eSAP_SHARED_KEY;
7006 else
7007 pConfig->authType = eSAP_AUTO_SWITCH;
7008#else
7009 if (auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
7010 pConfig->authType = eSAP_OPEN_SYSTEM;
7011 else if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
7012 pConfig->authType = eSAP_SHARED_KEY;
7013 else
7014 pConfig->authType = eSAP_AUTO_SWITCH;
7015#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007016
7017 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307018
7019 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07007020 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
7021
7022 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
7023
7024 /*Set wps station to configured*/
7025 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
7026
7027 if(pIe)
7028 {
7029 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
7030 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007031 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07007032 return -EINVAL;
7033 }
7034 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
7035 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007036 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07007037 /* Check 15 bit of WPS IE as it contain information for wps state
7038 * WPS state
7039 */
7040 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
7041 {
7042 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
7043 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
7044 {
7045 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
7046 }
7047 }
7048 }
7049 else
7050 {
7051 pConfig->wps_state = SAP_WPS_DISABLED;
7052 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307053 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07007054
c_hpothufe599e92014-06-16 11:38:55 +05307055 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7056 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7057 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
7058 eCSR_ENCRYPT_TYPE_NONE;
7059
Jeff Johnson295189b2012-06-20 16:38:30 -07007060 pConfig->RSNWPAReqIELength = 0;
7061 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307062 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007063 WLAN_EID_RSN);
7064 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307065 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007066 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7067 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7068 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307069 /* The actual processing may eventually be more extensive than
7070 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07007071 * by the app.
7072 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307073 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007074 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7075 &RSNEncryptType,
7076 &mcRSNEncryptType,
7077 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007078 &MFPCapable,
7079 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007080 pConfig->pRSNWPAReqIE[1]+2,
7081 pConfig->pRSNWPAReqIE );
7082
7083 if( VOS_STATUS_SUCCESS == status )
7084 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307085 /* Now copy over all the security attributes you have
7086 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007087 * */
7088 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7089 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7090 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7091 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307092 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007093 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007094 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7095 }
7096 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307097
Jeff Johnson295189b2012-06-20 16:38:30 -07007098 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7099 pBeacon->tail, pBeacon->tail_len);
7100
7101 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
7102 {
7103 if (pConfig->pRSNWPAReqIE)
7104 {
7105 /*Mixed mode WPA/WPA2*/
7106 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
7107 pConfig->RSNWPAReqIELength += pIe[1] + 2;
7108 }
7109 else
7110 {
7111 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7112 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7113 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307114 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007115 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7116 &RSNEncryptType,
7117 &mcRSNEncryptType,
7118 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007119 &MFPCapable,
7120 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007121 pConfig->pRSNWPAReqIE[1]+2,
7122 pConfig->pRSNWPAReqIE );
7123
7124 if( VOS_STATUS_SUCCESS == status )
7125 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307126 /* Now copy over all the security attributes you have
7127 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007128 * */
7129 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7130 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7131 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7132 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307133 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007134 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007135 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7136 }
7137 }
7138 }
7139
Jeff Johnson4416a782013-03-25 14:17:50 -07007140 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
7141 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
7142 return -EINVAL;
7143 }
7144
Jeff Johnson295189b2012-06-20 16:38:30 -07007145 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
7146
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007147#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007148 if (params->ssid != NULL)
7149 {
7150 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
7151 pConfig->SSIDinfo.ssid.length = params->ssid_len;
7152 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7153 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7154 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007155#else
7156 if (ssid != NULL)
7157 {
7158 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
7159 pConfig->SSIDinfo.ssid.length = ssid_len;
7160 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7161 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7162 }
7163#endif
7164
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307165 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07007166 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307167
Jeff Johnson295189b2012-06-20 16:38:30 -07007168 /* default value */
7169 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
7170 pConfig->num_accept_mac = 0;
7171 pConfig->num_deny_mac = 0;
7172
7173 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7174 pBeacon->tail, pBeacon->tail_len);
7175
7176 /* pIe for black list is following form:
7177 type : 1 byte
7178 length : 1 byte
7179 OUI : 4 bytes
7180 acl type : 1 byte
7181 no of mac addr in black list: 1 byte
7182 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307183 */
7184 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007185 {
7186 pConfig->SapMacaddr_acl = pIe[6];
7187 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007188 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007189 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307190 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
7191 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007192 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7193 for (i = 0; i < pConfig->num_deny_mac; i++)
7194 {
7195 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7196 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307197 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007198 }
7199 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7200 pBeacon->tail, pBeacon->tail_len);
7201
7202 /* pIe for white list is following form:
7203 type : 1 byte
7204 length : 1 byte
7205 OUI : 4 bytes
7206 acl type : 1 byte
7207 no of mac addr in white list: 1 byte
7208 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307209 */
7210 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007211 {
7212 pConfig->SapMacaddr_acl = pIe[6];
7213 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007214 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007215 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307216 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
7217 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007218 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7219 for (i = 0; i < pConfig->num_accept_mac; i++)
7220 {
7221 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7222 acl_entry++;
7223 }
7224 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307225
Jeff Johnson295189b2012-06-20 16:38:30 -07007226 wlan_hdd_set_sapHwmode(pHostapdAdapter);
7227
Jeff Johnsone7245742012-09-05 17:12:55 -07007228#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007229 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307230 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
7231 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05307232 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
7233 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007234 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
7235 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307236 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
7237 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07007238 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307239 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007240 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307241 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007242
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307243 /* If ACS disable and selected channel <= 14
7244 * OR
7245 * ACS enabled and ACS operating band is choosen as 2.4
7246 * AND
7247 * VHT in 2.4G Disabled
7248 * THEN
7249 * Fallback to 11N mode
7250 */
7251 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
7252 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05307253 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307254 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007255 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307256 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
7257 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007258 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
7259 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007260 }
7261#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307262
Jeff Johnson295189b2012-06-20 16:38:30 -07007263 // ht_capab is not what the name conveys,this is used for protection bitmap
7264 pConfig->ht_capab =
7265 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
7266
7267 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
7268 {
7269 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
7270 return -EINVAL;
7271 }
7272
7273 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307274 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07007275 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
7276 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307277 pConfig->obssProtEnabled =
7278 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07007279
Chet Lanctot8cecea22014-02-11 19:09:36 -08007280#ifdef WLAN_FEATURE_11W
7281 pConfig->mfpCapable = MFPCapable;
7282 pConfig->mfpRequired = MFPRequired;
7283 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
7284 pConfig->mfpCapable, pConfig->mfpRequired);
7285#endif
7286
Arif Hussain6d2a3322013-11-17 19:50:10 -08007287 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07007288 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007289 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
7290 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
7291 (int)pConfig->channel);
7292 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
7293 pConfig->SapHw_mode, pConfig->privacy,
7294 pConfig->authType);
7295 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
7296 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
7297 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
7298 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07007299
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307300 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007301 {
7302 //Bss already started. just return.
7303 //TODO Probably it should update some beacon params.
7304 hddLog( LOGE, "Bss Already started...Ignore the request");
7305 EXIT();
7306 return 0;
7307 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307308
Agarwal Ashish51325b52014-06-16 16:50:49 +05307309 if (vos_max_concurrent_connections_reached()) {
7310 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7311 return -EINVAL;
7312 }
7313
Jeff Johnson295189b2012-06-20 16:38:30 -07007314 pConfig->persona = pHostapdAdapter->device_mode;
7315
Peng Xu2446a892014-09-05 17:21:18 +05307316 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
7317 if ( NULL != psmeConfig)
7318 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307319 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05307320 sme_GetConfigParam(hHal, psmeConfig);
7321 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307322#ifdef WLAN_FEATURE_AP_HT40_24G
7323 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
7324 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
7325 && pHddCtx->cfg_ini->apHT40_24GEnabled)
7326 {
7327 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
7328 sme_UpdateConfig (hHal, psmeConfig);
7329 }
7330#endif
Peng Xu2446a892014-09-05 17:21:18 +05307331 vos_mem_free(psmeConfig);
7332 }
Peng Xuafc34e32014-09-25 13:23:55 +05307333 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05307334
Jeff Johnson295189b2012-06-20 16:38:30 -07007335 pSapEventCallback = hdd_hostapd_SAPEventCB;
7336 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
7337 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
7338 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007339 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007340 return -EINVAL;
7341 }
7342
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307343 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07007344 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
7345
7346 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307347
Jeff Johnson295189b2012-06-20 16:38:30 -07007348 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307349 {
7350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007351 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07007352 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007353 VOS_ASSERT(0);
7354 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307355
Jeff Johnson295189b2012-06-20 16:38:30 -07007356 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05307357 /* Initialize WMM configuation */
7358 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307359 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007360
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007361#ifdef WLAN_FEATURE_P2P_DEBUG
7362 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
7363 {
7364 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
7365 {
7366 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7367 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007368 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007369 }
7370 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
7371 {
7372 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7373 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007374 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007375 }
7376 }
7377#endif
7378
Jeff Johnson295189b2012-06-20 16:38:30 -07007379 pHostapdState->bCommit = TRUE;
7380 EXIT();
7381
7382 return 0;
7383}
7384
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007385#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307386static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307387 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007388 struct beacon_parameters *params)
7389{
7390 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307391 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307392 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007393
7394 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307395
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307396 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7397 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
7398 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307399 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
7400 hdd_device_modetoString(pAdapter->device_mode),
7401 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007402
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307403 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7404 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307405 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007406 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307407 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007408 }
7409
Agarwal Ashish51325b52014-06-16 16:50:49 +05307410 if (vos_max_concurrent_connections_reached()) {
7411 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7412 return -EINVAL;
7413 }
7414
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307415 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007416 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007417 )
7418 {
7419 beacon_data_t *old,*new;
7420
7421 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307422
Jeff Johnson295189b2012-06-20 16:38:30 -07007423 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307424 {
7425 hddLog(VOS_TRACE_LEVEL_WARN,
7426 FL("already beacon info added to session(%d)"),
7427 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007428 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307429 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007430
7431 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7432
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307433 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07007434 {
7435 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007436 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007437 return -EINVAL;
7438 }
7439
7440 pAdapter->sessionCtx.ap.beacon = new;
7441
7442 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7443 }
7444
7445 EXIT();
7446 return status;
7447}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307448
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307449static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
7450 struct net_device *dev,
7451 struct beacon_parameters *params)
7452{
7453 int ret;
7454
7455 vos_ssr_protect(__func__);
7456 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
7457 vos_ssr_unprotect(__func__);
7458
7459 return ret;
7460}
7461
7462static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007463 struct net_device *dev,
7464 struct beacon_parameters *params)
7465{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307466 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307467 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7468 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307469 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007470
7471 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307472
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307473 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7474 TRACE_CODE_HDD_CFG80211_SET_BEACON,
7475 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
7476 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7477 __func__, hdd_device_modetoString(pAdapter->device_mode),
7478 pAdapter->device_mode);
7479
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307480 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7481 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307482 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007483 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307484 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007485 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307486
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307487 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007488 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307489 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 {
7491 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307492
Jeff Johnson295189b2012-06-20 16:38:30 -07007493 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307494
Jeff Johnson295189b2012-06-20 16:38:30 -07007495 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307496 {
7497 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7498 FL("session(%d) old and new heads points to NULL"),
7499 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007500 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307501 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007502
7503 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7504
7505 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307506 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007507 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007508 return -EINVAL;
7509 }
7510
7511 pAdapter->sessionCtx.ap.beacon = new;
7512
7513 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7514 }
7515
7516 EXIT();
7517 return status;
7518}
7519
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307520static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
7521 struct net_device *dev,
7522 struct beacon_parameters *params)
7523{
7524 int ret;
7525
7526 vos_ssr_protect(__func__);
7527 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
7528 vos_ssr_unprotect(__func__);
7529
7530 return ret;
7531}
7532
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007533#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7534
7535#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307536static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007537 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007538#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307539static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007540 struct net_device *dev)
7541#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007542{
7543 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07007544 hdd_context_t *pHddCtx = NULL;
7545 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307546 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307547 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007548
7549 ENTER();
7550
7551 if (NULL == pAdapter)
7552 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307553 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007554 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007555 return -ENODEV;
7556 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007557
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307558 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7559 TRACE_CODE_HDD_CFG80211_STOP_AP,
7560 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307561 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7562 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307563 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007564 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307565 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07007566 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007567
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007568 pScanInfo = &pHddCtx->scan_info;
7569
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307570 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7571 __func__, hdd_device_modetoString(pAdapter->device_mode),
7572 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007573
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307574 ret = wlan_hdd_scan_abort(pAdapter);
7575
Girish Gowli4bf7a632014-06-12 13:42:11 +05307576 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07007577 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307578 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7579 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307580
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307581 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07007582 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307583 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7584 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08007585
Jeff Johnsone7245742012-09-05 17:12:55 -07007586 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307587 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07007588 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307589 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07007590 }
7591
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05307592 /* Delete all associated STAs before stopping AP/P2P GO */
7593 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05307594 hdd_hostapd_stop(dev);
7595
Jeff Johnson295189b2012-06-20 16:38:30 -07007596 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007597 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007598 )
7599 {
7600 beacon_data_t *old;
7601
7602 old = pAdapter->sessionCtx.ap.beacon;
7603
7604 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307605 {
7606 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7607 FL("session(%d) beacon data points to NULL"),
7608 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007609 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307610 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007611
Jeff Johnson295189b2012-06-20 16:38:30 -07007612 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007613
7614 mutex_lock(&pHddCtx->sap_lock);
7615 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7616 {
Jeff Johnson4416a782013-03-25 14:17:50 -07007617 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007618 {
7619 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7620
7621 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
7622
7623 if (!VOS_IS_STATUS_SUCCESS(status))
7624 {
7625 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007626 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007627 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307628 }
7629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307631 /* BSS stopped, clear the active sessions for this device mode */
7632 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007633 }
7634 mutex_unlock(&pHddCtx->sap_lock);
7635
7636 if(status != VOS_STATUS_SUCCESS)
7637 {
7638 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007639 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007640 return -EINVAL;
7641 }
7642
Jeff Johnson4416a782013-03-25 14:17:50 -07007643 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007644 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
7645 ==eHAL_STATUS_FAILURE)
7646 {
7647 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007648 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007649 }
7650
Jeff Johnson4416a782013-03-25 14:17:50 -07007651 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007652 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7653 eANI_BOOLEAN_FALSE) )
7654 {
7655 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007656 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007657 }
7658
7659 // Reset WNI_CFG_PROBE_RSP Flags
7660 wlan_hdd_reset_prob_rspies(pAdapter);
7661
7662 pAdapter->sessionCtx.ap.beacon = NULL;
7663 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007664#ifdef WLAN_FEATURE_P2P_DEBUG
7665 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
7666 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
7667 {
7668 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
7669 "GO got removed");
7670 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
7671 }
7672#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007673 }
7674 EXIT();
7675 return status;
7676}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007677
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307678#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7679static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
7680 struct net_device *dev)
7681{
7682 int ret;
7683
7684 vos_ssr_protect(__func__);
7685 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
7686 vos_ssr_unprotect(__func__);
7687
7688 return ret;
7689}
7690#else
7691static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
7692 struct net_device *dev)
7693{
7694 int ret;
7695
7696 vos_ssr_protect(__func__);
7697 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
7698 vos_ssr_unprotect(__func__);
7699
7700 return ret;
7701}
7702#endif
7703
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007704#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
7705
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307706static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307707 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007708 struct cfg80211_ap_settings *params)
7709{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307710 hdd_adapter_t *pAdapter;
7711 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307712 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007713
7714 ENTER();
7715
Girish Gowlib143d7a2015-02-18 19:39:55 +05307716 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007717 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307718 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05307719 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307720 return -ENODEV;
7721 }
7722
7723 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7724 if (NULL == pAdapter)
7725 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307726 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307727 "%s: HDD adapter is Null", __func__);
7728 return -ENODEV;
7729 }
7730
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307731 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7732 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
7733 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307734 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
7735 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307736 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307737 "%s: HDD adapter magic is invalid", __func__);
7738 return -ENODEV;
7739 }
7740
7741 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307742 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307743 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307744 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307745 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307746 }
7747
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307748 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
7749 __func__, hdd_device_modetoString(pAdapter->device_mode),
7750 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307751
7752 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007753 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007754 )
7755 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307756 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007757
7758 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307759
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007760 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307761 {
7762 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7763 FL("already beacon info added to session(%d)"),
7764 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007765 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307766 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007767
Girish Gowlib143d7a2015-02-18 19:39:55 +05307768#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7769 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7770 &new,
7771 &params->beacon);
7772#else
7773 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7774 &new,
7775 &params->beacon,
7776 params->dtim_period);
7777#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007778
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307779 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007780 {
7781 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307782 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007783 return -EINVAL;
7784 }
7785 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08007786#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07007787 wlan_hdd_cfg80211_set_channel(wiphy, dev,
7788#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
7789 params->channel, params->channel_type);
7790#else
7791 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
7792#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08007793#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007794 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307795 params->ssid_len, params->hidden_ssid,
7796 params->auth_type);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007797 }
7798
7799 EXIT();
7800 return status;
7801}
7802
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307803static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
7804 struct net_device *dev,
7805 struct cfg80211_ap_settings *params)
7806{
7807 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007808
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307809 vos_ssr_protect(__func__);
7810 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
7811 vos_ssr_unprotect(__func__);
7812
7813 return ret;
7814}
7815
7816static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007817 struct net_device *dev,
7818 struct cfg80211_beacon_data *params)
7819{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307820 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307821 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307822 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007823
7824 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307825
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307826 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7827 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
7828 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007829 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007830 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307831
7832 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7833 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307834 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007835 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307836 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007837 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007838
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307839 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007840 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307841 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007842 {
7843 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307844
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007845 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307846
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007847 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307848 {
7849 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7850 FL("session(%d) beacon data points to NULL"),
7851 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007852 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307853 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007854
7855 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
7856
7857 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307858 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007859 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007860 return -EINVAL;
7861 }
7862
7863 pAdapter->sessionCtx.ap.beacon = new;
7864
Kanchanapally, Vidyullathaacc59252015-05-20 16:49:07 +05307865 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0,
7866 pAdapter->sessionCtx.ap.sapConfig.authType);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007867 }
7868
7869 EXIT();
7870 return status;
7871}
7872
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307873static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
7874 struct net_device *dev,
7875 struct cfg80211_beacon_data *params)
7876{
7877 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007878
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307879 vos_ssr_protect(__func__);
7880 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
7881 vos_ssr_unprotect(__func__);
7882
7883 return ret;
7884}
7885
7886#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007887
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307888static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007889 struct net_device *dev,
7890 struct bss_parameters *params)
7891{
7892 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307893 hdd_context_t *pHddCtx;
7894 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007895
7896 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307897
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307898 if (NULL == pAdapter)
7899 {
7900 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7901 "%s: HDD adapter is Null", __func__);
7902 return -ENODEV;
7903 }
7904 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307905 ret = wlan_hdd_validate_context(pHddCtx);
7906 if (0 != ret)
7907 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307908 return ret;
7909 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307910 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7911 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
7912 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307913 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7914 __func__, hdd_device_modetoString(pAdapter->device_mode),
7915 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007916
7917 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007918 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307919 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007920 {
7921 /* ap_isolate == -1 means that in change bss, upper layer doesn't
7922 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307923 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07007924 {
7925 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307926 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007927 }
7928
7929 EXIT();
7930 return 0;
7931}
7932
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307933static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
7934 struct net_device *dev,
7935 struct bss_parameters *params)
7936{
7937 int ret;
7938
7939 vos_ssr_protect(__func__);
7940 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
7941 vos_ssr_unprotect(__func__);
7942
7943 return ret;
7944}
Kiet Lam10841362013-11-01 11:36:50 +05307945/* FUNCTION: wlan_hdd_change_country_code_cd
7946* to wait for contry code completion
7947*/
7948void* wlan_hdd_change_country_code_cb(void *pAdapter)
7949{
7950 hdd_adapter_t *call_back_pAdapter = pAdapter;
7951 complete(&call_back_pAdapter->change_country_code);
7952 return NULL;
7953}
7954
Jeff Johnson295189b2012-06-20 16:38:30 -07007955/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307956 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07007957 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
7958 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307959int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007960 struct net_device *ndev,
7961 enum nl80211_iftype type,
7962 u32 *flags,
7963 struct vif_params *params
7964 )
7965{
7966 struct wireless_dev *wdev;
7967 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007968 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07007969 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007970 tCsrRoamProfile *pRoamProfile = NULL;
7971 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307972 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007973 eMib_dot11DesiredBssType connectedBssType;
7974 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307975 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007976
7977 ENTER();
7978
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307979 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007980 {
7981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7982 "%s: Adapter context is null", __func__);
7983 return VOS_STATUS_E_FAILURE;
7984 }
7985
7986 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7987 if (!pHddCtx)
7988 {
7989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7990 "%s: HDD context is null", __func__);
7991 return VOS_STATUS_E_FAILURE;
7992 }
7993
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307994 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7995 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
7996 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307997 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307998 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007999 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308000 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008001 }
8002
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308003 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8004 __func__, hdd_device_modetoString(pAdapter->device_mode),
8005 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008006
Agarwal Ashish51325b52014-06-16 16:50:49 +05308007 if (vos_max_concurrent_connections_reached()) {
8008 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
8009 return -EINVAL;
8010 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308011 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07008012 wdev = ndev->ieee80211_ptr;
8013
8014#ifdef WLAN_BTAMP_FEATURE
8015 if((NL80211_IFTYPE_P2P_CLIENT == type)||
8016 (NL80211_IFTYPE_ADHOC == type)||
8017 (NL80211_IFTYPE_AP == type)||
8018 (NL80211_IFTYPE_P2P_GO == type))
8019 {
8020 pHddCtx->isAmpAllowed = VOS_FALSE;
8021 // stop AMP traffic
8022 status = WLANBAP_StopAmp();
8023 if(VOS_STATUS_SUCCESS != status )
8024 {
8025 pHddCtx->isAmpAllowed = VOS_TRUE;
8026 hddLog(VOS_TRACE_LEVEL_FATAL,
8027 "%s: Failed to stop AMP", __func__);
8028 return -EINVAL;
8029 }
8030 }
8031#endif //WLAN_BTAMP_FEATURE
8032 /* Reset the current device mode bit mask*/
8033 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
8034
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05308035 /* Notify Mode change in case of concurrency.
8036 * Below function invokes TDLS teardown Functionality Since TDLS is
8037 * not Supported in case of concurrency i.e Once P2P session
8038 * is detected disable offchannel and teardown TDLS links
8039 */
8040 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
8041
Jeff Johnson295189b2012-06-20 16:38:30 -07008042 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008043 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07008044 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07008045 )
8046 {
8047 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008048 if (!pWextState)
8049 {
8050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8051 "%s: pWextState is null", __func__);
8052 return VOS_STATUS_E_FAILURE;
8053 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008054 pRoamProfile = &pWextState->roamProfile;
8055 LastBSSType = pRoamProfile->BSSType;
8056
8057 switch (type)
8058 {
8059 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008060 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008061 hddLog(VOS_TRACE_LEVEL_INFO,
8062 "%s: setting interface Type to INFRASTRUCTURE", __func__);
8063 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07008064#ifdef WLAN_FEATURE_11AC
8065 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
8066 {
8067 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
8068 }
8069#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308070 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07008071 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008072 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008073 //Check for sub-string p2p to confirm its a p2p interface
8074 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308075 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008076 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8077 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8078 }
8079 else
8080 {
8081 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008082 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008083 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008084 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05308085
Jeff Johnson295189b2012-06-20 16:38:30 -07008086 case NL80211_IFTYPE_ADHOC:
8087 hddLog(VOS_TRACE_LEVEL_INFO,
8088 "%s: setting interface Type to ADHOC", __func__);
8089 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
8090 pRoamProfile->phyMode =
8091 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07008092 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008093 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +05308094 hdd_set_ibss_ops( pAdapter );
8095 hdd_ibss_init_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008096 break;
8097
8098 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008099 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008100 {
8101 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8102 "%s: setting interface Type to %s", __func__,
8103 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
8104
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008105 //Cancel any remain on channel for GO mode
8106 if (NL80211_IFTYPE_P2P_GO == type)
8107 {
8108 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
8109 }
Mohit Khanna0f232092012-09-11 14:46:08 -07008110 if (NL80211_IFTYPE_AP == type)
8111 {
8112 /* As Loading WLAN Driver one interface being created for p2p device
8113 * address. This will take one HW STA and the max number of clients
8114 * that can connect to softAP will be reduced by one. so while changing
8115 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
8116 * interface as it is not required in SoftAP mode.
8117 */
8118
8119 // Get P2P Adapter
8120 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
8121
8122 if (pP2pAdapter)
8123 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05308124 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +05308125 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07008126 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
8127 }
8128 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05308129 //Disable IMPS & BMPS for SAP/GO
8130 if(VOS_STATUS_E_FAILURE ==
8131 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
8132 {
8133 //Fail to Exit BMPS
8134 VOS_ASSERT(0);
8135 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05308136
8137 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
8138
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308139#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07008140
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308141 /* A Mutex Lock is introduced while changing the mode to
8142 * protect the concurrent access for the Adapters by TDLS
8143 * module.
8144 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308145 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308146#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008147 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +05308148 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008149 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07008150 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8151 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308152#ifdef FEATURE_WLAN_TDLS
8153 mutex_unlock(&pHddCtx->tdls_lock);
8154#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008155 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
8156 (pConfig->apRandomBssidEnabled))
8157 {
8158 /* To meet Android requirements create a randomized
8159 MAC address of the form 02:1A:11:Fx:xx:xx */
8160 get_random_bytes(&ndev->dev_addr[3], 3);
8161 ndev->dev_addr[0] = 0x02;
8162 ndev->dev_addr[1] = 0x1A;
8163 ndev->dev_addr[2] = 0x11;
8164 ndev->dev_addr[3] |= 0xF0;
8165 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
8166 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08008167 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
8168 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008169 }
8170
Jeff Johnson295189b2012-06-20 16:38:30 -07008171 hdd_set_ap_ops( pAdapter->dev );
8172
Kiet Lam10841362013-11-01 11:36:50 +05308173 /* This is for only SAP mode where users can
8174 * control country through ini.
8175 * P2P GO follows station country code
8176 * acquired during the STA scanning. */
8177 if((NL80211_IFTYPE_AP == type) &&
8178 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
8179 {
8180 int status = 0;
8181 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
8182 "%s: setting country code from INI ", __func__);
8183 init_completion(&pAdapter->change_country_code);
8184 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
8185 (void *)(tSmeChangeCountryCallback)
8186 wlan_hdd_change_country_code_cb,
8187 pConfig->apCntryCode, pAdapter,
8188 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05308189 eSIR_FALSE,
8190 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05308191 if (eHAL_STATUS_SUCCESS == status)
8192 {
8193 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308194 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05308195 &pAdapter->change_country_code,
8196 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308197 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05308198 {
8199 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308200 FL("SME Timed out while setting country code %ld"),
8201 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08008202
8203 if (pHddCtx->isLogpInProgress)
8204 {
8205 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8206 "%s: LOGP in Progress. Ignore!!!", __func__);
8207 return -EAGAIN;
8208 }
Kiet Lam10841362013-11-01 11:36:50 +05308209 }
8210 }
8211 else
8212 {
8213 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008214 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05308215 return -EINVAL;
8216 }
8217 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008218 status = hdd_init_ap_mode(pAdapter);
8219 if(status != VOS_STATUS_SUCCESS)
8220 {
8221 hddLog(VOS_TRACE_LEVEL_FATAL,
8222 "%s: Error initializing the ap mode", __func__);
8223 return -EINVAL;
8224 }
8225 hdd_set_conparam(1);
8226
Jeff Johnson295189b2012-06-20 16:38:30 -07008227 /*interface type changed update in wiphy structure*/
8228 if(wdev)
8229 {
8230 wdev->iftype = type;
8231 pHddCtx->change_iface = type;
8232 }
8233 else
8234 {
8235 hddLog(VOS_TRACE_LEVEL_ERROR,
8236 "%s: ERROR !!!! Wireless dev is NULL", __func__);
8237 return -EINVAL;
8238 }
8239 goto done;
8240 }
8241
8242 default:
8243 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8244 __func__);
8245 return -EOPNOTSUPP;
8246 }
8247 }
8248 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008249 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07008250 )
8251 {
8252 switch(type)
8253 {
8254 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008255 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008256 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05308257
8258 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308259#ifdef FEATURE_WLAN_TDLS
8260
8261 /* A Mutex Lock is introduced while changing the mode to
8262 * protect the concurrent access for the Adapters by TDLS
8263 * module.
8264 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308265 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308266#endif
c_hpothu002231a2015-02-05 14:58:51 +05308267 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008268 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008269 //Check for sub-string p2p to confirm its a p2p interface
8270 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008271 {
8272 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8273 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8274 }
8275 else
8276 {
8277 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008278 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008279 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008280 hdd_set_conparam(0);
8281 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008282 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
8283 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308284#ifdef FEATURE_WLAN_TDLS
8285 mutex_unlock(&pHddCtx->tdls_lock);
8286#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05308287 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008288 if( VOS_STATUS_SUCCESS != status )
8289 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07008290 /* In case of JB, for P2P-GO, only change interface will be called,
8291 * This is the right place to enable back bmps_imps()
8292 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308293 if (pHddCtx->hdd_wlan_suspended)
8294 {
8295 hdd_set_pwrparams(pHddCtx);
8296 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008297 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008298 goto done;
8299 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008300 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008301 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008302 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8303 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008304 goto done;
8305 default:
8306 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8307 __func__);
8308 return -EOPNOTSUPP;
8309
8310 }
8311
8312 }
8313 else
8314 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308315 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
8316 __func__, hdd_device_modetoString(pAdapter->device_mode),
8317 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008318 return -EOPNOTSUPP;
8319 }
8320
8321
8322 if(pRoamProfile)
8323 {
8324 if ( LastBSSType != pRoamProfile->BSSType )
8325 {
8326 /*interface type changed update in wiphy structure*/
8327 wdev->iftype = type;
8328
8329 /*the BSS mode changed, We need to issue disconnect
8330 if connected or in IBSS disconnect state*/
8331 if ( hdd_connGetConnectedBssType(
8332 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
8333 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
8334 {
8335 /*need to issue a disconnect to CSR.*/
8336 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8337 if( eHAL_STATUS_SUCCESS ==
8338 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8339 pAdapter->sessionId,
8340 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
8341 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308342 ret = wait_for_completion_interruptible_timeout(
8343 &pAdapter->disconnect_comp_var,
8344 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8345 if (ret <= 0)
8346 {
8347 hddLog(VOS_TRACE_LEVEL_ERROR,
8348 FL("wait on disconnect_comp_var failed %ld"), ret);
8349 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008350 }
8351 }
8352 }
8353 }
8354
8355done:
8356 /*set bitmask based on updated value*/
8357 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07008358
8359 /* Only STA mode support TM now
8360 * all other mode, TM feature should be disabled */
8361 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
8362 (~VOS_STA & pHddCtx->concurrency_mode) )
8363 {
8364 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
8365 }
8366
Jeff Johnson295189b2012-06-20 16:38:30 -07008367#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308368 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05308369 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07008370 {
8371 //we are ok to do AMP
8372 pHddCtx->isAmpAllowed = VOS_TRUE;
8373 }
8374#endif //WLAN_BTAMP_FEATURE
8375 EXIT();
8376 return 0;
8377}
8378
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308379/*
8380 * FUNCTION: wlan_hdd_cfg80211_change_iface
8381 * wrapper function to protect the actual implementation from SSR.
8382 */
8383int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
8384 struct net_device *ndev,
8385 enum nl80211_iftype type,
8386 u32 *flags,
8387 struct vif_params *params
8388 )
8389{
8390 int ret;
8391
8392 vos_ssr_protect(__func__);
8393 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
8394 vos_ssr_unprotect(__func__);
8395
8396 return ret;
8397}
8398
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008399#ifdef FEATURE_WLAN_TDLS
8400static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
8401 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
8402{
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008403 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008404 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308405 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308406 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308407 hdd_adapter_t *pAdapter;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008408
8409 ENTER();
8410
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308411 if (!dev) {
8412 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
8413 return -EINVAL;
8414 }
8415
8416 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8417 if (!pAdapter) {
8418 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
8419 return -EINVAL;
8420 }
8421
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308422 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008423 {
8424 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8425 "Invalid arguments");
8426 return -EINVAL;
8427 }
Hoonki Lee27511902013-03-14 18:19:06 -07008428
8429 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
8430 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
8431 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308432 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -07008433 "%s: TDLS mode is disabled OR not enabled in FW."
8434 MAC_ADDRESS_STR " Request declined.",
8435 __func__, MAC_ADDR_ARRAY(mac));
8436 return -ENOTSUPP;
8437 }
8438
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008439 if (pHddCtx->isLogpInProgress)
8440 {
8441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8442 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05308443 wlan_hdd_tdls_set_link_status(pAdapter,
8444 mac,
8445 eTDLS_LINK_IDLE,
8446 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008447 return -EBUSY;
8448 }
8449
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308450 mutex_lock(&pHddCtx->tdls_lock);
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05308451 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008452
8453 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308454 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008455 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
8456 __func__, MAC_ADDR_ARRAY(mac), update);
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308457 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008458 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008459 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +05308460 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008461
8462 /* in add station, we accept existing valid staId if there is */
8463 if ((0 == update) &&
8464 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
8465 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008466 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308467 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008468 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008469 " link_status %d. staId %d. add station ignored.",
8470 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
8471 return 0;
8472 }
8473 /* in change station, we accept only when staId is valid */
8474 if ((1 == update) &&
8475 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
8476 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
8477 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308478 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008479 "%s: " MAC_ADDRESS_STR
8480 " link status %d. staId %d. change station %s.",
8481 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
8482 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
8483 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008484 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008485
8486 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05308487 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008488 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008489 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8490 "%s: " MAC_ADDRESS_STR
8491 " TDLS setup is ongoing. Request declined.",
8492 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07008493 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008494 }
8495
8496 /* first to check if we reached to maximum supported TDLS peer.
8497 TODO: for now, return -EPERM looks working fine,
8498 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308499 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
8500 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008501 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008502 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8503 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308504 " TDLS Max peer already connected. Request declined."
8505 " Num of peers (%d), Max allowed (%d).",
8506 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
8507 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008508 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008509 }
8510 else
8511 {
8512 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308513 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008514 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008515 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008516 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8517 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
8518 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008519 return -EPERM;
8520 }
8521 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008522 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05308523 wlan_hdd_tdls_set_link_status(pAdapter,
8524 mac,
8525 eTDLS_LINK_CONNECTING,
8526 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008527
Jeff Johnsond75fe012013-04-06 10:53:06 -07008528 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308529 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008530 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008532 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008533 if(StaParams->htcap_present)
8534 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008536 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008538 "ht_capa->extended_capabilities: %0x",
8539 StaParams->HTCap.extendedHtCapInfo);
8540 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008542 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008544 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008545 if(StaParams->vhtcap_present)
8546 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008548 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
8549 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
8550 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
8551 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008552 {
8553 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008554 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008555 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008557 "[%d]: %x ", i, StaParams->supported_rates[i]);
8558 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07008559 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308560 else if ((1 == update) && (NULL == StaParams))
8561 {
8562 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8563 "%s : update is true, but staParams is NULL. Error!", __func__);
8564 return -EPERM;
8565 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008566
8567 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
8568
8569 if (!update)
8570 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308571 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008572 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308573 if (ret != eHAL_STATUS_SUCCESS) {
8574 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to add TDLS peer STA"));
8575 return -EPERM;
8576 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008577 }
8578 else
8579 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308580 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008581 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308582 if (ret != eHAL_STATUS_SUCCESS) {
8583 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
8584 return -EPERM;
8585 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008586 }
8587
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308588 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008589 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
8590
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308591 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008592 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008593 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308594 "%s: timeout waiting for tdls add station indication %ld",
8595 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008596 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008597 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308598
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008599 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
8600 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008602 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008603 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008604 }
8605
8606 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008607
8608error:
Atul Mittal115287b2014-07-08 13:26:33 +05308609 wlan_hdd_tdls_set_link_status(pAdapter,
8610 mac,
8611 eTDLS_LINK_IDLE,
8612 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008613 return -EPERM;
8614
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008615}
8616#endif
8617
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308618static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008619 struct net_device *dev,
8620 u8 *mac,
8621 struct station_parameters *params)
8622{
8623 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308624 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308625 hdd_context_t *pHddCtx;
8626 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008627 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308628 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008629#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008630 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008631 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308632 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008633#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008634
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308635 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308636
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308637 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308638 if ((NULL == pAdapter))
8639 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308641 "invalid adapter ");
8642 return -EINVAL;
8643 }
8644
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308645 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8646 TRACE_CODE_HDD_CHANGE_STATION,
8647 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05308648 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308649
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308650 ret = wlan_hdd_validate_context(pHddCtx);
8651 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +05308652 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308653 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308654 }
8655
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308656 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8657
8658 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008659 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8661 "invalid HDD station context");
8662 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008663 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008664 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
8665
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008666 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
8667 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07008668 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008669 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07008670 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308671 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008672 WLANTL_STA_AUTHENTICATED);
8673
Gopichand Nakkala29149562013-05-10 21:43:41 +05308674 if (status != VOS_STATUS_SUCCESS)
8675 {
8676 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8677 "%s: Not able to change TL state to AUTHENTICATED", __func__);
8678 return -EINVAL;
8679 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008680 }
8681 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07008682 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
8683 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308684#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008685 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
8686 StaParams.capability = params->capability;
8687 StaParams.uapsd_queues = params->uapsd_queues;
8688 StaParams.max_sp = params->max_sp;
8689
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308690 /* Convert (first channel , number of channels) tuple to
8691 * the total list of channels. This goes with the assumption
8692 * that if the first channel is < 14, then the next channels
8693 * are an incremental of 1 else an incremental of 4 till the number
8694 * of channels.
8695 */
8696 if (0 != params->supported_channels_len) {
8697 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
8698 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
8699 {
8700 int wifi_chan_index;
8701 StaParams.supported_channels[j] = params->supported_channels[i];
8702 wifi_chan_index =
8703 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
8704 no_of_channels = params->supported_channels[i+1];
8705 for(k=1; k <= no_of_channels; k++)
8706 {
8707 StaParams.supported_channels[j+1] =
8708 StaParams.supported_channels[j] + wifi_chan_index;
8709 j+=1;
8710 }
8711 }
8712 StaParams.supported_channels_len = j;
8713 }
8714 vos_mem_copy(StaParams.supported_oper_classes,
8715 params->supported_oper_classes,
8716 params->supported_oper_classes_len);
8717 StaParams.supported_oper_classes_len =
8718 params->supported_oper_classes_len;
8719
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008720 if (0 != params->ext_capab_len)
8721 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
8722 sizeof(StaParams.extn_capability));
8723
8724 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008725 {
8726 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008727 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008728 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008729
8730 StaParams.supported_rates_len = params->supported_rates_len;
8731
8732 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
8733 * The supported_rates array , for all the structures propogating till Add Sta
8734 * to the firmware has to be modified , if the supplicant (ieee80211) is
8735 * modified to send more rates.
8736 */
8737
8738 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
8739 */
8740 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
8741 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
8742
8743 if (0 != StaParams.supported_rates_len) {
8744 int i = 0;
8745 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
8746 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008747 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008748 "Supported Rates with Length %d", StaParams.supported_rates_len);
8749 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008750 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008751 "[%d]: %0x", i, StaParams.supported_rates[i]);
8752 }
8753
8754 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008755 {
8756 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008757 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008758 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008759
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008760 if (0 != params->ext_capab_len ) {
8761 /*Define A Macro : TODO Sunil*/
8762 if ((1<<4) & StaParams.extn_capability[3]) {
8763 isBufSta = 1;
8764 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308765 /* TDLS Channel Switching Support */
8766 if ((1<<6) & StaParams.extn_capability[3]) {
8767 isOffChannelSupported = 1;
8768 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008769 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308770 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
8771 &StaParams, isBufSta,
8772 isOffChannelSupported);
8773
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308774 if (VOS_STATUS_SUCCESS != status) {
8775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8776 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
8777 return -EINVAL;
8778 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008779 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
8780
8781 if (VOS_STATUS_SUCCESS != status) {
8782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8783 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
8784 return -EINVAL;
8785 }
8786 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008787#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05308788 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008789 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008790 return status;
8791}
8792
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308793static int wlan_hdd_change_station(struct wiphy *wiphy,
8794 struct net_device *dev,
8795 u8 *mac,
8796 struct station_parameters *params)
8797{
8798 int ret;
8799
8800 vos_ssr_protect(__func__);
8801 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
8802 vos_ssr_unprotect(__func__);
8803
8804 return ret;
8805}
8806
Jeff Johnson295189b2012-06-20 16:38:30 -07008807/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308808 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008809 * This function is used to initialize the key information
8810 */
8811#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308812static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008813 struct net_device *ndev,
8814 u8 key_index, bool pairwise,
8815 const u8 *mac_addr,
8816 struct key_params *params
8817 )
8818#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308819static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008820 struct net_device *ndev,
8821 u8 key_index, const u8 *mac_addr,
8822 struct key_params *params
8823 )
8824#endif
8825{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008826 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07008827 tCsrRoamSetKey setKey;
8828 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308829 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008830 v_U32_t roamId= 0xFF;
8831 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008832 hdd_hostapd_state_t *pHostapdState;
8833 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008834 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308835 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008836
8837 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308838
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308839 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8840 TRACE_CODE_HDD_CFG80211_ADD_KEY,
8841 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308842 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8843 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308844 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008845 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308846 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008847 }
8848
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308849 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8850 __func__, hdd_device_modetoString(pAdapter->device_mode),
8851 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008852
8853 if (CSR_MAX_NUM_KEY <= key_index)
8854 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008855 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008856 key_index);
8857
8858 return -EINVAL;
8859 }
8860
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008861 if (CSR_MAX_KEY_LEN < params->key_len)
8862 {
8863 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
8864 params->key_len);
8865
8866 return -EINVAL;
8867 }
8868
8869 hddLog(VOS_TRACE_LEVEL_INFO,
8870 "%s: called with key index = %d & key length %d",
8871 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07008872
8873 /*extract key idx, key len and key*/
8874 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8875 setKey.keyId = key_index;
8876 setKey.keyLength = params->key_len;
8877 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
8878
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008879 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07008880 {
8881 case WLAN_CIPHER_SUITE_WEP40:
8882 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
8883 break;
8884
8885 case WLAN_CIPHER_SUITE_WEP104:
8886 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
8887 break;
8888
8889 case WLAN_CIPHER_SUITE_TKIP:
8890 {
8891 u8 *pKey = &setKey.Key[0];
8892 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
8893
8894 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
8895
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008896 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07008897
8898 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008899 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008900 |--------------|----------|----------|
8901 <---16bytes---><--8bytes--><--8bytes-->
8902
8903 */
8904 /*Sme expects the 32 bytes key to be in the below order
8905
8906 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008907 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008908 |--------------|----------|----------|
8909 <---16bytes---><--8bytes--><--8bytes-->
8910 */
8911 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008912 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07008913
8914 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008915 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07008916
8917 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008918 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07008919
8920
8921 break;
8922 }
8923
8924 case WLAN_CIPHER_SUITE_CCMP:
8925 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
8926 break;
8927
8928#ifdef FEATURE_WLAN_WAPI
8929 case WLAN_CIPHER_SUITE_SMS4:
8930 {
8931 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8932 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
8933 params->key, params->key_len);
8934 return 0;
8935 }
8936#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008937
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008938#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008939 case WLAN_CIPHER_SUITE_KRK:
8940 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
8941 break;
8942#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008943
8944#ifdef WLAN_FEATURE_11W
8945 case WLAN_CIPHER_SUITE_AES_CMAC:
8946 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07008947 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07008948#endif
8949
Jeff Johnson295189b2012-06-20 16:38:30 -07008950 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008951 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07008952 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308953 status = -EOPNOTSUPP;
8954 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008955 }
8956
8957 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
8958 __func__, setKey.encType);
8959
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008960 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07008961#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8962 (!pairwise)
8963#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008964 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07008965#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008966 )
8967 {
8968 /* set group key*/
8969 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8970 "%s- %d: setting Broadcast key",
8971 __func__, __LINE__);
8972 setKey.keyDirection = eSIR_RX_ONLY;
8973 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
8974 }
8975 else
8976 {
8977 /* set pairwise key*/
8978 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8979 "%s- %d: setting pairwise key",
8980 __func__, __LINE__);
8981 setKey.keyDirection = eSIR_TX_RX;
8982 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
8983 }
8984 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
8985 {
8986 setKey.keyDirection = eSIR_TX_RX;
8987 /*Set the group key*/
8988 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8989 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008990
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008991 if ( 0 != status )
8992 {
8993 hddLog(VOS_TRACE_LEVEL_ERROR,
8994 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308995 status = -EINVAL;
8996 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008997 }
8998 /*Save the keys here and call sme_RoamSetKey for setting
8999 the PTK after peer joins the IBSS network*/
9000 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
9001 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309002 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009003 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05309004 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
9005 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
9006 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009007 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009008 if( pHostapdState->bssState == BSS_START )
9009 {
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009010 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9011 vos_status = wlan_hdd_check_ula_done(pAdapter);
9012
9013 if ( vos_status != VOS_STATUS_SUCCESS )
9014 {
9015 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9016 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9017 __LINE__, vos_status );
9018
9019 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9020
9021 status = -EINVAL;
9022 goto end;
9023 }
9024
Jeff Johnson295189b2012-06-20 16:38:30 -07009025 status = WLANSAP_SetKeySta( pVosContext, &setKey);
9026
9027 if ( status != eHAL_STATUS_SUCCESS )
9028 {
9029 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9030 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9031 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309032 status = -EINVAL;
9033 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009034 }
9035 }
9036
9037 /* Saving WEP keys */
9038 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
9039 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
9040 {
9041 //Save the wep key in ap context. Issue setkey after the BSS is started.
9042 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9043 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
9044 }
9045 else
9046 {
9047 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009048 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009049 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
9050 }
9051 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009052 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9053 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009054 {
9055 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9056 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9057
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309058#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9059 if (!pairwise)
9060#else
9061 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9062#endif
9063 {
9064 /* set group key*/
9065 if (pHddStaCtx->roam_info.deferKeyComplete)
9066 {
9067 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9068 "%s- %d: Perform Set key Complete",
9069 __func__, __LINE__);
9070 hdd_PerformRoamSetKeyComplete(pAdapter);
9071 }
9072 }
9073
Jeff Johnson295189b2012-06-20 16:38:30 -07009074 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
9075
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08009076 pWextState->roamProfile.Keys.defaultIndex = key_index;
9077
9078
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009079 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009080 params->key, params->key_len);
9081
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309082
Jeff Johnson295189b2012-06-20 16:38:30 -07009083 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9084
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309085 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009086 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309087 __func__, setKey.peerMac[0], setKey.peerMac[1],
9088 setKey.peerMac[2], setKey.peerMac[3],
9089 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009090 setKey.keyDirection);
9091
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009092 vos_status = wlan_hdd_check_ula_done(pAdapter);
Nirav Shah4f765af2015-01-21 19:51:30 +05309093
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009094 if ( vos_status != VOS_STATUS_SUCCESS )
9095 {
9096 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009097 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9098 __LINE__, vos_status );
9099
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009100 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009101
Nirav Shah4b53d4b2015-05-08 05:35:00 -07009102 status = -EINVAL;
9103 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009104
9105 }
9106
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009107#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309108 /* The supplicant may attempt to set the PTK once pre-authentication
9109 is done. Save the key in the UMAC and include it in the ADD BSS
9110 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009111 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309112 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009113 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309114 hddLog(VOS_TRACE_LEVEL_INFO_MED,
9115 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309116 status = 0;
9117 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309118 }
9119 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
9120 {
9121 hddLog(VOS_TRACE_LEVEL_ERROR,
9122 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309123 status = -EINVAL;
9124 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009125 }
9126#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07009127
9128 /* issue set key request to SME*/
9129 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9130 pAdapter->sessionId, &setKey, &roamId );
9131
9132 if ( 0 != status )
9133 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309134 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009135 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
9136 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309137 status = -EINVAL;
9138 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009139 }
9140
9141
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309142 /* in case of IBSS as there was no information available about WEP keys during
9143 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07009144 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309145 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
9146 !( ( IW_AUTH_KEY_MGMT_802_1X
9147 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07009148 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
9149 )
9150 &&
9151 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
9152 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
9153 )
9154 )
9155 {
9156 setKey.keyDirection = eSIR_RX_ONLY;
9157 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9158
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309159 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009160 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309161 __func__, setKey.peerMac[0], setKey.peerMac[1],
9162 setKey.peerMac[2], setKey.peerMac[3],
9163 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009164 setKey.keyDirection);
9165
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309166 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009167 pAdapter->sessionId, &setKey, &roamId );
9168
9169 if ( 0 != status )
9170 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309171 hddLog(VOS_TRACE_LEVEL_ERROR,
9172 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009173 __func__, status);
9174 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309175 status = -EINVAL;
9176 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009177 }
9178 }
9179 }
9180
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309181end:
9182 /* Need to clear any trace of key value in the memory.
9183 * Thus zero out the memory even though it is local
9184 * variable.
9185 */
9186 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309187 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309188 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009189}
9190
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309191#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9192static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9193 struct net_device *ndev,
9194 u8 key_index, bool pairwise,
9195 const u8 *mac_addr,
9196 struct key_params *params
9197 )
9198#else
9199static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9200 struct net_device *ndev,
9201 u8 key_index, const u8 *mac_addr,
9202 struct key_params *params
9203 )
9204#endif
9205{
9206 int ret;
9207 vos_ssr_protect(__func__);
9208#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9209 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
9210 mac_addr, params);
9211#else
9212 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
9213 params);
9214#endif
9215 vos_ssr_unprotect(__func__);
9216
9217 return ret;
9218}
9219
Jeff Johnson295189b2012-06-20 16:38:30 -07009220/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309221 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009222 * This function is used to get the key information
9223 */
9224#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309225static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309226 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309228 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009229 const u8 *mac_addr, void *cookie,
9230 void (*callback)(void *cookie, struct key_params*)
9231 )
9232#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309233static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309234 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009235 struct net_device *ndev,
9236 u8 key_index, const u8 *mac_addr, void *cookie,
9237 void (*callback)(void *cookie, struct key_params*)
9238 )
9239#endif
9240{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309241 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309242 hdd_wext_state_t *pWextState = NULL;
9243 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009244 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309245 hdd_context_t *pHddCtx;
9246 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009247
9248 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309249
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309250 if (NULL == pAdapter)
9251 {
9252 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9253 "%s: HDD adapter is Null", __func__);
9254 return -ENODEV;
9255 }
9256
9257 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9258 ret = wlan_hdd_validate_context(pHddCtx);
9259 if (0 != ret)
9260 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309261 return ret;
9262 }
9263
9264 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9265 pRoamProfile = &(pWextState->roamProfile);
9266
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309267 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9268 __func__, hdd_device_modetoString(pAdapter->device_mode),
9269 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309270
Jeff Johnson295189b2012-06-20 16:38:30 -07009271 memset(&params, 0, sizeof(params));
9272
9273 if (CSR_MAX_NUM_KEY <= key_index)
9274 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309275 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07009276 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009278
9279 switch(pRoamProfile->EncryptionType.encryptionType[0])
9280 {
9281 case eCSR_ENCRYPT_TYPE_NONE:
9282 params.cipher = IW_AUTH_CIPHER_NONE;
9283 break;
9284
9285 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
9286 case eCSR_ENCRYPT_TYPE_WEP40:
9287 params.cipher = WLAN_CIPHER_SUITE_WEP40;
9288 break;
9289
9290 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
9291 case eCSR_ENCRYPT_TYPE_WEP104:
9292 params.cipher = WLAN_CIPHER_SUITE_WEP104;
9293 break;
9294
9295 case eCSR_ENCRYPT_TYPE_TKIP:
9296 params.cipher = WLAN_CIPHER_SUITE_TKIP;
9297 break;
9298
9299 case eCSR_ENCRYPT_TYPE_AES:
9300 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
9301 break;
9302
9303 default:
9304 params.cipher = IW_AUTH_CIPHER_NONE;
9305 break;
9306 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309307
c_hpothuaaf19692014-05-17 17:01:48 +05309308 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9309 TRACE_CODE_HDD_CFG80211_GET_KEY,
9310 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309311
Jeff Johnson295189b2012-06-20 16:38:30 -07009312 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
9313 params.seq_len = 0;
9314 params.seq = NULL;
9315 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
9316 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309317 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009318 return 0;
9319}
9320
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309321#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9322static int wlan_hdd_cfg80211_get_key(
9323 struct wiphy *wiphy,
9324 struct net_device *ndev,
9325 u8 key_index, bool pairwise,
9326 const u8 *mac_addr, void *cookie,
9327 void (*callback)(void *cookie, struct key_params*)
9328 )
9329#else
9330static int wlan_hdd_cfg80211_get_key(
9331 struct wiphy *wiphy,
9332 struct net_device *ndev,
9333 u8 key_index, const u8 *mac_addr, void *cookie,
9334 void (*callback)(void *cookie, struct key_params*)
9335 )
9336#endif
9337{
9338 int ret;
9339
9340 vos_ssr_protect(__func__);
9341#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9342 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
9343 mac_addr, cookie, callback);
9344#else
9345 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
9346 callback);
9347#endif
9348 vos_ssr_unprotect(__func__);
9349
9350 return ret;
9351}
9352
Jeff Johnson295189b2012-06-20 16:38:30 -07009353/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309354 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009355 * This function is used to delete the key information
9356 */
9357#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309358static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009359 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309360 u8 key_index,
9361 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009362 const u8 *mac_addr
9363 )
9364#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309365static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009366 struct net_device *ndev,
9367 u8 key_index,
9368 const u8 *mac_addr
9369 )
9370#endif
9371{
9372 int status = 0;
9373
9374 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309375 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009376 //it is observed that this is invalidating peer
9377 //key index whenever re-key is done. This is affecting data link.
9378 //It should be ok to ignore del_key.
9379#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309380 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
9381 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009382 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
9383 tCsrRoamSetKey setKey;
9384 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309385
Jeff Johnson295189b2012-06-20 16:38:30 -07009386 ENTER();
9387
9388 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
9389 __func__,pAdapter->device_mode);
9390
9391 if (CSR_MAX_NUM_KEY <= key_index)
9392 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309393 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009394 key_index);
9395
9396 return -EINVAL;
9397 }
9398
9399 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9400 setKey.keyId = key_index;
9401
9402 if (mac_addr)
9403 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9404 else
9405 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
9406
9407 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
9408
9409 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009410 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309411 )
9412 {
9413
9414 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07009415 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9416 if( pHostapdState->bssState == BSS_START)
9417 {
9418 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309419
Jeff Johnson295189b2012-06-20 16:38:30 -07009420 if ( status != eHAL_STATUS_SUCCESS )
9421 {
9422 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9423 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9424 __LINE__, status );
9425 }
9426 }
9427 }
9428 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309429 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07009430 )
9431 {
9432 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9433
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309434 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9435
9436 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009437 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309438 __func__, setKey.peerMac[0], setKey.peerMac[1],
9439 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07009440 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309441 if(pAdapter->sessionCtx.station.conn_info.connState ==
9442 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07009443 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309444 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009445 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309446
Jeff Johnson295189b2012-06-20 16:38:30 -07009447 if ( 0 != status )
9448 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309449 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009450 "%s: sme_RoamSetKey failure, returned %d",
9451 __func__, status);
9452 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9453 return -EINVAL;
9454 }
9455 }
9456 }
9457#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07009458 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009459 return status;
9460}
9461
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309462#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9463static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9464 struct net_device *ndev,
9465 u8 key_index,
9466 bool pairwise,
9467 const u8 *mac_addr
9468 )
9469#else
9470static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9471 struct net_device *ndev,
9472 u8 key_index,
9473 const u8 *mac_addr
9474 )
9475#endif
9476{
9477 int ret;
9478
9479 vos_ssr_protect(__func__);
9480#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9481 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
9482 mac_addr);
9483#else
9484 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
9485#endif
9486 vos_ssr_unprotect(__func__);
9487
9488 return ret;
9489}
9490
Jeff Johnson295189b2012-06-20 16:38:30 -07009491/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309492 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009493 * This function is used to set the default tx key index
9494 */
9495#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309496static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009497 struct net_device *ndev,
9498 u8 key_index,
9499 bool unicast, bool multicast)
9500#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309501static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009502 struct net_device *ndev,
9503 u8 key_index)
9504#endif
9505{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309506 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309507 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05309508 hdd_wext_state_t *pWextState;
9509 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309510 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009511
9512 ENTER();
9513
Gopichand Nakkala29149562013-05-10 21:43:41 +05309514 if ((NULL == pAdapter))
9515 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309516 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05309517 "invalid adapter");
9518 return -EINVAL;
9519 }
9520
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309521 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9522 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
9523 pAdapter->sessionId, key_index));
9524
Gopichand Nakkala29149562013-05-10 21:43:41 +05309525 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9526 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9527
9528 if ((NULL == pWextState) || (NULL == pHddStaCtx))
9529 {
9530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9531 "invalid Wext state or HDD context");
9532 return -EINVAL;
9533 }
9534
Arif Hussain6d2a3322013-11-17 19:50:10 -08009535 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009536 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309537
Jeff Johnson295189b2012-06-20 16:38:30 -07009538 if (CSR_MAX_NUM_KEY <= key_index)
9539 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309540 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 key_index);
9542
9543 return -EINVAL;
9544 }
9545
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309546 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9547 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309548 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009549 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309550 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009551 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309552
Jeff Johnson295189b2012-06-20 16:38:30 -07009553 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07009554 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309555 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009556 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05309557 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08009558 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309559 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08009560 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009561 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309562 {
9563 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07009564 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309565
Jeff Johnson295189b2012-06-20 16:38:30 -07009566 tCsrRoamSetKey setKey;
9567 v_U32_t roamId= 0xFF;
9568 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309569
9570 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009571 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309572
Jeff Johnson295189b2012-06-20 16:38:30 -07009573 Keys->defaultIndex = (u8)key_index;
9574 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9575 setKey.keyId = key_index;
9576 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309577
9578 vos_mem_copy(&setKey.Key[0],
9579 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009580 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309581
Gopichand Nakkala29149562013-05-10 21:43:41 +05309582 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309583
9584 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07009585 &pHddStaCtx->conn_info.bssId[0],
9586 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309587
Gopichand Nakkala29149562013-05-10 21:43:41 +05309588 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
9589 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
9590 eCSR_ENCRYPT_TYPE_WEP104)
9591 {
9592 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
9593 even though ap is configured for WEP-40 encryption. In this canse the key length
9594 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
9595 type(104) and switching encryption type to 40*/
9596 pWextState->roamProfile.EncryptionType.encryptionType[0] =
9597 eCSR_ENCRYPT_TYPE_WEP40;
9598 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
9599 eCSR_ENCRYPT_TYPE_WEP40;
9600 }
9601
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309602 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07009603 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309604
Jeff Johnson295189b2012-06-20 16:38:30 -07009605 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309606 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009607 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309608
Jeff Johnson295189b2012-06-20 16:38:30 -07009609 if ( 0 != status )
9610 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309611 hddLog(VOS_TRACE_LEVEL_ERROR,
9612 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009613 status);
9614 return -EINVAL;
9615 }
9616 }
9617 }
9618
9619 /* In SoftAp mode setting key direction for default mode */
9620 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
9621 {
9622 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
9623 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
9624 (eCSR_ENCRYPT_TYPE_AES !=
9625 pWextState->roamProfile.EncryptionType.encryptionType[0])
9626 )
9627 {
9628 /* Saving key direction for default key index to TX default */
9629 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9630 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
9631 }
9632 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309633 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009634 return status;
9635}
9636
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309637#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9638static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9639 struct net_device *ndev,
9640 u8 key_index,
9641 bool unicast, bool multicast)
9642#else
9643static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9644 struct net_device *ndev,
9645 u8 key_index)
9646#endif
9647{
9648 int ret;
9649 vos_ssr_protect(__func__);
9650#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9651 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
9652 multicast);
9653#else
9654 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
9655#endif
9656 vos_ssr_unprotect(__func__);
9657
9658 return ret;
9659}
9660
Jeff Johnson295189b2012-06-20 16:38:30 -07009661/*
9662 * FUNCTION: wlan_hdd_cfg80211_inform_bss
9663 * This function is used to inform the BSS details to nl80211 interface.
9664 */
9665static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
9666 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
9667{
9668 struct net_device *dev = pAdapter->dev;
9669 struct wireless_dev *wdev = dev->ieee80211_ptr;
9670 struct wiphy *wiphy = wdev->wiphy;
9671 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
9672 int chan_no;
9673 int ie_length;
9674 const char *ie;
9675 unsigned int freq;
9676 struct ieee80211_channel *chan;
9677 int rssi = 0;
9678 struct cfg80211_bss *bss = NULL;
9679
Jeff Johnson295189b2012-06-20 16:38:30 -07009680 if( NULL == pBssDesc )
9681 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009682 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009683 return bss;
9684 }
9685
9686 chan_no = pBssDesc->channelId;
9687 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
9688 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
9689
9690 if( NULL == ie )
9691 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009692 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009693 return bss;
9694 }
9695
9696#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
9697 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
9698 {
9699 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9700 }
9701 else
9702 {
9703 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9704 }
9705#else
9706 freq = ieee80211_channel_to_frequency(chan_no);
9707#endif
9708
9709 chan = __ieee80211_get_channel(wiphy, freq);
9710
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05309711 if (!chan) {
9712 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
9713 return NULL;
9714 }
9715
Abhishek Singhaee43942014-06-16 18:55:47 +05309716 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07009717
Abhishek Singhaee43942014-06-16 18:55:47 +05309718 return cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309719 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07009720 pBssDesc->capabilityInfo,
9721 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05309722 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07009723}
9724
9725
9726
9727/*
9728 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
9729 * This function is used to inform the BSS details to nl80211 interface.
9730 */
9731struct cfg80211_bss*
9732wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
9733 tSirBssDescription *bss_desc
9734 )
9735{
9736 /*
9737 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
9738 already exists in bss data base of cfg80211 for that particular BSS ID.
9739 Using cfg80211_inform_bss_frame to update the bss entry instead of
9740 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
9741 now there is no possibility to get the mgmt(probe response) frame from PE,
9742 converting bss_desc to ieee80211_mgmt(probe response) and passing to
9743 cfg80211_inform_bss_frame.
9744 */
9745 struct net_device *dev = pAdapter->dev;
9746 struct wireless_dev *wdev = dev->ieee80211_ptr;
9747 struct wiphy *wiphy = wdev->wiphy;
9748 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009749#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9750 qcom_ie_age *qie_age = NULL;
9751 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
9752#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009753 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009754#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009755 const char *ie =
9756 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
9757 unsigned int freq;
9758 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309759 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009760 struct cfg80211_bss *bss_status = NULL;
9761 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
9762 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07009763 hdd_context_t *pHddCtx;
9764 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07009765#ifdef WLAN_OPEN_SOURCE
9766 struct timespec ts;
9767#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009768
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309769 ENTER();
9770
Wilson Yangf80a0542013-10-07 13:02:37 -07009771 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9772 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -07009773 if (0 != status)
9774 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009775 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009776 }
9777
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309778 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07009779 if (!mgmt)
9780 {
9781 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9782 "%s: memory allocation failed ", __func__);
9783 return NULL;
9784 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009785
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07009787
9788#ifdef WLAN_OPEN_SOURCE
9789 /* Android does not want the timestamp from the frame.
9790 Instead it wants a monotonic increasing value */
9791 get_monotonic_boottime(&ts);
9792 mgmt->u.probe_resp.timestamp =
9793 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
9794#else
9795 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07009796 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
9797 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07009798
9799#endif
9800
Jeff Johnson295189b2012-06-20 16:38:30 -07009801 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
9802 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009803
9804#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9805 /* GPS Requirement: need age ie per entry. Using vendor specific. */
9806 /* Assuming this is the last IE, copy at the end */
9807 ie_length -=sizeof(qcom_ie_age);
9808 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
9809 qie_age->element_id = QCOM_VENDOR_IE_ID;
9810 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
9811 qie_age->oui_1 = QCOM_OUI1;
9812 qie_age->oui_2 = QCOM_OUI2;
9813 qie_age->oui_3 = QCOM_OUI3;
9814 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
9815 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
9816#endif
9817
Jeff Johnson295189b2012-06-20 16:38:30 -07009818 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05309819 if (bss_desc->fProbeRsp)
9820 {
9821 mgmt->frame_control |=
9822 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
9823 }
9824 else
9825 {
9826 mgmt->frame_control |=
9827 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
9828 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009829
9830#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309831 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009832 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
9833 {
9834 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9835 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309836 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009837 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
9838
9839 {
9840 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9841 }
9842 else
9843 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309844 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
9845 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07009846 kfree(mgmt);
9847 return NULL;
9848 }
9849#else
9850 freq = ieee80211_channel_to_frequency(chan_no);
9851#endif
9852 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009853 /*when the band is changed on the fly using the GUI, three things are done
9854 * 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)
9855 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
9856 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
9857 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
9858 * and discards the channels correponding to previous band and calls back with zero bss results.
9859 * 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
9860 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
9861 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
9862 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
9863 * So drop the bss and continue to next bss.
9864 */
9865 if(chan == NULL)
9866 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309867 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07009868 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009869 return NULL;
9870 }
Hanumantha Reddy Pothula904bcef2015-06-19 11:56:29 +05309871 /*To keep the rssi icon of the connected AP in the scan window
9872 *and the rssi icon of the wireless networks in sync
9873 * */
9874 if (( eConnectionState_Associated ==
9875 pAdapter->sessionCtx.station.conn_info.connState ) &&
9876 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
9877 pAdapter->sessionCtx.station.conn_info.bssId,
9878 WNI_CFG_BSSID_LEN)) &&
9879 (pHddCtx->hdd_wlan_suspended == FALSE))
9880 {
9881 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
9882 rssi = (pAdapter->rssi * 100);
9883 }
9884 else
9885 {
9886 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
9887 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009888
Nirav Shah20ac06f2013-12-12 18:14:06 +05309889 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
Sushant Kaushik0b343422015-05-25 17:15:55 +05309890 " RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
9891 vos_freq_to_chan(chan->center_freq), (int)(rssi/100));
Nirav Shah20ac06f2013-12-12 18:14:06 +05309892
Jeff Johnson295189b2012-06-20 16:38:30 -07009893 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
9894 frame_len, rssi, GFP_KERNEL);
9895 kfree(mgmt);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309896 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009897 return bss_status;
9898}
9899
9900/*
9901 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
9902 * This function is used to update the BSS data base of CFG8011
9903 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309904struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07009905 tCsrRoamInfo *pRoamInfo
9906 )
9907{
9908 tCsrRoamConnectedProfile roamProfile;
9909 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9910 struct cfg80211_bss *bss = NULL;
9911
9912 ENTER();
9913
9914 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
9915 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
9916
9917 if (NULL != roamProfile.pBssDesc)
9918 {
Girish Gowlif4b68022014-08-28 23:18:57 +05309919 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
9920 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009921
9922 if (NULL == bss)
9923 {
9924 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
9925 __func__);
9926 }
9927
9928 sme_RoamFreeConnectProfile(hHal, &roamProfile);
9929 }
9930 else
9931 {
9932 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
9933 __func__);
9934 }
9935 return bss;
9936}
9937
9938/*
9939 * FUNCTION: wlan_hdd_cfg80211_update_bss
9940 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309941static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
9942 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07009943 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309944{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309945 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009946 tCsrScanResultInfo *pScanResult;
9947 eHalStatus status = 0;
9948 tScanResultHandle pResult;
9949 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009950 hdd_context_t *pHddCtx;
Deepthi Gowri10d0ae12015-05-25 14:39:50 +05309951 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07009952 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309953
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309954 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9955 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
9956 NO_SESSION, pAdapter->sessionId));
9957
Wilson Yangf80a0542013-10-07 13:02:37 -07009958 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9959
9960 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07009961 {
Wilson Yangf80a0542013-10-07 13:02:37 -07009962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9963 "%s:LOGP in Progress. Ignore!!!",__func__);
9964 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07009965 }
9966
Wilson Yangf80a0542013-10-07 13:02:37 -07009967
9968 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05309969 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07009970 {
9971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9972 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
9973 return VOS_STATUS_E_PERM;
9974 }
9975
Deepthi Gowri10d0ae12015-05-25 14:39:50 +05309976 if (pAdapter->request != NULL)
9977 {
9978 if ((pAdapter->request->n_ssids == 1)
9979 && (pAdapter->request->ssids != NULL)
9980 && vos_mem_compare(&pAdapter->request->ssids[0], "DIRECT-", 7))
9981 is_p2p_scan = true;
9982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009983 /*
9984 * start getting scan results and populate cgf80211 BSS database
9985 */
9986 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
9987
9988 /* no scan results */
9989 if (NULL == pResult)
9990 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309991 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
9992 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009993 return status;
9994 }
9995
9996 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
9997
9998 while (pScanResult)
9999 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010000 /*
10001 * cfg80211_inform_bss() is not updating ie field of bss entry, if
10002 * entry already exists in bss data base of cfg80211 for that
10003 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
10004 * bss entry instead of cfg80211_inform_bss, But this call expects
10005 * mgmt packet as input. As of now there is no possibility to get
10006 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -070010007 * ieee80211_mgmt(probe response) and passing to c
10008 * fg80211_inform_bss_frame.
10009 * */
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010010 if(is_p2p_scan && (pScanResult->ssId.ssId != NULL) &&
10011 !vos_mem_compare( pScanResult->ssId.ssId, "DIRECT-", 7) )
10012 {
10013 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Non P2P BSS skipped: =%s:"),
10014 pScanResult->ssId.ssId);
10015 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10016 continue; //Skip the non p2p bss entries
10017 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010018 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
10019 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010020
Jeff Johnson295189b2012-06-20 16:38:30 -070010021
10022 if (NULL == bss_status)
10023 {
10024 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010025 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010026 }
10027 else
10028 {
Yue Maf49ba872013-08-19 12:04:25 -070010029 cfg80211_put_bss(
10030#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
10031 wiphy,
10032#endif
10033 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010034 }
10035
10036 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10037 }
10038
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010039 sme_ScanResultPurge(hHal, pResult);
Deepthi Gowri10d0ae12015-05-25 14:39:50 +053010040 is_p2p_scan = false;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010041 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010042}
10043
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010044void
10045hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
10046{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010047 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080010048 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010049} /****** end hddPrintMacAddr() ******/
10050
10051void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010052hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010053{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010054 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010055 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010056 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
10057 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
10058 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010059} /****** end hddPrintPmkId() ******/
10060
10061//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
10062//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
10063
10064//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
10065//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
10066
10067#define dump_bssid(bssid) \
10068 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010069 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
10070 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010071 }
10072
10073#define dump_pmkid(pMac, pmkid) \
10074 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010075 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
10076 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010077 }
10078
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070010079#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010080/*
10081 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
10082 * This function is used to notify the supplicant of a new PMKSA candidate.
10083 */
10084int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010085 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010086 int index, bool preauth )
10087{
Jeff Johnsone7245742012-09-05 17:12:55 -070010088#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010089 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010090 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010091
10092 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070010093 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010094
10095 if( NULL == pRoamInfo )
10096 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010097 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010098 return -EINVAL;
10099 }
10100
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010101 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
10102 {
10103 dump_bssid(pRoamInfo->bssid);
10104 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010105 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010106 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010107#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010108 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010109}
10110#endif //FEATURE_WLAN_LFR
10111
Yue Maef608272013-04-08 23:09:17 -070010112#ifdef FEATURE_WLAN_LFR_METRICS
10113/*
10114 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
10115 * 802.11r/LFR metrics reporting function to report preauth initiation
10116 *
10117 */
10118#define MAX_LFR_METRICS_EVENT_LENGTH 100
10119VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
10120 tCsrRoamInfo *pRoamInfo)
10121{
10122 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10123 union iwreq_data wrqu;
10124
10125 ENTER();
10126
10127 if (NULL == pAdapter)
10128 {
10129 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10130 return VOS_STATUS_E_FAILURE;
10131 }
10132
10133 /* create the event */
10134 memset(&wrqu, 0, sizeof(wrqu));
10135 memset(metrics_notification, 0, sizeof(metrics_notification));
10136
10137 wrqu.data.pointer = metrics_notification;
10138 wrqu.data.length = scnprintf(metrics_notification,
10139 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
10140 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10141
10142 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10143
10144 EXIT();
10145
10146 return VOS_STATUS_SUCCESS;
10147}
10148
10149/*
10150 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
10151 * 802.11r/LFR metrics reporting function to report preauth completion
10152 * or failure
10153 */
10154VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
10155 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
10156{
10157 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10158 union iwreq_data wrqu;
10159
10160 ENTER();
10161
10162 if (NULL == pAdapter)
10163 {
10164 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10165 return VOS_STATUS_E_FAILURE;
10166 }
10167
10168 /* create the event */
10169 memset(&wrqu, 0, sizeof(wrqu));
10170 memset(metrics_notification, 0, sizeof(metrics_notification));
10171
10172 scnprintf(metrics_notification, sizeof(metrics_notification),
10173 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
10174 MAC_ADDR_ARRAY(pRoamInfo->bssid));
10175
10176 if (1 == preauth_status)
10177 strncat(metrics_notification, " TRUE", 5);
10178 else
10179 strncat(metrics_notification, " FALSE", 6);
10180
10181 wrqu.data.pointer = metrics_notification;
10182 wrqu.data.length = strlen(metrics_notification);
10183
10184 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10185
10186 EXIT();
10187
10188 return VOS_STATUS_SUCCESS;
10189}
10190
10191/*
10192 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
10193 * 802.11r/LFR metrics reporting function to report handover initiation
10194 *
10195 */
10196VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
10197 tCsrRoamInfo *pRoamInfo)
10198{
10199 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10200 union iwreq_data wrqu;
10201
10202 ENTER();
10203
10204 if (NULL == pAdapter)
10205 {
10206 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10207 return VOS_STATUS_E_FAILURE;
10208 }
10209
10210 /* create the event */
10211 memset(&wrqu, 0, sizeof(wrqu));
10212 memset(metrics_notification, 0, sizeof(metrics_notification));
10213
10214 wrqu.data.pointer = metrics_notification;
10215 wrqu.data.length = scnprintf(metrics_notification,
10216 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
10217 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10218
10219 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10220
10221 EXIT();
10222
10223 return VOS_STATUS_SUCCESS;
10224}
10225#endif
10226
Jeff Johnson295189b2012-06-20 16:38:30 -070010227/*
10228 * FUNCTION: hdd_cfg80211_scan_done_callback
10229 * scanning callback function, called after finishing scan
10230 *
10231 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010232static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070010233 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
10234{
10235 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010236 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070010237 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010238 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010239 struct cfg80211_scan_request *req = NULL;
10240 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010241 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010242 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010243 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010244 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010245
10246 ENTER();
10247
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010248 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Siddharth Bhal5c2e02d2015-05-05 17:35:29 +053010249 if (NULL == pHddCtx) {
10250 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is Null"));
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010251 goto allow_suspend;
10252 }
10253
10254 pScanInfo = &pHddCtx->scan_info;
10255
Jeff Johnson295189b2012-06-20 16:38:30 -070010256 hddLog(VOS_TRACE_LEVEL_INFO,
10257 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080010258 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010259 __func__, halHandle, pContext, (int) scanId, (int) status);
10260
Kiet Lamac06e2c2013-10-23 16:25:07 +053010261 pScanInfo->mScanPendingCounter = 0;
10262
Jeff Johnson295189b2012-06-20 16:38:30 -070010263 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010264 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070010265 &pScanInfo->scan_req_completion_event,
10266 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010267 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070010268 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010269 hddLog(VOS_TRACE_LEVEL_ERROR,
10270 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070010271 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010272 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010273 }
10274
Yue Maef608272013-04-08 23:09:17 -070010275 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010276 {
10277 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010278 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010279 }
10280
10281 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010282 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070010283 {
10284 hddLog(VOS_TRACE_LEVEL_INFO,
10285 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010286 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070010287 (int) scanId);
10288 }
10289
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010290 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010291 pAdapter);
10292
10293 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010294 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010295
10296
10297 /* If any client wait scan result through WEXT
10298 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010299 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070010300 {
10301 /* The other scan request waiting for current scan finish
10302 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010303 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010304 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010305 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070010306 }
10307 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010308 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010309 {
10310 struct net_device *dev = pAdapter->dev;
10311 union iwreq_data wrqu;
10312 int we_event;
10313 char *msg;
10314
10315 memset(&wrqu, '\0', sizeof(wrqu));
10316 we_event = SIOCGIWSCAN;
10317 msg = NULL;
10318 wireless_send_event(dev, we_event, &wrqu, msg);
10319 }
10320 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010321 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010322
10323 /* Get the Scan Req */
10324 req = pAdapter->request;
10325
10326 if (!req)
10327 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010328 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010329 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010330 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010331 }
10332
Jeff Johnson295189b2012-06-20 16:38:30 -070010333 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070010334 /* Scan is no longer pending */
10335 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010336
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010337 /* last_scan_timestamp is used to decide if new scan
10338 * is needed or not on station interface. If last station
10339 * scan time and new station scan time is less then
10340 * last_scan_timestamp ; driver will return cached scan.
10341 */
10342 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
10343 {
10344 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
10345
10346 if ( req->n_channels )
10347 {
10348 for (i = 0; i < req->n_channels ; i++ )
10349 {
10350 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
10351 }
10352 /* store no of channel scanned */
10353 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
10354 }
10355
10356 }
10357
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070010358 /*
10359 * cfg80211_scan_done informing NL80211 about completion
10360 * of scanning
10361 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010362 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
10363 {
10364 aborted = true;
10365 }
10366 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080010367 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070010368
Siddharth Bhal76972212014-10-15 16:22:51 +053010369 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
10370 /* Generate new random mac addr for next scan */
10371 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
10372 hdd_processSpoofMacAddrRequest(pHddCtx);
10373 }
10374
Jeff Johnsone7245742012-09-05 17:12:55 -070010375allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010376 /* release the wake lock at the end of the scan*/
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010377 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070010378
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010379 /* Acquire wakelock to handle the case where APP's tries to suspend
10380 * immediatly after the driver gets connect request(i.e after scan)
10381 * from supplicant, this result in app's is suspending and not able
10382 * to process the connect request to AP */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010383 hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_SCAN);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010384
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010385#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010386 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010387#endif
10388
Jeff Johnson295189b2012-06-20 16:38:30 -070010389 EXIT();
10390 return 0;
10391}
10392
10393/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053010394 * FUNCTION: hdd_isConnectionInProgress
10395 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010396 *
10397 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010398v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010399{
10400 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10401 hdd_station_ctx_t *pHddStaCtx = NULL;
10402 hdd_adapter_t *pAdapter = NULL;
10403 VOS_STATUS status = 0;
10404 v_U8_t staId = 0;
10405 v_U8_t *staMac = NULL;
10406
c_hpothu9b781ba2013-12-30 20:57:45 +053010407 if (TRUE == pHddCtx->btCoexModeSet)
10408 {
10409 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053010410 FL("BTCoex Mode operation in progress"));
10411 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053010412 }
10413
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010414 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10415
10416 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10417 {
10418 pAdapter = pAdapterNode->pAdapter;
10419
10420 if( pAdapter )
10421 {
10422 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010423 "%s: Adapter with device mode %s (%d) exists",
10424 __func__, hdd_device_modetoString(pAdapter->device_mode),
10425 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010426 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053010427 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10428 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
10429 (eConnectionState_Connecting ==
10430 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
10431 {
10432 hddLog(VOS_TRACE_LEVEL_ERROR,
10433 "%s: %p(%d) Connection is in progress", __func__,
10434 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10435 return VOS_TRUE;
10436 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010437 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053010438 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010439 {
10440 hddLog(VOS_TRACE_LEVEL_ERROR,
10441 "%s: %p(%d) Reassociation is in progress", __func__,
10442 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10443 return VOS_TRUE;
10444 }
10445 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010446 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10447 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010448 {
10449 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10450 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010451 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010452 {
10453 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
10454 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010455 "%s: client " MAC_ADDRESS_STR
10456 " is in the middle of WPS/EAPOL exchange.", __func__,
10457 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010458 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010459 }
10460 }
10461 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
10462 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
10463 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010464 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10465 ptSapContext pSapCtx = NULL;
10466 pSapCtx = VOS_GET_SAP_CB(pVosContext);
10467 if(pSapCtx == NULL){
10468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10469 FL("psapCtx is NULL"));
10470 return VOS_FALSE;
10471 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010472 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
10473 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010474 if ((pSapCtx->aStaInfo[staId].isUsed) &&
10475 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010476 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010477 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010478
10479 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010480 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
10481 "middle of WPS/EAPOL exchange.", __func__,
10482 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010483 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010484 }
10485 }
10486 }
10487 }
10488 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10489 pAdapterNode = pNext;
10490 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053010491 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010492}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010493
10494/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010495 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070010496 * this scan respond to scan trigger and update cfg80211 scan database
10497 * later, scan dump command can be used to recieve scan results
10498 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010499int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010500#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10501 struct net_device *dev,
10502#endif
10503 struct cfg80211_scan_request *request)
10504{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010505 hdd_adapter_t *pAdapter = NULL;
10506 hdd_context_t *pHddCtx = NULL;
10507 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010508 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010509 tCsrScanRequest scanRequest;
10510 tANI_U8 *channelList = NULL, i;
10511 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010512 int status;
10513 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010514 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010515 int ret = 0;
Sushant Kaushik86592172015-04-27 16:35:03 +053010516 v_U8_t *pWpsIe=NULL;
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010517 bool is_p2p_scan = false;
Jeff Johnson295189b2012-06-20 16:38:30 -070010518
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010519#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
10520 struct net_device *dev = NULL;
10521 if (NULL == request)
10522 {
10523 hddLog(VOS_TRACE_LEVEL_ERROR,
10524 "%s: scan req param null", __func__);
10525 return -EINVAL;
10526 }
10527 dev = request->wdev->netdev;
10528#endif
10529
10530 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
10531 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
10532 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10533
Jeff Johnson295189b2012-06-20 16:38:30 -070010534 ENTER();
10535
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010536 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10537 __func__, hdd_device_modetoString(pAdapter->device_mode),
10538 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010539
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010540 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010541 if (0 != status)
10542 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010543 return status;
10544 }
10545
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010546 if (NULL == pwextBuf)
10547 {
10548 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
10549 __func__);
10550 return -EIO;
10551 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010552 cfg_param = pHddCtx->cfg_ini;
10553 pScanInfo = &pHddCtx->scan_info;
10554
Jeff Johnson295189b2012-06-20 16:38:30 -070010555#ifdef WLAN_BTAMP_FEATURE
10556 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010557 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070010558 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010559 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010560 "%s: No scanning when AMP is on", __func__);
10561 return -EOPNOTSUPP;
10562 }
10563#endif
10564 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010565 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010566 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010567 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010568 "%s: Not scanning on device_mode = %s (%d)",
10569 __func__, hdd_device_modetoString(pAdapter->device_mode),
10570 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010571 return -EOPNOTSUPP;
10572 }
10573
10574 if (TRUE == pScanInfo->mScanPending)
10575 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010576 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
10577 {
10578 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
10579 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010580 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010581 }
10582
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010583 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070010584 //Channel and action frame is pending
10585 //Otherwise Cancel Remain On Channel and allow Scan
10586 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010587 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070010588 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010589 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010590 return -EBUSY;
10591 }
10592
Jeff Johnson295189b2012-06-20 16:38:30 -070010593 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
10594 {
10595 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080010596 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010597 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010598 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010599 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
10600 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010601 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010602 "%s: MAX TM Level Scan not allowed", __func__);
10603 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010604 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010605 }
10606 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
10607
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010608 /* Check if scan is allowed at this point of time.
10609 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010610 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010611 {
10612 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
10613 return -EBUSY;
10614 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010615
Jeff Johnson295189b2012-06-20 16:38:30 -070010616 vos_mem_zero( &scanRequest, sizeof(scanRequest));
10617
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010618 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
10619 (int)request->n_ssids);
10620
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010621
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010622 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
10623 * Becasue of this, driver is assuming that this is not wildcard scan and so
10624 * is not aging out the scan results.
10625 */
10626 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070010627 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010628 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010629 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010630
10631 if ((request->ssids) && (0 < request->n_ssids))
10632 {
10633 tCsrSSIDInfo *SsidInfo;
10634 int j;
10635 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
10636 /* Allocate num_ssid tCsrSSIDInfo structure */
10637 SsidInfo = scanRequest.SSIDs.SSIDList =
10638 ( tCsrSSIDInfo *)vos_mem_malloc(
10639 request->n_ssids*sizeof(tCsrSSIDInfo));
10640
10641 if(NULL == scanRequest.SSIDs.SSIDList)
10642 {
10643 hddLog(VOS_TRACE_LEVEL_ERROR,
10644 "%s: memory alloc failed SSIDInfo buffer", __func__);
10645 return -ENOMEM;
10646 }
10647
10648 /* copy all the ssid's and their length */
10649 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
10650 {
10651 /* get the ssid length */
10652 SsidInfo->SSID.length = request->ssids[j].ssid_len;
10653 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
10654 SsidInfo->SSID.length);
10655 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
10656 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
10657 j, SsidInfo->SSID.ssId);
10658 }
10659 /* set the scan type to active */
10660 scanRequest.scanType = eSIR_ACTIVE_SCAN;
10661 }
10662 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070010663 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010664 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10665 TRACE_CODE_HDD_CFG80211_SCAN,
10666 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070010667 /* set the scan type to active */
10668 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010669 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010670 else
10671 {
10672 /*Set the scan type to default type, in this case it is ACTIVE*/
10673 scanRequest.scanType = pScanInfo->scan_mode;
10674 }
10675 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
10676 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070010677
10678 /* set BSSType to default type */
10679 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
10680
10681 /*TODO: scan the requested channels only*/
10682
10683 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010684 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070010685 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010686 hddLog(VOS_TRACE_LEVEL_WARN,
10687 "No of Scan Channels exceeded limit: %d", request->n_channels);
10688 request->n_channels = MAX_CHANNEL;
10689 }
10690
10691 hddLog(VOS_TRACE_LEVEL_INFO,
10692 "No of Scan Channels: %d", request->n_channels);
10693
10694
10695 if( request->n_channels )
10696 {
10697 char chList [(request->n_channels*5)+1];
10698 int len;
10699 channelList = vos_mem_malloc( request->n_channels );
10700 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053010701 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010702 hddLog(VOS_TRACE_LEVEL_ERROR,
10703 "%s: memory alloc failed channelList", __func__);
10704 status = -ENOMEM;
10705 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053010706 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010707
10708 for( i = 0, len = 0; i < request->n_channels ; i++ )
10709 {
10710 channelList[i] = request->channels[i]->hw_value;
10711 len += snprintf(chList+len, 5, "%d ", channelList[i]);
10712 }
10713
Nirav Shah20ac06f2013-12-12 18:14:06 +053010714 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010715 "Channel-List: %s ", chList);
10716 }
c_hpothu53512302014-04-15 18:49:53 +053010717
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010718 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
10719 scanRequest.ChannelInfo.ChannelList = channelList;
10720
10721 /* set requestType to full scan */
10722 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
10723
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010724 /* if there is back to back scan happening in driver with in
10725 * nDeferScanTimeInterval interval driver should defer new scan request
10726 * and should provide last cached scan results instead of new channel list.
10727 * This rule is not applicable if scan is p2p scan.
10728 * This condition will work only in case when last request no of channels
10729 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053010730 * This should be done only in connected state
Sushant Kaushik86592172015-04-27 16:35:03 +053010731 * Scan shouldn't be defered for WPS scan case.
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010732 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010733
Sushant Kaushik86592172015-04-27 16:35:03 +053010734 pWpsIe = wlan_hdd_get_wps_ie_ptr((v_U8_t*)request->ie,request->ie_len);
10735 /* if wps ie is NULL , then only defer scan */
10736 if ( pWpsIe == NULL &&
10737 (VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
Agarwal Ashish57e84372014-12-05 18:26:53 +053010738 {
10739 if ( pScanInfo->last_scan_timestamp !=0 &&
10740 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
10741 {
10742 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
10743 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
10744 vos_mem_compare(pScanInfo->last_scan_channelList,
10745 channelList, pScanInfo->last_scan_numChannels))
10746 {
10747 hddLog(VOS_TRACE_LEVEL_WARN,
10748 " New and old station scan time differ is less then %u",
10749 pHddCtx->cfg_ini->nDeferScanTimeInterval);
10750
10751 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010752 pAdapter);
10753
Agarwal Ashish57e84372014-12-05 18:26:53 +053010754 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010755 "Return old cached scan as all channels and no of channels are same");
10756
Agarwal Ashish57e84372014-12-05 18:26:53 +053010757 if (0 > ret)
10758 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010759
Agarwal Ashish57e84372014-12-05 18:26:53 +053010760 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010761
10762 status = eHAL_STATUS_SUCCESS;
10763 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053010764 }
10765 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010766 }
10767
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010768 /* Flush the scan results(only p2p beacons) for STA scan and P2P
10769 * search (Flush on both full scan and social scan but not on single
10770 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
10771 */
10772
10773 /* Supplicant does single channel scan after 8-way handshake
10774 * and in that case driver shoudnt flush scan results. If
10775 * driver flushes the scan results here and unfortunately if
10776 * the AP doesnt respond to our probe req then association
10777 * fails which is not desired
10778 */
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010779 if ((request->n_ssids == 1)
10780 && (request->ssids != NULL)
10781 && vos_mem_compare(&request->ssids[0], "DIRECT-", 7))
10782 is_p2p_scan = true;
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010783
Deepthi Gowrid5c5c2b2015-06-11 17:00:46 +053010784 if( is_p2p_scan ||
10785 (request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN) )
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010786 {
10787 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
10788 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
10789 pAdapter->sessionId );
10790 }
10791
10792 if( request->ie_len )
10793 {
10794 /* save this for future association (join requires this) */
10795 /*TODO: Array needs to be converted to dynamic allocation,
10796 * as multiple ie.s can be sent in cfg80211_scan_request structure
10797 * CR 597966
10798 */
10799 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
10800 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
10801 pScanInfo->scanAddIE.length = request->ie_len;
10802
10803 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
10804 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10805 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010806 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053010807 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070010808 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010809 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
10810 memcpy( pwextBuf->roamProfile.addIEScan,
10811 request->ie, request->ie_len);
10812 }
10813 else
10814 {
10815 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
10816 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070010817 }
10818
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010819 }
10820 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
10821 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
10822
10823 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
10824 request->ie_len);
10825 if (pP2pIe != NULL)
10826 {
10827#ifdef WLAN_FEATURE_P2P_DEBUG
10828 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
10829 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
10830 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053010831 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010832 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
10833 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10834 "Go nego completed to Connection is started");
10835 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10836 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053010837 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010838 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
10839 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010840 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010841 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
10842 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10843 "Disconnected state to Connection is started");
10844 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10845 "for 4way Handshake");
10846 }
10847#endif
10848
10849 /* no_cck will be set during p2p find to disable 11b rates */
10850 if(TRUE == request->no_cck)
10851 {
10852 hddLog(VOS_TRACE_LEVEL_INFO,
10853 "%s: This is a P2P Search", __func__);
10854 scanRequest.p2pSearch = 1;
10855
10856 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053010857 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010858 /* set requestType to P2P Discovery */
10859 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
10860 }
10861
10862 /*
10863 Skip Dfs Channel in case of P2P Search
10864 if it is set in ini file
10865 */
10866 if(cfg_param->skipDfsChnlInP2pSearch)
10867 {
10868 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010869 }
10870 else
10871 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010872 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010873 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010874
Agarwal Ashish4f616132013-12-30 23:32:50 +053010875 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010876 }
10877 }
10878
10879 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
10880
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010881#ifdef FEATURE_WLAN_TDLS
10882 /* if tdls disagree scan right now, return immediately.
10883 tdls will schedule the scan when scan is allowed. (return SUCCESS)
10884 or will reject the scan if any TDLS is in progress. (return -EBUSY)
10885 */
10886 status = wlan_hdd_tdls_scan_callback (pAdapter,
10887 wiphy,
10888#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10889 dev,
10890#endif
10891 request);
10892 if(status <= 0)
10893 {
10894 if(!status)
10895 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
10896 "scan rejected %d", __func__, status);
10897 else
10898 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
10899 __func__, status);
10900
10901 return status;
10902 }
10903#endif
10904
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010905 /* acquire the wakelock to avoid the apps suspend during the scan. To
10906 * address the following issues.
10907 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
10908 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
10909 * for long time, this result in apps running at full power for long time.
10910 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
10911 * be stuck in full power because of resume BMPS
10912 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010913 hdd_prevent_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Jeff Johnsone7245742012-09-05 17:12:55 -070010914
Nirav Shah20ac06f2013-12-12 18:14:06 +053010915 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10916 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010917 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
10918 scanRequest.requestType, scanRequest.scanType,
10919 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053010920 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
10921
Siddharth Bhal76972212014-10-15 16:22:51 +053010922 if (pHddCtx->spoofMacAddr.isEnabled)
10923 {
10924 hddLog(VOS_TRACE_LEVEL_INFO,
10925 "%s: MAC Spoofing enabled for current scan", __func__);
10926 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
10927 * to fill TxBds for probe request during current scan
10928 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053010929 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053010930 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053010931
10932 if(status != VOS_STATUS_SUCCESS)
10933 {
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010934 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053010935 status = -EFAULT;
Ganesh Kondabattini6d3b4902015-05-12 23:19:22 +053010936#ifdef FEATURE_WLAN_TDLS
10937 wlan_hdd_tdls_scan_done_callback(pAdapter);
10938#endif
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053010939 goto free_mem;
10940 }
Siddharth Bhal76972212014-10-15 16:22:51 +053010941 }
10942
Jeff Johnsone7245742012-09-05 17:12:55 -070010943 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070010944 pAdapter->sessionId, &scanRequest, &scanId,
10945 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070010946
Jeff Johnson295189b2012-06-20 16:38:30 -070010947 if (eHAL_STATUS_SUCCESS != status)
10948 {
10949 hddLog(VOS_TRACE_LEVEL_ERROR,
10950 "%s: sme_ScanRequest returned error %d", __func__, status);
10951 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070010952 if(eHAL_STATUS_RESOURCES == status)
10953 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010954 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
10955 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070010956 status = -EBUSY;
10957 } else {
10958 status = -EIO;
10959 }
Sushant Kaushik83392fa2015-05-05 17:44:40 +053010960 hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_SCAN);
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010961
10962#ifdef FEATURE_WLAN_TDLS
10963 wlan_hdd_tdls_scan_done_callback(pAdapter);
10964#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010965 goto free_mem;
10966 }
10967
10968 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010969 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010970 pAdapter->request = request;
10971 pScanInfo->scanId = scanId;
10972
10973 complete(&pScanInfo->scan_req_completion_event);
10974
10975free_mem:
10976 if( scanRequest.SSIDs.SSIDList )
10977 {
10978 vos_mem_free(scanRequest.SSIDs.SSIDList);
10979 }
10980
10981 if( channelList )
10982 vos_mem_free( channelList );
10983
10984 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010985 return status;
10986}
10987
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010988int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
10989#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10990 struct net_device *dev,
10991#endif
10992 struct cfg80211_scan_request *request)
10993{
10994 int ret;
10995
10996 vos_ssr_protect(__func__);
10997 ret = __wlan_hdd_cfg80211_scan(wiphy,
10998#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10999 dev,
11000#endif
11001 request);
11002 vos_ssr_unprotect(__func__);
11003
11004 return ret;
11005}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011006
11007void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
11008{
11009 v_U8_t iniDot11Mode =
11010 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
11011 eHddDot11Mode hddDot11Mode = iniDot11Mode;
11012
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011013 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
11014 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011015 switch ( iniDot11Mode )
11016 {
11017 case eHDD_DOT11_MODE_AUTO:
11018 case eHDD_DOT11_MODE_11ac:
11019 case eHDD_DOT11_MODE_11ac_ONLY:
11020#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053011021 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
11022 sme_IsFeatureSupportedByFW(DOT11AC) )
11023 hddDot11Mode = eHDD_DOT11_MODE_11ac;
11024 else
11025 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011026#else
11027 hddDot11Mode = eHDD_DOT11_MODE_11n;
11028#endif
11029 break;
11030 case eHDD_DOT11_MODE_11n:
11031 case eHDD_DOT11_MODE_11n_ONLY:
11032 hddDot11Mode = eHDD_DOT11_MODE_11n;
11033 break;
11034 default:
11035 hddDot11Mode = iniDot11Mode;
11036 break;
11037 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011038#ifdef WLAN_FEATURE_AP_HT40_24G
11039 if (operationChannel > SIR_11B_CHANNEL_END)
11040#endif
11041 {
11042 /* This call decides required channel bonding mode */
11043 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011044 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
11045 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053011046 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011047}
11048
Jeff Johnson295189b2012-06-20 16:38:30 -070011049/*
11050 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011051 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011052 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011053int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011054 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070011055{
11056 int status = 0;
11057 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080011058 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011059 v_U32_t roamId;
11060 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070011061 eCsrAuthType RSNAuthType;
11062
11063 ENTER();
11064
11065 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080011066 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11067
11068 status = wlan_hdd_validate_context(pHddCtx);
11069 if (status)
11070 {
Yue Mae36e3552014-03-05 17:06:20 -080011071 return status;
11072 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011073
Jeff Johnson295189b2012-06-20 16:38:30 -070011074 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
11075 {
11076 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
11077 return -EINVAL;
11078 }
11079
11080 pRoamProfile = &pWextState->roamProfile;
11081
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011082 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070011083 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011084 hdd_station_ctx_t *pHddStaCtx;
11085 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011086
Siddharth Bhalda0d1622015-04-24 15:47:49 +053011087 wlan_hdd_get_frame_logs(pAdapter, WLAN_HDD_GET_FRAME_LOG_CMD_CLEAR);
11088
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011089 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070011090 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
11091 {
11092 /*QoS not enabled in cfg file*/
11093 pRoamProfile->uapsd_mask = 0;
11094 }
11095 else
11096 {
11097 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011098 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070011099 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
11100 }
11101
11102 pRoamProfile->SSIDs.numOfSSIDs = 1;
11103 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
11104 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011105 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070011106 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
11107 ssid, ssid_len);
11108
11109 if (bssid)
11110 {
11111 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
11112 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
11113 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011114 /* Save BSSID in seperate variable as well, as RoamProfile
11115 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070011116 case of join failure we should send valid BSSID to supplicant
11117 */
11118 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
11119 WNI_CFG_BSSID_LEN);
11120 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070011121 else
11122 {
11123 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
11124 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011125
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011126 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
11127 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011128 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
11129 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011130 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011131 /*set gen ie*/
11132 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
11133 /*set auth*/
11134 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
11135 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011136#ifdef FEATURE_WLAN_WAPI
11137 if (pAdapter->wapi_info.nWapiMode)
11138 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011139 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011140 switch (pAdapter->wapi_info.wapiAuthMode)
11141 {
11142 case WAPI_AUTH_MODE_PSK:
11143 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011144 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011145 pAdapter->wapi_info.wapiAuthMode);
11146 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
11147 break;
11148 }
11149 case WAPI_AUTH_MODE_CERT:
11150 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011151 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011152 pAdapter->wapi_info.wapiAuthMode);
11153 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
11154 break;
11155 }
11156 } // End of switch
11157 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
11158 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
11159 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011160 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011161 pRoamProfile->AuthType.numEntries = 1;
11162 pRoamProfile->EncryptionType.numEntries = 1;
11163 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11164 pRoamProfile->mcEncryptionType.numEntries = 1;
11165 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11166 }
11167 }
11168#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011169#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011170 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011171 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11172 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
11173 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011174 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
11175 sizeof (tSirGtkOffloadParams));
11176 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011177 }
11178#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011179 pRoamProfile->csrPersona = pAdapter->device_mode;
11180
Jeff Johnson32d95a32012-09-10 13:15:23 -070011181 if( operatingChannel )
11182 {
11183 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
11184 pRoamProfile->ChannelInfo.numOfChannels = 1;
11185 }
Chet Lanctot186b5732013-03-18 10:26:30 -070011186 else
11187 {
11188 pRoamProfile->ChannelInfo.ChannelList = NULL;
11189 pRoamProfile->ChannelInfo.numOfChannels = 0;
11190 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011191 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
11192 {
11193 hdd_select_cbmode(pAdapter,operatingChannel);
11194 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011195
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011196 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
11197 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011198 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011199 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011200 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
11201 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011202 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11203 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053011204 {
11205 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11206 "%s: Set HDD connState to eConnectionState_Connecting",
11207 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011208 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
11209 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053011210 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011211 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011212 pAdapter->sessionId, pRoamProfile, &roamId);
11213
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011214 if ((eHAL_STATUS_SUCCESS != status) &&
11215 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11216 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011217
11218 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011219 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
11220 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
11221 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011222 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011223 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011224 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011225
11226 pRoamProfile->ChannelInfo.ChannelList = NULL;
11227 pRoamProfile->ChannelInfo.numOfChannels = 0;
11228
Jeff Johnson295189b2012-06-20 16:38:30 -070011229 }
11230 else
11231 {
11232 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
11233 return -EINVAL;
11234 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080011235 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011236 return status;
11237}
11238
11239/*
11240 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
11241 * This function is used to set the authentication type (OPEN/SHARED).
11242 *
11243 */
11244static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
11245 enum nl80211_auth_type auth_type)
11246{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011247 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011248 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11249
11250 ENTER();
11251
11252 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011253 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070011254 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011255 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011256 hddLog(VOS_TRACE_LEVEL_INFO,
11257 "%s: set authentication type to AUTOSWITCH", __func__);
11258 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
11259 break;
11260
11261 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011262#ifdef WLAN_FEATURE_VOWIFI_11R
11263 case NL80211_AUTHTYPE_FT:
11264#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011265 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011266 "%s: set authentication type to OPEN", __func__);
11267 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11268 break;
11269
11270 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011271 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011272 "%s: set authentication type to SHARED", __func__);
11273 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
11274 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011275#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011276 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011277 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011278 "%s: set authentication type to CCKM WPA", __func__);
11279 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
11280 break;
11281#endif
11282
11283
11284 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011285 hddLog(VOS_TRACE_LEVEL_ERROR,
11286 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011287 auth_type);
11288 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
11289 return -EINVAL;
11290 }
11291
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011292 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011293 pHddStaCtx->conn_info.authType;
11294 return 0;
11295}
11296
11297/*
11298 * FUNCTION: wlan_hdd_set_akm_suite
11299 * This function is used to set the key mgmt type(PSK/8021x).
11300 *
11301 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011302static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011303 u32 key_mgmt
11304 )
11305{
11306 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11307 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053011308 /* Should be in ieee802_11_defs.h */
11309#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
11310#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070011311 /*set key mgmt type*/
11312 switch(key_mgmt)
11313 {
11314 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053011315 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011316#ifdef WLAN_FEATURE_VOWIFI_11R
11317 case WLAN_AKM_SUITE_FT_PSK:
11318#endif
11319 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070011320 __func__);
11321 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
11322 break;
11323
11324 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053011325 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011326#ifdef WLAN_FEATURE_VOWIFI_11R
11327 case WLAN_AKM_SUITE_FT_8021X:
11328#endif
11329 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011330 __func__);
11331 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11332 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011333#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011334#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
11335#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
11336 case WLAN_AKM_SUITE_CCKM:
11337 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
11338 __func__);
11339 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
11340 break;
11341#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070011342#ifndef WLAN_AKM_SUITE_OSEN
11343#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
11344 case WLAN_AKM_SUITE_OSEN:
11345 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
11346 __func__);
11347 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11348 break;
11349#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011350
11351 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011352 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011353 __func__, key_mgmt);
11354 return -EINVAL;
11355
11356 }
11357 return 0;
11358}
11359
11360/*
11361 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011362 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070011363 * (NONE/WEP40/WEP104/TKIP/CCMP).
11364 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011365static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
11366 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070011367 bool ucast
11368 )
11369{
11370 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011371 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011372 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11373
11374 ENTER();
11375
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011376 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011377 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011378 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070011379 __func__, cipher);
11380 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11381 }
11382 else
11383 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011384
Jeff Johnson295189b2012-06-20 16:38:30 -070011385 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011386 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011387 {
11388 case IW_AUTH_CIPHER_NONE:
11389 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11390 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011391
Jeff Johnson295189b2012-06-20 16:38:30 -070011392 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011393 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070011394 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011395
Jeff Johnson295189b2012-06-20 16:38:30 -070011396 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011397 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070011398 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011399
Jeff Johnson295189b2012-06-20 16:38:30 -070011400 case WLAN_CIPHER_SUITE_TKIP:
11401 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
11402 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011403
Jeff Johnson295189b2012-06-20 16:38:30 -070011404 case WLAN_CIPHER_SUITE_CCMP:
11405 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11406 break;
11407#ifdef FEATURE_WLAN_WAPI
11408 case WLAN_CIPHER_SUITE_SMS4:
11409 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
11410 break;
11411#endif
11412
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011413#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011414 case WLAN_CIPHER_SUITE_KRK:
11415 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
11416 break;
11417#endif
11418 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011419 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011420 __func__, cipher);
11421 return -EOPNOTSUPP;
11422 }
11423 }
11424
11425 if (ucast)
11426 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011427 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011428 __func__, encryptionType);
11429 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11430 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011431 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011432 encryptionType;
11433 }
11434 else
11435 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011436 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011437 __func__, encryptionType);
11438 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
11439 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
11440 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
11441 }
11442
11443 return 0;
11444}
11445
11446
11447/*
11448 * FUNCTION: wlan_hdd_cfg80211_set_ie
11449 * This function is used to parse WPA/RSN IE's.
11450 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011451int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
11452 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -070011453 size_t ie_len
11454 )
11455{
11456 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11457 u8 *genie = ie;
11458 v_U16_t remLen = ie_len;
11459#ifdef FEATURE_WLAN_WAPI
11460 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
11461 u16 *tmp;
11462 v_U16_t akmsuiteCount;
11463 int *akmlist;
11464#endif
11465 ENTER();
11466
11467 /* clear previous assocAddIE */
11468 pWextState->assocAddIE.length = 0;
11469 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011470 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011471
11472 while (remLen >= 2)
11473 {
11474 v_U16_t eLen = 0;
11475 v_U8_t elementId;
11476 elementId = *genie++;
11477 eLen = *genie++;
11478 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011479
Arif Hussain6d2a3322013-11-17 19:50:10 -080011480 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070011481 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011482
11483 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070011484 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011485 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011486 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 -070011487 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011488 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011489 "%s: Invalid WPA IE", __func__);
11490 return -EINVAL;
11491 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011492 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070011493 {
11494 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011495 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011496 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011497
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011498 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011499 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011500 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
11501 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011502 VOS_ASSERT(0);
11503 return -ENOMEM;
11504 }
11505 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11506 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11507 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011508
Jeff Johnson295189b2012-06-20 16:38:30 -070011509 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
11510 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11511 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11512 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011513 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
11514 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011515 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
11516 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11517 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
11518 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
11519 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
11520 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011521 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053011522 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070011523 {
11524 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011525 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011526 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011527
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011528 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011529 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011530 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11531 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011532 VOS_ASSERT(0);
11533 return -ENOMEM;
11534 }
11535 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11536 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11537 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011538
Jeff Johnson295189b2012-06-20 16:38:30 -070011539 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11540 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11541 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011542#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011543 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
11544 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011545 /*Consider WFD IE, only for P2P Client */
11546 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
11547 {
11548 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011549 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011550 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011551
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011552 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011553 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011554 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11555 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011556 VOS_ASSERT(0);
11557 return -ENOMEM;
11558 }
11559 // WFD IE is saved to Additional IE ; it should be accumulated to handle
11560 // WPS IE + P2P IE + WFD IE
11561 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11562 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011563
Jeff Johnson295189b2012-06-20 16:38:30 -070011564 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11565 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11566 }
11567#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011568 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011569 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011570 HS20_OUI_TYPE_SIZE)) )
11571 {
11572 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011573 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011574 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011575
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011576 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011577 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011578 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11579 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011580 VOS_ASSERT(0);
11581 return -ENOMEM;
11582 }
11583 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11584 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011585
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011586 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11587 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11588 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011589 /* Appending OSEN Information Element in Assiciation Request */
11590 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
11591 OSEN_OUI_TYPE_SIZE)) )
11592 {
11593 v_U16_t curAddIELen = pWextState->assocAddIE.length;
11594 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
11595 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011596
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011597 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011598 {
11599 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11600 "Need bigger buffer space");
11601 VOS_ASSERT(0);
11602 return -ENOMEM;
11603 }
11604 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11605 pWextState->assocAddIE.length += eLen + 2;
11606
11607 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
11608 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11609 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11610 }
11611
Abhishek Singh4322e622015-06-10 15:42:54 +053011612 /* Update only for WPA IE */
11613 if (!memcmp(genie, WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) &&
11614 (WLAN_HDD_IBSS == pAdapter->device_mode)) {
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011615
11616 /* populating as ADDIE in beacon frames */
11617 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11618 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
11619 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
11620 {
11621 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11622 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
11623 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11624 {
11625 hddLog(LOGE,
11626 "Coldn't pass "
11627 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
11628 }
11629 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
11630 else
11631 hddLog(LOGE,
11632 "Could not pass on "
11633 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
11634
11635 /* IBSS mode doesn't contain params->proberesp_ies still
11636 beaconIE's need to be populated in probe response frames */
11637 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
11638 {
11639 u16 rem_probe_resp_ie_len = eLen + 2;
11640 u8 probe_rsp_ie_len[3] = {0};
11641 u8 counter = 0;
11642
11643 /* Check Probe Resp Length if it is greater then 255 then
11644 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
11645 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
11646 not able Store More then 255 bytes into One Variable */
11647
11648 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
11649 {
11650 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
11651 {
11652 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
11653 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
11654 }
11655 else
11656 {
11657 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
11658 rem_probe_resp_ie_len = 0;
11659 }
11660 }
11661
11662 rem_probe_resp_ie_len = 0;
11663
11664 if (probe_rsp_ie_len[0] > 0)
11665 {
11666 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11667 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
11668 (tANI_U8*)(genie - 2),
11669 probe_rsp_ie_len[0], NULL,
11670 eANI_BOOLEAN_FALSE)
11671 == eHAL_STATUS_FAILURE)
11672 {
11673 hddLog(LOGE,
11674 "Could not pass"
11675 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
11676 }
11677 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
11678 }
11679
11680 if (probe_rsp_ie_len[1] > 0)
11681 {
11682 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11683 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
11684 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11685 probe_rsp_ie_len[1], NULL,
11686 eANI_BOOLEAN_FALSE)
11687 == eHAL_STATUS_FAILURE)
11688 {
11689 hddLog(LOGE,
11690 "Could not pass"
11691 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
11692 }
11693 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
11694 }
11695
11696 if (probe_rsp_ie_len[2] > 0)
11697 {
11698 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11699 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
11700 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11701 probe_rsp_ie_len[2], NULL,
11702 eANI_BOOLEAN_FALSE)
11703 == eHAL_STATUS_FAILURE)
11704 {
11705 hddLog(LOGE,
11706 "Could not pass"
11707 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
11708 }
11709 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
11710 }
11711
11712 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11713 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
11714 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11715 {
11716 hddLog(LOGE,
11717 "Could not pass"
11718 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
11719 }
11720 }
11721 else
11722 {
11723 // Reset WNI_CFG_PROBE_RSP Flags
11724 wlan_hdd_reset_prob_rspies(pAdapter);
11725
11726 hddLog(VOS_TRACE_LEVEL_INFO,
11727 "%s: No Probe Response IE received in set beacon",
11728 __func__);
11729 }
11730 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070011731 break;
11732 case DOT11F_EID_RSN:
11733 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
11734 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11735 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
11736 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
11737 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
11738 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053011739
11740 /* Appending Extended Capabilities with Interworking bit set
11741 * in Assoc Req.
11742 *
11743 * In assoc req this EXT Cap will only be taken into account if
11744 * interworkingService bit is set to 1. Currently
11745 * driver is only interested in interworkingService capability
11746 * from supplicant. If in future any other EXT Cap info is
11747 * required from supplicat, it needs to be handled while
11748 * sending Assoc Req in LIM.
11749 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011750 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011751 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011752 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011753 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011754 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011755
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011756 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011757 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011758 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11759 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011760 VOS_ASSERT(0);
11761 return -ENOMEM;
11762 }
11763 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11764 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011765
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011766 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11767 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11768 break;
11769 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011770#ifdef FEATURE_WLAN_WAPI
11771 case WLAN_EID_WAPI:
11772 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011773 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070011774 pAdapter->wapi_info.nWapiMode);
11775 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011776 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070011777 akmsuiteCount = WPA_GET_LE16(tmp);
11778 tmp = tmp + 1;
11779 akmlist = (int *)(tmp);
11780 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
11781 {
11782 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
11783 }
11784 else
11785 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011786 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070011787 VOS_ASSERT(0);
11788 return -EINVAL;
11789 }
11790
11791 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
11792 {
11793 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011794 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011795 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011796 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011797 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011798 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011799 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011800 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011801 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
11802 }
11803 break;
11804#endif
11805 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011806 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011807 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011808 /* when Unknown IE is received we should break and continue
11809 * to the next IE in the buffer instead we were returning
11810 * so changing this to break */
11811 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011812 }
11813 genie += eLen;
11814 remLen -= eLen;
11815 }
11816 EXIT();
11817 return 0;
11818}
11819
11820/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053011821 * FUNCTION: hdd_isWPAIEPresent
11822 * Parse the received IE to find the WPA IE
11823 *
11824 */
11825static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
11826{
11827 v_U8_t eLen = 0;
11828 v_U16_t remLen = ie_len;
11829 v_U8_t elementId = 0;
11830
11831 while (remLen >= 2)
11832 {
11833 elementId = *ie++;
11834 eLen = *ie++;
11835 remLen -= 2;
11836 if (eLen > remLen)
11837 {
11838 hddLog(VOS_TRACE_LEVEL_ERROR,
11839 "%s: IE length is wrong %d", __func__, eLen);
11840 return FALSE;
11841 }
11842 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
11843 {
11844 /* OUI - 0x00 0X50 0XF2
11845 WPA Information Element - 0x01
11846 WPA version - 0x01*/
11847 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
11848 return TRUE;
11849 }
11850 ie += eLen;
11851 remLen -= eLen;
11852 }
11853 return FALSE;
11854}
11855
11856/*
Jeff Johnson295189b2012-06-20 16:38:30 -070011857 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011858 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070011859 * parameters during connect operation.
11860 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011861int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011862 struct cfg80211_connect_params *req
11863 )
11864{
11865 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011866 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011867 ENTER();
11868
11869 /*set wpa version*/
11870 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11871
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011872 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011873 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053011874 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011875 {
11876 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
11877 }
11878 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
11879 {
11880 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
11881 }
11882 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011883
11884 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011885 pWextState->wpaVersion);
11886
11887 /*set authentication type*/
11888 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
11889
11890 if (0 > status)
11891 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011892 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011893 "%s: failed to set authentication type ", __func__);
11894 return status;
11895 }
11896
11897 /*set key mgmt type*/
11898 if (req->crypto.n_akm_suites)
11899 {
11900 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
11901 if (0 > status)
11902 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011903 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070011904 __func__);
11905 return status;
11906 }
11907 }
11908
11909 /*set pairwise cipher type*/
11910 if (req->crypto.n_ciphers_pairwise)
11911 {
11912 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
11913 req->crypto.ciphers_pairwise[0], true);
11914 if (0 > status)
11915 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011916 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011917 "%s: failed to set unicast cipher type", __func__);
11918 return status;
11919 }
11920 }
11921 else
11922 {
11923 /*Reset previous cipher suite to none*/
11924 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
11925 if (0 > status)
11926 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011927 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011928 "%s: failed to set unicast cipher type", __func__);
11929 return status;
11930 }
11931 }
11932
11933 /*set group cipher type*/
11934 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
11935 false);
11936
11937 if (0 > status)
11938 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011939 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070011940 __func__);
11941 return status;
11942 }
11943
Chet Lanctot186b5732013-03-18 10:26:30 -070011944#ifdef WLAN_FEATURE_11W
11945 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
11946#endif
11947
Jeff Johnson295189b2012-06-20 16:38:30 -070011948 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
11949 if (req->ie_len)
11950 {
11951 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
11952 if ( 0 > status)
11953 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011954 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070011955 __func__);
11956 return status;
11957 }
11958 }
11959
11960 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011961 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070011962 {
11963 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
11964 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
11965 )
11966 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011967 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070011968 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
11969 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011970 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070011971 __func__);
11972 return -EOPNOTSUPP;
11973 }
11974 else
11975 {
11976 u8 key_len = req->key_len;
11977 u8 key_idx = req->key_idx;
11978
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011979 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070011980 && (CSR_MAX_NUM_KEY > key_idx)
11981 )
11982 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011983 hddLog(VOS_TRACE_LEVEL_INFO,
11984 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011985 __func__, key_idx, key_len);
11986 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011987 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011988 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011989 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011990 (u8)key_len;
11991 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
11992 }
11993 }
11994 }
11995 }
11996
11997 return status;
11998}
11999
12000/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012001 * FUNCTION: wlan_hdd_try_disconnect
12002 * This function is used to disconnect from previous
12003 * connection
12004 */
12005static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
12006{
12007 long ret = 0;
12008 hdd_station_ctx_t *pHddStaCtx;
12009 eMib_dot11DesiredBssType connectedBssType;
12010
12011 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12012
12013 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
12014
12015 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
12016 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
12017 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
12018 {
12019 /* Issue disconnect to CSR */
12020 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12021 if( eHAL_STATUS_SUCCESS ==
12022 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12023 pAdapter->sessionId,
12024 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
12025 {
12026 ret = wait_for_completion_interruptible_timeout(
12027 &pAdapter->disconnect_comp_var,
12028 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12029 if (0 >= ret)
12030 {
12031 hddLog(LOGE, FL("Failed to receive disconnect event"));
12032 return -EALREADY;
12033 }
12034 }
12035 }
12036 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
12037 {
12038 ret = wait_for_completion_interruptible_timeout(
12039 &pAdapter->disconnect_comp_var,
12040 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
12041 if (0 >= ret)
12042 {
12043 hddLog(LOGE, FL("Failed to receive disconnect event"));
12044 return -EALREADY;
12045 }
12046 }
12047
12048 return 0;
12049}
12050
12051/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053012052 * FUNCTION: __wlan_hdd_cfg80211_connect
12053 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070012054 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012055static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012056 struct net_device *ndev,
12057 struct cfg80211_connect_params *req
12058 )
12059{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012060 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012061 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012062 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053012063 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012064
12065 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012066
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012067 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12068 TRACE_CODE_HDD_CFG80211_CONNECT,
12069 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012070 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012071 "%s: device_mode = %s (%d)", __func__,
12072 hdd_device_modetoString(pAdapter->device_mode),
12073 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012074
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012075 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012076 if (!pHddCtx)
12077 {
12078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12079 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053012080 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012081 }
12082
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012083 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012084 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012085 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012086 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012087 }
12088
Agarwal Ashish51325b52014-06-16 16:50:49 +053012089 if (vos_max_concurrent_connections_reached()) {
12090 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12091 return -ECONNREFUSED;
12092 }
12093
Jeff Johnson295189b2012-06-20 16:38:30 -070012094#ifdef WLAN_BTAMP_FEATURE
12095 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012096 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070012097 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012098 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012099 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080012100 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012101 }
12102#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012103
12104 //If Device Mode is Station Concurrent Sessions Exit BMps
12105 //P2P Mode will be taken care in Open/close adapter
12106 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012107 (vos_concurrent_open_sessions_running())) {
12108 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
12109 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012110 }
12111
12112 /*Try disconnecting if already in connected state*/
12113 status = wlan_hdd_try_disconnect(pAdapter);
12114 if ( 0 > status)
12115 {
12116 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12117 " connection"));
12118 return -EALREADY;
12119 }
12120
Jeff Johnson295189b2012-06-20 16:38:30 -070012121 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012122 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070012123
12124 if ( 0 > status)
12125 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012126 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070012127 __func__);
12128 return status;
12129 }
Mohit Khanna765234a2012-09-11 15:08:35 -070012130 if ( req->channel )
12131 {
12132 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
12133 req->ssid_len, req->bssid,
12134 req->channel->hw_value);
12135 }
12136 else
12137 {
12138 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012139 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070012140 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012141
Sushant Kaushikd7083982015-03-18 14:33:24 +053012142 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012143 {
12144 //ReEnable BMPS if disabled
12145 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
12146 (NULL != pHddCtx))
12147 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012148 if (pHddCtx->hdd_wlan_suspended)
12149 {
12150 hdd_set_pwrparams(pHddCtx);
12151 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012152 //ReEnable Bmps and Imps back
12153 hdd_enable_bmps_imps(pHddCtx);
12154 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053012155 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012156 return status;
12157 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012158 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012159 EXIT();
12160 return status;
12161}
12162
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012163static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
12164 struct net_device *ndev,
12165 struct cfg80211_connect_params *req)
12166{
12167 int ret;
12168 vos_ssr_protect(__func__);
12169 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
12170 vos_ssr_unprotect(__func__);
12171
12172 return ret;
12173}
Jeff Johnson295189b2012-06-20 16:38:30 -070012174
12175/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012176 * FUNCTION: wlan_hdd_disconnect
12177 * This function is used to issue a disconnect request to SME
12178 */
12179int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
12180{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012181 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012182 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012183 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012184 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012185
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012186 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012187
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012188 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012189 if (0 != status)
12190 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012191 return status;
12192 }
12193
12194 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012195
Agarwal Ashish47d18112014-08-04 19:55:07 +053012196 /* Need to apply spin lock before decreasing active sessions
12197 * as there can be chance for double decrement if context switch
12198 * Calls hdd_DisConnectHandler.
12199 */
12200
12201 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012202 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
12203 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012204 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
12205 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053012206 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
12207 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012208
Abhishek Singhf4669da2014-05-26 15:07:49 +053012209 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053012210 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
12211
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012212 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012213
Mihir Shete182a0b22014-08-18 16:08:48 +053012214 /*
12215 * stop tx queues before deleting STA/BSS context from the firmware.
12216 * tx has to be disabled because the firmware can get busy dropping
12217 * the tx frames after BSS/STA has been deleted and will not send
12218 * back a response resulting in WDI timeout
12219 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053012220 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053012221 netif_tx_disable(pAdapter->dev);
12222 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012223
Mihir Shete182a0b22014-08-18 16:08:48 +053012224 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012225 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12226 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012227 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
12228 {
12229 hddLog(VOS_TRACE_LEVEL_INFO,
12230 FL("status = %d, already disconnected"),
12231 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012232
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012233 }
12234 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012235 {
12236 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012237 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012238 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012239 result = -EINVAL;
12240 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012241 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012242 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012243 &pAdapter->disconnect_comp_var,
12244 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012245 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012246 {
12247 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012248 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012249 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012250 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012251 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012252 {
12253 hddLog(VOS_TRACE_LEVEL_ERROR,
12254 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012255 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012256 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012257disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012258 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12259 FL("Set HDD connState to eConnectionState_NotConnected"));
12260 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
12261
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012262 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012263 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012264}
12265
12266
12267/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012268 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070012269 * This function is used to issue a disconnect request to SME
12270 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012271static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012272 struct net_device *dev,
12273 u16 reason
12274 )
12275{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012276 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012277 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012278 tCsrRoamProfile *pRoamProfile;
12279 hdd_station_ctx_t *pHddStaCtx;
12280 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012281#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012282 tANI_U8 staIdx;
12283#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012284
Jeff Johnson295189b2012-06-20 16:38:30 -070012285 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012286
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012287 if (!pAdapter) {
12288 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
12289 return -EINVAL;
12290 }
12291
12292 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12293 if (!pHddStaCtx) {
12294 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
12295 return -EINVAL;
12296 }
12297
12298 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12299 status = wlan_hdd_validate_context(pHddCtx);
12300 if (0 != status)
12301 {
12302 return status;
12303 }
12304
12305 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
12306
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012307 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12308 TRACE_CODE_HDD_CFG80211_DISCONNECT,
12309 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012310 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
12311 __func__, hdd_device_modetoString(pAdapter->device_mode),
12312 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012313
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012314 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
12315 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070012316
Jeff Johnson295189b2012-06-20 16:38:30 -070012317 if (NULL != pRoamProfile)
12318 {
12319 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012320 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
12321 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070012322 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012323 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070012324 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012325 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012326 switch(reason)
12327 {
12328 case WLAN_REASON_MIC_FAILURE:
12329 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
12330 break;
12331
12332 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
12333 case WLAN_REASON_DISASSOC_AP_BUSY:
12334 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
12335 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
12336 break;
12337
12338 case WLAN_REASON_PREV_AUTH_NOT_VALID:
12339 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053012340 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070012341 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
12342 break;
12343
Jeff Johnson295189b2012-06-20 16:38:30 -070012344 default:
12345 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
12346 break;
12347 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012348 pScanInfo = &pHddCtx->scan_info;
12349 if (pScanInfo->mScanPending)
12350 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012351 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012352 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053012353 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012354 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012355 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012356
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012357#ifdef FEATURE_WLAN_TDLS
12358 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012359 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012360 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012361 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
12362 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012363 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012364 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012365 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012367 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012368 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012369 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012370 status = sme_DeleteTdlsPeerSta(
12371 WLAN_HDD_GET_HAL_CTX(pAdapter),
12372 pAdapter->sessionId,
12373 mac);
12374 if (status != eHAL_STATUS_SUCCESS) {
12375 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
12376 return -EPERM;
12377 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012378 }
12379 }
12380#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012381 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012382 status = wlan_hdd_disconnect(pAdapter, reasonCode);
12383 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070012384 {
12385 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012386 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012387 __func__, (int)status );
12388 return -EINVAL;
12389 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012390 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012391 else
12392 {
12393 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
12394 "called while in %d state", __func__,
12395 pHddStaCtx->conn_info.connState);
12396 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012397 }
12398 else
12399 {
12400 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
12401 }
12402
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012403 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012404 return status;
12405}
12406
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012407static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
12408 struct net_device *dev,
12409 u16 reason
12410 )
12411{
12412 int ret;
12413 vos_ssr_protect(__func__);
12414 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
12415 vos_ssr_unprotect(__func__);
12416
12417 return ret;
12418}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012419
Jeff Johnson295189b2012-06-20 16:38:30 -070012420/*
12421 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012422 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012423 * settings in IBSS mode.
12424 */
12425static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012426 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012427 struct cfg80211_ibss_params *params
12428 )
12429{
12430 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012431 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012432 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
12433 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012434
Jeff Johnson295189b2012-06-20 16:38:30 -070012435 ENTER();
12436
12437 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070012438 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070012439
12440 if (params->ie_len && ( NULL != params->ie) )
12441 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012442 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12443 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012444 {
12445 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12446 encryptionType = eCSR_ENCRYPT_TYPE_AES;
12447 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012448 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012449 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012450 tDot11fIEWPA dot11WPAIE;
12451 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012452 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012453
Wilson Yang00256342013-10-10 23:13:38 -070012454 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012455 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12456 params->ie_len, DOT11F_EID_WPA);
12457 if ( NULL != ie )
12458 {
12459 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12460 // Unpack the WPA IE
12461 //Skip past the EID byte and length byte - and four byte WiFi OUI
12462 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
12463 &ie[2+4],
12464 ie[1] - 4,
12465 &dot11WPAIE);
12466 /*Extract the multicast cipher, the encType for unicast
12467 cipher for wpa-none is none*/
12468 encryptionType =
12469 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
12470 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012471 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012472
Jeff Johnson295189b2012-06-20 16:38:30 -070012473 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
12474
12475 if (0 > status)
12476 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012477 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012478 __func__);
12479 return status;
12480 }
12481 }
12482
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012483 pWextState->roamProfile.AuthType.authType[0] =
12484 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012485 eCSR_AUTH_TYPE_OPEN_SYSTEM;
12486
12487 if (params->privacy)
12488 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012489 /* Security enabled IBSS, At this time there is no information available
12490 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070012491 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012492 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070012493 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012494 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070012495 *enable privacy bit in beacons */
12496
12497 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
12498 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012499 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
12500 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012501 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
12502 pWextState->roamProfile.EncryptionType.numEntries = 1;
12503 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012504 return status;
12505}
12506
12507/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012508 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012509 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012510 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012511static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012512 struct net_device *dev,
12513 struct cfg80211_ibss_params *params
12514 )
12515{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012516 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012517 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12518 tCsrRoamProfile *pRoamProfile;
12519 int status;
krunal sonie9002db2013-11-25 14:24:17 -080012520 bool alloc_bssid = VOS_FALSE;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012521 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12522 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012523
12524 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012525
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012526 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12527 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
12528 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012529 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012530 "%s: device_mode = %s (%d)", __func__,
12531 hdd_device_modetoString(pAdapter->device_mode),
12532 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012533
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012534 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012535 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012536 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012537 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012538 }
12539
12540 if (NULL == pWextState)
12541 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012542 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012543 __func__);
12544 return -EIO;
12545 }
12546
Agarwal Ashish51325b52014-06-16 16:50:49 +053012547 if (vos_max_concurrent_connections_reached()) {
12548 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12549 return -ECONNREFUSED;
12550 }
12551
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012552 /*Try disconnecting if already in connected state*/
12553 status = wlan_hdd_try_disconnect(pAdapter);
12554 if ( 0 > status)
12555 {
12556 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12557 " IBSS connection"));
12558 return -EALREADY;
12559 }
12560
Jeff Johnson295189b2012-06-20 16:38:30 -070012561 pRoamProfile = &pWextState->roamProfile;
12562
12563 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
12564 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012565 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012566 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012567 return -EINVAL;
12568 }
12569
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012570 /* BSSID is provided by upper layers hence no need to AUTO generate */
12571 if (NULL != params->bssid) {
12572 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12573 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
12574 hddLog (VOS_TRACE_LEVEL_ERROR,
12575 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12576 return -EIO;
12577 }
12578 }
krunal sonie9002db2013-11-25 14:24:17 -080012579 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
12580 {
12581 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12582 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
12583 {
12584 hddLog (VOS_TRACE_LEVEL_ERROR,
12585 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12586 return -EIO;
12587 }
Sachin Ahuja46ff4912015-03-23 22:48:43 +053012588 params->bssid = vos_mem_malloc(VOS_MAC_ADDR_SIZE);
krunal sonie9002db2013-11-25 14:24:17 -080012589 if (!params->bssid)
12590 {
12591 hddLog (VOS_TRACE_LEVEL_ERROR,
12592 "%s:Failed memory allocation", __func__);
12593 return -EIO;
12594 }
12595 vos_mem_copy((v_U8_t *)params->bssid,
12596 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
12597 VOS_MAC_ADDR_SIZE);
12598 alloc_bssid = VOS_TRUE;
12599 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012600
Jeff Johnson295189b2012-06-20 16:38:30 -070012601 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070012602 if (NULL !=
12603#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12604 params->chandef.chan)
12605#else
12606 params->channel)
12607#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012608 {
12609 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012610 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12611 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
12612 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12613 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012614
12615 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012616 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070012617 ieee80211_frequency_to_channel(
12618#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12619 params->chandef.chan->center_freq);
12620#else
12621 params->channel->center_freq);
12622#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012623
12624 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
12625 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070012626 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012627 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
12628 __func__);
12629 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070012630 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012631
12632 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012633 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012634 if (channelNum == validChan[indx])
12635 {
12636 break;
12637 }
12638 }
12639 if (indx >= numChans)
12640 {
12641 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012642 __func__, channelNum);
12643 return -EINVAL;
12644 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012645 /* Set the Operational Channel */
12646 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
12647 channelNum);
12648 pRoamProfile->ChannelInfo.numOfChannels = 1;
12649 pHddStaCtx->conn_info.operationChannel = channelNum;
12650 pRoamProfile->ChannelInfo.ChannelList =
12651 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070012652 }
12653
12654 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012655 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070012656 if (status < 0)
12657 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012658 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070012659 __func__);
12660 return status;
12661 }
12662
12663 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012664 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012665 params->ssid_len, params->bssid,
12666 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070012667
12668 if (0 > status)
12669 {
12670 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
12671 return status;
12672 }
12673
krunal sonie9002db2013-11-25 14:24:17 -080012674 if (NULL != params->bssid &&
12675 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
12676 alloc_bssid == VOS_TRUE)
12677 {
12678 vos_mem_free(params->bssid);
12679 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012680 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012681 return 0;
12682}
12683
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012684static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
12685 struct net_device *dev,
12686 struct cfg80211_ibss_params *params
12687 )
12688{
12689 int ret = 0;
12690
12691 vos_ssr_protect(__func__);
12692 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
12693 vos_ssr_unprotect(__func__);
12694
12695 return ret;
12696}
12697
Jeff Johnson295189b2012-06-20 16:38:30 -070012698/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012699 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012700 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012701 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012702static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012703 struct net_device *dev
12704 )
12705{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012706 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012707 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12708 tCsrRoamProfile *pRoamProfile;
12709 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012710 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012711
12712 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012713
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012714 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12715 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
12716 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012717 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012718 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012719 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012720 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012721 }
12722
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012723 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
12724 hdd_device_modetoString(pAdapter->device_mode),
12725 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012726 if (NULL == pWextState)
12727 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012728 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012729 __func__);
12730 return -EIO;
12731 }
12732
12733 pRoamProfile = &pWextState->roamProfile;
12734
12735 /* Issue disconnect only if interface type is set to IBSS */
12736 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
12737 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012738 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070012739 __func__);
12740 return -EINVAL;
12741 }
12742
12743 /* Issue Disconnect request */
12744 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12745 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
12746 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
12747
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012748 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012749 return 0;
12750}
12751
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012752static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
12753 struct net_device *dev
12754 )
12755{
12756 int ret = 0;
12757
12758 vos_ssr_protect(__func__);
12759 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
12760 vos_ssr_unprotect(__func__);
12761
12762 return ret;
12763}
12764
Jeff Johnson295189b2012-06-20 16:38:30 -070012765/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012766 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070012767 * This function is used to set the phy parameters
12768 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
12769 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012770static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012771 u32 changed)
12772{
12773 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
12774 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012775 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012776
12777 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012778
12779 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012780 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
12781 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012782
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012783 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012784 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012785 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012786 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012787 }
12788
Jeff Johnson295189b2012-06-20 16:38:30 -070012789 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
12790 {
12791 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
12792 WNI_CFG_RTS_THRESHOLD_STAMAX :
12793 wiphy->rts_threshold;
12794
12795 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012796 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070012797 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012798 hddLog(VOS_TRACE_LEVEL_ERROR,
12799 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012800 __func__, rts_threshold);
12801 return -EINVAL;
12802 }
12803
12804 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
12805 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012806 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012807 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012808 hddLog(VOS_TRACE_LEVEL_ERROR,
12809 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012810 __func__, rts_threshold);
12811 return -EIO;
12812 }
12813
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012814 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012815 rts_threshold);
12816 }
12817
12818 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
12819 {
12820 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
12821 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
12822 wiphy->frag_threshold;
12823
12824 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012825 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012826 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012827 hddLog(VOS_TRACE_LEVEL_ERROR,
12828 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012829 frag_threshold);
12830 return -EINVAL;
12831 }
12832
12833 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
12834 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012835 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012836 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012837 hddLog(VOS_TRACE_LEVEL_ERROR,
12838 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012839 __func__, frag_threshold);
12840 return -EIO;
12841 }
12842
12843 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
12844 frag_threshold);
12845 }
12846
12847 if ((changed & WIPHY_PARAM_RETRY_SHORT)
12848 || (changed & WIPHY_PARAM_RETRY_LONG))
12849 {
12850 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
12851 wiphy->retry_short :
12852 wiphy->retry_long;
12853
12854 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
12855 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
12856 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012857 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012858 __func__, retry_value);
12859 return -EINVAL;
12860 }
12861
12862 if (changed & WIPHY_PARAM_RETRY_SHORT)
12863 {
12864 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
12865 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012866 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012867 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012868 hddLog(VOS_TRACE_LEVEL_ERROR,
12869 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012870 __func__, retry_value);
12871 return -EIO;
12872 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012873 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012874 __func__, retry_value);
12875 }
12876 else if (changed & WIPHY_PARAM_RETRY_SHORT)
12877 {
12878 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
12879 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012880 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012881 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012882 hddLog(VOS_TRACE_LEVEL_ERROR,
12883 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012884 __func__, retry_value);
12885 return -EIO;
12886 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012887 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012888 __func__, retry_value);
12889 }
12890 }
12891
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012892 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012893 return 0;
12894}
12895
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012896static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
12897 u32 changed)
12898{
12899 int ret;
12900
12901 vos_ssr_protect(__func__);
12902 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
12903 vos_ssr_unprotect(__func__);
12904
12905 return ret;
12906}
12907
Jeff Johnson295189b2012-06-20 16:38:30 -070012908/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012909 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070012910 * This function is used to set the txpower
12911 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012912static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070012913#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12914 struct wireless_dev *wdev,
12915#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012916#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012917 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070012918#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012919 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070012920#endif
12921 int dbm)
12922{
12923 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012924 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012925 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
12926 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012927 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012928
12929 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012930
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012931 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12932 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
12933 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012934 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012935 if (0 != status)
12936 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012937 return status;
12938 }
12939
12940 hHal = pHddCtx->hHal;
12941
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012942 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
12943 dbm, ccmCfgSetCallback,
12944 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012945 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012946 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012947 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
12948 return -EIO;
12949 }
12950
12951 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
12952 dbm);
12953
12954 switch(type)
12955 {
12956 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
12957 /* Fall through */
12958 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
12959 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
12960 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012961 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
12962 __func__);
12963 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070012964 }
12965 break;
12966 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012967 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012968 __func__);
12969 return -EOPNOTSUPP;
12970 break;
12971 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012972 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
12973 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070012974 return -EIO;
12975 }
12976
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012977 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012978 return 0;
12979}
12980
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012981static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
12982#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12983 struct wireless_dev *wdev,
12984#endif
12985#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
12986 enum tx_power_setting type,
12987#else
12988 enum nl80211_tx_power_setting type,
12989#endif
12990 int dbm)
12991{
12992 int ret;
12993 vos_ssr_protect(__func__);
12994 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
12995#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12996 wdev,
12997#endif
12998#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
12999 type,
13000#else
13001 type,
13002#endif
13003 dbm);
13004 vos_ssr_unprotect(__func__);
13005
13006 return ret;
13007}
13008
Jeff Johnson295189b2012-06-20 16:38:30 -070013009/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013010 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070013011 * This function is used to read the txpower
13012 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013013static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070013014#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13015 struct wireless_dev *wdev,
13016#endif
13017 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070013018{
13019
13020 hdd_adapter_t *pAdapter;
13021 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013022 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013023
Jeff Johnsone7245742012-09-05 17:12:55 -070013024 ENTER();
13025
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013026 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013027 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013028 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013029 *dbm = 0;
13030 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013031 }
13032
Jeff Johnson295189b2012-06-20 16:38:30 -070013033 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
13034 if (NULL == pAdapter)
13035 {
13036 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
13037 return -ENOENT;
13038 }
13039
13040 wlan_hdd_get_classAstats(pAdapter);
13041 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
13042
Jeff Johnsone7245742012-09-05 17:12:55 -070013043 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013044 return 0;
13045}
13046
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013047static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
13048#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13049 struct wireless_dev *wdev,
13050#endif
13051 int *dbm)
13052{
13053 int ret;
13054
13055 vos_ssr_protect(__func__);
13056 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
13057#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13058 wdev,
13059#endif
13060 dbm);
13061 vos_ssr_unprotect(__func__);
13062
13063 return ret;
13064}
13065
13066
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013067static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070013068 u8* mac, struct station_info *sinfo)
13069{
13070 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13071 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13072 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053013073 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013074
13075 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
13076 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070013077
13078 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
13079 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
13080 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
13081 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
13082 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
13083 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
13084 tANI_U16 maxRate = 0;
13085 tANI_U16 myRate;
13086 tANI_U16 currentRate = 0;
13087 tANI_U8 maxSpeedMCS = 0;
13088 tANI_U8 maxMCSIdx = 0;
13089 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053013090 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013091 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013092 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013093
Leo Chang6f8870f2013-03-26 18:11:36 -070013094#ifdef WLAN_FEATURE_11AC
13095 tANI_U32 vht_mcs_map;
13096 eDataRate11ACMaxMcs vhtMaxMcs;
13097#endif /* WLAN_FEATURE_11AC */
13098
Jeff Johnsone7245742012-09-05 17:12:55 -070013099 ENTER();
13100
Jeff Johnson295189b2012-06-20 16:38:30 -070013101 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
13102 (0 == ssidlen))
13103 {
13104 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
13105 " Invalid ssidlen, %d", __func__, ssidlen);
13106 /*To keep GUI happy*/
13107 return 0;
13108 }
13109
Mukul Sharma811205f2014-07-09 21:07:30 +053013110 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
13111 {
13112 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13113 "%s: Roaming in progress, so unable to proceed this request", __func__);
13114 return 0;
13115 }
13116
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013117 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013118 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013119 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013120 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013121 }
13122
Jeff Johnson295189b2012-06-20 16:38:30 -070013123
Kiet Lam3b17fc82013-09-27 05:24:08 +053013124 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
13125 sinfo->filled |= STATION_INFO_SIGNAL;
13126
c_hpothu09f19542014-05-30 21:53:31 +053013127 wlan_hdd_get_station_stats(pAdapter);
13128 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
13129
13130 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053013131 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
13132 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053013133 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053013134 {
13135 rate_flags = pAdapter->maxRateFlags;
13136 }
c_hpothu44ff4e02014-05-08 00:13:57 +053013137
Jeff Johnson295189b2012-06-20 16:38:30 -070013138 //convert to the UI units of 100kbps
13139 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
13140
13141#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070013142 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 -070013143 sinfo->signal,
13144 pCfg->reportMaxLinkSpeed,
13145 myRate,
13146 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013147 (int) pCfg->linkSpeedRssiMid,
13148 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070013149 (int) rate_flags,
13150 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013151#endif //LINKSPEED_DEBUG_ENABLED
13152
13153 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
13154 {
13155 // we do not want to necessarily report the current speed
13156 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
13157 {
13158 // report the max possible speed
13159 rssidx = 0;
13160 }
13161 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
13162 {
13163 // report the max possible speed with RSSI scaling
13164 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
13165 {
13166 // report the max possible speed
13167 rssidx = 0;
13168 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013169 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070013170 {
13171 // report middle speed
13172 rssidx = 1;
13173 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013174 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
13175 {
13176 // report middle speed
13177 rssidx = 2;
13178 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013179 else
13180 {
13181 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013182 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070013183 }
13184 }
13185 else
13186 {
13187 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
13188 hddLog(VOS_TRACE_LEVEL_ERROR,
13189 "%s: Invalid value for reportMaxLinkSpeed: %u",
13190 __func__, pCfg->reportMaxLinkSpeed);
13191 rssidx = 0;
13192 }
13193
13194 maxRate = 0;
13195
13196 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013197 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
13198 OperationalRates, &ORLeng))
13199 {
13200 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13201 /*To keep GUI happy*/
13202 return 0;
13203 }
13204
Jeff Johnson295189b2012-06-20 16:38:30 -070013205 for (i = 0; i < ORLeng; i++)
13206 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013207 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013208 {
13209 /* Validate Rate Set */
13210 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
13211 {
13212 currentRate = supported_data_rate[j].supported_rate[rssidx];
13213 break;
13214 }
13215 }
13216 /* Update MAX rate */
13217 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13218 }
13219
13220 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013221 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
13222 ExtendedRates, &ERLeng))
13223 {
13224 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13225 /*To keep GUI happy*/
13226 return 0;
13227 }
13228
Jeff Johnson295189b2012-06-20 16:38:30 -070013229 for (i = 0; i < ERLeng; i++)
13230 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013231 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013232 {
13233 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
13234 {
13235 currentRate = supported_data_rate[j].supported_rate[rssidx];
13236 break;
13237 }
13238 }
13239 /* Update MAX rate */
13240 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13241 }
c_hpothu79aab322014-07-14 21:11:01 +053013242
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013243 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053013244 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013245 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053013246 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070013247 {
c_hpothu79aab322014-07-14 21:11:01 +053013248 if (rate_flags & eHAL_TX_RATE_VHT80)
13249 mode = 2;
13250 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
13251 mode = 1;
13252 else
13253 mode = 0;
13254
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013255 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
13256 MCSRates, &MCSLeng))
13257 {
13258 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13259 /*To keep GUI happy*/
13260 return 0;
13261 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013262 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070013263#ifdef WLAN_FEATURE_11AC
13264 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013265 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070013266 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013267 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013268 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070013269 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070013270 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013271 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013272 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013273 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070013274 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013275 maxMCSIdx = 7;
13276 }
13277 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
13278 {
13279 maxMCSIdx = 8;
13280 }
13281 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
13282 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013283 //VHT20 is supporting 0~8
13284 if (rate_flags & eHAL_TX_RATE_VHT20)
13285 maxMCSIdx = 8;
13286 else
13287 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070013288 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013289
c_hpothu79aab322014-07-14 21:11:01 +053013290 if (0 != rssidx)/*check for scaled */
13291 {
13292 //get middle rate MCS index if rssi=1/2
13293 for (i=0; i <= maxMCSIdx; i++)
13294 {
13295 if (sinfo->signal <= rssiMcsTbl[mode][i])
13296 {
13297 maxMCSIdx = i;
13298 break;
13299 }
13300 }
13301 }
13302
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013303 if (rate_flags & eHAL_TX_RATE_VHT80)
13304 {
13305 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
13306 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
13307 }
13308 else if (rate_flags & eHAL_TX_RATE_VHT40)
13309 {
13310 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
13311 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
13312 }
13313 else if (rate_flags & eHAL_TX_RATE_VHT20)
13314 {
13315 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
13316 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
13317 }
13318
Leo Chang6f8870f2013-03-26 18:11:36 -070013319 maxSpeedMCS = 1;
13320 if (currentRate > maxRate)
13321 {
13322 maxRate = currentRate;
13323 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013324
Leo Chang6f8870f2013-03-26 18:11:36 -070013325 }
13326 else
13327#endif /* WLAN_FEATURE_11AC */
13328 {
13329 if (rate_flags & eHAL_TX_RATE_HT40)
13330 {
13331 rateFlag |= 1;
13332 }
13333 if (rate_flags & eHAL_TX_RATE_SGI)
13334 {
13335 rateFlag |= 2;
13336 }
13337
Girish Gowli01abcee2014-07-31 20:18:55 +053013338 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053013339 if (rssidx == 1 || rssidx == 2)
13340 {
13341 //get middle rate MCS index if rssi=1/2
13342 for (i=0; i <= 7; i++)
13343 {
13344 if (sinfo->signal <= rssiMcsTbl[mode][i])
13345 {
13346 temp = i+1;
13347 break;
13348 }
13349 }
13350 }
c_hpothu79aab322014-07-14 21:11:01 +053013351
13352 for (i = 0; i < MCSLeng; i++)
13353 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013354 for (j = 0; j < temp; j++)
13355 {
13356 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
13357 {
13358 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013359 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013360 break;
13361 }
13362 }
13363 if ((j < temp) && (currentRate > maxRate))
13364 {
13365 maxRate = currentRate;
Leo Chang6f8870f2013-03-26 18:11:36 -070013366 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013367 }
Hanumantha Reddy Pothulafa623742015-06-16 14:08:24 +053013368 maxSpeedMCS = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013369 }
13370 }
13371
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013372 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
13373 {
13374 maxRate = myRate;
13375 maxSpeedMCS = 1;
13376 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13377 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013378 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053013379 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070013380 {
13381 maxRate = myRate;
13382 if (rate_flags & eHAL_TX_RATE_LEGACY)
13383 {
13384 maxSpeedMCS = 0;
13385 }
13386 else
13387 {
13388 maxSpeedMCS = 1;
13389 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13390 }
13391 }
13392
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013393 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070013394 {
13395 sinfo->txrate.legacy = maxRate;
13396#ifdef LINKSPEED_DEBUG_ENABLED
13397 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
13398#endif //LINKSPEED_DEBUG_ENABLED
13399 }
13400 else
13401 {
13402 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070013403#ifdef WLAN_FEATURE_11AC
13404 sinfo->txrate.nss = 1;
13405 if (rate_flags & eHAL_TX_RATE_VHT80)
13406 {
13407 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013408 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070013409 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013410 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070013411 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013412 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13413 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13414 }
13415 else if (rate_flags & eHAL_TX_RATE_VHT20)
13416 {
13417 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13418 }
13419#endif /* WLAN_FEATURE_11AC */
13420 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
13421 {
13422 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13423 if (rate_flags & eHAL_TX_RATE_HT40)
13424 {
13425 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13426 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013427 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013428 if (rate_flags & eHAL_TX_RATE_SGI)
13429 {
13430 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13431 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013432
Jeff Johnson295189b2012-06-20 16:38:30 -070013433#ifdef LINKSPEED_DEBUG_ENABLED
13434 pr_info("Reporting MCS rate %d flags %x\n",
13435 sinfo->txrate.mcs,
13436 sinfo->txrate.flags );
13437#endif //LINKSPEED_DEBUG_ENABLED
13438 }
13439 }
13440 else
13441 {
13442 // report current rate instead of max rate
13443
13444 if (rate_flags & eHAL_TX_RATE_LEGACY)
13445 {
13446 //provide to the UI in units of 100kbps
13447 sinfo->txrate.legacy = myRate;
13448#ifdef LINKSPEED_DEBUG_ENABLED
13449 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
13450#endif //LINKSPEED_DEBUG_ENABLED
13451 }
13452 else
13453 {
13454 //must be MCS
13455 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013456#ifdef WLAN_FEATURE_11AC
13457 sinfo->txrate.nss = 1;
13458 if (rate_flags & eHAL_TX_RATE_VHT80)
13459 {
13460 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13461 }
13462 else
13463#endif /* WLAN_FEATURE_11AC */
13464 {
13465 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13466 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013467 if (rate_flags & eHAL_TX_RATE_SGI)
13468 {
13469 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13470 }
13471 if (rate_flags & eHAL_TX_RATE_HT40)
13472 {
13473 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13474 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013475#ifdef WLAN_FEATURE_11AC
13476 else if (rate_flags & eHAL_TX_RATE_VHT80)
13477 {
13478 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
13479 }
13480#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070013481#ifdef LINKSPEED_DEBUG_ENABLED
13482 pr_info("Reporting actual MCS rate %d flags %x\n",
13483 sinfo->txrate.mcs,
13484 sinfo->txrate.flags );
13485#endif //LINKSPEED_DEBUG_ENABLED
13486 }
13487 }
13488 sinfo->filled |= STATION_INFO_TX_BITRATE;
13489
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013490 sinfo->tx_packets =
13491 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
13492 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
13493 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
13494 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
13495
13496 sinfo->tx_retries =
13497 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
13498 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
13499 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
13500 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
13501
13502 sinfo->tx_failed =
13503 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
13504 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
13505 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
13506 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
13507
13508 sinfo->filled |=
13509 STATION_INFO_TX_PACKETS |
13510 STATION_INFO_TX_RETRIES |
13511 STATION_INFO_TX_FAILED;
13512
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013513 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13514 TRACE_CODE_HDD_CFG80211_GET_STA,
13515 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013516 EXIT();
13517 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013518}
13519
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013520static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13521 u8* mac, struct station_info *sinfo)
13522{
13523 int ret;
13524
13525 vos_ssr_protect(__func__);
13526 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
13527 vos_ssr_unprotect(__func__);
13528
13529 return ret;
13530}
13531
13532static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070013533 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070013534{
13535 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013536 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013537 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013538 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013539
Jeff Johnsone7245742012-09-05 17:12:55 -070013540 ENTER();
13541
Jeff Johnson295189b2012-06-20 16:38:30 -070013542 if (NULL == pAdapter)
13543 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013544 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013545 return -ENODEV;
13546 }
13547
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013548 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13549 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
13550 pAdapter->sessionId, timeout));
13551
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013552 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013553 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013554 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013555 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013556 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013557 }
13558
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013559 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
13560 (TRUE == pHddCtx->hdd_wlan_suspended) &&
13561 (pHddCtx->cfg_ini->fhostArpOffload) &&
13562 (eConnectionState_Associated ==
13563 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13564 {
Amar Singhald53568e2013-09-26 11:03:45 -070013565
13566 hddLog(VOS_TRACE_LEVEL_INFO,
13567 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053013568 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013569 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13570 {
13571 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013572 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013573 __func__, vos_status);
13574 }
13575 }
13576
Jeff Johnson295189b2012-06-20 16:38:30 -070013577 /**The get power cmd from the supplicant gets updated by the nl only
13578 *on successful execution of the function call
13579 *we are oppositely mapped w.r.t mode in the driver
13580 **/
13581 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
13582
13583 if (VOS_STATUS_E_FAILURE == vos_status)
13584 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013585 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13586 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013587 return -EINVAL;
13588 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013589 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013590 return 0;
13591}
13592
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013593static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
13594 struct net_device *dev, bool mode, int timeout)
13595{
13596 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013597
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013598 vos_ssr_protect(__func__);
13599 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
13600 vos_ssr_unprotect(__func__);
13601
13602 return ret;
13603}
Jeff Johnson295189b2012-06-20 16:38:30 -070013604#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013605static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
13606 struct net_device *netdev,
13607 u8 key_index)
13608{
13609 ENTER();
13610 return 0;
13611}
13612
Jeff Johnson295189b2012-06-20 16:38:30 -070013613static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013614 struct net_device *netdev,
13615 u8 key_index)
13616{
13617 int ret;
13618 vos_ssr_protect(__func__);
13619 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
13620 vos_ssr_unprotect(__func__);
13621 return ret;
13622}
13623#endif //LINUX_VERSION_CODE
13624
13625#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13626static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13627 struct net_device *dev,
13628 struct ieee80211_txq_params *params)
13629{
13630 ENTER();
13631 return 0;
13632}
13633#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13634static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13635 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013636{
Jeff Johnsone7245742012-09-05 17:12:55 -070013637 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070013638 return 0;
13639}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013640#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070013641
13642#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13643static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013644 struct net_device *dev,
13645 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013646{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013647 int ret;
13648
13649 vos_ssr_protect(__func__);
13650 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
13651 vos_ssr_unprotect(__func__);
13652 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013653}
13654#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13655static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
13656 struct ieee80211_txq_params *params)
13657{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013658 int ret;
13659
13660 vos_ssr_protect(__func__);
13661 ret = __wlan_hdd_set_txq_params(wiphy, params);
13662 vos_ssr_unprotect(__func__);
13663 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013664}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013665#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013666
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013667static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013668 struct net_device *dev,
13669 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070013670{
13671 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013672 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013673 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013674 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013675 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013676 v_CONTEXT_t pVosContext = NULL;
13677 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013678
Jeff Johnsone7245742012-09-05 17:12:55 -070013679 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013680
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013681 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070013682 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013683 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013684 return -EINVAL;
13685 }
13686
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013687 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13688 TRACE_CODE_HDD_CFG80211_DEL_STA,
13689 pAdapter->sessionId, pAdapter->device_mode));
13690
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013691 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13692 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013693 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013694 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013695 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013696 }
13697
Jeff Johnson295189b2012-06-20 16:38:30 -070013698 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013699 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013700 )
13701 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013702 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13703 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13704 if(pSapCtx == NULL){
13705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13706 FL("psapCtx is NULL"));
13707 return -ENOENT;
13708 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013709 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070013710 {
13711 v_U16_t i;
13712 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
13713 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013714 if ((pSapCtx->aStaInfo[i].isUsed) &&
13715 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070013716 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013717 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013718 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013719 ETHER_ADDR_LEN);
13720
Jeff Johnson295189b2012-06-20 16:38:30 -070013721 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013722 "%s: Delete STA with MAC::"
13723 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013724 __func__,
13725 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
13726 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070013727 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013728 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013729 }
13730 }
13731 }
13732 else
13733 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013734
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013735 vos_status = hdd_softap_GetStaId(pAdapter,
13736 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013737 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13738 {
13739 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013740 "%s: Skip this DEL STA as this is not used::"
13741 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013742 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013743 return -ENOENT;
13744 }
13745
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013746 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013747 {
13748 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013749 "%s: Skip this DEL STA as deauth is in progress::"
13750 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013751 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013752 return -ENOENT;
13753 }
13754
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013755 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013756
Jeff Johnson295189b2012-06-20 16:38:30 -070013757 hddLog(VOS_TRACE_LEVEL_INFO,
13758 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013759 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013760 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013761 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013762
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013763 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013764 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13765 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013766 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013767 hddLog(VOS_TRACE_LEVEL_INFO,
13768 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013769 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013770 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013771 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013772 return -ENOENT;
13773 }
13774
Jeff Johnson295189b2012-06-20 16:38:30 -070013775 }
13776 }
13777
13778 EXIT();
13779
13780 return 0;
13781}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013782
13783#ifdef CFG80211_DEL_STA_V2
13784static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13785 struct net_device *dev,
13786 struct station_del_parameters *param)
13787#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013788static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13789 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013790#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013791{
13792 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013793 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070013794
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013795 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013796
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013797#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013798 if (NULL == param) {
13799 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013800 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013801 return -EINVAL;
13802 }
13803
13804 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
13805 param->subtype, &delStaParams);
13806
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013807#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053013808 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013809 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013810#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013811 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
13812
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013813 vos_ssr_unprotect(__func__);
13814
13815 return ret;
13816}
13817
13818static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013819 struct net_device *dev, u8 *mac, struct station_parameters *params)
13820{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013821 hdd_adapter_t *pAdapter;
13822 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013823 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013824#ifdef FEATURE_WLAN_TDLS
13825 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013826
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013827 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013828
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013829 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13830 if (NULL == pAdapter)
13831 {
13832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13833 "%s: Adapter is NULL",__func__);
13834 return -EINVAL;
13835 }
13836 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13837 status = wlan_hdd_validate_context(pHddCtx);
13838 if (0 != status)
13839 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013840 return status;
13841 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013842
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013843 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13844 TRACE_CODE_HDD_CFG80211_ADD_STA,
13845 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013846 mask = params->sta_flags_mask;
13847
13848 set = params->sta_flags_set;
13849
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053013850 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013851 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
13852 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013853
13854 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
13855 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013856 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013857 }
13858 }
13859#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013860 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013861 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013862}
13863
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013864static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
13865 struct net_device *dev, u8 *mac, struct station_parameters *params)
13866{
13867 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013868
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013869 vos_ssr_protect(__func__);
13870 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
13871 vos_ssr_unprotect(__func__);
13872
13873 return ret;
13874}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013875#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070013876
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013877static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070013878 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013879{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013880 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13881 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013882 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013883 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013884 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013885 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070013886
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013887 ENTER();
13888
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013889 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013890 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013891 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013892 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013893 return -EINVAL;
13894 }
13895
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013896 if (!pmksa) {
13897 hddLog(LOGE, FL("pmksa is NULL"));
13898 return -EINVAL;
13899 }
13900
13901 if (!pmksa->bssid || !pmksa->pmkid) {
13902 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
13903 pmksa->bssid, pmksa->pmkid);
13904 return -EINVAL;
13905 }
13906
13907 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
13908 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
13909
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013910 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13911 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013912 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013913 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013914 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013915 }
13916
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013917 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013918 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13919
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013920 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
13921 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013922
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013923 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013924 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013925 &pmk_id, 1, FALSE);
13926
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013927 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13928 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
13929 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013930
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013931 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013932 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013933}
13934
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013935static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
13936 struct cfg80211_pmksa *pmksa)
13937{
13938 int ret;
13939
13940 vos_ssr_protect(__func__);
13941 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
13942 vos_ssr_unprotect(__func__);
13943
13944 return ret;
13945}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013946
Wilson Yang6507c4e2013-10-01 20:11:19 -070013947
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013948static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070013949 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013950{
Wilson Yang6507c4e2013-10-01 20:11:19 -070013951 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13952 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013953 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080013954 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013955
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013956 ENTER();
13957
Wilson Yang6507c4e2013-10-01 20:11:19 -070013958 /* Validate pAdapter */
13959 if (NULL == pAdapter)
13960 {
13961 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
13962 return -EINVAL;
13963 }
13964
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013965 if (!pmksa) {
13966 hddLog(LOGE, FL("pmksa is NULL"));
13967 return -EINVAL;
13968 }
13969
13970 if (!pmksa->bssid) {
13971 hddLog(LOGE, FL("pmksa->bssid is NULL"));
13972 return -EINVAL;
13973 }
13974
Kiet Lam98c46a12014-10-31 15:34:57 -070013975 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
13976 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
13977
Wilson Yang6507c4e2013-10-01 20:11:19 -070013978 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13979 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070013980 if (0 != status)
13981 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070013982 return status;
13983 }
13984
13985 /*Retrieve halHandle*/
13986 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13987
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013988 /* Delete the PMKID CSR cache */
13989 if (eHAL_STATUS_SUCCESS !=
13990 sme_RoamDelPMKIDfromCache(halHandle,
13991 pAdapter->sessionId, pmksa->bssid, FALSE)) {
13992 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
13993 MAC_ADDR_ARRAY(pmksa->bssid));
13994 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013995 }
13996
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013997 EXIT();
13998 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013999}
14000
Wilson Yang6507c4e2013-10-01 20:11:19 -070014001
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014002static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
14003 struct cfg80211_pmksa *pmksa)
14004{
14005 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014006
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014007 vos_ssr_protect(__func__);
14008 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
14009 vos_ssr_unprotect(__func__);
14010
14011 return ret;
14012
14013}
14014
14015static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014016{
Wilson Yang6507c4e2013-10-01 20:11:19 -070014017 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14018 tHalHandle halHandle;
14019 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080014020 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014021
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014022 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070014023
14024 /* Validate pAdapter */
14025 if (NULL == pAdapter)
14026 {
14027 hddLog(VOS_TRACE_LEVEL_ERROR,
14028 "%s: Invalid Adapter" ,__func__);
14029 return -EINVAL;
14030 }
14031
14032 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14033 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070014034 if (0 != status)
14035 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070014036 return status;
14037 }
14038
14039 /*Retrieve halHandle*/
14040 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
14041
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053014042 /* Flush the PMKID cache in CSR */
14043 if (eHAL_STATUS_SUCCESS !=
14044 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
14045 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
14046 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070014047 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014048 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080014049 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014050}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014051
14052static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
14053{
14054 int ret;
14055
14056 vos_ssr_protect(__func__);
14057 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
14058 vos_ssr_unprotect(__func__);
14059
14060 return ret;
14061}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014062#endif
14063
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014064#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014065static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14066 struct net_device *dev,
14067 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014068{
14069 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14070 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014071 hdd_context_t *pHddCtx;
14072 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014073
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014074 ENTER();
14075
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014076 if (NULL == pAdapter)
14077 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014078 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014079 return -ENODEV;
14080 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014081 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14082 ret = wlan_hdd_validate_context(pHddCtx);
14083 if (0 != ret)
14084 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014085 return ret;
14086 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014087 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014088 if (NULL == pHddStaCtx)
14089 {
14090 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
14091 return -EINVAL;
14092 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014093
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014094 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14095 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
14096 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014097 // Added for debug on reception of Re-assoc Req.
14098 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
14099 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014100 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014101 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080014102 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014103 }
14104
14105#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080014106 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014107 ftie->ie_len);
14108#endif
14109
14110 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014111 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14112 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014113 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014114
14115 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014116 return 0;
14117}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014118
14119static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14120 struct net_device *dev,
14121 struct cfg80211_update_ft_ies_params *ftie)
14122{
14123 int ret;
14124
14125 vos_ssr_protect(__func__);
14126 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
14127 vos_ssr_unprotect(__func__);
14128
14129 return ret;
14130}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014131#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014132
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014133#ifdef FEATURE_WLAN_SCAN_PNO
14134
14135void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
14136 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
14137{
14138 int ret;
14139 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
14140 hdd_context_t *pHddCtx;
14141
Nirav Shah80830bf2013-12-31 16:35:12 +053014142 ENTER();
14143
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014144 if (NULL == pAdapter)
14145 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014146 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014147 "%s: HDD adapter is Null", __func__);
14148 return ;
14149 }
14150
14151 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14152 if (NULL == pHddCtx)
14153 {
14154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14155 "%s: HDD context is Null!!!", __func__);
14156 return ;
14157 }
14158
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014159 spin_lock(&pHddCtx->schedScan_lock);
14160 if (TRUE == pHddCtx->isWiphySuspended)
14161 {
14162 pHddCtx->isSchedScanUpdatePending = TRUE;
14163 spin_unlock(&pHddCtx->schedScan_lock);
14164 hddLog(VOS_TRACE_LEVEL_INFO,
14165 "%s: Update cfg80211 scan database after it resume", __func__);
14166 return ;
14167 }
14168 spin_unlock(&pHddCtx->schedScan_lock);
14169
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014170 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
14171
14172 if (0 > ret)
14173 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
14174
14175 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14177 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014178}
14179
14180/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014181 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014182 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014183 */
14184static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
14185{
14186 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
14187 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014188 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014189 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14190 int status = 0;
14191 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
14192
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014193 /* The current firmware design does not allow PNO during any
14194 * active sessions. Hence, determine the active sessions
14195 * and return a failure.
14196 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014197 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
14198 {
14199 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014200 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014201
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014202 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
14203 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
14204 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
14205 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
14206 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053014207 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014208 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014209 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014210 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014211 }
14212 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14213 pAdapterNode = pNext;
14214 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014215 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014216}
14217
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014218void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
14219{
14220 hdd_adapter_t *pAdapter = callbackContext;
14221 hdd_context_t *pHddCtx;
14222
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014223 ENTER();
14224
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014225 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
14226 {
14227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14228 FL("Invalid adapter or adapter has invalid magic"));
14229 return;
14230 }
14231
14232 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14233 if (0 != wlan_hdd_validate_context(pHddCtx))
14234 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014235 return;
14236 }
14237
c_hpothub53c45d2014-08-18 16:53:14 +053014238 if (VOS_STATUS_SUCCESS != status)
14239 {
14240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014241 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053014242 pHddCtx->isPnoEnable = FALSE;
14243 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014244
14245 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
14246 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014247 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014248}
14249
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014250/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014251 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
14252 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014253 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014254static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014255 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14256{
14257 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014258 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014259 hdd_context_t *pHddCtx;
14260 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014261 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053014262 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
14263 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014264 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14265 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014266 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014267 hdd_config_t *pConfig = NULL;
14268 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014269
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014270 ENTER();
14271
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014272 if (NULL == pAdapter)
14273 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014274 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014275 "%s: HDD adapter is Null", __func__);
14276 return -ENODEV;
14277 }
14278
14279 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014280 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014281
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014282 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014283 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014284 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014285 }
14286
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014287 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014288 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14289 if (NULL == hHal)
14290 {
14291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14292 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014293 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014294 }
Sushant Kaushik2fe89932014-09-03 10:58:09 +053014295 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014296 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053014297 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014298 {
14299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14300 "%s: aborting the existing scan is unsuccessfull", __func__);
14301 return -EBUSY;
14302 }
14303
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014304 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014305 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014307 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014308 return -EBUSY;
14309 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014310
c_hpothu37f21312014-04-09 21:49:54 +053014311 if (TRUE == pHddCtx->isPnoEnable)
14312 {
14313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14314 FL("already PNO is enabled"));
14315 return -EBUSY;
14316 }
c_hpothu225aa7c2014-10-22 17:45:13 +053014317
14318 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
14319 {
14320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14321 "%s: abort ROC failed ", __func__);
14322 return -EBUSY;
14323 }
14324
c_hpothu37f21312014-04-09 21:49:54 +053014325 pHddCtx->isPnoEnable = TRUE;
14326
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014327 pnoRequest.enable = 1; /*Enable PNO */
14328 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014329
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014330 if (( !pnoRequest.ucNetworksCount ) ||
14331 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014332 {
14333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014334 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014335 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014336 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014337 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014338 goto error;
14339 }
14340
14341 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
14342 {
14343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014344 "%s: Incorrect number of channels %d",
14345 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014346 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014347 goto error;
14348 }
14349
14350 /* Framework provides one set of channels(all)
14351 * common for all saved profile */
14352 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14353 channels_allowed, &num_channels_allowed))
14354 {
14355 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14356 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014357 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014358 goto error;
14359 }
14360 /* Checking each channel against allowed channel list */
14361 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053014362 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014363 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014364 char chList [(request->n_channels*5)+1];
14365 int len;
14366 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014367 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014368 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014369 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014370 if (request->channels[i]->hw_value == channels_allowed[indx])
14371 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014372 if ((!pConfig->enableDFSPnoChnlScan) &&
14373 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
14374 {
14375 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14376 "%s : Dropping DFS channel : %d",
14377 __func__,channels_allowed[indx]);
14378 num_ignore_dfs_ch++;
14379 break;
14380 }
14381
Nirav Shah80830bf2013-12-31 16:35:12 +053014382 valid_ch[num_ch++] = request->channels[i]->hw_value;
14383 len += snprintf(chList+len, 5, "%d ",
14384 request->channels[i]->hw_value);
14385 break ;
14386 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014387 }
14388 }
Nirav Shah80830bf2013-12-31 16:35:12 +053014389 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014390
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014391 /*If all channels are DFS and dropped, then ignore the PNO request*/
14392 if (num_ignore_dfs_ch == request->n_channels)
14393 {
14394 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14395 "%s : All requested channels are DFS channels", __func__);
14396 ret = -EINVAL;
14397 goto error;
14398 }
14399 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014400
14401 pnoRequest.aNetworks =
14402 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14403 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014404 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014405 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14406 FL("failed to allocate memory aNetworks %u"),
14407 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14408 goto error;
14409 }
14410 vos_mem_zero(pnoRequest.aNetworks,
14411 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14412
14413 /* Filling per profile params */
14414 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
14415 {
14416 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014417 request->match_sets[i].ssid.ssid_len;
14418
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014419 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
14420 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014421 {
14422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014423 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014424 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014425 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014426 goto error;
14427 }
14428
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014429 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014430 request->match_sets[i].ssid.ssid,
14431 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14433 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014434 i, pnoRequest.aNetworks[i].ssId.ssId);
14435 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
14436 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
14437 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014438
14439 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014440 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
14441 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014442
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014443 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014444 }
14445
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014446 for (i = 0; i < request->n_ssids; i++)
14447 {
14448 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014449 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014450 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014451 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014452 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014453 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014454 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014455 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014456 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014457 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014458 break;
14459 }
14460 j++;
14461 }
14462 }
14463 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14464 "Number of hidden networks being Configured = %d",
14465 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080014467 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014468
14469 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14470 if (pnoRequest.p24GProbeTemplate == NULL)
14471 {
14472 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14473 FL("failed to allocate memory p24GProbeTemplate %u"),
14474 SIR_PNO_MAX_PB_REQ_SIZE);
14475 goto error;
14476 }
14477
14478 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14479 if (pnoRequest.p5GProbeTemplate == NULL)
14480 {
14481 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14482 FL("failed to allocate memory p5GProbeTemplate %u"),
14483 SIR_PNO_MAX_PB_REQ_SIZE);
14484 goto error;
14485 }
14486
14487 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14488 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14489
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053014490 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
14491 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014492 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014493 pnoRequest.us24GProbeTemplateLen = request->ie_len;
14494 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
14495 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014496
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014497 pnoRequest.us5GProbeTemplateLen = request->ie_len;
14498 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
14499 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014500 }
14501
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014502 /* Driver gets only one time interval which is hardcoded in
14503 * supplicant for 10000ms. Taking power consumption into account 6 timers
14504 * will be used, Timervalue is increased exponentially i.e 10,20,40,
14505 * 80,160,320 secs. And number of scan cycle for each timer
14506 * is configurable through INI param gPNOScanTimerRepeatValue.
14507 * If it is set to 0 only one timer will be used and PNO scan cycle
14508 * will be repeated after each interval specified by supplicant
14509 * till PNO is disabled.
14510 */
14511 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014512 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014513 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014514 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014515 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
14516
14517 tempInterval = (request->interval)/1000;
14518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14519 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
14520 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014521 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014522 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014523 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014524 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014525 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014526 tempInterval *= 2;
14527 }
14528 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014529 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014530
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014531 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014532
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014533 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014534 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
14535 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014536 pAdapter->pno_req_status = 0;
14537
Nirav Shah80830bf2013-12-31 16:35:12 +053014538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14539 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014540 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
14541 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053014542
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014543 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014544 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014545 hdd_cfg80211_sched_scan_done_callback, pAdapter);
14546 if (eHAL_STATUS_SUCCESS != status)
14547 {
14548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014549 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014550 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014551 goto error;
14552 }
14553
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014554 ret = wait_for_completion_timeout(
14555 &pAdapter->pno_comp_var,
14556 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
14557 if (0 >= ret)
14558 {
14559 // Did not receive the response for PNO enable in time.
14560 // Assuming the PNO enable was success.
14561 // Returning error from here, because we timeout, results
14562 // in side effect of Wifi (Wifi Setting) not to work.
14563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14564 FL("Timed out waiting for PNO to be Enabled"));
14565 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014566 }
14567
14568 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053014569 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014570
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014571error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014572 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14573 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053014574 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014575 if (pnoRequest.aNetworks)
14576 vos_mem_free(pnoRequest.aNetworks);
14577 if (pnoRequest.p24GProbeTemplate)
14578 vos_mem_free(pnoRequest.p24GProbeTemplate);
14579 if (pnoRequest.p5GProbeTemplate)
14580 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014581
14582 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014583 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014584}
14585
14586/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014587 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
14588 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014589 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014590static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
14591 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14592{
14593 int ret;
14594
14595 vos_ssr_protect(__func__);
14596 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
14597 vos_ssr_unprotect(__func__);
14598
14599 return ret;
14600}
14601
14602/*
14603 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
14604 * Function to disable PNO
14605 */
14606static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014607 struct net_device *dev)
14608{
14609 eHalStatus status = eHAL_STATUS_FAILURE;
14610 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14611 hdd_context_t *pHddCtx;
14612 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014613 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014614 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014615
14616 ENTER();
14617
14618 if (NULL == pAdapter)
14619 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014621 "%s: HDD adapter is Null", __func__);
14622 return -ENODEV;
14623 }
14624
14625 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014626
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014627 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014628 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014629 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014630 "%s: HDD context is Null", __func__);
14631 return -ENODEV;
14632 }
14633
14634 /* The return 0 is intentional when isLogpInProgress and
14635 * isLoadUnloadInProgress. We did observe a crash due to a return of
14636 * failure in sched_scan_stop , especially for a case where the unload
14637 * of the happens at the same time. The function __cfg80211_stop_sched_scan
14638 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
14639 * success. If it returns a failure , then its next invocation due to the
14640 * clean up of the second interface will have the dev pointer corresponding
14641 * to the first one leading to a crash.
14642 */
14643 if (pHddCtx->isLogpInProgress)
14644 {
14645 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14646 "%s: LOGP in Progress. Ignore!!!", __func__);
14647 return ret;
14648 }
14649
Mihir Shete18156292014-03-11 15:38:30 +053014650 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014651 {
14652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14653 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14654 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014655 }
14656
14657 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14658 if (NULL == hHal)
14659 {
14660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14661 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014662 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014663 }
14664
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014665 pnoRequest.enable = 0; /* Disable PNO */
14666 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014667
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014668 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014669 pAdapter->sessionId,
14670 NULL, pAdapter);
14671 if (eHAL_STATUS_SUCCESS != status)
14672 {
14673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14674 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014675 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014676 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014677 }
c_hpothu37f21312014-04-09 21:49:54 +053014678 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014679
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014680error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014681 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014682 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014683
14684 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014685 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014686}
14687
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014688/*
14689 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
14690 * NL interface to disable PNO
14691 */
14692static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
14693 struct net_device *dev)
14694{
14695 int ret;
14696
14697 vos_ssr_protect(__func__);
14698 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
14699 vos_ssr_unprotect(__func__);
14700
14701 return ret;
14702}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014703#endif /*FEATURE_WLAN_SCAN_PNO*/
14704
14705
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014706#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014707#if TDLS_MGMT_VERSION2
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014708static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014709 u8 *peer, u8 action_code, u8 dialog_token,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014710 u16 status_code, u32 peer_capability, const u8 *buf, size_t len)
14711#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014712static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014713 u8 *peer, u8 action_code, u8 dialog_token,
14714 u16 status_code, const u8 *buf, size_t len)
14715#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014716{
14717
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014718 hdd_adapter_t *pAdapter;
14719 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014720 u8 peerMac[6];
14721 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070014722 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080014723 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070014724 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014725 int ret;
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014726#if !(TDLS_MGMT_VERSION2)
14727 u32 peer_capability = 0;
14728#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014729 tANI_U16 numCurrTdlsPeers;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014730
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014731 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14732 if (NULL == pAdapter)
14733 {
14734 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14735 "%s: Adapter is NULL",__func__);
14736 return -EINVAL;
14737 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014738 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14739 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
14740 pAdapter->sessionId, action_code));
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014741 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014742 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014743 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014744 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014745 "Invalid arguments");
14746 return -EINVAL;
14747 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014748 if (pHddCtx->isLogpInProgress)
14749 {
14750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14751 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053014752 wlan_hdd_tdls_set_link_status(pAdapter,
14753 peer,
14754 eTDLS_LINK_IDLE,
14755 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014756 return -EBUSY;
14757 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014758 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
14759 {
14760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14761 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14762 return -EAGAIN;
14763 }
Hoonki Lee27511902013-03-14 18:19:06 -070014764 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014765 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014766 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070014767 "%s: TDLS mode is disabled OR not enabled in FW."
14768 MAC_ADDRESS_STR " action %d declined.",
14769 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014770 return -ENOTSUPP;
14771 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014772
Hoonki Lee27511902013-03-14 18:19:06 -070014773 /* other than teardown frame, other mgmt frames are not sent if disabled */
14774 if (SIR_MAC_TDLS_TEARDOWN != action_code)
14775 {
14776 /* if tdls_mode is disabled to respond to peer's request */
14777 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
14778 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014779 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070014780 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014781 " TDLS mode is disabled. action %d declined.",
14782 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070014783
14784 return -ENOTSUPP;
14785 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053014786
14787 if (vos_max_concurrent_connections_reached())
14788 {
14789 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
14790 return -EINVAL;
14791 }
Hoonki Lee27511902013-03-14 18:19:06 -070014792 }
14793
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014794 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
14795 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053014796 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014797 {
14798 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014799 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014800 " TDLS setup is ongoing. action %d declined.",
14801 __func__, MAC_ADDR_ARRAY(peer), action_code);
14802 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014803 }
14804 }
14805
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014806 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
14807 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080014808 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014809 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
14810 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080014811 {
14812 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
14813 we return error code at 'add_station()'. Hence we have this
14814 check again in addtion to add_station().
14815 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014816 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080014817 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014818 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14819 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014820 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
14821 __func__, MAC_ADDR_ARRAY(peer), action_code,
14822 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053014823 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080014824 }
14825 else
14826 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014827 /* maximum reached. tweak to send error code to peer and return
14828 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080014829 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014830 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14831 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014832 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
14833 __func__, MAC_ADDR_ARRAY(peer), status_code,
14834 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070014835 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014836 /* fall through to send setup resp with failure status
14837 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080014838 }
14839 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014840 else
14841 {
14842 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053014843 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014844 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014845 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014846 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014847 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
14848 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014849 return -EPERM;
14850 }
14851 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014852 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014853 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014854
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014855 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053014856 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014857 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
14858 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014859
Hoonki Leea34dd892013-02-05 22:56:02 -080014860 /*Except teardown responder will not be used so just make 0*/
14861 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014862 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080014863 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014864
14865 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053014866 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014867
14868 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
14869 responder = pTdlsPeer->is_responder;
14870 else
Hoonki Leea34dd892013-02-05 22:56:02 -080014871 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014872 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053014873 "%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 -070014874 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
14875 dialog_token, status_code, len);
14876 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080014877 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014878 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014879
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014880 /* For explicit trigger of DIS_REQ come out of BMPS for
14881 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070014882 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014883 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
14884 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070014885 {
14886 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
14887 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014888 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014889 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014890 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
14891 if (status != VOS_STATUS_SUCCESS) {
14892 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
14893 }
Hoonki Lee14621352013-04-16 17:51:19 -070014894 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014895 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
14896 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED)) {
14897 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
14898 }
14899 }
Hoonki Lee14621352013-04-16 17:51:19 -070014900 }
14901
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014902 /* make sure doesn't call send_mgmt() while it is pending */
14903 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
14904 {
14905 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014906 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014907 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014908 ret = -EBUSY;
14909 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014910 }
14911
14912 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014913 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
14914
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014915 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053014916 peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014917
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014918 if (VOS_STATUS_SUCCESS != status)
14919 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014920 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14921 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014922 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014923 ret = -EINVAL;
14924 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014925 }
14926
Hoonki Leed37cbb32013-04-20 00:31:14 -070014927 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
14928 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
14929
14930 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014931 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070014932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070014933 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070014934 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014935 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080014936
14937 if (pHddCtx->isLogpInProgress)
14938 {
14939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14940 "%s: LOGP in Progress. Ignore!!!", __func__);
14941 return -EAGAIN;
14942 }
14943
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014944 ret = -EINVAL;
14945 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014946 }
14947
Gopichand Nakkala05922802013-03-14 12:23:19 -070014948 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070014949 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014950 ret = max_sta_failed;
14951 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070014952 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014953
Hoonki Leea34dd892013-02-05 22:56:02 -080014954 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
14955 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014956 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE)) {
14957 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
14958 }
Hoonki Leea34dd892013-02-05 22:56:02 -080014959 }
14960 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
14961 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014962 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE)) {
14963 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
14964 }
Hoonki Leea34dd892013-02-05 22:56:02 -080014965 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014966
14967 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014968
14969tx_failed:
14970 /* add_station will be called before sending TDLS_SETUP_REQ and
14971 * TDLS_SETUP_RSP and as part of add_station driver will enable
14972 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
14973 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
14974 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
14975 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
14976 */
14977
14978 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
14979 (SIR_MAC_TDLS_SETUP_RSP == action_code))
14980 wlan_hdd_tdls_check_bmps(pAdapter);
14981 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014982}
14983
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014984#if TDLS_MGMT_VERSION2
14985static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
14986 u8 *peer, u8 action_code, u8 dialog_token,
14987 u16 status_code, u32 peer_capability,
14988 const u8 *buf, size_t len)
14989#else
14990static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
14991 u8 *peer, u8 action_code, u8 dialog_token,
14992 u16 status_code, const u8 *buf, size_t len)
14993#endif
14994{
14995 int ret;
14996
14997 vos_ssr_protect(__func__);
14998#if TDLS_MGMT_VERSION2
14999 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, dialog_token,
15000 status_code, peer_capability, buf, len);
15001#else
15002 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, dialog_token,
15003 status_code, buf, len);
15004#endif
15005 vos_ssr_unprotect(__func__);
15006
15007 return ret;
15008}
Atul Mittal115287b2014-07-08 13:26:33 +053015009
15010int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
15011 u8 *peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015012 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053015013 cfg80211_exttdls_callback callback)
15014{
15015
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015016 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053015017 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015018 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053015019 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15020 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
15021 __func__, MAC_ADDR_ARRAY(peer));
15022
15023 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15024 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15025
15026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015027 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15028 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15029 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015030 return -ENOTSUPP;
15031 }
15032
15033 /* To cater the requirement of establishing the TDLS link
15034 * irrespective of the data traffic , get an entry of TDLS peer.
15035 */
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015036 mutex_lock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015037 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
15038 if (pTdlsPeer == NULL) {
15039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15040 "%s: peer " MAC_ADDRESS_STR " not existing",
15041 __func__, MAC_ADDR_ARRAY(peer));
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015042 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015043 return -EINVAL;
15044 }
Masti, Narayanraddi6dbcdbb2015-05-13 10:28:06 +053015045 mutex_unlock(&pHddCtx->tdls_lock);
Atul Mittal115287b2014-07-08 13:26:33 +053015046
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015047 /* check FW TDLS Off Channel capability */
15048 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015049 (TRUE == pHddCtx->cfg_ini->fEnableTDLSOffChannel) &&
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015050 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015051 {
15052 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
15053 pTdlsPeer->peerParams.global_operating_class =
15054 tdls_peer_params->global_operating_class;
15055 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
15056 pTdlsPeer->peerParams.min_bandwidth_kbps =
15057 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015058 /* check configured channel is valid, non dfs and
15059 * not current operating channel */
15060 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
15061 tdls_peer_params->channel)) &&
15062 (pHddStaCtx) &&
15063 (tdls_peer_params->channel !=
15064 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015065 {
15066 pTdlsPeer->isOffChannelConfigured = TRUE;
15067 }
15068 else
15069 {
15070 pTdlsPeer->isOffChannelConfigured = FALSE;
15071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15072 "%s: Configured Tdls Off Channel is not valid", __func__);
15073
15074 }
15075 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015076 "%s: tdls_off_channel %d isOffChannelConfigured %d "
15077 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015078 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015079 pTdlsPeer->isOffChannelConfigured,
15080 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015081 }
15082 else
15083 {
15084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI0cb99bc2015-06-08 12:59:09 +053015085 "%s: TDLS off channel FW capability %d, "
15086 "host capab %d or Invalid TDLS Peer Params", __func__,
15087 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL),
15088 pHddCtx->cfg_ini->fEnableTDLSOffChannel);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015089 }
15090
Atul Mittal115287b2014-07-08 13:26:33 +053015091 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
15092
15093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15094 " %s TDLS Add Force Peer Failed",
15095 __func__);
15096 return -EINVAL;
15097 }
15098 /*EXT TDLS*/
15099
15100 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
15101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15102 " %s TDLS set callback Failed",
15103 __func__);
15104 return -EINVAL;
15105 }
15106
15107 return(0);
15108
15109}
15110
15111int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter, u8 *peer)
15112{
15113
15114 hddTdlsPeer_t *pTdlsPeer;
15115 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15117 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
15118 __func__, MAC_ADDR_ARRAY(peer));
15119
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015120 if (0 != wlan_hdd_validate_context(pHddCtx)) {
15121 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
15122 return -EINVAL;
15123 }
15124
Atul Mittal115287b2014-07-08 13:26:33 +053015125 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15126 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15127
15128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015129 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15130 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15131 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015132 return -ENOTSUPP;
15133 }
15134
15135
15136 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15137
15138 if ( NULL == pTdlsPeer ) {
15139 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
15140 " peer not exsting",
15141 __func__, MAC_ADDR_ARRAY(peer));
15142 return -EINVAL;
15143 }
15144 else {
15145 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
15146 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015147 /* if channel switch is configured, reset
15148 the channel for this peer */
15149 if (TRUE == pTdlsPeer->isOffChannelConfigured)
15150 {
15151 pTdlsPeer->peerParams.channel = 0;
15152 pTdlsPeer->isOffChannelConfigured = FALSE;
15153 }
Atul Mittal115287b2014-07-08 13:26:33 +053015154 }
15155
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015156 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
15157 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053015158 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015159 }
Atul Mittal115287b2014-07-08 13:26:33 +053015160
15161 /*EXT TDLS*/
15162
15163 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
15164
15165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15166 " %s TDLS set callback Failed",
15167 __func__);
15168 return -EINVAL;
15169 }
15170 return(0);
15171
15172}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015173static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015174 u8 *peer, enum nl80211_tdls_operation oper)
15175{
15176 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15177 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015178 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015179 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015180
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015181 ENTER();
15182
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015183 if (!pAdapter) {
15184 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15185 return -EINVAL;
15186 }
15187
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015188 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15189 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
15190 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015191 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015192 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015193 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070015194 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015195 return -EINVAL;
15196 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015197
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015198 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015199 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015200 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015201 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015202 }
15203
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015204
15205 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015206 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015207 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015208 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015209 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
15210 "Cannot process TDLS commands",
15211 pHddCtx->cfg_ini->fEnableTDLSSupport,
15212 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015213 return -ENOTSUPP;
15214 }
15215
15216 switch (oper) {
15217 case NL80211_TDLS_ENABLE_LINK:
15218 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015219 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015220 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015221 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053015222 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015223 tANI_U16 numCurrTdlsPeers = 0;
15224 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015225 tANI_U8 suppChannelLen = 0;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015226
Sunil Dutt41de4e22013-11-14 18:09:02 +053015227 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015228 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015229 if ( NULL == pTdlsPeer ) {
15230 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15231 " (oper %d) not exsting. ignored",
15232 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15233 return -EINVAL;
15234 }
15235
15236 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15237 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15238 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15239 "NL80211_TDLS_ENABLE_LINK");
15240
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070015241 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
15242 {
15243 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
15244 MAC_ADDRESS_STR " failed",
15245 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
15246 return -EINVAL;
15247 }
15248
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015249 /* before starting tdls connection, set tdls
15250 * off channel established status to default value */
15251 pTdlsPeer->isOffChannelEstablished = FALSE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015252 /* TDLS Off Channel, Disable tdls channel switch,
15253 when there are more than one tdls link */
15254 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053015255 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015256 {
15257 /* get connected peer and send disable tdls off chan */
15258 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015259 if ((connPeer) &&
15260 (connPeer->isOffChannelSupported == TRUE) &&
15261 (connPeer->isOffChannelConfigured == TRUE))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015262 {
15263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15264 "%s: More then one peer connected, Disable "
15265 "TDLS channel switch", __func__);
15266
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015267 connPeer->isOffChannelEstablished = FALSE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015268 ret = sme_SendTdlsChanSwitchReq(
15269 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015270 pAdapter->sessionId,
15271 connPeer->peerMac,
15272 connPeer->peerParams.channel,
15273 TDLS_OFF_CHANNEL_BW_OFFSET,
15274 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015275 if (ret != VOS_STATUS_SUCCESS) {
15276 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel request"));
15277 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015278 }
15279 else
15280 {
15281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15282 "%s: No TDLS Connected Peer or "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015283 "isOffChannelSupported %d "
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015284 "isOffChannelConfigured %d",
15285 __func__,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015286 (connPeer ? (connPeer->isOffChannelSupported)
15287 : -1),
15288 (connPeer ? (connPeer->isOffChannelConfigured)
15289 : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015290 }
15291 }
15292
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015293 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015294 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015295 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053015296
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015297 if (0 != wlan_hdd_tdls_get_link_establish_params(
15298 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015299 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015300 return -EINVAL;
15301 }
15302 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015303
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015304 ret = sme_SendTdlsLinkEstablishParams(
15305 WLAN_HDD_GET_HAL_CTX(pAdapter),
15306 pAdapter->sessionId, peer,
15307 &tdlsLinkEstablishParams);
15308 if (ret != VOS_STATUS_SUCCESS) {
15309 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
15310 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015311 /* Send TDLS peer UAPSD capabilities to the firmware and
15312 * register with the TL on after the response for this operation
15313 * is received .
15314 */
15315 ret = wait_for_completion_interruptible_timeout(
15316 &pAdapter->tdls_link_establish_req_comp,
15317 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
15318 if (ret <= 0)
15319 {
15320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15321 "%s: Link Establish Request Faled Status %ld",
15322 __func__, ret);
15323 return -EINVAL;
15324 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015325 }
Atul Mittal115287b2014-07-08 13:26:33 +053015326 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15327 eTDLS_LINK_CONNECTED,
15328 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015329 staDesc.ucSTAId = pTdlsPeer->staId;
15330 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015331 ret = WLANTL_UpdateTdlsSTAClient(
15332 pHddCtx->pvosContext,
15333 &staDesc);
15334 if (ret != VOS_STATUS_SUCCESS) {
15335 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
15336 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053015337
Gopichand Nakkala471708b2013-06-04 20:03:01 +053015338 /* Mark TDLS client Authenticated .*/
15339 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
15340 pTdlsPeer->staId,
15341 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015342 if (VOS_STATUS_SUCCESS == status)
15343 {
Hoonki Lee14621352013-04-16 17:51:19 -070015344 if (pTdlsPeer->is_responder == 0)
15345 {
15346 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
15347
15348 wlan_hdd_tdls_timer_restart(pAdapter,
15349 &pTdlsPeer->initiatorWaitTimeoutTimer,
15350 WAIT_TIME_TDLS_INITIATOR);
15351 /* suspend initiator TX until it receives direct packet from the
15352 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015353 ret = WLANTL_SuspendDataTx(
15354 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15355 &staId, NULL);
15356 if (ret != VOS_STATUS_SUCCESS) {
15357 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
15358 }
Hoonki Lee14621352013-04-16 17:51:19 -070015359 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015360
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015361 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015362 (TRUE == pTdlsPeer->isOffChannelConfigured))
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015363 {
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015364 suppChannelLen =
15365 tdlsLinkEstablishParams.supportedChannelsLen;
15366
15367 if ((suppChannelLen > 0) &&
15368 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
15369 {
15370 tANI_U8 suppPeerChannel = 0;
15371 int i = 0;
15372 for (i = 0U; i < suppChannelLen; i++)
15373 {
15374 suppPeerChannel =
15375 tdlsLinkEstablishParams.supportedChannels[i];
15376
15377 pTdlsPeer->isOffChannelSupported = FALSE;
15378 if (suppPeerChannel ==
15379 pTdlsPeer->peerParams.channel)
15380 {
15381 pTdlsPeer->isOffChannelSupported = TRUE;
15382 break;
15383 }
15384 }
15385 }
15386 else
15387 {
15388 pTdlsPeer->isOffChannelSupported = FALSE;
15389 }
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015390 }
15391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15392 "%s: TDLS channel switch request for channel "
15393 "%d isOffChannelConfigured %d suppChannelLen "
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015394 "%d isOffChannelSupported %d", __func__,
15395 pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015396 pTdlsPeer->isOffChannelConfigured,
Pradeep Reddy POTTETIfdaf38b2015-05-13 13:01:22 +053015397 suppChannelLen,
15398 pTdlsPeer->isOffChannelSupported);
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015399
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015400 /* TDLS Off Channel, Enable tdls channel switch,
15401 when their is only one tdls link and it supports */
15402 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15403 if ((numCurrTdlsPeers == 1) &&
15404 (TRUE == pTdlsPeer->isOffChannelSupported) &&
15405 (TRUE == pTdlsPeer->isOffChannelConfigured))
15406 {
15407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15408 "%s: Send TDLS channel switch request for channel %d",
15409 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015410
15411 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015412 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
15413 pAdapter->sessionId,
15414 pTdlsPeer->peerMac,
15415 pTdlsPeer->peerParams.channel,
15416 TDLS_OFF_CHANNEL_BW_OFFSET,
15417 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015418 if (ret != VOS_STATUS_SUCCESS) {
15419 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
15420 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015421 }
15422 else
15423 {
15424 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15425 "%s: TDLS channel switch request not sent"
15426 " numCurrTdlsPeers %d "
15427 "isOffChannelSupported %d "
15428 "isOffChannelConfigured %d",
15429 __func__, numCurrTdlsPeers,
15430 pTdlsPeer->isOffChannelSupported,
15431 pTdlsPeer->isOffChannelConfigured);
15432 }
15433
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015434 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015435 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015436
15437 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015438 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
15439 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015440 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015441 int ac;
15442 uint8 ucAc[4] = { WLANTL_AC_VO,
15443 WLANTL_AC_VI,
15444 WLANTL_AC_BK,
15445 WLANTL_AC_BE };
15446 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
15447 for(ac=0; ac < 4; ac++)
15448 {
15449 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15450 pTdlsPeer->staId, ucAc[ac],
15451 tlTid[ac], tlTid[ac], 0, 0,
15452 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015453 if (status != VOS_STATUS_SUCCESS) {
15454 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
15455 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015456 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015457 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015458 }
15459
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015460 }
15461 break;
15462 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080015463 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015464 tANI_U16 numCurrTdlsPeers = 0;
15465 hddTdlsPeer_t *connPeer = NULL;
15466
Sunil Dutt41de4e22013-11-14 18:09:02 +053015467 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15468
15469 if ( NULL == pTdlsPeer ) {
15470 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15471 " (oper %d) not exsting. ignored",
15472 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15473 return -EINVAL;
15474 }
15475
15476 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15477 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15478 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15479 "NL80211_TDLS_DISABLE_LINK");
15480
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015481 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080015482 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015483 long status;
15484
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015485 /* set tdls off channel status to false for this peer */
15486 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053015487 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15488 eTDLS_LINK_TEARING,
15489 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
15490 eTDLS_LINK_UNSPECIFIED:
15491 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015492 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
15493
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015494 status = sme_DeleteTdlsPeerSta(
15495 WLAN_HDD_GET_HAL_CTX(pAdapter),
15496 pAdapter->sessionId, peer );
15497 if (status != VOS_STATUS_SUCCESS) {
15498 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15499 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015500
15501 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
15502 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053015503 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053015504 eTDLS_LINK_IDLE,
15505 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015506 if (status <= 0)
15507 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15509 "%s: Del station failed status %ld",
15510 __func__, status);
15511 return -EPERM;
15512 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015513
15514 /* TDLS Off Channel, Enable tdls channel switch,
15515 when their is only one tdls link and it supports */
15516 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15517 if (numCurrTdlsPeers == 1)
15518 {
15519 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15520 if ((connPeer) &&
15521 (connPeer->isOffChannelSupported == TRUE) &&
15522 (connPeer->isOffChannelConfigured == TRUE))
15523 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015524 connPeer->isOffChannelEstablished = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015525 status = sme_SendTdlsChanSwitchReq(
15526 WLAN_HDD_GET_HAL_CTX(pAdapter),
15527 pAdapter->sessionId,
15528 connPeer->peerMac,
15529 connPeer->peerParams.channel,
15530 TDLS_OFF_CHANNEL_BW_OFFSET,
15531 TDLS_CHANNEL_SWITCH_ENABLE);
15532 if (status != VOS_STATUS_SUCCESS) {
15533 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
15534 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015535 }
15536 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15537 "%s: TDLS channel switch "
15538 "isOffChannelSupported %d "
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015539 "isOffChannelConfigured %d "
15540 "isOffChannelEstablished %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015541 __func__,
15542 (connPeer ? connPeer->isOffChannelSupported : -1),
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015543 (connPeer ? connPeer->isOffChannelConfigured : -1),
15544 (connPeer ? connPeer->isOffChannelEstablished : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015545 }
15546 else
15547 {
15548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15549 "%s: TDLS channel switch request not sent "
15550 "numCurrTdlsPeers %d ",
15551 __func__, numCurrTdlsPeers);
15552 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015553 }
15554 else
15555 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015556 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15557 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080015558 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015559 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015560 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015561 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015562 {
Atul Mittal115287b2014-07-08 13:26:33 +053015563 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015564
Atul Mittal115287b2014-07-08 13:26:33 +053015565 if (0 != status)
15566 {
15567 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15568 "%s: Error in TDLS Teardown", __func__);
15569 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015570 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053015571 break;
15572 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015573 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015574 {
Atul Mittal115287b2014-07-08 13:26:33 +053015575 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
15576 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015577 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053015578 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015579
Atul Mittal115287b2014-07-08 13:26:33 +053015580 if (0 != status)
15581 {
15582 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15583 "%s: Error in TDLS Setup", __func__);
15584 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053015585 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053015586 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015587 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015588 case NL80211_TDLS_DISCOVERY_REQ:
15589 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
15591 "%s: We don't support in-driver setup/teardown/discovery "
15592 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015593 return -ENOTSUPP;
15594 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15596 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015597 return -ENOTSUPP;
15598 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015599
15600 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015601 return 0;
15602}
Chilam NG571c65a2013-01-19 12:27:36 +053015603
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015604static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
15605 u8 *peer, enum nl80211_tdls_operation oper)
15606{
15607 int ret;
15608
15609 vos_ssr_protect(__func__);
15610 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
15611 vos_ssr_unprotect(__func__);
15612
15613 return ret;
15614}
15615
Chilam NG571c65a2013-01-19 12:27:36 +053015616int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
15617 struct net_device *dev, u8 *peer)
15618{
Arif Hussaina7c8e412013-11-20 11:06:42 -080015619 hddLog(VOS_TRACE_LEVEL_INFO,
15620 "tdls send discover req: "MAC_ADDRESS_STR,
15621 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053015622
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015623#if TDLS_MGMT_VERSION2
15624 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15625 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
15626#else
Chilam NG571c65a2013-01-19 12:27:36 +053015627 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15628 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015629#endif
Chilam NG571c65a2013-01-19 12:27:36 +053015630}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015631#endif
15632
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015633#ifdef WLAN_FEATURE_GTK_OFFLOAD
15634/*
15635 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
15636 * Callback rountine called upon receiving response for
15637 * get offload info
15638 */
15639void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
15640 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
15641{
15642
15643 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015644 tANI_U8 tempReplayCounter[8];
15645 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015646
15647 ENTER();
15648
15649 if (NULL == pAdapter)
15650 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053015651 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015652 "%s: HDD adapter is Null", __func__);
15653 return ;
15654 }
15655
15656 if (NULL == pGtkOffloadGetInfoRsp)
15657 {
15658 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15659 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
15660 return ;
15661 }
15662
15663 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
15664 {
15665 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15666 "%s: wlan Failed to get replay counter value",
15667 __func__);
15668 return ;
15669 }
15670
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015671 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15672 /* Update replay counter */
15673 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
15674 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
15675
15676 {
15677 /* changing from little to big endian since supplicant
15678 * works on big endian format
15679 */
15680 int i;
15681 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
15682
15683 for (i = 0; i < 8; i++)
15684 {
15685 tempReplayCounter[7-i] = (tANI_U8)p[i];
15686 }
15687 }
15688
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015689 /* Update replay counter to NL */
15690 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015691 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015692}
15693
15694/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015695 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015696 * This function is used to offload GTK rekeying job to the firmware.
15697 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015698int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015699 struct cfg80211_gtk_rekey_data *data)
15700{
15701 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15702 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
15703 hdd_station_ctx_t *pHddStaCtx;
15704 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015705 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015706 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015707 eHalStatus status = eHAL_STATUS_FAILURE;
15708
15709 ENTER();
15710
15711 if (NULL == pAdapter)
15712 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015713 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015714 "%s: HDD adapter is Null", __func__);
15715 return -ENODEV;
15716 }
15717
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015718 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15719 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
15720 pAdapter->sessionId, pAdapter->device_mode));
15721
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015722 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015723 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015724 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015725 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015726 }
15727
15728 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15729 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
15730 if (NULL == hHal)
15731 {
15732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15733 "%s: HAL context is Null!!!", __func__);
15734 return -EAGAIN;
15735 }
15736
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015737 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
15738 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
15739 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
15740 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015741 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015742 {
15743 /* changing from big to little endian since driver
15744 * works on little endian format
15745 */
15746 tANI_U8 *p =
15747 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
15748 int i;
15749
15750 for (i = 0; i < 8; i++)
15751 {
15752 p[7-i] = data->replay_ctr[i];
15753 }
15754 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015755
15756 if (TRUE == pHddCtx->hdd_wlan_suspended)
15757 {
15758 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015759 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
15760 sizeof (tSirGtkOffloadParams));
15761 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015762 pAdapter->sessionId);
15763
15764 if (eHAL_STATUS_SUCCESS != status)
15765 {
15766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15767 "%s: sme_SetGTKOffload failed, returned %d",
15768 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053015769
15770 /* Need to clear any trace of key value in the memory.
15771 * Thus zero out the memory even though it is local
15772 * variable.
15773 */
15774 vos_mem_zero(&hddGtkOffloadReqParams,
15775 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015776 return status;
15777 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15779 "%s: sme_SetGTKOffload successfull", __func__);
15780 }
15781 else
15782 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15784 "%s: wlan not suspended GTKOffload request is stored",
15785 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015786 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015787
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053015788 /* Need to clear any trace of key value in the memory.
15789 * Thus zero out the memory even though it is local
15790 * variable.
15791 */
15792 vos_mem_zero(&hddGtkOffloadReqParams,
15793 sizeof(hddGtkOffloadReqParams));
15794
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015795 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015796 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015797}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015798
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015799int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
15800 struct cfg80211_gtk_rekey_data *data)
15801{
15802 int ret;
15803
15804 vos_ssr_protect(__func__);
15805 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
15806 vos_ssr_unprotect(__func__);
15807
15808 return ret;
15809}
15810#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015811/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015812 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015813 * This function is used to set access control policy
15814 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015815static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
15816 struct net_device *dev,
15817 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015818{
15819 int i;
15820 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15821 hdd_hostapd_state_t *pHostapdState;
15822 tsap_Config_t *pConfig;
15823 v_CONTEXT_t pVosContext = NULL;
15824 hdd_context_t *pHddCtx;
15825 int status;
15826
15827 ENTER();
15828
15829 if (NULL == pAdapter)
15830 {
15831 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15832 "%s: HDD adapter is Null", __func__);
15833 return -ENODEV;
15834 }
15835
15836 if (NULL == params)
15837 {
15838 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15839 "%s: params is Null", __func__);
15840 return -EINVAL;
15841 }
15842
15843 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15844 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015845 if (0 != status)
15846 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015847 return status;
15848 }
15849
15850 pVosContext = pHddCtx->pvosContext;
15851 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
15852
15853 if (NULL == pHostapdState)
15854 {
15855 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15856 "%s: pHostapdState is Null", __func__);
15857 return -EINVAL;
15858 }
15859
15860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
15861 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
15862
15863 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
15864 {
15865 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
15866
15867 /* default value */
15868 pConfig->num_accept_mac = 0;
15869 pConfig->num_deny_mac = 0;
15870
15871 /**
15872 * access control policy
15873 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
15874 * listed in hostapd.deny file.
15875 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
15876 * listed in hostapd.accept file.
15877 */
15878 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
15879 {
15880 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
15881 }
15882 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
15883 {
15884 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
15885 }
15886 else
15887 {
15888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15889 "%s:Acl Policy : %d is not supported",
15890 __func__, params->acl_policy);
15891 return -ENOTSUPP;
15892 }
15893
15894 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
15895 {
15896 pConfig->num_accept_mac = params->n_acl_entries;
15897 for (i = 0; i < params->n_acl_entries; i++)
15898 {
15899 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15900 "** Add ACL MAC entry %i in WhiletList :"
15901 MAC_ADDRESS_STR, i,
15902 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
15903
15904 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
15905 sizeof(qcmacaddr));
15906 }
15907 }
15908 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
15909 {
15910 pConfig->num_deny_mac = params->n_acl_entries;
15911 for (i = 0; i < params->n_acl_entries; i++)
15912 {
15913 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15914 "** Add ACL MAC entry %i in BlackList :"
15915 MAC_ADDRESS_STR, i,
15916 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
15917
15918 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
15919 sizeof(qcmacaddr));
15920 }
15921 }
15922
15923 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
15924 {
15925 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15926 "%s: SAP Set Mac Acl fail", __func__);
15927 return -EINVAL;
15928 }
15929 }
15930 else
15931 {
15932 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015933 "%s: Invalid device_mode = %s (%d)",
15934 __func__, hdd_device_modetoString(pAdapter->device_mode),
15935 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015936 return -EINVAL;
15937 }
15938
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015939 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015940 return 0;
15941}
15942
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015943static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
15944 struct net_device *dev,
15945 const struct cfg80211_acl_data *params)
15946{
15947 int ret;
15948 vos_ssr_protect(__func__);
15949 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
15950 vos_ssr_unprotect(__func__);
15951
15952 return ret;
15953}
15954
Leo Chang9056f462013-08-01 19:21:11 -070015955#ifdef WLAN_NL80211_TESTMODE
15956#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070015957void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070015958(
15959 void *pAdapter,
15960 void *indCont
15961)
15962{
Leo Changd9df8aa2013-09-26 13:32:26 -070015963 tSirLPHBInd *lphbInd;
15964 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053015965 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070015966
15967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070015968 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070015969
c_hpothu73f35e62014-04-18 13:40:08 +053015970 if (pAdapter == NULL)
15971 {
15972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15973 "%s: pAdapter is NULL\n",__func__);
15974 return;
15975 }
15976
Leo Chang9056f462013-08-01 19:21:11 -070015977 if (NULL == indCont)
15978 {
15979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070015980 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070015981 return;
15982 }
15983
c_hpothu73f35e62014-04-18 13:40:08 +053015984 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070015985 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070015986 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053015987 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070015988 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070015989 GFP_ATOMIC);
15990 if (!skb)
15991 {
15992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15993 "LPHB timeout, NL buffer alloc fail");
15994 return;
15995 }
15996
Leo Changac3ba772013-10-07 09:47:04 -070015997 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070015998 {
15999 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16000 "WLAN_HDD_TM_ATTR_CMD put fail");
16001 goto nla_put_failure;
16002 }
Leo Changac3ba772013-10-07 09:47:04 -070016003 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070016004 {
16005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16006 "WLAN_HDD_TM_ATTR_TYPE put fail");
16007 goto nla_put_failure;
16008 }
Leo Changac3ba772013-10-07 09:47:04 -070016009 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070016010 sizeof(tSirLPHBInd), lphbInd))
16011 {
16012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16013 "WLAN_HDD_TM_ATTR_DATA put fail");
16014 goto nla_put_failure;
16015 }
Leo Chang9056f462013-08-01 19:21:11 -070016016 cfg80211_testmode_event(skb, GFP_ATOMIC);
16017 return;
16018
16019nla_put_failure:
16020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16021 "NLA Put fail");
16022 kfree_skb(skb);
16023
16024 return;
16025}
16026#endif /* FEATURE_WLAN_LPHB */
16027
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016028static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070016029{
16030 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
16031 int err = 0;
16032#ifdef FEATURE_WLAN_LPHB
16033 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070016034 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016035
16036 ENTER();
16037
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016038 err = wlan_hdd_validate_context(pHddCtx);
16039 if (0 != err)
16040 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016041 return err;
16042 }
Leo Chang9056f462013-08-01 19:21:11 -070016043#endif /* FEATURE_WLAN_LPHB */
16044
16045 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
16046 if (err)
16047 {
16048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16049 "%s Testmode INV ATTR", __func__);
16050 return err;
16051 }
16052
16053 if (!tb[WLAN_HDD_TM_ATTR_CMD])
16054 {
16055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16056 "%s Testmode INV CMD", __func__);
16057 return -EINVAL;
16058 }
16059
16060 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
16061 {
16062#ifdef FEATURE_WLAN_LPHB
16063 /* Low Power Heartbeat configuration request */
16064 case WLAN_HDD_TM_CMD_WLAN_HB:
16065 {
16066 int buf_len;
16067 void *buf;
16068 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080016069 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070016070
16071 if (!tb[WLAN_HDD_TM_ATTR_DATA])
16072 {
16073 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16074 "%s Testmode INV DATA", __func__);
16075 return -EINVAL;
16076 }
16077
16078 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
16079 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080016080
16081 hb_params_temp =(tSirLPHBReq *)buf;
16082 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
16083 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
16084 return -EINVAL;
16085
Leo Chang9056f462013-08-01 19:21:11 -070016086 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
16087 if (NULL == hb_params)
16088 {
16089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16090 "%s Request Buffer Alloc Fail", __func__);
16091 return -EINVAL;
16092 }
16093
16094 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070016095 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
16096 hb_params,
16097 wlan_hdd_cfg80211_lphb_ind_handler);
16098 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070016099 {
Leo Changd9df8aa2013-09-26 13:32:26 -070016100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16101 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070016102 vos_mem_free(hb_params);
16103 }
Leo Chang9056f462013-08-01 19:21:11 -070016104 return 0;
16105 }
16106#endif /* FEATURE_WLAN_LPHB */
16107 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16109 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070016110 return -EOPNOTSUPP;
16111 }
16112
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016113 EXIT();
16114 return err;
Leo Chang9056f462013-08-01 19:21:11 -070016115}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016116
16117static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
16118{
16119 int ret;
16120
16121 vos_ssr_protect(__func__);
16122 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
16123 vos_ssr_unprotect(__func__);
16124
16125 return ret;
16126}
Leo Chang9056f462013-08-01 19:21:11 -070016127#endif /* CONFIG_NL80211_TESTMODE */
16128
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016129static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016130 struct net_device *dev,
16131 int idx, struct survey_info *survey)
16132{
16133 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16134 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053016135 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016136 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053016137 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016138 v_S7_t snr,rssi;
16139 int status, i, j, filled = 0;
16140
16141 ENTER();
16142
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016143 if (NULL == pAdapter)
16144 {
16145 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16146 "%s: HDD adapter is Null", __func__);
16147 return -ENODEV;
16148 }
16149
16150 if (NULL == wiphy)
16151 {
16152 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16153 "%s: wiphy is Null", __func__);
16154 return -ENODEV;
16155 }
16156
16157 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16158 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016159 if (0 != status)
16160 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016161 return status;
16162 }
16163
Mihir Sheted9072e02013-08-21 17:02:29 +053016164 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16165
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016166 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053016167 0 != pAdapter->survey_idx ||
16168 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016169 {
16170 /* The survey dump ops when implemented completely is expected to
16171 * return a survey of all channels and the ops is called by the
16172 * kernel with incremental values of the argument 'idx' till it
16173 * returns -ENONET. But we can only support the survey for the
16174 * operating channel for now. survey_idx is used to track
16175 * that the ops is called only once and then return -ENONET for
16176 * the next iteration
16177 */
16178 pAdapter->survey_idx = 0;
16179 return -ENONET;
16180 }
16181
Mukul Sharma9d5233b2015-06-11 20:28:20 +053016182 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
16183 {
16184 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16185 "%s: Roaming in progress, hence return ", __func__);
16186 return -ENONET;
16187 }
16188
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016189 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16190
16191 wlan_hdd_get_snr(pAdapter, &snr);
16192 wlan_hdd_get_rssi(pAdapter, &rssi);
16193
16194 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
16195 hdd_wlan_get_freq(channel, &freq);
16196
16197
16198 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
16199 {
16200 if (NULL == wiphy->bands[i])
16201 {
16202 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
16203 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
16204 continue;
16205 }
16206
16207 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
16208 {
16209 struct ieee80211_supported_band *band = wiphy->bands[i];
16210
16211 if (band->channels[j].center_freq == (v_U16_t)freq)
16212 {
16213 survey->channel = &band->channels[j];
16214 /* The Rx BDs contain SNR values in dB for the received frames
16215 * while the supplicant expects noise. So we calculate and
16216 * return the value of noise (dBm)
16217 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
16218 */
16219 survey->noise = rssi - snr;
16220 survey->filled = SURVEY_INFO_NOISE_DBM;
16221 filled = 1;
16222 }
16223 }
16224 }
16225
16226 if (filled)
16227 pAdapter->survey_idx = 1;
16228 else
16229 {
16230 pAdapter->survey_idx = 0;
16231 return -ENONET;
16232 }
16233
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016234 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016235 return 0;
16236}
16237
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016238static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
16239 struct net_device *dev,
16240 int idx, struct survey_info *survey)
16241{
16242 int ret;
16243
16244 vos_ssr_protect(__func__);
16245 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
16246 vos_ssr_unprotect(__func__);
16247
16248 return ret;
16249}
16250
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016251/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016252 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016253 * this is called when cfg80211 driver resume
16254 * driver updates latest sched_scan scan result(if any) to cfg80211 database
16255 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016256int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016257{
16258 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16259 hdd_adapter_t *pAdapter;
16260 hdd_adapter_list_node_t *pAdapterNode, *pNext;
16261 VOS_STATUS status = VOS_STATUS_SUCCESS;
16262
16263 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016264
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016265 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016266 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016267 return 0;
16268 }
16269
16270 spin_lock(&pHddCtx->schedScan_lock);
16271 pHddCtx->isWiphySuspended = FALSE;
16272 if (TRUE != pHddCtx->isSchedScanUpdatePending)
16273 {
16274 spin_unlock(&pHddCtx->schedScan_lock);
16275 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16276 "%s: Return resume is not due to PNO indication", __func__);
16277 return 0;
16278 }
16279 // Reset flag to avoid updatating cfg80211 data old results again
16280 pHddCtx->isSchedScanUpdatePending = FALSE;
16281 spin_unlock(&pHddCtx->schedScan_lock);
16282
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016283
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016284 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
16285
16286 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
16287 {
16288 pAdapter = pAdapterNode->pAdapter;
16289 if ( (NULL != pAdapter) &&
16290 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
16291 {
16292 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016293 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16295 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016296 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016297 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016298 {
16299 /* Acquire wakelock to handle the case where APP's tries to
16300 * suspend immediately after updating the scan results. Whis
16301 * results in app's is in suspended state and not able to
16302 * process the connect request to AP
16303 */
Sushant Kaushik83392fa2015-05-05 17:44:40 +053016304 hdd_prevent_suspend_timeout(2000,
16305 WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016306 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016307 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016308
16309 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16310 "%s : cfg80211 scan result database updated", __func__);
16311
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016312 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016313 return 0;
16314
16315 }
16316 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16317 pAdapterNode = pNext;
16318 }
16319
16320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16321 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016322 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016323 return 0;
16324}
16325
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016326int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
16327{
16328 int ret;
16329
16330 vos_ssr_protect(__func__);
16331 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
16332 vos_ssr_unprotect(__func__);
16333
16334 return ret;
16335}
16336
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016337/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016338 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016339 * this is called when cfg80211 driver suspends
16340 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016341int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016342 struct cfg80211_wowlan *wow)
16343{
16344 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016345 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016346
16347 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016348
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016349 ret = wlan_hdd_validate_context(pHddCtx);
16350 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016351 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016352 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016353 }
16354
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016355
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016356 pHddCtx->isWiphySuspended = TRUE;
16357
16358 EXIT();
16359
16360 return 0;
16361}
16362
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016363int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
16364 struct cfg80211_wowlan *wow)
16365{
16366 int ret;
16367
16368 vos_ssr_protect(__func__);
16369 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
16370 vos_ssr_unprotect(__func__);
16371
16372 return ret;
16373}
Jeff Johnson295189b2012-06-20 16:38:30 -070016374/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016375static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070016376{
16377 .add_virtual_intf = wlan_hdd_add_virtual_intf,
16378 .del_virtual_intf = wlan_hdd_del_virtual_intf,
16379 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
16380 .change_station = wlan_hdd_change_station,
16381#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
16382 .add_beacon = wlan_hdd_cfg80211_add_beacon,
16383 .del_beacon = wlan_hdd_cfg80211_del_beacon,
16384 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016385#else
16386 .start_ap = wlan_hdd_cfg80211_start_ap,
16387 .change_beacon = wlan_hdd_cfg80211_change_beacon,
16388 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070016389#endif
16390 .change_bss = wlan_hdd_cfg80211_change_bss,
16391 .add_key = wlan_hdd_cfg80211_add_key,
16392 .get_key = wlan_hdd_cfg80211_get_key,
16393 .del_key = wlan_hdd_cfg80211_del_key,
16394 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016395#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070016396 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016397#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016398 .scan = wlan_hdd_cfg80211_scan,
16399 .connect = wlan_hdd_cfg80211_connect,
16400 .disconnect = wlan_hdd_cfg80211_disconnect,
16401 .join_ibss = wlan_hdd_cfg80211_join_ibss,
16402 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
16403 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
16404 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
16405 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070016406 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
16407 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053016408 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070016409#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16410 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
16411 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
16412 .set_txq_params = wlan_hdd_set_txq_params,
16413#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016414 .get_station = wlan_hdd_cfg80211_get_station,
16415 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
16416 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016417 .add_station = wlan_hdd_cfg80211_add_station,
16418#ifdef FEATURE_WLAN_LFR
16419 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
16420 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
16421 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
16422#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016423#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
16424 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
16425#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016426#ifdef FEATURE_WLAN_TDLS
16427 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
16428 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
16429#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016430#ifdef WLAN_FEATURE_GTK_OFFLOAD
16431 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
16432#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016433#ifdef FEATURE_WLAN_SCAN_PNO
16434 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
16435 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
16436#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016437 .resume = wlan_hdd_cfg80211_resume_wlan,
16438 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016439 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070016440#ifdef WLAN_NL80211_TESTMODE
16441 .testmode_cmd = wlan_hdd_cfg80211_testmode,
16442#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016443 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070016444};
16445